From: Raphaël Barrois Date: Mon, 22 Mar 2010 21:53:11 +0000 (+0100) Subject: Add Profile->displayEmail() X-Git-Tag: xorg/1.0.0~332^2~2 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=564e2b2ae7ed134190d60ebc4447f476c4b024dd;p=platal.git Add Profile->displayEmail() Either fetches it from the owner User, of from the profile.email_directory field in the DB Signed-off-by: Raphaël Barrois --- diff --git a/classes/profile.php b/classes/profile.php index da54907..96cc71e 100644 --- a/classes/profile.php +++ b/classes/profile.php @@ -151,6 +151,8 @@ class Profile private $pid; private $hrpid; + private $owner; + private $owner_fetched = false; private $data = array(); private $visibility = null; @@ -174,6 +176,15 @@ class Profile return $this->hrpid; } + public function owner() + { + if ($this->owner == null && !$this->owner_fetched) { + $this->owner_fetched = true; + $this->owner = User::getSilent($this); + } + return $this->owner; + } + public function promo() { return $this->promo; @@ -247,6 +258,16 @@ class Profile return ($this->deathdate != null); } + public function displayEmail() + { + $o = $this->owner(); + if ($o != null) { + return $o->bestEmail(); + } else { + return $this->email_directory; + } + } + public function data() { $this->first_name; @@ -628,11 +649,6 @@ class Profile return $this->medals->medals; } - public function owner() - { - return User::getSilent($this); - } - public function compareNames($firstname, $lastname) { $_lastname = mb_strtoupper($this->lastName());