From 9ddc36c19f494568e806b7a445074ef80640d467 Mon Sep 17 00:00:00 2001 From: Vincent Zanotti Date: Sun, 24 Aug 2008 17:30:59 +0200 Subject: [PATCH] Fixes improper code in __get (code was inadvertantly calling __isset). Adds a public method for extending the user secondary properties. Signed-off-by: Vincent Zanotti --- classes/pluser.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/classes/pluser.php b/classes/pluser.php index 86cdf26..1aa5814 100644 --- a/classes/pluser.php +++ b/classes/pluser.php @@ -177,7 +177,7 @@ abstract class PlUser public function __get($name) { - if (isset($this->$name)) { + if (property_exists($this, $name)) { return $this->$name; } @@ -190,7 +190,7 @@ abstract class PlUser public function __isset($name) { - return isset($this->$name) || isset($this->data[$name]); + return property_exists($this, $name) || isset($this->data[$name]); } /** @@ -213,6 +213,21 @@ abstract class PlUser $this->data = array_merge($this->data, $values); } + /** + * Adds properties to the object; this method does not allow the caller to + * update core properties (id, ...). + * + * @param $values An associative array of non-core properties. + */ + public function addProperties(array $values) + { + foreach ($values as $key => $value) { + if (!property_exists($this, $key)) { + $this->data[$key] = $value; + } + } + } + /** * Build the permissions flags for the user. -- 2.1.4