Beispiel #1
0
 public function save(ProfilePage $page, $field, $value)
 {
     $deletePrivate = S::user()->isMe($page->owner) || S::admin();
     XDB::execute('DELETE FROM  pj, pjt
                         USING  profile_job      AS pj
                     LEFT JOIN  profile_job_term AS pjt ON (pj.pid = pjt.pid AND pj.id = pjt.jid)
                         WHERE  pj.pid = {?}' . ($deletePrivate ? '' : ' AND pj.pub IN (\'public\', \'ax\')'), $page->pid());
     Address::deleteAddresses($page->pid(), Address::LINK_JOB, null, null, $deletePrivate);
     Phone::deletePhones($page->pid(), Phone::LINK_JOB, null, $deletePrivate);
     $previous_requests = EntrReq::get_typed_requests($page->pid(), 'entreprise');
     foreach ($previous_requests as $request) {
         $request->clean();
     }
     $terms_values = array();
     foreach ($value as $id => &$job) {
         if (($job['pub'] != 'private' || $deletePrivate) && (isset($job['name']) && $job['name'])) {
             if (isset($job['jobid']) && $job['jobid']) {
                 XDB::execute('INSERT INTO  profile_job (pid, id, description, email, entry_year,
                                                         url, pub, email_pub, jobid)
                                    VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})', $page->pid(), $id, $job['description'], $job['w_email'], $job['w_entry_year'], $job['w_url'], $job['pub'], $job['w_email_pub'], $job['jobid']);
             } else {
                 XDB::execute('INSERT INTO  profile_job (pid, id, description, email, entry_year,
                                                         url, pub, email_pub)
                                    VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})', $page->pid(), $id, $job['description'], $job['w_email'], $job['w_entry_year'], $job['w_url'], $job['pub'], $job['w_email_pub']);
                 $request = new EntrReq(S::user(), $page->profile, $id, $job['name'], $job['hq_acronym'], $job['hq_url'], $job['hq_email'], $job['hq_fixed'], $job['hq_fax'], $job['hq_address']);
                 $request->submit();
                 sleep(1);
             }
             $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::format('({?}, {?}, {?}, {?})', $page->pid(), $id, $term['jtid'], "original");
                 }
             }
         }
     }
     if (count($terms_values) > 0) {
         XDB::rawExecute('INSERT INTO  profile_job_term (pid, jid, jtid, computed)
                               VALUES  ' . implode(', ', $terms_values) . '
              ON DUPLICATE KEY UPDATE  computed = VALUES(computed)');
     }
     if (S::user()->isMe($page->owner) && count($value) > 1) {
         Platal::page()->trigWarning('Attention, tu as plusieurs emplois sur ton profil. Pense à supprimer ceux qui sont obsolètes.');
     }
 }
Beispiel #2
0
 public function save($notify_ungeocoded = true)
 {
     if (!$this->isEmpty()) {
         XDB::execute('INSERT IGNORE INTO  profile_addresses (pid, jobid, groupid, type, id, flags, text, postalText, pub, comment,
                                                              types, formatted_address, location_type, partial_match, latitude, longitude,
                                                              southwest_latitude, southwest_longitude, northeast_latitude, northeast_longitude,
                                                              geocoding_date, geocoding_calls, postal_code_fr)
                                   VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?},
                                            {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, NOW(), {?}, {?})', $this->pid, $this->jobid, $this->groupid, $this->type, $this->id, $this->flags, $this->text, $this->postalText, $this->pub, $this->comment, $this->types, $this->formatted_address, $this->location_type, $this->partial_match, $this->latitude, $this->longitude, $this->southwest_latitude, $this->southwest_longitude, $this->northeast_latitude, $this->northeast_longitude, $this->geocoding_calls, $this->postal_code_fr);
         // In an ideal world there would not be any components to clean up before insertion.
         // In real world, it happens that some addresses are badly removed and this query removes the leaked trash.
         XDB::execute('DELETE FROM  profile_addresses_components
                             WHERE  pid = {?} AND jobid = {?} AND groupid = {?} AND type = {?} AND id = {?}', $this->pid, $this->jobid, $this->groupid, $this->type, $this->id);
         if ($this->componentsIds) {
             foreach (explode(',', $this->componentsIds) as $component_id) {
                 XDB::execute('INSERT IGNORE INTO  profile_addresses_components (pid, jobid, groupid, type, id, component_id)
                                           VALUES  ({?}, {?}, {?}, {?}, {?}, {?})', $this->pid, $this->jobid, $this->groupid, $this->type, $this->id, $component_id);
             }
         } elseif ($notify_ungeocoded) {
             // If the address was not geocoded, notifies it to the appropriate ML.
             $mailer = new PlMailer('profile/no_geocoding.mail.tpl');
             $mailer->assign('text', $this->text);
             $mailer->assign('primary_key', $this->pid . '-' . $this->jobid . '-' . $this->groupid . '-' . $this->type . '-' . $this->id);
             $mailer->send();
         }
         if ($this->type == self::LINK_PROFILE) {
             Phone::savePhones($this->phones, $this->pid, Phone::LINK_ADDRESS, $this->id);
         }
         if ($this->request) {
             $req = new AddressReq(S::user(), $this->toFormArray(), $this->pid, $this->jobid, $this->groupid, $this->type, $this->id);
             $req->submit();
         }
         if ($this->pid != 0) {
             self::updateBestMail($this->pid);
         }
     }
 }
Beispiel #3
0
 public function save(ProfilePage $page, $field, $value)
 {
     Phone::deletePhones($page->pid(), Phone::LINK_PROFILE, null, S::user()->isMe($page->owner) || S::admin());
     Phone::savePhones($value, $page->pid(), Phone::LINK_PROFILE);
 }