}
}
- return self::formArrayWalk($data, 'toFormArray', $success, true);
+ $addresses = self::formArrayWalk($data, 'toFormArray', $success, true);
+ usort($addresses, 'ProfileVisibility::comparePublicity');
+ return $addresses;
}
static public function formArrayToString(array $data)
// Formats an array of form phones into an array of form formatted phones.
static public function formatFormArray(array $data, &$success = true, $maxPublicity = null)
{
- return self::formArrayWalk($data, 'toFormArray', $success, true, $maxPublicity);
+ $phones = self::formArrayWalk($data, 'toFormArray', $success, true, $maxPublicity);
+ usort($phones, 'ProfileVisibility::comparePublicity');
+ return $phones;
}
static public function formArrayToString(array $data)
private $level;
- public function __construct($level = null)
+ public function __construct($level = null, $force = false)
{
- $this->setLevel($level);
+ if ($force) {
+ $this->forceLevel($level);
+ } else {
+ $this->setLevel($level);
+ }
}
public function setLevel($level = self::VIS_PUBLIC)
}
}
+ public function forceLevel($level)
+ {
+ if ($level != self::VIS_PRIVATE && $level != self::VIS_AX && $level != self::VIS_PUBLIC) {
+ Platal::page()->kill('Invalid visibility: ' . $level);
+ }
+
+ $this->level = $level;
+ }
+
public function level()
{
if ($this->level == null) {
{
return in_array($visibility, $this->levels());
}
+
+ static public function comparePublicity($a, $b)
+ {
+ $a_pub = new ProfileVisibility($a['pub'], true);
+ $b_pub = new ProfileVisibility($b['pub'], true);
+
+ return !$a_pub->isVisible($b_pub->level());
+ }
}
$success = ($success && $s);
}
}
+ usort($value, 'ProfileVisibility::comparePublicity');
return $value;
}