Пример #1
0
 private function cleanJob(ProfilePage $page, $jobid, array &$job, &$success, $job_level)
 {
     if ($job['w_email'] == "*****@*****.**") {
         $job['w_email'] = $job['w_email_new'];
     }
     foreach ($this->checks as $obj => &$fields) {
         $chk =& $this->{$obj};
         foreach ($fields as $field) {
             $job[$field] = $chk->value($page, $field, $job[$field], $s);
             if (!$s) {
                 $success = false;
                 $job[$field . '_error'] = true;
             }
         }
     }
     if (count($job['terms'])) {
         $termsid = array();
         foreach ($job['terms'] as $term) {
             if (!isset($term['full_name'])) {
                 $termsid[] = $term['jtid'];
             }
         }
         if (count($termsid)) {
             $res = XDB::query("SELECT  jtid, full_name\n                                    FROM  profile_job_term_enum\n                                   WHERE  jtid IN {?}", $termsid);
             $term_id_to_name = $res->fetchAllAssoc('jtid', false);
             foreach ($job['terms'] as &$term) {
                 if (!isset($term['full_name'])) {
                     $term['full_name'] = $term_id_to_name[$term['jtid']];
                 }
             }
         }
     }
     if ($job['name']) {
         $res = XDB::query("SELECT  id\n                                 FROM  profile_job_enum\n                                WHERE  name = {?}", $job['name']);
         if ($res->numRows() != 1) {
             $job['jobid'] = null;
         } else {
             $job['jobid'] = $res->fetchOneCell();
         }
     }
     if (Visibility::isLessRestrictive($job_level, $job['w_email_pub'])) {
         $job['w_email_pub'] = $job_level;
     }
     $job['w_phone'] = Phone::formatFormArray($job['w_phone'], $s, $job_level);
     if ($job['w_entry_year'] && strlen($job['w_entry_year']) != 4) {
         $job['w_entry_year_error'] = true;
         $success = false;
     }
     unset($job['removed']);
     unset($job['new']);
 }
Пример #2
0
 public function toFormArray()
 {
     $address = array('text' => $this->text, 'postalText' => $this->postalText, 'types' => $this->types, 'formatted_address' => $this->formatted_address, 'latitude' => $this->latitude, 'longitude' => $this->longitude, 'southwest_latitude' => $this->southwest_latitude, 'southwest_longitude' => $this->southwest_longitude, 'northeast_latitude' => $this->northeast_latitude, 'northeast_longitude' => $this->northeast_longitude, 'location_type' => $this->location_type, 'partial_match' => $this->partial_match, 'componentsIds' => $this->componentsIds, 'geocoding_date' => $this->geocoding_date, 'geocoding_calls' => $this->geocoding_calls, 'request' => $this->request);
     if ($this->type == self::LINK_JOB) {
         $address['pub'] = $this->pub;
         $address['mail'] = $this->flags->hasFlag('mail');
     }
     if ($this->type == self::LINK_PROFILE) {
         static $flags = array('current', 'temporary', 'secondary', 'mail', 'cedex', 'deliveryIssue');
         foreach ($flags as $flag) {
             $address[$flag] = $this->flags->hasFlag($flag);
         }
         $address['pub'] = $this->pub;
         $address['comment'] = $this->comment;
         $address['phones'] = Phone::formatFormArray($this->phones);
     }
     return $address;
 }
Пример #3
0
 public function value(ProfilePage $page, $field, $value, &$success)
 {
     $success = true;
     $phones = array();
     if (is_null($value)) {
         $it = Phone::iterate(array($page->pid()), array(Phone::LINK_PROFILE), array(0), Visibility::get(Visibility::VIEW_ADMIN));
         while ($phone = $it->next()) {
             $success = $phone->format() && $success;
             $phones[] = $phone->toFormArray();
         }
         if (count($phones) == 0) {
             $phone = new Phone();
             $phones[] = $phone->toFormArray();
         }
         return $phones;
     } else {
         $phones = Phone::formatFormArray($value, $success);
         if (!$success) {
             Platal::page()->trigError('Numéro de téléphone invalide');
         }
         return $phones;
     }
 }