diff options
author | plegall <plg@piwigo.org> | 2005-04-28 22:06:20 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2005-04-28 22:06:20 +0000 |
commit | 5293402be5299d3c7b6b0f55b4130223ece04dd6 (patch) | |
tree | d0b449d369d02dfb1a2ab376075b766da546bcb1 /admin | |
parent | a32a5a7d36d08a7efb4f6242c1acbd95545e9416 (diff) |
- user list updated : ability to filter list on group
git-svn-id: http://piwigo.org/svn/trunk@776 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin')
-rw-r--r-- | admin/user_list.php | 95 |
1 files changed, 80 insertions, 15 deletions
diff --git a/admin/user_list.php b/admin/user_list.php index 8e50f9c02..9bfbacd33 100644 --- a/admin/user_list.php +++ b/admin/user_list.php @@ -122,7 +122,36 @@ foreach ($direction_items as $item => $label) array( 'VALUE' => $item, 'CONTENT' => $label, - 'SELECTED' => $selected + 'SELECTED' => $selected + )); +} + +$blockname = 'group_option'; + +$template->assign_block_vars( + $blockname, + array( + 'VALUE'=> -1, + 'CONTENT' => '------------', + 'SELECTED' => '' + )); + +$query = ' +SELECT id, name + FROM '.GROUPS_TABLE.' +;'; +$result = pwg_query($query); + +while ($row = mysql_fetch_array($result)) +{ + $selected = (isset($_GET['group']) and $_GET['group'] == $row['id']) ? + 'selected="selected"' : ''; + $template->assign_block_vars( + $blockname, + array( + 'VALUE' => $row['id'], + 'CONTENT' => $row['name'], + 'SELECTED' => $selected )); } @@ -130,27 +159,53 @@ foreach ($direction_items as $item => $label) // | filter | // +-----------------------------------------------------------------------+ -$username = !empty($_GET['username']) ? $_GET['username'] : '%'; -$username = str_replace('*', '%', $username); -if (function_exists('mysql_real_escape_string')) +$filter = array(); + +if (isset($_GET['username']) and !empty($_GET['username'])) { - $username = mysql_real_escape_string($username); + $username = str_replace('*', '%', $_GET['username']); + if (function_exists('mysql_real_escape_string')) + { + $username = mysql_real_escape_string($username); + } + else + { + $username = mysql_escape_string($username); + } + + if (!empty($username)) + { + $filter['username'] = $username; + } } -else + +if (isset($_GET['group']) + and -1 != $_GET['group'] + and is_numeric($_GET['group'])) { - $username = mysql_escape_string($username); + $filter['group'] = $_GET['group']; } -$username = !empty($username) ? $username : '%'; + // +-----------------------------------------------------------------------+ // | navigation bar | // +-----------------------------------------------------------------------+ $query = ' -SELECT count(*) - FROM '.USERS_TABLE.' - WHERE id != 2 - AND username LIKE \''.$username.'\' +SELECT COUNT(DISTINCT(id)) + FROM '.USERS_TABLE.' LEFT JOIN '.USER_GROUP_TABLE.' ON id = user_id + WHERE id != 2'; +if (isset($filter['username'])) +{ + $query.= ' + AND username LIKE \''.$filter['username'].'\''; +} +if (isset($filter['group'])) +{ + $query.= ' + AND group_id = '.$filter['group']; +} +$query.= ' ;'; list($counter) = mysql_fetch_row(pwg_query($query)); @@ -191,9 +246,19 @@ if (isset($_GET['direction']) $query = ' SELECT id, username, mail_address, status - FROM '.USERS_TABLE.' - WHERE id != 2 - AND username LIKE \''.$username.'\' + FROM '.USERS_TABLE.' LEFT JOIN '.USER_GROUP_TABLE.' ON id = user_id + WHERE id != 2'; +if (isset($filter['username'])) +{ + $query.= ' + AND username LIKE \''.$filter['username'].'\''; +} +if (isset($filter['group'])) +{ + $query.= ' + AND group_id = '.$filter['group']; +} +$query.= ' ORDER BY '.$order_by.' '.$direction.' LIMIT '.$start.', '.$conf['users_page'].' ;'; |