From 990cb17b12f0e4bd2971de1e87fba658cd1d2be4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Barrois?= Date: Wed, 17 Mar 2010 00:26:50 +0100 Subject: [PATCH] Enable "on access" fetching of data MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaël Barrois --- classes/profile.php | 18 +++++++++++++----- include/profilefields.inc.php | 6 ++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/classes/profile.php b/classes/profile.php index b016b6d..a064402 100644 --- a/classes/profile.php +++ b/classes/profile.php @@ -305,6 +305,11 @@ class Profile return self::$v_values[$visibility]; } + private function getProfileField($cls) + { + return ProfileField::getForPID($cls, $this->id(), $this->visibility); + } + /* Photo */ private $photo = null; @@ -315,6 +320,10 @@ class Profile public function getPhoto($fallback = true) { + if ($this->photo == null) { + $this->setPhoto($this->getProfileField('ProfilePhoto')); + } + if ($this->photo != null) { return $this->photo->pic; } else if ($fallback) { @@ -335,10 +344,9 @@ class Profile public function getAddresses($flags, $limit = null) { if ($this->addresses == null) { - return PlIteratorUtils::fromArray(array()); - } else { - return $this->addresses->get($flags, $limit); + $this->setAddresses($this->getProfileField('ProfileAddresses')); } + return $this->addresses->get($flags, $limit); } public function getMainAddress() @@ -363,7 +371,7 @@ class Profile public function getEducations($flags, $limit = null) { if ($this->educations == null) { - return PlIteratorUtils::fromArray(array()); + $this->setEducations($this->getProfileField('ProfileEducation')); } return $this->educations->get($flags, $limit); } @@ -385,7 +393,7 @@ class Profile public function getNetworking($flags, $limit = null) { if ($this->networks == null) { - return PlIteratorUtils::fromArray(array()); + $this->setNetworking($this->getProfileField('ProfileNetworking')); } return $this->networks->get($flags, $limit); } diff --git a/include/profilefields.inc.php b/include/profilefields.inc.php index 44aa6e2..9e91c90 100644 --- a/include/profilefields.inc.php +++ b/include/profilefields.inc.php @@ -58,6 +58,12 @@ abstract class ProfileField } return $res; } + + public static function getForPID($cls, $pid, $visibility) + { + $it = new ProfileFieldIterator($cls, array($pid), $visibility); + return $it->next(); + } } // }}} -- 2.1.4