// 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, $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;
- }
+ 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) && array_key_exists($maxPublicity, $publicity)) {
- if ($publicity[$phone->pub] > $publicity[$maxPublicity]) {
- $phone->pub = $maxPublicity;
- }
+ if (!is_null($maxPublicity) && $maxPublicity->isVisible($phone->pub)) {
+ $phone->pub = $maxPublicity->level();
}
$phones[] = call_user_func(array($phone, $function));
}