patch from Klaus Leithoff: implementing lettersearch for group-list

This commit is contained in:
Ralf Becker 2006-12-06 15:15:42 +00:00
parent 94359ad8fd
commit 343d5a6eac
2 changed files with 111 additions and 18 deletions

View File

@ -68,6 +68,13 @@
function list_groups() function list_groups()
{ {
$query_types = array(
'all' => 'all fields',
'lid' => 'LoginID',
'start' => 'start with',
'exact' => 'exact',
);
if ($GLOBALS['egw']->acl->check('group_access',1,'admin')) if ($GLOBALS['egw']->acl->check('group_access',1,'admin'))
{ {
$GLOBALS['egw']->redirect($GLOBALS['egw']->link('/admin/index.php')); $GLOBALS['egw']->redirect($GLOBALS['egw']->link('/admin/index.php'));
@ -75,11 +82,11 @@
$GLOBALS['cd'] = ($_GET['cd']?$_GET['cd']:0); $GLOBALS['cd'] = ($_GET['cd']?$_GET['cd']:0);
if(isset($_POST['query'])) if(isset($_REQUEST['query']))
{ {
// limit query to limit characters // limit query to limit characters
if(eregi('^[a-z_0-9]+$',$_POST['query'])) //if(eregi('^[a-z_0-9]+$',$_REQUEST['query']))
$GLOBALS['query'] = $_POST['query']; $GLOBALS['query'] = $_REQUEST['query'];
} }
if(isset($_POST['start'])) if(isset($_POST['start']))
@ -90,22 +97,21 @@
{ {
$start = 0; $start = 0;
} }
switch($_REQUEST['order'])
switch($_GET['order'])
{ {
case 'account_lid': case 'account_lid':
$order = $_GET['order']; $order = $_REQUEST['order'];
break; break;
default: default:
$order = 'account_lid'; $order = 'account_lid';
break; break;
} }
switch($_GET['sort']) switch($_REQUEST['sort'])
{ {
case 'ASC': case 'ASC':
case 'DESC': case 'DESC':
$sort = $_GET['sort']; $sort = $_REQUEST['sort'];
break; break;
default: default:
$sort = 'ASC'; $sort = 'ASC';
@ -132,24 +138,38 @@
$p->set_block('groups','list','list'); $p->set_block('groups','list','list');
$p->set_block('groups','row','row'); $p->set_block('groups','row','row');
$p->set_block('groups','row_empty','row_empty'); $p->set_block('groups','row_empty','row_empty');
$p->set_block('list','letter_search','letter_search_cells');
$search_param = array(
'type' => 'groups',
'start' => $start,
'sort' => $sort,
'order' => $order,
'query_type' => $_REQUEST['query_type'],
);
//_debug_array($search_param);
if (!$GLOBALS['egw']->acl->check('account_access',2,'admin')) if (!$GLOBALS['egw']->acl->check('account_access',2,'admin'))
{ {
$account_info = $GLOBALS['egw']->accounts->get_list('groups',$start,$sort, $order, $GLOBALS['query']); $search_param['query'] = $GLOBALS['query'];
}
else
{
$account_info = $GLOBALS['egw']->accounts->get_list('groups',$start,$sort, $order);
} }
$account_info = $GLOBALS['egw']->accounts->search($search_param);
$total = $GLOBALS['egw']->accounts->total; $total = $GLOBALS['egw']->accounts->total;
$link_data = array(
'menuaction' => 'admin.uiaccounts.list_groups',
//'group_id' => $_REQUEST['group_id'],
'query_type' => $_REQUEST['query_type'],
'query' => $GLOBALS['query'],
);
$var = Array( $var = Array(
'left_next_matchs' => $this->nextmatchs->left('/index.php',$start,$total,'menuaction=admin.uiaccounts.list_groups'), 'left_next_matchs' => $this->nextmatchs->left('/index.php',$start,$total,$link_data),
'right_next_matchs' => $this->nextmatchs->right('/index.php',$start,$total,'menuaction=admin.uiaccounts.list_groups'), 'right_next_matchs' => $this->nextmatchs->right('/index.php',$start,$total,$link_data),
'lang_groups' => lang('%1 - %2 of %3 user groups',$start+1,$start+count($account_info),$total), 'lang_groups' => lang('%1 - %2 of %3 user groups',$start+1,$start+count($account_info),$total),
'sort_name' => $this->nextmatchs->show_sort_order($sort,'account_lid',$order,'/index.php',lang('name'),'menuaction=admin.uiaccounts.list_groups'), 'sort_name' => $this->nextmatchs->show_sort_order($sort,'account_lid',$order,'/index.php',lang('name'),$link_data),
'header_edit' => lang('Edit'), 'header_edit' => lang('Edit'),
'header_delete' => lang('Delete') 'header_delete' => lang('Delete'),
'lang_search' => lang('search') // KL 20061128 Text fr den Suchbutton hinzugefeugt
); );
$p->set_var($var); $p->set_var($var);
@ -206,6 +226,40 @@
} }
} }
$link_data += array(
'order' => $order,
'sort' => $sort,
);
$p->set_var(array(
'query' => $GLOBALS['egw']->html->htmlspecialchars($GLOBALS['query']),
'query_type' => is_array($query_types) ? $GLOBALS['egw']->html->select('query_type',$_REQUEST['query_type'],$query_types) : '',
//'lang_group' => lang('group'),
//'group' => $uiaccountsel->selection('group_id','admin_uiaccount_listusers_group_id',$_REQUEST['group_id'],'groups',0,False,'','this.form.submit();',lang('all')),
'accounts_url' => $GLOBALS['egw']->link('/index.php',$link_data),
));
$letters = lang('alphabet');
$letters = explode(',',substr($letters,-1) != '*' ? $letters : 'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z');
$link_data['query_type'] = 'start';
foreach($letters as $letter)
{
$link_data['query'] = $letter;
$p->set_var(array(
'letter' => $letter,
'link' => $GLOBALS['egw']->link('/index.php',$link_data),
'class' => $GLOBALS['query'] == $letter && $_REQUEST['query_type'] == 'start' ? 'letter_box_active' : 'letter_box',
));
$p->fp('letter_search_cells','letter_search',True);
}
unset($link_data['query']);
unset($link_data['query_type']);
$p->set_var(array(
'letter' => lang('all'),
'link' => $GLOBALS['egw']->link('/index.php',$link_data),
'class' => $_REQUEST['query_type'] != 'start' || !in_array($GLOBALS['query'],$letters) ? 'letter_box_active' : 'letter_box',
));
$p->fp('letter_search_cells','letter_search',True);
$var = Array( $var = Array(
'new_action' => $GLOBALS['egw']->link('/index.php','menuaction=admin.uiaccounts.add_group'), 'new_action' => $GLOBALS['egw']->link('/index.php','menuaction=admin.uiaccounts.add_group'),
'search_action' => $GLOBALS['egw']->link('/index.php','menuaction=admin.uiaccounts.list_groups') 'search_action' => $GLOBALS['egw']->link('/index.php','menuaction=admin.uiaccounts.list_groups')

View File

@ -1,6 +1,33 @@
<!-- BEGIN list --> <!-- BEGIN list -->
<style type="text/css">
.letter_box,.letter_box_active {
background-color: #D3DCE3;
width: 25px;
border: 1px solid #D3DCE3;
text-align: center;
cursor: pointer;
cusror: hand;
}
.letter_box_active {
font-weight: bold;
background-color: #E8F0F0;
}
.letter_box_active,.letter_box:hover {
border: 1px solid black;
background-color: #E8F0F0;
}
</style>
<p> <p>
<table border="0" width="45%" align="center"> <table border="0" width="45%" align="center">
<tr>
<td colspan="5">
<table width="100%"><tr>
<!-- BEGIN letter_search -->
<td class="{class}" onclick="location.href='{link}';">{letter}</td>
<!-- END letter_search -->
</tr></table>
</td>
</tr>
<tr> <tr>
{left_next_matchs} {left_next_matchs}
<td align="center">{lang_groups}</td> <td align="center">{lang_groups}</td>
@ -27,9 +54,21 @@
</form> </form>
</td> </td>
<td align="right"> <td align="right">
<!--
<form method="POST" action="{search_action}"> <form method="POST" action="{search_action}">
{input_search} {input_search}
</form> </form>
-->
<form method="POST" action="{accounts_url}">
<table width="100%"><tr>
<td>{lang_group} {group}</td>
<td align="right">
{query_type}
<input type="text" name="query" value="{query}">
<input type="submit" name="search" value="{lang_search}">
</td>
</tr></table>
</form>
</td> </td>
</tr> </tr>
</table> </table>