aboutsummaryrefslogtreecommitdiff
path: root/engine/classes/ElggUser.php
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-09-24 21:03:51 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-09-24 21:03:51 +0000
commitf448f7b8c7a49e46736c82450b625a6d634b5803 (patch)
tree25eee1db334174441444a2702999abc2898ef25d /engine/classes/ElggUser.php
parent902c59bac60e7e9c8b494aff311effbe257963a4 (diff)
downloadelgg-f448f7b8c7a49e46736c82450b625a6d634b5803.tar.gz
elgg-f448f7b8c7a49e46736c82450b625a6d634b5803.tar.bz2
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
Diffstat (limited to 'engine/classes/ElggUser.php')
-rw-r--r--engine/classes/ElggUser.php24
1 files 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;
}
/**