From 564e2b2ae7ed134190d60ebc4447f476c4b024dd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Barrois?= Date: Mon, 22 Mar 2010 22:53:11 +0100 Subject: [PATCH] Add Profile->displayEmail() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Either fetches it from the owner User, of from the profile.email_directory field in the DB Signed-off-by: Raphaël Barrois --- classes/profile.php | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) 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()); -- 2.1.4