mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2024-09-20 03:36:20 +02:00
list.php:
- add search support: - new parameters: - search[$field] - value to search for - searchmode[$field] - search mode (=, <, > etc.) - reset_search - if given, empty $search and $searchmode - remember $search and $searchmode via session - display errormsg and infomsg from $handler, if any list.tpl: - display current search parameters and a "[x]" link to remove all search parameters This change doesn't add a search form, but you can use ?search[field]= and ?searchmode[field]= URL parameters git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1732 a1433add-5e2c-0410-b055-b7f2511e0802
This commit is contained in:
parent
13f1a28b6e
commit
03b0c869dd
27
list.php
27
list.php
@ -53,9 +53,32 @@ if ($is_admin) {
|
||||
}
|
||||
}
|
||||
|
||||
$handler->getList('');
|
||||
$search = safeget('search', safesession("search_$table", array()));
|
||||
$searchmode = safeget('searchmode', safesession("searchmode_$table", array()));
|
||||
|
||||
if (!is_array($search) || !is_array($searchmode)) {
|
||||
# avoid injection of raw SQL if $search is a string instead of an array
|
||||
die("Invalid parameter");
|
||||
}
|
||||
|
||||
if (safeget('reset_search', 0)) {
|
||||
$search = array();
|
||||
$searchmode = array();
|
||||
}
|
||||
$_SESSION["search_$table"] = $search;
|
||||
$_SESSION["searchmode_$table"] = $searchmode;
|
||||
|
||||
if (count($search)) {
|
||||
$handler->getList($search, $searchmode);
|
||||
} else {
|
||||
$handler->getList('');
|
||||
}
|
||||
$items = $handler->result();
|
||||
|
||||
if (count($handler->errormsg)) flash_error($handler->errormsg);
|
||||
if (count($handler->infomsg)) flash_error($handler->infomsg);
|
||||
|
||||
|
||||
if (safeget('output') == 'csv') {
|
||||
|
||||
$out = fopen('php://output', 'w');
|
||||
@ -103,6 +126,8 @@ if (safeget('output') == 'csv') {
|
||||
$smarty->assign('items', $items);
|
||||
$smarty->assign('id_field', $handler->getId_field());
|
||||
$smarty->assign('formconf', $formconf);
|
||||
$smarty->assign('search', $search);
|
||||
$smarty->assign('searchmode', $searchmode);
|
||||
|
||||
$smarty->display ('index.tpl');
|
||||
|
||||
|
@ -8,6 +8,19 @@
|
||||
{#form_search#}
|
||||
</div>
|
||||
|
||||
{if ($search|count > 0)}
|
||||
<div class='searchparams'>
|
||||
<p>{$PALANG.searchparams}
|
||||
{foreach key=key item=field from=$search}
|
||||
<span>{if $struct.$key.label}{$struct.$key.label}{else}{$key}{/if}
|
||||
{if isset($searchmode.$key)}{$searchmode.$key}{else}={/if} {$field}
|
||||
</span>
|
||||
{/foreach}
|
||||
<span><a href="list.php?table={$table}&reset_search=1">[x]</a></span>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
|
||||
|
||||
<div id="list">
|
||||
<table border=0 id='admin_table'><!-- TODO: 'admin_table' needed because of CSS for table header -->
|
||||
|
Loading…
Reference in New Issue
Block a user