return $this->phones;
}
- public function addPhone(Phone &$phone)
+ public function addPhone(Phone $phone)
{
if ($phone->linkType() == Phone::LINK_ADDRESS && $phone->pid() == $this->pid) {
$this->phones[$phone->uniqueId()] = $phone;
}
}
$this->text = trim($this->text);
+ $this->phones = Phone::formatFormArray($this->phones, $this->error, new ProfileVisibility($this->pub));
if ($this->removed == 1) {
- $this->text = '';
- return true;
+ 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;
+ }
}
if ($format['requireGeocoding'] || $this->changed == 1) {
$this->error = !empty($this->geocodedText);
}
if ($format['stripGeocoding'] || ($this->type == self::LINK_COMPANY && $this->error) || $this->geocodeChosen === '0') {
- $gmapsGeocoder = new GMapsGeocoder();
- $gmapsGeocoder->stripGeocodingFromAddress($this);
if ($this->geocodeChosen === '0') {
$mailer = new PlMailer('profile/geocoding.mail.tpl');
$mailer->assign('text', $this->text);
$mailer->assign('geoloc', $this->geocodedText);
$mailer->send();
}
+ $gmapsGeocoder = new GMapsGeocoder();
+ $gmapsGeocoder->stripGeocodingFromAddress($this);
}
if ($this->countryId == '') {
$this->countryId = null;
}
$this->geocodeChosen = null;
- $this->phones = Phone::formatFormArray($this->phones, $this->error, new ProfileVisibility($this->pub));
if ($format['postalText']) {
$this->formatPostalAddress();
}
Geocoder::getAreaId($this, $area);
}
- XDB::execute('INSERT INTO profile_addresses (pid, jobid, type, id, flags, accuracy,
- text, postalText, postalCode, localityId,
- subAdministrativeAreaId, administrativeAreaId,
- countryId, latitude, longitude, pub, comment,
- north, south, east, west)
- VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?},
- {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})',
+ XDB::execute('INSERT IGNORE INTO profile_addresses (pid, jobid, type, id, flags, accuracy,
+ text, postalText, postalCode, localityId,
+ subAdministrativeAreaId, administrativeAreaId,
+ countryId, latitude, longitude, pub, comment,
+ north, south, east, west)
+ VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?},
+ {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})',
$this->pid, $this->jobid, $this->type, $this->id, $this->flags, $this->accuracy,
$this->text, $this->postalText, $this->postalCode, $this->localityId,
$this->subAdministrativeAreaId, $this->administrativeAreaId,
}
}
- return self::formArrayWalk($data, 'toFormArray', $success, true);
+ $addresses = self::formArrayWalk($data, 'toFormArray', $success, true);
+ usort($addresses, 'ProfileVisibility::comparePublicity');
+ return $addresses;
}
static public function formArrayToString(array $data)
return implode(', ', self::formArrayWalk($data, 'toString'));
}
+ static public function hasPrivate(array $addresses)
+ {
+ foreach ($addresses as $address) {
+ if ($address['pub'] == 'private') {
+ return true;
+ }
+ }
+ return false;
+ }
+
static public function iterate(array $pids = array(), array $types = array(),
array $jobids = array(), array $pubs = array())
{