From 724d9fa421dad542a9ea74f14cd8b43ec44e22d3 Mon Sep 17 00:00:00 2001 From: cweiske Date: Tue, 22 Sep 2009 06:12:25 +0000 Subject: Fix bug #2674961: editAllowed optimization - make less queries for each bookmark git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@366 b3834d28-1941-0410-a4f8-b48e95affb8f --- services/userservice.php | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'services/userservice.php') diff --git a/services/userservice.php b/services/userservice.php index 512204c..a24c7ba 100644 --- a/services/userservice.php +++ b/services/userservice.php @@ -213,11 +213,24 @@ class UserService { } } - function isAdmin($userid) { - $user = $this->getUser($userid); + /** + * Checks if the given user is an administrator. + * Uses global admin_users property containing admin + * user names + * + * @param integer|array $user User ID or user row from DB + * + * @return boolean True if the user is admin + */ + function isAdmin($user) + { + if (is_numeric($user)) { + $user = $this->getUser($user); + } - if(isset($GLOBALS['admin_users']) - && in_array($user['username'], $GLOBALS['admin_users'])) { + if (isset($GLOBALS['admin_users']) + && in_array($user['username'], $GLOBALS['admin_users']) + ) { return true; } else { return false; -- cgit v1.2.3