From fdb4b147001fb40151e39f4b846b928914c306d7 Mon Sep 17 00:00:00 2001 From: marcus Date: Thu, 8 Jan 2009 17:34:55 +0000 Subject: 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 --- engine/lib/users.php | 54 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 11 deletions(-) (limited to 'engine/lib') 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; } /** -- cgit v1.2.3