From f448f7b8c7a49e46736c82450b625a6d634b5803 Mon Sep 17 00:00:00 2001 From: brettp Date: Fri, 24 Sep 2010 21:03:51 +0000 Subject: Refs #617: ElggUser:makeAdmin() and removeAdmin() correctly set the attribute for unsaved users. git-svn-id: http://code.elgg.org/elgg/trunk@6965 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/classes/ElggUser.php | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/engine/classes/ElggUser.php b/engine/classes/ElggUser.php index e887b271e..3bd93bba2 100644 --- a/engine/classes/ElggUser.php +++ b/engine/classes/ElggUser.php @@ -204,11 +204,15 @@ class ElggUser extends ElggEntity * @return bool */ public function makeAdmin() { - if (make_user_admin($this->guid)) { - $this->attributes['admin'] = 'yes'; - return TRUE; + // If already saved, use the standard function. + if ($this->guid && !make_user_admin($this->guid)) { + return FALSE; } - return FALSE; + + // need to manually set attributes since they've already been loaded. + $this->attributes['admin'] = 'yes'; + + return TRUE; } /** @@ -217,11 +221,15 @@ class ElggUser extends ElggEntity * @return bool */ public function removeAdmin() { - if (remove_user_admin($this->guid)) { - $this->attributes['admin'] = 'no'; - return TRUE; + // If already saved, use the standard function. + if ($this->guid && !remove_user_admin($this->guid)) { + return FALSE; } - return FALSE; + + // need to manually set attributes since they've already been loaded. + $this->attributes['admin'] = 'no'; + + return TRUE; } /** -- cgit v1.2.3