From: Raphaël Barrois Date: Tue, 16 Mar 2010 23:26:50 +0000 (+0100) Subject: Enable "on access" fetching of data X-Git-Tag: xorg/1.0.0~332^2~49 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=990cb17b12f0e4bd2971de1e87fba658cd1d2be4;p=platal.git Enable "on access" fetching of data Signed-off-by: Raphaël Barrois --- 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(); + } } // }}}