X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=upgrade%2Fnewdirectory-0.0.1%2Faddresses.php;h=01193d82249c4e706e43074b7bea2f3f9ac59396;hb=c76545c351fae4e2298624ff9ee5bf854dc5a5b6;hp=12c049706f1257d3ec58538d5d2080625a376f0d;hpb=b4cb22fbbcb622a8f93010a5ff19e71ffc6a2e95;p=platal.git diff --git a/upgrade/newdirectory-0.0.1/addresses.php b/upgrade/newdirectory-0.0.1/addresses.php index 12c0497..01193d8 100755 --- a/upgrade/newdirectory-0.0.1/addresses.php +++ b/upgrade/newdirectory-0.0.1/addresses.php @@ -17,6 +17,7 @@ echo "This will take a few minutes.\n"; // Fills the 'text' field in profile_addresses. for ($pid = $minPid; $pid < $maxPid + 1; ++$pid) { + // First deals with home addresses (located in #x4dat#.adresses). $res = XDB::iterator("SELECT a.adrid AS id, a.adr1, a.adr2, a.adr3, UNIX_TIMESTAMP(a.datemaj) AS datemaj, a.postcode, a.city, a.cityid, a.region, a.regiontxt, @@ -37,10 +38,31 @@ for ($pid = $minPid; $pid < $maxPid + 1; ++$pid) { while ($address = $res->next()) { $text = get_address_text($address); - XDB::iterator('UPDATE profile_addresses - SET text = {?} - WHERE pid = {?} AND type = {?} AND id = {?}', - $text, $pid, $address['pro'] ? 'job' : 'home', $address['id']); + XDB::execute('UPDATE profile_addresses + SET text = {?} + WHERE pid = {?} AND type = {?} AND id = {?}', + $text, $pid, $address['pro'] ? 'job' : 'home', $address['id']); + } + + // Then deals with job addresses (located in #x4dat#.entreprises). + $res = XDB::iterator("SELECT e.entrid AS id, j.id AS jobid, e.adr1, e.adr2, e.adr3, + e.postcode, e.city, e.cityid, e.region, e.regiontxt, + e.adr_pub AS pub, e.country, gp.pays AS countrytxt, gp.display, + e.glat AS precise_lat, e.glng AS precise_lon + FROM #x4dat#.entreprises AS e + INNER JOIN #x4dat#.geoloc_pays AS gp ON (gp.a2 = e.country) + INNER JOIN account_profiles AS ap ON (e.uid = ap.uid AND FIND_IN_SET('owner', ap.perms)) + INNER JOIN profile_job_enum AS j ON (e.entreprise = j.name) + WHERE ap.pid = {?} + ORDER BY e.entrid", + $pid); + + while ($address = $res->next()) { + $text = get_address_text($address); + XDB::execute('UPDATE profile_addresses + SET text = {?} + WHERE pid = {?} AND type = {?} AND id = {?} AND jobid = {?}', + $text, $pid, 'job', $address['id'], $address['jobid']); } }