]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
make isAdmin accept a user name, too
authorcweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>
Sat, 20 Feb 2010 11:18:49 +0000 (11:18 +0000)
committercweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>
Sat, 20 Feb 2010 11:18:49 +0000 (11:18 +0000)
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@669 b3834d28-1941-0410-a4f8-b48e95affb8f

src/SemanticScuttle/Service/User.php

index cedde9271b037ac01e77483e67ace14e03589d02..0b28663f2099ef142d9c478b9dd071a8b88fb6af 100644 (file)
@@ -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 {