diff options
Diffstat (limited to 'settings/ajax')
-rw-r--r-- | settings/ajax/creategroup.php | 1 | ||||
-rw-r--r-- | settings/ajax/createuser.php | 9 | ||||
-rw-r--r-- | settings/ajax/enableapp.php | 4 | ||||
-rw-r--r-- | settings/ajax/grouplist.php | 48 | ||||
-rw-r--r-- | settings/ajax/userlist.php | 51 |
5 files changed, 98 insertions, 15 deletions
diff --git a/settings/ajax/creategroup.php b/settings/ajax/creategroup.php index 0a79527c219..854f2c37189 100644 --- a/settings/ajax/creategroup.php +++ b/settings/ajax/creategroup.php @@ -4,6 +4,7 @@ OCP\JSON::callCheck(); OC_JSON::checkAdminUser(); $groupname = $_POST["groupname"]; +$l = OC_L10N::get('settings'); // Does the group exist? if( in_array( $groupname, OC_Group::getGroups())) { diff --git a/settings/ajax/createuser.php b/settings/ajax/createuser.php index 94b56fa0349..ae1d8856f43 100644 --- a/settings/ajax/createuser.php +++ b/settings/ajax/createuser.php @@ -43,12 +43,15 @@ try { OC_Group::addToGroup( $username, $i ); } - OC_JSON::success(array("data" => + $userManager = \OC_User::getManager(); + $user = $userManager->get($username); + OCP\JSON::success(array("data" => array( // returns whether the home already existed "homeExists" => $homeExists, "username" => $username, - "groups" => OC_Group::getUserGroups( $username )))); + "groups" => OC_Group::getUserGroups( $username ), + 'storageLocation' => $user->getHome()))); } catch (Exception $exception) { - OC_JSON::error(array("data" => array( "message" => $exception->getMessage()))); + OCP\JSON::error(array("data" => array( "message" => $exception->getMessage()))); } diff --git a/settings/ajax/enableapp.php b/settings/ajax/enableapp.php index 735794360b3..81ca1e0338d 100644 --- a/settings/ajax/enableapp.php +++ b/settings/ajax/enableapp.php @@ -3,8 +3,10 @@ OC_JSON::checkAdminUser(); OCP\JSON::callCheck(); +$groups = isset($_POST['groups']) ? $_POST['groups'] : null; + try { - OC_App::enable(OC_App::cleanAppId($_POST['appid'])); + OC_App::enable(OC_App::cleanAppId($_POST['appid']), $groups); OC_JSON::success(); } catch (Exception $e) { OC_Log::write('core', $e->getMessage(), OC_Log::ERROR); diff --git a/settings/ajax/grouplist.php b/settings/ajax/grouplist.php new file mode 100644 index 00000000000..91700adc359 --- /dev/null +++ b/settings/ajax/grouplist.php @@ -0,0 +1,48 @@ +<?php +/** + * ownCloud + * + * @author Arthur Schiwon + * @copyright 2014 Arthur Schiwon <blizzz@owncloud.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + * + */ + +OC_JSON::callCheck(); +OC_JSON::checkSubAdminUser(); +if (isset($_GET['pattern']) && !empty($_GET['pattern'])) { + $pattern = $_GET['pattern']; +} else { + $pattern = ''; +} +$groups = array(); +$adminGroups = array(); +$groupManager = \OC_Group::getManager(); +$isAdmin = OC_User::isAdminUser(OC_User::getUser()); + +//we pass isAdmin as true, because OC_SubAdmin has no search feature, +//groups will be filtered out later +$groupsInfo = new \OC\Group\MetaData(OC_User::getUser(), true, $groupManager); +$groupsInfo->setSorting($groupsInfo::SORT_USERCOUNT); +list($adminGroups, $groups) = $groupsInfo->get($pattern); + +$accessibleGroups = $groupManager->search($pattern); +if(!$isAdmin) { + $subadminGroups = OC_SubAdmin::getSubAdminsGroups(OC_User::getUser()); + $accessibleGroups = array_intersect($groups, $subadminGroups); +} + +OC_JSON::success( + array('data' => array('adminGroups' => $adminGroups, 'groups' => $groups))); diff --git a/settings/ajax/userlist.php b/settings/ajax/userlist.php index 4abf54b8987..32237d60b6e 100644 --- a/settings/ajax/userlist.php +++ b/settings/ajax/userlist.php @@ -32,26 +32,55 @@ if (isset($_GET['limit'])) { } else { $limit = 10; } +if (isset($_GET['gid']) && !empty($_GET['gid'])) { + $gid = $_GET['gid']; +} else { + $gid = false; +} +if (isset($_GET['pattern']) && !empty($_GET['pattern'])) { + $pattern = $_GET['pattern']; +} else { + $pattern = ''; +} $users = array(); +$userManager = \OC_User::getManager(); if (OC_User::isAdminUser(OC_User::getUser())) { - $batch = OC_User::getDisplayNames('', $limit, $offset); - foreach ($batch as $user => $displayname) { + if($gid !== false) { + $batch = OC_Group::displayNamesInGroup($gid, $pattern, $limit, $offset); + } else { + $batch = OC_User::getDisplayNames($pattern, $limit, $offset); + } + foreach ($batch as $uid => $displayname) { + $user = $userManager->get($uid); $users[] = array( - 'name' => $user, + 'name' => $uid, 'displayname' => $displayname, - 'groups' => join(', ', OC_Group::getUserGroups($user)), - 'subadmin' => join(', ', OC_SubAdmin::getSubAdminsGroups($user)), - 'quota' => OC_Preferences::getValue($user, 'files', 'quota', 'default')); + 'groups' => join(', ', OC_Group::getUserGroups($uid)), + 'subadmin' => join(', ', OC_SubAdmin::getSubAdminsGroups($uid)), + 'quota' => OC_Preferences::getValue($uid, 'files', 'quota', 'default'), + 'storageLocation' => $user->getHome(), + 'lastLogin' => $user->getLastLogin(), + ); } } else { $groups = OC_SubAdmin::getSubAdminsGroups(OC_User::getUser()); - $batch = OC_Group::usersInGroups($groups, '', $limit, $offset); - foreach ($batch as $user) { + if($gid !== false && in_array($gid, $groups)) { + $groups = array($gid); + } elseif($gid !== false) { + //don't you try to investigate loops you must not know about + $groups = array(); + } + $batch = OC_Group::usersInGroups($groups, $pattern, $limit, $offset); + foreach ($batch as $uid) { + $user = $userManager->get($uid); $users[] = array( 'name' => $user, - 'displayname' => OC_User::getDisplayName($user), - 'groups' => join(', ', OC_Group::getUserGroups($user)), - 'quota' => OC_Preferences::getValue($user, 'files', 'quota', 'default')); + 'displayname' => $user->getDisplayName(), + 'groups' => join(', ', OC_Group::getUserGroups($uid)), + 'quota' => OC_Preferences::getValue($uid, 'files', 'quota', 'default'), + 'storageLocation' => $user->getHome(), + 'lastLogin' => $user->getLastLogin(), + ); } } OC_JSON::success(array('data' => $users)); |