$this->countryId = null;
}
$this->geocodeChosen = null;
- $this->phones = Phone::formatFormArray($this->phones, $this->error);
+ $this->phones = Phone::formatFormArray($this->phones, $this->error, $this->pub);
if ($format['postalText']) {
$this->formatPostalAddress();
}
}
}
- static private function formArrayWalk(array $data, $function, &$success = true, $requiresEmptyPhone = false)
+ static private function formArrayWalk(array $data, $function, &$success = true, $requiresEmptyPhone = false, $maxPublicity = null)
{
+ static $publicity = array('private' => 0, 'ax' => 1, 'public' => 2);
+
$phones = array();
foreach ($data as $item) {
$phone = new Phone($item);
$success = (!$phone->error && ($phone->format() || $phone->isEmpty()) && $success);
if (!$phone->isEmpty()) {
+ if (!is_null($maxPublicity) && array_key_exists($maxPublicity, $publicity)) {
+ if ($publicity[$phone->pub] > $publicity[$maxPublicity]) {
+ $phone->pub = $maxPublicity;
+ }
+ }
$phones[] = call_user_func(array($phone, $function));
}
}
if (count($phones) == 0 && $requiresEmptyPhone) {
$phone = new Phone();
+ if (!is_null($maxPublicity) && array_key_exists($maxPublicity, $publicity)) {
+ if ($publicity[$phone->pub] > $publicity[$maxPublicity]) {
+ $phone->pub = $maxPublicity;
+ }
+ }
$phones[] = call_user_func(array($phone, $function));
}
return $phones;
}
// Formats an array of form phones into an array of form formatted phones.
- static public function formatFormArray(array $data, &$success = true)
+ static public function formatFormArray(array $data, &$success = true, $maxPublicity = null)
{
- return self::formArrayWalk($data, 'toFormArray', $success, true);
+ return self::formArrayWalk($data, 'toFormArray', $success, true, $maxPublicity);
}
static public function formArrayToString(array $data)
private function cleanJob(ProfilePage &$page, $jobid, array &$job, &$success)
{
+ static $publicity = array('private' => 0, 'ax' => 1, 'public' => 2);
+
if ($job['w_email'] == "new@example.org") {
$job['w_email'] = $job['w_email_new'];
}
$job['jobid'] = $res->fetchOneCell();
}
}
- $job['w_phone'] = Phone::formatFormArray($job['w_phone'], $s);
+
+ if ($publicity[$job['w_email_pub']] > $publicity[$job['pub']]) {
+ $job['w_email_pub'] = $job['pub'];
+ }
+
+ $job['w_phone'] = Phone::formatFormArray($job['w_phone'], $s, $job['pub']);
unset($job['removed']);
unset($job['new']);
public function value(ProfilePage &$page, $field, $value, &$success)
{
+ static $publicity = array('private' => 0, 'ax' => 1, 'public' => 2);
+
$entreprise = ProfileValidate::get_typed_requests($page->pid(), 'entreprise');
$entr_val = 0;
foreach ($value as $key => &$job) {
$address = new Address($job['w_address']);
$s = $address->format();
+ if ($publicity[$address->pub] > $publicity[$job['pub']]) {
+ $address->pub = $job['pub'];
+ }
$job['w_address'] = $address->toFormArray();
$this->cleanJob($page, $key, $job, $s);
if (!$init) {