Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2013-01-14 22:45:17 +0400
committerLukas Reschke <lukas@statuscode.ch>2013-01-14 22:45:17 +0400
commit31b1a73e1f508a33843835b632ee05c7bfc2aaaf (patch)
treee590662315799744155151b2c6c9148d2e9e860e /lib/subadmin.php
parentfa78fbe0c3e281c91468bee92c871be7b1e48c79 (diff)
Check if user is admin - bool
There was no "isAdminUser()" function which returned bool. This is irritiating as there were a loooooooot of places in the code which checked this itself with `OC_Group::inGroup($uid, 'admin)` - why not use a function for this? (Especially if you consider that we might change the group name in the future, which would lead to problems then) Additionally, @Raydiation needed such a method for his AppFramework :)
Diffstat (limited to 'lib/subadmin.php')
-rw-r--r--lib/subadmin.php7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/subadmin.php b/lib/subadmin.php
index 9e83e6da430..8cda7240ac9 100644
--- a/lib/subadmin.php
+++ b/lib/subadmin.php
@@ -122,6 +122,11 @@ class OC_SubAdmin{
* @return bool
*/
public static function isSubAdmin($uid) {
+ // Check if the user is already an admin
+ if(OC_Group::inGroup($uid, 'admin' )) {
+ return true;
+ }
+
$stmt = OC_DB::prepare('SELECT COUNT(*) AS `count` FROM `*PREFIX*group_admin` WHERE `uid` = ?');
$result = $stmt->execute(array($uid));
$result = $result->fetchRow();
@@ -141,7 +146,7 @@ class OC_SubAdmin{
if(!self::isSubAdmin($subadmin)) {
return false;
}
- if(OC_Group::inGroup($user, 'admin')) {
+ if(OC_User::isAdminUser($user)) {
return false;
}
$accessiblegroups = self::getSubAdminsGroups($subadmin);