summaryrefslogtreecommitdiffstats
path: root/settings/ajax/togglegroups.php
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2013-01-14 19:45:17 +0100
committerLukas Reschke <lukas@statuscode.ch>2013-01-14 19:45:17 +0100
commit31b1a73e1f508a33843835b632ee05c7bfc2aaaf (patch)
treee590662315799744155151b2c6c9148d2e9e860e /settings/ajax/togglegroups.php
parentfa78fbe0c3e281c91468bee92c871be7b1e48c79 (diff)
downloadnextcloud-server-31b1a73e1f508a33843835b632ee05c7bfc2aaaf.tar.gz
nextcloud-server-31b1a73e1f508a33843835b632ee05c7bfc2aaaf.zip
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 'settings/ajax/togglegroups.php')
-rw-r--r--settings/ajax/togglegroups.php4
1 files changed, 2 insertions, 2 deletions
diff --git a/settings/ajax/togglegroups.php b/settings/ajax/togglegroups.php
index 83d455550ae..548dc2e209b 100644
--- a/settings/ajax/togglegroups.php
+++ b/settings/ajax/togglegroups.php
@@ -7,13 +7,13 @@ $success = true;
$username = $_POST["username"];
$group = $_POST["group"];
-if($username == OC_User::getUser() && $group == "admin" && OC_Group::inGroup($username, 'admin')) {
+if($username == OC_User::getUser() && $group == "admin" && OC_User::isAdminUser($username)) {
$l = OC_L10N::get('core');
OC_JSON::error(array( 'data' => array( 'message' => $l->t('Admins can\'t remove themself from the admin group'))));
exit();
}
-if(!OC_Group::inGroup(OC_User::getUser(), 'admin') && (!OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username) || !OC_SubAdmin::isGroupAccessible(OC_User::getUser(), $group))) {
+if(!OC_User::isAdminUser(OC_User::getUser()) && (!OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username) || !OC_SubAdmin::isGroupAccessible(OC_User::getUser(), $group))) {
$l = OC_L10N::get('core');
OC_JSON::error(array( 'data' => array( 'message' => $l->t('Authentication error') )));
exit();