Merge branch 'xorg/1.0.2/master' into xorg/master
[platal.git] / classes / phone.php
index 95a72ad..64dfe0e 100644 (file)
@@ -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;
 
@@ -351,27 +351,21 @@ class Phone
 
     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));
         }