diff options
author | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-01-08 17:34:55 +0000 |
---|---|---|
committer | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-01-08 17:34:55 +0000 |
commit | fdb4b147001fb40151e39f4b846b928914c306d7 (patch) | |
tree | 49d287cc0760cb0b3e948c3dbb12eacb05e493a6 /engine/lib | |
parent | 62d82935fcb7214467bd3f99518fa15b43c31966 (diff) | |
download | elgg-fdb4b147001fb40151e39f4b846b928914c306d7.tar.gz elgg-fdb4b147001fb40151e39f4b846b928914c306d7.tar.bz2 |
Refs #668: Building on [2546] and providing ban and unban functions. Later these will be replaced with "banning" functions.
git-svn-id: https://code.elgg.org/elgg/trunk@2549 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r-- | engine/lib/users.php | 54 |
1 files changed, 43 insertions, 11 deletions
diff --git a/engine/lib/users.php b/engine/lib/users.php index 9b8594a93..79e9c9d24 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -162,21 +162,12 @@ * * @param string $reason Optional reason */ - public function ban($reason = "") - { - if (disable_user_entities($this->guid)) - return $this->disable($reason); - - return false; - } + public function ban($reason = "") { return ban_user($this->guid, $reason); } /** * Unban this user. */ - public function unban() - { - return enable_entity($this->guid); - }
+ public function unban() { return unban_user($this->guid); }
/**
* Get sites that this user is a member of
@@ -442,6 +433,47 @@ } return false; + } + + /** + * Ban a user + * + * @param int $user_guid The user guid + * @param string $reason A reason + */ + function ban_user($user_guid, $reason = "") + { + $user_guid = (int)$user_guid; + $reason = sanitise_string($reason); + + $user = get_entity($user_guid); + + if (($user) && ($user->canEdit()) && ($user instanceof ElggUser)) + { + if (disable_user_entities($user_guid)) + return $user->disable($reason); + } + + return false; + } + + /** + * Unban a user. + * + * @param int $user_guid Unban a user. + */ + function unban_user($user_guid) + { + $user_guid = (int)$user_guid; + + $user = get_entity($user_guid); + + if (($user) && ($user->canEdit()) && ($user instanceof ElggUser)) + { + return enable_entity($user_guid); + } + + return false; }
/**
|