diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2014-04-02 23:48:35 +0400 |
---|---|---|
committer | Arthur Schiwon <blizzz@owncloud.com> | 2014-06-02 14:53:55 +0400 |
commit | 5b8ba79356c50934b949a9e2a1942aeddd7640ff (patch) | |
tree | 7dee9aa3e363b21611e4a361d7b0c440f9b32519 /settings | |
parent | 19fd7cd9c7206cea7c0eba21ed2b5d34ce652429 (diff) |
make filter work on server-side
Diffstat (limited to 'settings')
-rw-r--r-- | settings/ajax/userlist.php | 11 | ||||
-rw-r--r-- | settings/js/users/filter.js | 39 | ||||
-rw-r--r-- | settings/js/users/users.js | 16 | ||||
-rw-r--r-- | settings/users.php | 1 |
4 files changed, 51 insertions, 16 deletions
diff --git a/settings/ajax/userlist.php b/settings/ajax/userlist.php index 7ca1d535a46..32237d60b6e 100644 --- a/settings/ajax/userlist.php +++ b/settings/ajax/userlist.php @@ -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( diff --git a/settings/js/users/filter.js b/settings/js/users/filter.js new file mode 100644 index 00000000000..134ca47a7d1 --- /dev/null +++ b/settings/js/users/filter.js @@ -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(); +}
\ No newline at end of file diff --git a/settings/js/users/users.js b/settings/js/users/users.js index f5c3b1decc5..92ce8277baf 100644 --- a/settings/js/users/users.js +++ b/settings/js/users/users.js @@ -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); }); diff --git a/settings/users.php b/settings/users.php index c0c1adc74c7..d6e270bbc32 100644 --- a/settings/users.php +++ b/settings/users.php @@ -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' ); |