X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fprofilevisibility.php;h=cf5687d6717a9c833201a35cfe6ebfcc68a950b6;hb=977168f6915e290cf8d9351651b9d8a0c908ac70;hp=4b91fcc22ee6693ebf5e3e772ae4b9596503f0a1;hpb=12ddbc2037b16496dfb9d91c4f7091850146fcde;p=platal.git diff --git a/classes/profilevisibility.php b/classes/profilevisibility.php index 4b91fcc..cf5687d 100644 --- a/classes/profilevisibility.php +++ b/classes/profilevisibility.php @@ -1,6 +1,6 @@ setLevel($level); + if ($force) { + $this->forceLevel($level); + } else { + $this->setLevel($level); + } } public function setLevel($level = self::VIS_PUBLIC) @@ -62,6 +66,15 @@ class ProfileVisibility } } + 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) { @@ -80,6 +93,14 @@ class ProfileVisibility { 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()); + } }