public function format() { $this->text = trim($this->text); $this->phones = Phone::formatFormArray($this->phones, $this->error, $this->pub); if ($this->removed == 1) { if (!S::user()->checkPerms('directory_private') && Phone::hasPrivate($this->phones)) { Platal::page()->trigWarning("L'adresse ne peut être supprimée car elle contient des informations pour lesquelles vous n'avez le droit d'édition."); } else { $this->text = ''; return true; } } $this->formatPostalAddress(); if ($this->changed == 1) { $gmapsGeocoder = new GMapsGeocoder(); $gmapsGeocoder->getGeocodedAddress($this); $componants = array(); foreach ($this->components as $component) { $componants[] = Geocoder::getComponentId($component); } $this->componentsIds = implode(',', $componants); } if ($this->componentsIds == '') { $this->latitude = null; $this->longitude = null; } return true; }
public function value(ProfilePage $page, $field, $value, &$success) { $entreprise = ProfileValidate::get_typed_requests($page->pid(), 'entreprise'); $entr_val = 0; $init = false; if (is_null($value)) { $value = $this->fetchJobs($page); $init = true; } $success = true; foreach ($value as $key => $job) { $job['name'] = trim($job['name']); if ($job['name'] == '' && $entreprise[$entr_val]->id == $key) { $job['tmp_name'] = $entreprise[$entr_val]->name; ++$entr_val; } else { if ($job['name'] == '') { if ($job['description'] == '' && $job['w_url'] == '' && $job['w_address']['text'] == '' && $job['w_email'] == '' && count($job['w_phone']) >= 1 && $job['w_phone'][0]['display'] == '') { unset($value[$key]); continue; } if (!$init) { $job['name_error'] = true; $success = false; } } } if (isset($job['removed']) && $job['removed']) { if (!S::user()->checkPerms('directory_private') && (Phone::hasPrivate($job['w_phone']) || Address::hasPrivate($job['w_address']) || $job['w_email_pub'] == 'private')) { Platal::page()->trigWarning("L'entreprise ne peut être supprimée car elle contient des informations pour lesquelles vous n'avez pas le droit d'édition."); } else { if ($job['name'] == '' && $entreprise && isset($entreprise[$entr_val - 1])) { $entreprise[$entr_val - 1]->clean(); } unset($value[$key]); continue; } } if (!isset($job['pub']) || !$job['pub']) { $job['pub'] = 'private'; } $value[$key] = $job; } foreach ($value as $key => &$job) { $address = new Address($job['w_address']); $s = $address->format(); // Force the address publicity to be at least as restricted as // the job publicity. $job_level = $job['pub']; if (Visibility::isLessRestrictive($job_level, $address->pub)) { $address->pub = $job_level; } $job['w_address'] = $address->toFormArray(); $this->cleanJob($page, $key, $job, $s, $job_level); if (!$init) { $success = $success && $s; } } usort($value, 'Visibility::comparePublicity'); return $value; }