- XDB::execute("DELETE FROM entreprises
- WHERE uid = {?}",
- S::i('uid'));
- $i = 0;
- foreach ($value as &$job) {
- XDB::execute("INSERT INTO entreprises (uid, entrid, entreprise, secteur, ss_secteur,
- fonction, poste, adr1, adr2, adr3, postcode,
- city, cityid, country, region, regiontxt,
- tel, fax, mobile, email, web,
- pub, adr_pub, tel_pub, email_pub, flags,
- glat, glng)
- VALUES ({?}, {?}, {?}, {?}, {?},
- {?}, {?}, {?}, {?}, {?}, {?},
- {?}, {?}, {?}, {?}, {?},
- {?}, {?}, {?}, {?}, {?},
- {?}, {?}, {?}, {?}, {?},
- {?}, {?})",
- S::i('uid'), $i++, $job['name'], $job['secteur'], $job['ss_secteur'],
- $job['fonction'], $job['poste'], $job['adr']['adr1'], $job['adr']['adr2'], $job['adr']['adr3'],
- $job['adr']['postcode'],
- $job['adr']['city'], $job['adr']['cityid'], $job['adr']['country'], $job['adr']['region'],
- $job['adr']['regiontxt'],
- $job['tel'], $job['fax'], $job['mobile'], $job['email'], $job['web'],
- $job['pub'], $job['adr']['pub'], $job['tel_pub'], $job['email_pub'],
- $job['adr']['checked'] ? 'geoloc' : '', $job['adr']['precise_lat'],
- $job['adr']['precise_lon']);
+ XDB::execute("DELETE FROM profile_job
+ WHERE pid = {?}",
+ $page->pid());
+ Address::delete($page->pid(), Address::LINK_JOB);
+ Phone::deletePhones($page->pid(), Phone::LINK_JOB);
+ $terms_values = array();
+ foreach ($value as $id => &$job) {
+ if (isset($job['name']) && $job['name']) {
+ if (isset($job['jobid']) && $job['jobid']) {
+ XDB::execute('INSERT INTO profile_job (pid, id, description, email, url, pub, email_pub, jobid)
+ VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})',
+ $page->pid(), $id, $job['description'], $job['w_email'], $job['w_url'], $job['pub'], $job['w_email_pub'], $job['jobid']);
+ } else {
+ XDB::execute('INSERT INTO profile_job (pid, id, description, email, url, pub, email_pub)
+ VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?})',
+ $page->pid(), $id, $job['description'], $job['w_email'], $job['w_url'], $job['pub'], $job['w_email_pub']);
+ }
+ $address = new Address(array_merge($job['w_address'], array('pid' => $page->pid(), 'id' => $id, 'type' => Address::LINK_JOB)));
+ $address->save();
+ Phone::savePhones($job['w_phone'], $page->pid(), Phone::LINK_JOB, $id);
+ if (isset($job['terms'])) {
+ foreach ($job['terms'] as $term) {
+ $terms_values[] = '('.XDB::escape($page->pid()).', '. XDB::escape($id).', '.XDB::escape($term['jtid']).', "original")';
+ }
+ }
+ }
+ }
+ if (count($terms_values) > 0) {
+ XDB::execute('INSERT INTO profile_job_term (pid, jid, jtid, computed)
+ VALUES '.implode(', ', $terms_values));