- user list updated : ability to filter list on group
git-svn-id: http://piwigo.org/svn/trunk@776 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
a32a5a7d36
commit
5293402be5
3 changed files with 91 additions and 15 deletions
|
|
@ -122,7 +122,36 @@ foreach ($direction_items as $item => $label)
|
||||||
array(
|
array(
|
||||||
'VALUE' => $item,
|
'VALUE' => $item,
|
||||||
'CONTENT' => $label,
|
'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 |
|
// | filter |
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
$username = !empty($_GET['username']) ? $_GET['username'] : '%';
|
$filter = array();
|
||||||
$username = str_replace('*', '%', $username);
|
|
||||||
if (function_exists('mysql_real_escape_string'))
|
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 |
|
// | navigation bar |
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
$query = '
|
$query = '
|
||||||
SELECT count(*)
|
SELECT COUNT(DISTINCT(id))
|
||||||
FROM '.USERS_TABLE.'
|
FROM '.USERS_TABLE.' LEFT JOIN '.USER_GROUP_TABLE.' ON id = user_id
|
||||||
WHERE id != 2
|
WHERE id != 2';
|
||||||
AND username LIKE \''.$username.'\'
|
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));
|
list($counter) = mysql_fetch_row(pwg_query($query));
|
||||||
|
|
||||||
|
|
@ -191,9 +246,19 @@ if (isset($_GET['direction'])
|
||||||
|
|
||||||
$query = '
|
$query = '
|
||||||
SELECT id, username, mail_address, status
|
SELECT id, username, mail_address, status
|
||||||
FROM '.USERS_TABLE.'
|
FROM '.USERS_TABLE.' LEFT JOIN '.USER_GROUP_TABLE.' ON id = user_id
|
||||||
WHERE id != 2
|
WHERE id != 2';
|
||||||
AND username LIKE \''.$username.'\'
|
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.'
|
ORDER BY '.$order_by.' '.$direction.'
|
||||||
LIMIT '.$start.', '.$conf['users_page'].'
|
LIMIT '.$start.', '.$conf['users_page'].'
|
||||||
;';
|
;';
|
||||||
|
|
|
||||||
|
|
@ -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
|
2005-04-25 Pierrick LE GALL
|
||||||
|
|
||||||
* include/config.inc.php becomes include/config_default.inc.php :
|
* include/config.inc.php becomes include/config_default.inc.php :
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,13 @@
|
||||||
|
|
||||||
username <input type="text" name="username" value="{F_USERNAME}" />
|
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}
|
{L_ORDER_BY}
|
||||||
<select name="order_by">
|
<select name="order_by">
|
||||||
<!-- BEGIN order_by -->
|
<!-- BEGIN order_by -->
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue