X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fphone.php;h=64dfe0ef2dfcfddcf5a34b055f4e9c843d3611e6;hb=e429cd03ff90d7f50f68775245df33403ddcd986;hp=e8aad782c6d0d1e915cd70bce60d13b7c69365ef;hpb=6592a26462d852171d477c8f273ca3477b72b970;p=platal.git diff --git a/classes/phone.php b/classes/phone.php index e8aad78..64dfe0e 100644 --- a/classes/phone.php +++ b/classes/phone.php @@ -67,7 +67,7 @@ class Phone // 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; @@ -349,27 +349,33 @@ class Phone } } - 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)