// The following fields are the fields of the form in the profile edition.
private $type = 'fixed';
public $display = '';
- private $pub = 'ax';
+ public $pub = 'ax';
public $comment = '';
private $error = false;
}
}
- static private function formArrayWalk(array $data, $function, &$success = true, $requiresEmptyPhone = false)
+ static private function formArrayWalk(array $data, $function, &$success = true, $requiresEmptyPhone = false, $maxPublicity = null)
{
$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) && $maxPublicity->isVisible($phone->pub)) {
+ $phone->pub = $maxPublicity->level();
+ }
$phones[] = call_user_func(array($phone, $function));
}
}
if (count($phones) == 0 && $requiresEmptyPhone) {
$phone = new Phone();
+ if (!is_null($maxPublicity) && $maxPublicity->isVisible($phone->pub)) {
+ $phone->pub = $maxPublicity->level();
+ }
$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)