diff --git a/settings/ajax/grouplist.php b/settings/ajax/grouplist.php
new file mode 100644
index 0000000000..1041d7374e
--- /dev/null
+++ b/settings/ajax/grouplist.php
@@ -0,0 +1,75 @@
+
+ *
+ * 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 .
+ *
+ */
+
+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();
+
+$accessiblegroups = $groupManager->search($pattern);
+if (!OC_User::isAdminUser(OC_User::getUser())) {
+ $subadminGroups = OC_SubAdmin::getSubAdminsGroups(OC_User::getUser());
+ $accessiblegroups = array_intersect($accessiblegroups, $subadminGroups);
+}
+
+$sortGroupsIndex = 0;
+$sortGroupsKeys = array();
+$sortAdminGroupsIndex = 0;
+$sortAdminGroupsKeys = array();
+
+foreach($accessiblegroups as $group) {
+ $gid = $group->getGID();
+ $usersInGroup = OC_Group::usersInGroup($gid, '');
+ if (!OC_User::isAdminUser($gid)) {
+ $groups[] = array(
+ 'id' => str_replace(' ','', $gid ),
+ 'name' => $gid,
+ 'usercount' => count($usersInGroup),
+ );
+ $sortGroupsKeys[$sortGroupsIndex] = count($usersInGroup);
+ $sortGroupsIndex++;
+ } else {
+ $adminGroup[] = array(
+ 'id' => str_replace(' ','', $gid ),
+ 'name' => $gid,
+ 'usercount' => count($usersInGroup)
+ );
+ $sortAdminGroupsKeys[$sortAdminGroupsIndex] = count($usersInGroup);
+ $sortAdminGroupsIndex++;
+ }
+}
+
+if(!empty($groups)) {
+ array_multisort($sortGroupsKeys, SORT_DESC, $groups);
+}
+if(!empty($adminGroup)) {
+ array_multisort($sortAdminGroupsKeys, SORT_DESC, $adminGroup);
+}
+
+OC_JSON::success(
+ array('data' => array('adminGroups' => $adminGroups, 'groups' => $groups)));
diff --git a/settings/js/users/filter.js b/settings/js/users/filter.js
index 2c0eefe25d..89c2f46dac 100644
--- a/settings/js/users/filter.js
+++ b/settings/js/users/filter.js
@@ -10,9 +10,10 @@
* @param jQuery input element that works as the user text input field
* @param object the UserList object
*/
-function UserManagementFilter(filterInput, userList) {
+function UserManagementFilter(filterInput, userList, groupList) {
this.filterInput = filterInput;
this.userList = userList;
+ this.groupList = groupList;
this.thread = undefined;
this.oldval = this.filterInput.val();
@@ -25,8 +26,6 @@ function UserManagementFilter(filterInput, userList) {
UserManagementFilter.prototype.init = function() {
umf = this;
this.filterInput.keyup(function(e) {
- console.log(e.keyCode);
-
//we want to react on any printable letter, plus on modyfing stuff like
//Backspace and Delete. extended https://stackoverflow.com/a/12467610
var valid =
@@ -61,6 +60,8 @@ UserManagementFilter.prototype.init = function() {
UserManagementFilter.prototype.run = function() {
this.userList.empty();
this.userList.update();
+ this.groupList.empty();
+ this.groupList.update();
}
/**
diff --git a/settings/js/users/groups.js b/settings/js/users/groups.js
index 0180cb6489..1088467ca1 100644
--- a/settings/js/users/groups.js
+++ b/settings/js/users/groups.js
@@ -6,17 +6,22 @@
*/
var GroupList = {
- addGroup: function(gid) {
+ addGroup: function(gid, usercount) {
+ if(usercount === undefined || usercount === 0) {
+ usercount = '';
+ }
var li = $('li[data-gid]').last().clone();
var ul = $('li[data-gid]').first().parent();
li.attr('data-gid', gid);
- li.attr('data-usercount', 0);
+ li.attr('data-usercount', usercount);
li.find('a span').first().text(gid);
- li.find('span[class=usercount]').first().text('');
+ li.find('span[class=usercount]').first().text(usercount);
$(li).appendTo(ul);
GroupList.sortGroups(0);
+
+ return li;
},
sortGroups: function(usercount) {
@@ -75,6 +80,41 @@
)
},
+ update: function() {
+ if (GroupList.updating) {
+ return;
+ }
+ GroupList.updating = true;
+ pattern = filter.getPattern();
+ var query = $.param({ pattern: pattern });
+ $.get(OC.generateUrl('/settings/ajax/grouplist') + '?' + query, function (result) {
+ var lis = [];
+ if (result.status === 'success') {
+ $.each(result.data, function (i, subset) {
+ $.each(subset, function (index, group) {
+ if($('li[data-gid="' + group.name + '"]').length > 0) {
+ return true;
+ }
+ var li = GroupList.addGroup(group.name, group.usercount);
+ li.addClass('appear transparent');
+ lis.push(li);
+ });
+ });
+ if (result.data.length > 0) {
+ GroupList.doSort();
+ } else {
+ GroupList.noMoreEntries = true;
+ }
+ setTimeout(function() {
+ for (var i = 0; i < lis.length; i++) {
+ lis[i].removeClass('transparent');
+ }
+ }, 0);
+ }
+ GroupList.updating = false;
+ });
+ },
+
elementBelongsToAddGroup: function(el) {
return !(el !== $('#newgroup-form').get(0)
&& $('#newgroup-form').find($(el)).length === 0);
@@ -134,6 +174,9 @@
remove: function(gid) {
$('li').filterAttr('data-gid', gid).remove();
},
+ empty: function() {
+ $('li:not([data-gid=""])').remove();
+ },
initDeleteHandling: function() {
//set up handler
GroupDeleteHandler = new DeleteHandler('removegroup.php', 'groupname',
diff --git a/settings/js/users/users.js b/settings/js/users/users.js
index 481cf1586c..e9c85d20e9 100644
--- a/settings/js/users/users.js
+++ b/settings/js/users/users.js
@@ -403,8 +403,6 @@ $(document).ready(function () {
UserList.applyMultiplySelect($(element));
});
-
-
$('table').on('click', 'td.password>img', function (event) {
event.stopPropagation();
var img = $(this);
@@ -549,5 +547,6 @@ $(document).ready(function () {
);
});
// Implements User Search
- filter = new UserManagementFilter($('#usersearchform input'), UserList);
+ filter = new UserManagementFilter(
+ $('#usersearchform input'), UserList, GroupList);
});
diff --git a/settings/routes.php b/settings/routes.php
index 1352fac838..9acfc2852b 100644
--- a/settings/routes.php
+++ b/settings/routes.php
@@ -25,6 +25,8 @@ $this->create('settings_admin', '/settings/admin')
// users
$this->create('settings_ajax_userlist', '/settings/ajax/userlist')
->actionInclude('settings/ajax/userlist.php');
+$this->create('settings_ajax_grouplist', '/settings/ajax/grouplist')
+ ->actionInclude('settings/ajax/grouplist.php');
$this->create('settings_ajax_createuser', '/settings/ajax/createuser.php')
->actionInclude('settings/ajax/createuser.php');
$this->create('settings_ajax_removeuser', '/settings/ajax/removeuser.php')
diff --git a/settings/templates/users/part.grouplist.php b/settings/templates/users/part.grouplist.php
index 4b1958c1a6..0d5fef7775 100644
--- a/settings/templates/users/part.grouplist.php
+++ b/settings/templates/users/part.grouplist.php
@@ -18,6 +18,9 @@
t('Everyone')); ?>
+
+
+
@@ -25,21 +28,21 @@
t('Admins')); ?>
- 0) { p(count($adminGroup['useringroup'])); } ?>
+ 0) { p($adminGroup['useringroup']); } ?>
-
+
" title="t("change group name"))?>" />
- 0) { p(count($group['useringroup'])); } ?>
+ 0) { p($group['useringroup']); } ?>
diff --git a/settings/users.php b/settings/users.php
index d6e270bbc3..d3fcbb26a3 100644
--- a/settings/users.php
+++ b/settings/users.php
@@ -22,6 +22,7 @@ $users = array();
$groups = array();
$adminGroup = array();
$userManager = \OC_User::getManager();
+$groupManager = \OC_Group::getManager();
if (isset($_GET['offset'])) {
$offset = $_GET['offset'];
@@ -89,14 +90,18 @@ $sortGroupsKeys = array();
$sortAdminGroupsIndex = 0;
$sortAdminGroupsKeys = array();
foreach( $accessiblegroups as $gid ) {
- $usersInGroup = OC_Group::usersInGroup($gid, '', $limit, $offset);
+ $group = $groupManager->get($gid);
+ if(!$group) {
+ continue;
+ }
+ $usersInGroup = $group->count();
if (!OC_User::isAdminUser($gid)) {
$groups[] = array(
'id' => str_replace(' ','', $gid ),
'name' => $gid,
'useringroup' => $usersInGroup,
);
- $sortGroupsKeys[$sortGroupsIndex] = count($usersInGroup);
+ $sortGroupsKeys[$sortGroupsIndex] = $usersInGroup;
$sortGroupsIndex++;
} else {
$adminGroup[] = array(
@@ -104,7 +109,7 @@ foreach( $accessiblegroups as $gid ) {
'name' => $gid,
'useringroup' => $usersInGroup
);
- $sortAdminGroupsKeys[$sortAdminGroupsIndex] = count($usersInGroup);
+ $sortAdminGroupsKeys[$sortAdminGroupsIndex] = $usersInGroup;
$sortAdminGroupsIndex++;
}
}