diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2013-01-14 19:45:17 +0100 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2013-01-14 19:45:17 +0100 |
commit | 31b1a73e1f508a33843835b632ee05c7bfc2aaaf (patch) | |
tree | e590662315799744155151b2c6c9148d2e9e860e /settings | |
parent | fa78fbe0c3e281c91468bee92c871be7b1e48c79 (diff) | |
download | nextcloud-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')
-rw-r--r-- | settings/ajax/changepassword.php | 2 | ||||
-rw-r--r-- | settings/ajax/createuser.php | 4 | ||||
-rw-r--r-- | settings/ajax/removeuser.php | 2 | ||||
-rw-r--r-- | settings/ajax/setquota.php | 2 | ||||
-rw-r--r-- | settings/ajax/togglegroups.php | 4 | ||||
-rw-r--r-- | settings/ajax/userlist.php | 2 | ||||
-rw-r--r-- | settings/help.php | 2 | ||||
-rw-r--r-- | settings/users.php | 3 |
8 files changed, 9 insertions, 12 deletions
diff --git a/settings/ajax/changepassword.php b/settings/ajax/changepassword.php index b2db2611518..cf440c577da 100644 --- a/settings/ajax/changepassword.php +++ b/settings/ajax/changepassword.php @@ -9,7 +9,7 @@ $password = $_POST["password"]; $oldPassword=isset($_POST["oldpassword"])?$_POST["oldpassword"]:''; $userstatus = null; -if(OC_Group::inGroup(OC_User::getUser(), 'admin')) { +if(OC_User::isAdminUser(OC_User::getUser()) { $userstatus = 'admin'; } if(OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username)) { diff --git a/settings/ajax/createuser.php b/settings/ajax/createuser.php index addae78517a..09ef25d92fa 100644 --- a/settings/ajax/createuser.php +++ b/settings/ajax/createuser.php @@ -3,9 +3,7 @@ OCP\JSON::callCheck(); OC_JSON::checkSubAdminUser(); -$isadmin = OC_Group::inGroup(OC_User::getUser(), 'admin')?true:false; - -if($isadmin) { +if(OC_User::isAdminUser(OC_User::getUser())) { $groups = array(); if( isset( $_POST["groups"] )) { $groups = $_POST["groups"]; diff --git a/settings/ajax/removeuser.php b/settings/ajax/removeuser.php index 9ffb32a0b23..bf3a34f1472 100644 --- a/settings/ajax/removeuser.php +++ b/settings/ajax/removeuser.php @@ -10,7 +10,7 @@ if(OC_User::getUser() === $username) { exit; } -if(!OC_Group::inGroup(OC_User::getUser(), 'admin') && !OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username)) { +if(!OC_User::isAdminUser(OC_User::getUser()) && !OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username)) { $l = OC_L10N::get('core'); OC_JSON::error(array( 'data' => array( 'message' => $l->t('Authentication error') ))); exit(); diff --git a/settings/ajax/setquota.php b/settings/ajax/setquota.php index 845f8ea408c..89c46294d08 100644 --- a/settings/ajax/setquota.php +++ b/settings/ajax/setquota.php @@ -10,7 +10,7 @@ OCP\JSON::callCheck(); $username = isset($_POST["username"])?$_POST["username"]:''; -if(($username == '' && !OC_Group::inGroup(OC_User::getUser(), 'admin')) || (!OC_Group::inGroup(OC_User::getUser(), 'admin') && !OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username))) { +if(($username == '' && !OC_User::isAdminUser($user)) || (!OC_User::isAdminUser(OC_User::getUser()) && !OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username))) { $l = OC_L10N::get('core'); OC_JSON::error(array( 'data' => array( 'message' => $l->t('Authentication error') ))); exit(); 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(); diff --git a/settings/ajax/userlist.php b/settings/ajax/userlist.php index eaeade60a39..9bbff80ea0c 100644 --- a/settings/ajax/userlist.php +++ b/settings/ajax/userlist.php @@ -28,7 +28,7 @@ if (isset($_GET['offset'])) { $offset = 0; } $users = array(); -if (OC_Group::inGroup(OC_User::getUser(), 'admin')) { +if (OC_User::isAdminUser(OC_User::getUser())) { $batch = OC_User::getUsers('', 10, $offset); foreach ($batch as $user) { $users[] = array( diff --git a/settings/help.php b/settings/help.php index cd3d615425c..a5ac11ec9a3 100644 --- a/settings/help.php +++ b/settings/help.php @@ -27,7 +27,7 @@ $url1=OC_Helper::linkToRoute( "settings_help" ).'?mode=user'; $url2=OC_Helper::linkToRoute( "settings_help" ).'?mode=admin'; $tmpl = new OC_Template( "settings", "help", "user" ); -$tmpl->assign( "admin", OC_Group::inGroup(OC_User::getUser(), 'admin') ); +$tmpl->assign( "admin", OC_User::isAdminUser(OC_User::getUser())); $tmpl->assign( "url", $url ); $tmpl->assign( "url1", $url1 ); $tmpl->assign( "url2", $url2 ); diff --git a/settings/users.php b/settings/users.php index 07a7620d3c0..1a32a7ecb5b 100644 --- a/settings/users.php +++ b/settings/users.php @@ -18,8 +18,7 @@ OC_App::setActiveNavigationEntry( 'core_users' ); $users = array(); $groups = array(); -$isadmin = OC_Group::inGroup(OC_User::getUser(), 'admin')?true:false; -if($isadmin) { +if(OC_User::isAdminUser(OC_User::getUser())) { $accessiblegroups = OC_Group::getGroups(); $accessibleusers = OC_User::getUsers('', 30); $subadmins = OC_SubAdmin::getAllSubAdmins(); |