}
}
$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_ax') && 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->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 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())
{
{
$this->format();
if (!$this->isEmpty()) {
- XDB::execute('INSERT INTO profile_phones (pid, link_type, link_id, tel_id, tel_type,
- search_tel, display_tel, pub, comment)
- VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})',
+ XDB::execute('INSERT IGNORE INTO profile_phones (pid, link_type, link_id, tel_id, tel_type,
+ search_tel, display_tel, pub, comment)
+ VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})',
$this->pid, $this->link_type, $this->link_id, $this->id, $this->type,
$this->search, $this->display, $this->pub, $this->comment);
}
return implode(', ', self::formArrayWalk($data, 'toString'));
}
+ static public function hasPrivate(array $phones)
+ {
+ foreach ($phones as $phone) {
+ if ($phone['pub'] == 'private') {
+ return true;
+ }
+ }
+ return false;
+ }
+
static public function iterate(array $pids = array(), array $link_types = array(),
array $link_ids = array(), array $pubs = array())
{