changes for using maxmatches and paging

This commit is contained in:
skeeter 2001-01-25 04:07:26 +00:00
parent c075d32f83
commit 0d2fc30cbf
3 changed files with 132 additions and 20 deletions

View File

@ -86,6 +86,40 @@
$phpgw->common->phpgw_exit();
}
$groups = $phpgw->accounts->read_group_names($phpgw->info["user"]["account_id"]);
$total = 0;
if(!isset($start)) {
$start = 0;
}
if(!$start) {
$s_groups = 0;
$s_users = 0;
}
if(!isset($s_groups)) {
$s_groups = 0;
}
if(!isset($s_users)) {
$s_users = 0;
}
if(!isset($maxm)) {
$maxm = $phpgw_info["user"]["preferences"]["common"]["maxmatchs"];
}
if(!isset($totalentries)) {
$totalentries = count($groups);
$db = $phpgw->db;
$db->query("SELECT count(*) FROM accounts");
$db->next_record();
$totalentries += $db->f(0);
}
$p = CreateObject('phpgwapi.Template',$phpgw_info["server"]["app_tpl"]);
$p->set_file(array('preferences' => 'preference_acl.tpl',
'row_colspan' => 'preference_colspan.tpl',
@ -97,32 +131,74 @@
$p->set_var('action_url',$phpgw->link(''));
$p->set_var('bg_color',$phpgw_info["theme"]["th_bg"]);
$p->set_var('submit_lang',lang('submit'));
$p->set_var('string',lang('Groups'));
$p->set_var('read_lang',lang('Read'));
$p->set_var('add_lang',lang('Add'));
$p->set_var('edit_lang',lang('Edit'));
$p->set_var('delete_lang',lang('Delete'));
$p->parse('row','row_colspan',True);
$groups = $phpgw->accounts->read_group_names($phpgw->info["user"]["account_id"]);
while(list(,$group) = each($groups)) {
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
display_row($tr_color,'g_',$group[0],$group[1]);
}
$p->set_var(array('read_lang' => lang('Read'),
'add_lang' => lang('Add'),
'edit_lang' => lang('Edit'),
'delete_lang' => lang('Delete')));
$db = $phpgw->db;
$db->query("select account_id from accounts ORDER BY account_lastname, account_firstname, account_lid",__LINE__,__FILE__);
if($db->num_rows()) {
$p->set_var('string',ucfirst(lang('Users')));
if(intval($s_groups) <> count($groups)) {
$p->set_var('string',lang('Groups'));
$p->parse('row','row_colspan',True);
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
while($db->next_record()) {
while(list(,$group) = each($groups)) {
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
$id = $db->f("account_id");
display_row($tr_color,'u_',$id,$phpgw->common->grab_owner_name($id));
display_row($tr_color,'g_',$group[0],$group[1]);
$s_groups++;
$processed[] = ',g_'.$group[0];
$total++;
if($total == $maxm) break;
}
}
if($total <> $maxm) {
if(!is_object($db)) {
$db = $phpgw->db;
}
$db->query("select account_id from accounts ORDER BY account_lastname, account_firstname, account_lid LIMIT ".$phpgw->nextmatchs->sql_limit(intval($s_users)),__LINE__,__FILE__);
$users = $db->num_rows();
if($total <> $maxm) {
if($users) {
$p->set_var('string',ucfirst(lang('Users')));
$p->parse('row','row_colspan',True);
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
while($db->next_record()) {
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
$id = $db->f("account_id");
display_row($tr_color,'u_',$id,$phpgw->common->grab_owner_name($id));
$s_users++;
$processed[] = ',u_'.$id;
$total++;
if($total == $maxm) break;
}
}
}
}
$extra_parms = "&s_users=".$s_users."&s_groups=".$s_groups."&maxm=".$maxm."&totalentries=".$totalentries."&total=".($start + $total);
$p->set_var("nml",$phpgw->nextmatchs->left("",$start,$totalentries,$extra_parms));
$p->set_var("nmr",$phpgw->nextmatchs->right("",$start,$totalentries,$extra_parms));
$start += $total;
$common_hidden_vars = ' <input type="hidden" name="s_groups" value="'.$s_groups.'">'."\n"
. ' <input type="hidden" name="s_users" value="'.$s_users.'">'."\n"
. ' <input type="hidden" name="maxm" value="'.$maxm.'">'."\n"
. ' <input type="hidden" name="totalentries" value="'.$totalentries.'">'."\n"
. ' <input type="hidden" name="start" value="'.$start.'">'."\n";
$p->set_var('common_hidden_vars_form',$common_hidden_vars);
if(isset($query_result) && $query_result)
$common_hidden_vars .= "<input type=\"hidden\" name=\"query_result\" value=\"".$query_result."\">\n";
$p->set_var('common_hidden_vars',$common_hidden_vars);
$p->set_var("search_value",(isset($query) && $query?$query:""));
$p->set_var("search",lang("search"));
$p->set_var("next",lang("next"));
$p->set_var('processed',urlencode(serialize($processed)));
$p->pparse('out','preferences');
$phpgw->common->phpgw_footer();
?>

View File

@ -1,9 +1,27 @@
{errors}
{title}
<table border="0" align="center" width="70%">
<tr>
{nml}
<td width="40%">
<div align="center">
<form method="GET" action="{action_url}">
{common_hidden_vars}
<input type="text" name="query" value="{search_value}">
<input type="submit" name="search" value="{search}">
<input type="submit" name="next" value="{next}">
</form>
</div>
</td>
{nmr}
</tr>
</table>
<form method="POST" action="{action_url}">
<table border="0" align="center" width="50%" cols="4">
{row}
</table>
{common_hidden_vars_form}
<input type="hidden" name="processed" value="{processed}">
<center><input type="submit" name="submit" value="{submit_lang}"></center>
</form>

View File

@ -1,9 +1,27 @@
{errors}
{title}
<table border="0" align="center" width="70%">
<tr>
{nml}
<td width="40%">
<div align="center">
<form method="GET" action="{action_url}">
{common_hidden_vars}
<input type="text" name="query" value="{search_value}">
<input type="submit" name="search" value="{search}">
<input type="submit" name="next" value="{next}">
</form>
</div>
</td>
{nmr}
</tr>
</table>
<form method="POST" action="{action_url}">
<table border="0" align="center" width="50%" cols="4">
{row}
</table>
{common_hidden_vars_form}
<input type="hidden" name="processed" value="{processed}">
<center><input type="submit" name="submit" value="{submit_lang}"></center>
</form>