summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2010-02-20 11:18:49 +0000
committercweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2010-02-20 11:18:49 +0000
commit6c9542f24b630f60490949f4e77bcb0cf1bf7377 (patch)
tree06ce0ab35e80f3f2c1af9fe373169efe7a9fe766 /src
parent6a6cba1a4d61d42bd93fb385f576d299bd99cc59 (diff)
downloadsemanticscuttle-6c9542f24b630f60490949f4e77bcb0cf1bf7377.tar.gz
semanticscuttle-6c9542f24b630f60490949f4e77bcb0cf1bf7377.tar.bz2
make isAdmin accept a user name, too
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@669 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'src')
-rw-r--r--src/SemanticScuttle/Service/User.php14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/SemanticScuttle/Service/User.php b/src/SemanticScuttle/Service/User.php
index cedde92..0b28663 100644
--- a/src/SemanticScuttle/Service/User.php
+++ b/src/SemanticScuttle/Service/User.php
@@ -305,9 +305,14 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
/**
* Checks if the given user is an administrator.
* Uses global admin_users property containing admin
- * user names
+ * user names.
*
- * @param integer|array $user User ID or user row from DB
+ * Passing the user id makes this function load the user
+ * from database. For efficiency reasons, try to pass
+ * the user name or database row.
+ *
+ * @param integer|array|string $user User ID or user row from DB
+ * or user name
*
* @return boolean True if the user is admin
*/
@@ -315,10 +320,13 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
{
if (is_numeric($user)) {
$user = $this->getUser($user);
+ $user = $user['username'];
+ } else if (is_array($user)) {
+ $user = $user['username'];
}
if (isset($GLOBALS['admin_users'])
- && in_array($user['username'], $GLOBALS['admin_users'])
+ && in_array($user, $GLOBALS['admin_users'])
) {
return true;
} else {