diff options
author | Lukas Reschke <lukas@owncloud.com> | 2015-10-27 14:09:45 +0100 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2015-10-29 11:31:18 +0100 |
commit | c6f6a8758b3f08e47c3a8f45a67d09698376b2e2 (patch) | |
tree | bfd52190961e28ae97fa65a96df05b1fe0390a2f /settings/ajax | |
parent | f428d31a5d1f91c6e7aa96fd8550c75c02cc0963 (diff) | |
download | nextcloud-server-c6f6a8758b3f08e47c3a8f45a67d09698376b2e2.tar.gz nextcloud-server-c6f6a8758b3f08e47c3a8f45a67d09698376b2e2.zip |
Drop OC_SubAdmin and replace usages
Diffstat (limited to 'settings/ajax')
-rw-r--r-- | settings/ajax/changedisplayname.php | 10 | ||||
-rw-r--r-- | settings/ajax/geteveryonecount.php | 7 | ||||
-rw-r--r-- | settings/ajax/setquota.php | 9 | ||||
-rw-r--r-- | settings/ajax/togglegroups.php | 14 | ||||
-rw-r--r-- | settings/ajax/togglesubadmins.php | 17 |
5 files changed, 48 insertions, 9 deletions
diff --git a/settings/ajax/changedisplayname.php b/settings/ajax/changedisplayname.php index 36c36e73184..380cbac43da 100644 --- a/settings/ajax/changedisplayname.php +++ b/settings/ajax/changedisplayname.php @@ -37,7 +37,15 @@ $userstatus = null; if(OC_User::isAdminUser(OC_User::getUser())) { $userstatus = 'admin'; } -if(OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username)) { + +$isUserAccessible = false; +$subadminUserObject = \OC::$server->getUserManager()->get(\OC_User::getUser()); +$targetUserObject = \OC::$server->getUserManager()->get($username); +if($subadminUserObject !== null && $targetUserObject !== null) { + $isUserAccessible = \OC::$server->getGroupManager()->getSubAdmin()->isUserAccessible($subadminUserObject, $targetUserObject); +} + +if($isUserAccessible) { $userstatus = 'subadmin'; } diff --git a/settings/ajax/geteveryonecount.php b/settings/ajax/geteveryonecount.php index 659c8466f72..002c849fd39 100644 --- a/settings/ajax/geteveryonecount.php +++ b/settings/ajax/geteveryonecount.php @@ -29,7 +29,12 @@ $userCount = 0; $currentUser = \OC::$server->getUserSession()->getUser()->getUID(); if (!OC_User::isAdminUser($currentUser)) { - $groups = OC_SubAdmin::getSubAdminsGroups($currentUser); + $groups = \OC::$server->getGroupManager()->getSubAdmin()->getSubAdminsGroups(\OC::$server->getUserSession()->getUser()); + // New class returns IGroup[] so convert back + foreach ($groups as $key => $group) { + $groups[$key] = $group->getGID(); + } + foreach ($groups as $group) { $userCount += count(OC_Group::usersInGroup($group)); diff --git a/settings/ajax/setquota.php b/settings/ajax/setquota.php index a9012a55345..8e6d44c2d8d 100644 --- a/settings/ajax/setquota.php +++ b/settings/ajax/setquota.php @@ -32,9 +32,16 @@ OCP\JSON::callCheck(); $username = isset($_POST["username"]) ? (string)$_POST["username"] : ''; +$isUserAccessible = false; +$currentUserObject = \OC::$server->getUserSession()->getUser(); +$targetUserObject = \OC::$server->getUserManager()->get($username); +if($targetUserObject !== null && $currentUserObject !== null) { + $isUserAccessible = \OC::$server->getGroupManager()->getSubAdmin()->isUserAccessible($currentUserObject, $targetUserObject); +} + if(($username === '' && !OC_User::isAdminUser(OC_User::getUser())) || (!OC_User::isAdminUser(OC_User::getUser()) - && !OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username))) { + && !$isUserAccessible)) { $l = \OC::$server->getL10N('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 4d248408db0..f46fa356549 100644 --- a/settings/ajax/togglegroups.php +++ b/settings/ajax/togglegroups.php @@ -37,9 +37,19 @@ if($username === OC_User::getUser() && $group === "admin" && OC_User::isAdminUs exit(); } +$isUserAccessible = false; +$isGroupAccessible = false; +$currentUserObject = \OC::$server->getUserSession()->getUser(); +$targetUserObject = \OC::$server->getUserManager()->get($username); +$targetGroupObject = \OC::$server->getGroupManager()->get($group); +if($targetUserObject !== null && $currentUserObject !== null && $targetGroupObject !== null) { + $isUserAccessible = \OC::$server->getGroupManager()->getSubAdmin()->isUserAccessible($currentUserObject, $targetUserObject); + $isGroupAccessible = \OC::$server->getGroupManager()->getSubAdmin()->isSubAdminofGroup($currentUserObject, $targetGroupObject); +} + if(!OC_User::isAdminUser(OC_User::getUser()) - && (!OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username) - || !OC_SubAdmin::isGroupAccessible(OC_User::getUser(), $group))) { + && (!$isUserAccessible + || !$isGroupAccessible)) { $l = \OC::$server->getL10N('core'); OC_JSON::error(array( 'data' => array( 'message' => $l->t('Authentication error') ))); exit(); diff --git a/settings/ajax/togglesubadmins.php b/settings/ajax/togglesubadmins.php index 767baa9f3ee..6d6bf6d6724 100644 --- a/settings/ajax/togglesubadmins.php +++ b/settings/ajax/togglesubadmins.php @@ -27,11 +27,20 @@ OCP\JSON::callCheck(); $username = (string)$_POST['username']; $group = (string)$_POST['group']; +$subAdminManager = \OC::$server->getGroupManager()->getSubAdmin(); +$targetUserObject = \OC::$server->getUserManager()->get($username); +$targetGroupObject = \OC::$server->getGroupManager()->get($group); + +$isSubAdminOfGroup = false; +if($targetUserObject !== null && $targetUserObject !== null) { + $isSubAdminOfGroup = $subAdminManager->isSubAdminofGroup($targetUserObject, $targetGroupObject); +} + // Toggle group -if(OC_SubAdmin::isSubAdminofGroup($username, $group)) { - OC_SubAdmin::deleteSubAdmin($username, $group); -}else{ - OC_SubAdmin::createSubAdmin($username, $group); +if($isSubAdminOfGroup) { + $subAdminManager->deleteSubAdmin($targetUserObject, $targetGroupObject); +} else { + $subAdminManager->createSubAdmin($targetUserObject, $targetGroupObject); } OC_JSON::success(); |