X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fprofile.php;h=d3a1fddf3964f6cf998a9271b700bf06d5c5ef33;hb=c76545c351fae4e2298624ff9ee5bf854dc5a5b6;hp=a74706364b337a23a0ef76dabea307de65119680;hpb=3ac45f10c6b54e4db4bfeb0aeb5eef0f5ee5d1b2;p=platal.git diff --git a/classes/profile.php b/classes/profile.php index a747063..d3a1fdd 100644 --- a/classes/profile.php +++ b/classes/profile.php @@ -19,64 +19,6 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ -class ProfileVisibility -{ - static private $v_values = array(self::VIS_PUBLIC => array(self::VIS_PUBLIC), - self::VIS_AX => array(self::VIS_AX, self::VIS_PUBLIC), - self::VIS_PRIVATE => array(self::VIS_PRIVATE, self::VIS_AX, self::VIS_PUBLIC)); - - const VIS_PUBLIC = 'public'; - const VIS_AX = 'ax'; - const VIS_PRIVATE = 'private'; - - private $level; - - public function __construct($level = null) - { - $this->setLevel($level); - } - - public function setLevel($level = self::VIS_PUBLIC) - { - if ($level != null && $level != self::VIS_PRIVATE && $level != self::VIS_AX && $level != self::VIS_PUBLIC) { - Platal::page()->kill("Invalid visibility: " . $level); - } - - if (!S::logged()) { - $level = self::VIS_PUBLIC; - } else if ($level == null) { - $level = self::VIS_PRIVATE; - } - - if ($this->level == null || $this->level == self::VIS_PRIVATE) { - $this->level = $level; - } else if ($this->level == self::VIS_AX && $level == self::VIS_PRIVATE) { - return; - } else { - $this->level = self::VIS_PUBLIC; - } - } - - public function level() - { - if ($this->level == null) { - return self::VIS_PUBLIC; - } else { - return $this->level; - } - } - - public function levels() - { - return self::$v_values[$this->level()]; - } - - public function isVisible($visibility) - { - return in_array($visibility, $this->levels()); - } -} - class Profile { @@ -481,10 +423,12 @@ class Profile $this->fetched_fields = $fields; } + /** Have we already fetched this field ? + */ private function fetched($field) { - if (($fields | self::FETCH_ALL) != self::FETCH_ALL) { - Platal::page()->kill("Invalid fetched fields: $fields"); + if (!array_key_exists($field, ProfileField::$fields)) { + Platal::page()->kill("Invalid field: $field"); } return ($this->fetched_fields & $field); @@ -514,6 +458,7 @@ class Profile */ private function consolidateFields() { + // Link phones to addresses if ($this->phones != null) { if ($this->addresses != null) { $this->addresses->addPhones($this->phones); @@ -524,9 +469,12 @@ class Profile } } + // Link addresses to jobs if ($this->addresses != null && $this->jobs != null) { $this->jobs->addAddresses($this->addresses); } + + // Link jobterms to jobs if ($this->jobs != null && $this->jobterms != null) { $this->jobs->addJobTerms($this->jobterms); }