make filter work on server-side
This commit is contained in:
parent
19fd7cd9c7
commit
5b8ba79356
4 changed files with 51 additions and 16 deletions
|
@ -37,13 +37,18 @@ if (isset($_GET['gid']) && !empty($_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())) {
|
||||
if($gid !== false) {
|
||||
$batch = OC_Group::displayNamesInGroup($gid, '', $limit, $offset);
|
||||
$batch = OC_Group::displayNamesInGroup($gid, $pattern, $limit, $offset);
|
||||
} else {
|
||||
$batch = OC_User::getDisplayNames('', $limit, $offset);
|
||||
$batch = OC_User::getDisplayNames($pattern, $limit, $offset);
|
||||
}
|
||||
foreach ($batch as $uid => $displayname) {
|
||||
$user = $userManager->get($uid);
|
||||
|
@ -65,7 +70,7 @@ if (OC_User::isAdminUser(OC_User::getUser())) {
|
|||
//don't you try to investigate loops you must not know about
|
||||
$groups = array();
|
||||
}
|
||||
$batch = OC_Group::usersInGroups($groups, '', $limit, $offset);
|
||||
$batch = OC_Group::usersInGroups($groups, $pattern, $limit, $offset);
|
||||
foreach ($batch as $uid) {
|
||||
$user = $userManager->get($uid);
|
||||
$users[] = array(
|
||||
|
|
39
settings/js/users/filter.js
Normal file
39
settings/js/users/filter.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
/**
|
||||
* Copyright (c) 2014, Arthur Schiwon <blizzz@owncloud.com>
|
||||
* This file is licensed under the Affero General Public License version 3 or later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief foobar
|
||||
* @param jQuery input element that works as the user text input field
|
||||
*/
|
||||
function UserManagementFilter(filterInput, userList) {
|
||||
this.filterInput = filterInput;
|
||||
this.userList = userList;
|
||||
this.thread = undefined;
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
UserManagementFilter.prototype.init = function() {
|
||||
umf = this;
|
||||
this.filterInput.keyup(function() {
|
||||
clearTimeout(umf.thread);
|
||||
umf.thread = setTimeout(
|
||||
function() {
|
||||
umf.run();
|
||||
},
|
||||
300
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
UserManagementFilter.prototype.run = function() {
|
||||
this.userList.empty();
|
||||
this.userList.update();
|
||||
}
|
||||
|
||||
UserManagementFilter.prototype.getPattern = function() {
|
||||
return this.filterInput.val();
|
||||
}
|
|
@ -219,7 +219,8 @@ var UserList = {
|
|||
gid = '';
|
||||
}
|
||||
UserList.currentGid = gid;
|
||||
var query = $.param({ offset: UserList.offset, limit: UserList.usersToLoad, gid: gid });
|
||||
pattern = filter.getPattern();
|
||||
var query = $.param({ offset: UserList.offset, limit: UserList.usersToLoad, gid: gid, pattern: pattern });
|
||||
$.get(OC.generateUrl('/settings/ajax/userlist') + '?' + query, function (result) {
|
||||
var loadedUsers = 0;
|
||||
var trs = [];
|
||||
|
@ -538,16 +539,5 @@ $(document).ready(function () {
|
|||
);
|
||||
});
|
||||
// Implements User Search
|
||||
$('#usersearchform input').keyup(function() {
|
||||
var inputVal = $(this).val(), regex = new RegExp(inputVal, "i");;
|
||||
$('table tbody tr td.name').each(function (key,element) {
|
||||
if (regex.test($(element).text())) {
|
||||
$(element).parent().show();
|
||||
} else {
|
||||
$(element).parent().hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
filter = new UserManagementFilter($('#usersearchform input'), UserList);
|
||||
});
|
||||
|
|
|
@ -9,6 +9,7 @@ OC_Util::checkSubAdminUser();
|
|||
|
||||
// We have some javascript foo!
|
||||
OC_Util::addScript('settings', 'users/deleteHandler');
|
||||
OC_Util::addScript('settings', 'users/filter');
|
||||
OC_Util::addScript( 'settings', 'users/users' );
|
||||
OC_Util::addScript( 'settings', 'users/groups' );
|
||||
OC_Util::addScript( 'core', 'multiselect' );
|
||||
|
|
Loading…
Reference in a new issue