diff options
author | Georg Ehrke <dev@georgswebsite.de> | 2012-07-09 21:51:19 +0200 |
---|---|---|
committer | Georg Ehrke <dev@georgswebsite.de> | 2012-07-09 21:51:19 +0200 |
commit | d0b625352cc8acc160e22cb2f4e9ae8e10f753f6 (patch) | |
tree | 70ce62fafd75de45d7c1c5e9616ac5229ef7537e /lib/util.php | |
parent | acb196e17fb6d01a808e8758b5f852447cc03d99 (diff) | |
download | nextcloud-server-d0b625352cc8acc160e22cb2f4e9ae8e10f753f6.tar.gz nextcloud-server-d0b625352cc8acc160e22cb2f4e9ae8e10f753f6.zip |
some work on subadmins
Diffstat (limited to 'lib/util.php')
-rwxr-xr-x | lib/util.php | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/util.php b/lib/util.php index 2a7b8a922f9..de9171edc8e 100755 --- a/lib/util.php +++ b/lib/util.php @@ -66,7 +66,7 @@ class OC_Util { * @return array */ public static function getVersion(){ - return array(4,80,1); + return array(4,81,2); } /** @@ -321,6 +321,26 @@ class OC_Util { } /** + * Check if the user is a subadmin, redirects to home if not + * @return array $groups where the current user is subadmin + */ + public static function checkSubAdminUser(){ + // Check if we are a user + self::checkLoggedIn(); + if(OC_Group::inGroup(OC_User::getUser(),'admin')){ + return OC_Group::getGroups(); + } + $stmt = OC_DB::prepare('SELECT COUNT(*) as count FROM *PREFIX*group_admin WHERE uid = ?'); + $result = $stmt->execute(array(OC_User::getUser())); + $result = $result->fetchRow(); + if($result['count'] == 0){ + header( 'Location: '.OC_Helper::linkToAbsolute( '', 'index.php' )); + exit(); + } + return $groups; + } + + /** * Redirect to the user default page */ public static function redirectToDefaultPage(){ |