X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fprofile%2Fjobs.inc.php;h=723370bef2415d963be4374077fddbb5ccb8b70e;hb=dd9b361324a289efb9b4c9d67c5324a3d5036d53;hp=719d6639e970c843a4c78cd4318fe0de1e82e25e;hpb=0fc3d4a7abbfa9926170235ca896fef8d14db521;p=platal.git diff --git a/modules/profile/jobs.inc.php b/modules/profile/jobs.inc.php index 719d663..723370b 100644 --- a/modules/profile/jobs.inc.php +++ b/modules/profile/jobs.inc.php @@ -83,29 +83,30 @@ class ProfileSettingJob implements ProfileSetting $backtrack = array(); foreach ($jobs as $key=>$job) { $compagnies[] = $job['jobid']; - $backtrack[$job['jobid']] = $key; + $backtrack[$job['id']] = $key; } $it = Address::iterate(array($page->pid()), array(Address::LINK_JOB)); while ($address = $it->next()) { - $jobs[$address->jobid]['w_address'] = $address->toFormArray(); + $jobs[$address->id]['w_address'] = $address->toFormArray(); } $it = Phone::iterate(array($page->pid()), array(Phone::LINK_JOB)); while ($phone = $it->next()) { $jobs[$phone->linkId()]['w_phone'][$phone->id()] = $phone->toFormArray(); } - $res = XDB::iterator("SELECT e.jtid, e.full_name, j.jid AS jobid + $res = XDB::iterator("SELECT e.jtid, e.full_name, j.jid FROM profile_job_term_enum AS e INNER JOIN profile_job_term AS j USING(jtid) WHERE pid = {?} ORDER BY j.jid", $page->pid()); while ($term = $res->next()) { - $jobid = $term['jobid']; - if (!isset($backtrack[$jobid])) { + // $jid is the ID of the job among this user's jobs + $jid = $term['jid']; + if (!isset($backtrack[$jid])) { continue; } - $job =& $jobs[$backtrack[$jobid]]; + $job =& $jobs[$backtrack[$jid]]; if (!isset($job['terms'])) { $job['terms'] = array(); } @@ -250,7 +251,7 @@ class ProfileSettingJob implements ProfileSetting XDB::execute("DELETE FROM profile_job_term WHERE pid = {?}", $page->pid()); - Address::delete($page->pid(), Address::LINK_JOB); + Address::deleteAddresses($page->pid(), Address::LINK_JOB); Phone::deletePhones($page->pid(), Phone::LINK_JOB); $terms_values = array(); foreach ($value as $id => &$job) { @@ -283,15 +284,17 @@ class ProfileSettingJob implements ProfileSetting } } if (count($terms_values) > 0) { - XDB::execute('REPLACE INTO profile_job_term (pid, jid, jtid, computed) - VALUES '.implode(', ', $terms_values)); + XDB::rawExecute('INSERT INTO profile_job_term (pid, jid, jtid, computed) + VALUES ' . implode(', ', $terms_values) . ' + ON DUPLICATE KEY UPDATE computed = VALUES(computed)'); } } - public function getText($value) { + public function getText($value) + { $jobs = array(); foreach ($value as $id => $job) { - $address = Address::formArrayToString($job['w_address']); + $address = Address::formArrayToString(array($job['w_address'])); $phones = Phone::formArrayToString($job['w_phone']); // TODO: add jobterms here. $jobs[] = 'Entreprise : ' . $job['name'] @@ -321,8 +324,10 @@ class ProfileSettingCorps implements ProfileSetting public function save(ProfilePage &$page, $field, $value) { - XDB::execute('REPLACE INTO profile_corps (original_corpsid, current_corpsid, rankid, corps_pub, pid) - VALUES ({?}, {?}, {?}, {?}, {?})', + XDB::execute('INSERT INTO profile_corps (original_corpsid, current_corpsid, rankid, corps_pub, pid) + VALUES ({?}, {?}, {?}, {?}, {?}) + ON DUPLICATE KEY UPDATE original_corpsid = VALUES(original_corpsid), current_corpsid = VALUES(current_corpsid), + rankid = VALUES(rankid), corps_pub = VALUES(corps_pub)', $value['original'], $value['current'], $value['rank'], $value['pub'], $page->pid()); }