summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2014-02-19 11:40:07 +0100
committerArthur Schiwon <blizzz@owncloud.com>2014-06-02 12:53:52 +0200
commit478393e15ad3d6c884368f0b1a922eda6f9ffe0e (patch)
tree9447ce1813a66d3aa6ae8ecef751123bea2c4494
parente681e1eec094385e2a41ea301834d6593d97ec0b (diff)
downloadnextcloud-server-478393e15ad3d6c884368f0b1a922eda6f9ffe0e.tar.gz
nextcloud-server-478393e15ad3d6c884368f0b1a922eda6f9ffe0e.zip
load groups when clicking on them
-rw-r--r--settings/ajax/userlist.php17
-rw-r--r--settings/js/users/groups.js5
-rw-r--r--settings/js/users/users.js34
3 files changed, 49 insertions, 7 deletions
diff --git a/settings/ajax/userlist.php b/settings/ajax/userlist.php
index b1c26429534..7ca1d535a46 100644
--- a/settings/ajax/userlist.php
+++ b/settings/ajax/userlist.php
@@ -32,10 +32,19 @@ if (isset($_GET['limit'])) {
} else {
$limit = 10;
}
+if (isset($_GET['gid']) && !empty($_GET['gid'])) {
+ $gid = $_GET['gid'];
+} else {
+ $gid = false;
+}
$users = array();
$userManager = \OC_User::getManager();
if (OC_User::isAdminUser(OC_User::getUser())) {
- $batch = OC_User::getDisplayNames('', $limit, $offset);
+ if($gid !== false) {
+ $batch = OC_Group::displayNamesInGroup($gid, '', $limit, $offset);
+ } else {
+ $batch = OC_User::getDisplayNames('', $limit, $offset);
+ }
foreach ($batch as $uid => $displayname) {
$user = $userManager->get($uid);
$users[] = array(
@@ -50,6 +59,12 @@ if (OC_User::isAdminUser(OC_User::getUser())) {
}
} else {
$groups = OC_SubAdmin::getSubAdminsGroups(OC_User::getUser());
+ 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, '', $limit, $offset);
foreach ($batch as $uid) {
$user = $userManager->get($uid);
diff --git a/settings/js/users/groups.js b/settings/js/users/groups.js
index 5e9f5582b5a..f6124eaa795 100644
--- a/settings/js/users/groups.js
+++ b/settings/js/users/groups.js
@@ -19,6 +19,11 @@
OC.Notification.showHtml(t('settings', 'deleted') + ' ' + escapeHTML(gid) + '<span class="undo">' + t('settings', 'undo') + '</span>');
},
+ showGroup: function (gid) {
+ UserList.empty();
+ UserList.update(gid);
+ },
+
finishDelete: function (ready) {
if (!GroupList.deleteCanceled && GroupList.deleteGid) {
$.ajax({
diff --git a/settings/js/users/users.js b/settings/js/users/users.js
index 47fe5cc5a69..3ef6706b98c 100644
--- a/settings/js/users/users.js
+++ b/settings/js/users/users.js
@@ -139,7 +139,13 @@ var UserList = {
}
tr.find('td.lastLogin').text(lastLogin);
$(tr).appendTo('tbody');
-
+ if(UserList.isEmpty === true) {
+ //when the list was emptied, one row was left, necessary to keep
+ //add working and the layout unbroken. We need to remove this item
+ tr.show();
+ $('tbody tr').first().remove();
+ UserList.isEmpty = false;
+ }
if (sort) {
UserList.doSort();
}
@@ -215,16 +221,23 @@ var UserList = {
$('tbody').append(items);
}
},
- update: function () {
+ empty: function() {
+ //one row needs to be kept, because it is cloned to add new rows
+ $('tbody tr:not(:first)').remove();
+ $('tbody tr').first().hide();
+ UserList.isEmpty = true;
+ UserList.offset = 0;
+ },
+ update: function (gid) {
if (UserList.updating) {
return;
}
$('table+.loading').css('visibility', 'visible');
UserList.updating = true;
- var query = $.param({ offset: UserList.offset, limit: UserList.usersToLoad });
- $.get(OC.generateUrl('/settings/ajax/userlist') + '?' + query, function (result) {
- var loadedUsers = 0;
- var trs = [];
+ if(gid === undefined) {
+ gid = '';
+ }
+ $.get(OC.Router.generate('settings_ajax_userlist', { offset: UserList.offset, limit: UserList.usersToLoad, gid: gid }), function (result) {
if (result.status === 'success') {
//The offset does not mirror the amount of users available,
//because it is backend-dependent. For correct retrieval,
@@ -485,6 +498,15 @@ $(document).ready(function () {
});
});
+ // click on group name
+ // FIXME: also triggered when clicking on "remove"
+ $('ul').on('click', 'li', function (event) {
+ var li = $(this);
+ var gid = $(li).attr('data-gid');
+ // Call function for handling delete/undo on Groups
+ GroupList.showGroup(gid);
+ });
+
$('#newuser').submit(function (event) {
event.preventDefault();
var username = $('#newusername').val();