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 | |
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 '')
-rw-r--r-- | admin/user_list.php | 95 | ||||
-rw-r--r-- | doc/ChangeLog | 4 | ||||
-rw-r--r-- | template/default/admin/user_list.tpl | 7 |
3 files changed, 91 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'].' ;'; diff --git a/doc/ChangeLog b/doc/ChangeLog index b1d7224bc..b3e45227c 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,7 @@ +2005-04-28 Pierrick LE GALL + + * user list updated : ability to filter list on group + 2005-04-25 Pierrick LE GALL * include/config.inc.php becomes include/config_default.inc.php : diff --git a/template/default/admin/user_list.tpl b/template/default/admin/user_list.tpl index 906828afa..5aa108298 100644 --- a/template/default/admin/user_list.tpl +++ b/template/default/admin/user_list.tpl @@ -22,6 +22,13 @@ username <input type="text" name="username" value="{F_USERNAME}" /> + group + <select name="group"> + <!-- BEGIN group_option --> + <option value="{group_option.VALUE}" {group_option.SELECTED} > {group_option.CONTENT}</option> + <!-- END group_option --> + </select> + {L_ORDER_BY} <select name="order_by"> <!-- BEGIN order_by --> |