Esempio n. 1
0
 public function save(ProfilePage $page, $field, $value)
 {
     $deletePrivate = S::user()->isMe($page->owner) || S::admin();
     Phone::deletePhones($page->pid(), Phone::LINK_ADDRESS, null, $deletePrivate);
     Address::deleteAddresses($page->pid(), Address::LINK_PROFILE, null, null, $deletePrivate);
     AddressReq::purge_requests($page->pid(), 0, 0, Address::LINK_PROFILE);
     Address::saveFromArray($value, $page->pid(), Address::LINK_PROFILE, null, $deletePrivate);
     if (S::user()->isMe($page->owner) && count($value) > 1) {
         Platal::page()->trigWarning('Attention, tu as plusieurs adresses sur ton profil. Pense à supprimer celles qui sont obsolètes.');
     }
 }
Esempio n. 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);
         }
     }
 }