Add preference for default filter - response to patch #429178

This commit is contained in:
Miles Lott 2001-06-24 01:30:37 +00:00
parent 2dd2c42356
commit 99ddadcacc
4 changed files with 140 additions and 86 deletions

View File

@ -38,6 +38,35 @@
}
}
/* Generic formatted list function */
function formatted_list($name,$list,$id='',$default=False,$java=False)
{
if ($java)
{
$jselect = ' onChange="this.form.submit();"';
}
$select = "\n" .'<select name="' . $name . '"' . $jselect . ">\n";
if($default)
{
$select .= '<option value="">' . lang('Please Select') . '</option>'."\n";
}
while (list($key,$val) = each($list))
{
$select .= '<option value="' . $key . '"';
if ($key == $id && $id != '')
{
$select .= ' selected';
}
$select .= '>' . $val . '</option>'."\n";
}
$select .= '</select>'."\n";
$select .= '<noscript><input type="submit" name="' . $name . '_select" value="True"></noscript>' . "\n";
return $select;
}
function read_custom_fields($start='',$limit='',$query='',$sort='ASC')
{
global $phpgw,$phpgw_info;

View File

@ -115,13 +115,25 @@
$offset = 30;
}
// Set qfilter to display entries where tid=n (normal contact entry),
// else they may be accounts, etc.
if (!$filter) { $filter = 'none'; }
if (!$filter)
{
$filter = 'none';
}
if($phpgw_info['user']['preferences']['addressbook']['default_filter'])
{
$filter = $phpgw_info['user']['preferences']['addressbook']['default_filter'];
}
/*
Set qfilter to display entries where tid=n (normal contact entry),
else they may be accounts, etc.
*/
$qfilter = 'tid=n';
switch ($filter) {
switch ($filter)
{
case 'blank':
$nosearch = True;
break;
case 'none':
break;
case 'private':
@ -132,7 +144,8 @@
default:
$qfilter .= ',owner='.$filter;
}
if ($cat_id) {
if ($cat_id)
{
$qfilter .= ',cat_id='.$cat_id;
}
@ -164,8 +177,16 @@
if (!$userid) { $userid = $phpgw_info['user']['account_id']; }
// read the entry list
if ($nosearch && !$query)
{
$entries = array();
$this->total_records = 0;
}
else
{
/* read the entry list */
$entries = addressbook_read_entries($start,$offset,$qcols,$query,$qfilter,$sort,$order,$userid);
}
$search_filter = $phpgw->nextmatchs->show_tpl('/addressbook/index.php',
$start, $this->total_records,"&order=$order&filter=$filter&sort=$sort&query=$query&cat_id=$cat_id","75%",

View File

@ -78,7 +78,15 @@
{
$phpgw->preferences->delete('addressbook','mainscreen_showbirthdays');
}
if ($default_filter)
{
$phpgw->preferences->delete('addressbook','default_filter');
$phpgw->preferences->add('addressbook','default_filter');
}
else
{
$phpgw->preferences->delete('addressbook','default_filter');
}
if ($autosave_category)
{
$phpgw->preferences->delete('addressbook','autosave_category');
@ -163,34 +171,42 @@
. '>' . $cf . '</option></td>' . "\n"
. '</tr>' . "\n";
}
$t->set_var(custom_fields,$custom_var);
$t->set_var('custom_fields',$custom_var);
}
else
{
$t->set_var(custom_fields,'');
$t->set_var('custom_fields','');
}
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
$t->set_var(tr_color,$tr_color);
$t->set_var(lang_showbirthday,lang('show birthday reminders on main screen'));
$t->set_var('lang_showbirthday',lang('show birthday reminders on main screen'));
if ($phpgw_info['user']['preferences']['addressbook']['mainscreen_showbirthdays'])
{
$t->set_var(show_birthday,' checked');
$t->set_var('show_birthday',' checked');
}
else
{
$t->set_var(show_birthday,'');
$t->set_var('show_birthday','');
}
$t->set_var(lang_autosave,lang('Autosave default category'));
$list = array(
'' => lang('All'),
'private' => lang('Private'),
'blank' => lang('Blank')
);
$t->set_var('lang_default_filter',lang('Default Filter'));
$t->set_var('filter_select',formatted_list('default_filter',$list,$phpgw_info['user']['preferences']['addressbook']['default_filter']));
$t->set_var('lang_autosave',lang('Autosave default category'));
if ($phpgw_info['user']['preferences']['addressbook']['autosave_category'])
{
$t->set_var(autosave,' checked');
$t->set_var('autosave',' checked');
}
else
{
$t->set_var(autosave,'');
$t->set_var('autosave','');
}
$t->set_var('lang_defaultcat',lang('Default Category'));
$t->set_var('cat_select',cat_option($phpgw_info['user']['preferences']['addressbook']['default_category']));
@ -203,6 +219,10 @@
$t->set_var('lang_other',lang('Other').' '.lang('Fields'));
$t->set_var('lang_otherprefs',lang('Other').' '.lang('Preferences'));
$t->set_var('lang_submit',lang('submit'));
$t->set_var('th_bg',$phpgw_info['theme']['th_bg']);
$t->set_var('th_text',$phpgw_info['theme']['th_text']);
$t->set_var('row_on',$phpgw_info['theme']['row_on']);
$t->set_var('row_off',$phpgw_info['theme']['row_off']);
$t->pparse('out','preferences');
$phpgw->common->phpgw_footer();

View File

@ -2,19 +2,13 @@
<p><b>{lang_abprefs}:</b><hr><p>
<form method="POST" action="{action_url}">
<table border="0" align="center" cellspacing="1" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td colspan="2"><font color="#000000" face="">{lang_fields}:</font></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<tr bgcolor="{th_bg}">
<td colspan="6" align="center"><font color="#000000" face="">{lang_fields}:</font></td>
</tr>
<tr>
<td><font color="#000000" face="">{lang_personal}:</font></td>
<td></td>
<td></td>
<tr bgcolor="{row_on}">
<td colspan="6"><font color="#000000" face="">{lang_personal}:</font></td>
</tr>
<tr bgcolor="DDDDDD">
<tr bgcolor="{row_off}">
<td><input type="checkbox" name="ab_selected[fn]"{fn_checked}>{fn}</option></td>
<td><input type="checkbox" name="ab_selected[n_given]"{n_given_checked}>{n_given}</option></td>
<td><input type="checkbox" name="ab_selected[n_family]"{n_family_checked}>{n_family}</option></td>
@ -22,7 +16,7 @@
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr bgcolor="EEEEEE">
<tr bgcolor="{row_off}">
<td><input type="checkbox" name="ab_selected[n_prefix]"{n_prefix_checked}>{n_prefix}</option></td>
<td><input type="checkbox" name="ab_selected[n_suffix]"{n_suffix_checked}>{n_suffix}</option></td>
<td><input type="checkbox" name="ab_selected[bday]"{bday_checked}>{bday}</option></td>
@ -33,12 +27,10 @@
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><font color="#000000" face="">{lang_business}:</font></td>
<td></td>
<td></td>
<tr bgcolor="{row_on}">
<td colspan="6"><font color="#000000" face="">{lang_business}:</font></td>
</tr>
<tr bgcolor="DDDDDD">
<tr bgcolor="{row_off}">
<td><input type="checkbox" name="ab_selected[org_name]"{org_name_checked}>{org_name}</option></td>
<td><input type="checkbox" name="ab_selected[org_unit]"{org_unit_checked}>{org_unit}</option></td>
<td><input type="checkbox" name="ab_selected[title]"{title_checked}>{title}</option></td>
@ -46,7 +38,7 @@
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr bgcolor="EEEEEE">
<tr bgcolor="{row_off}">
<td><input type="checkbox" name="ab_selected[adr_one_street]"{adr_one_street_checked}>{adr_one_street}</option></td>
<td><input type="checkbox" name="ab_selected[address2]"{address2_checked}>{address2}</option></td>
<td><input type="checkbox" name="ab_selected[address3]"{address3_checked}>{address3}</option></td>
@ -54,7 +46,7 @@
<td><input type="checkbox" name="ab_selected[adr_one_region]"{adr_one_region_checked}>{adr_one_region}</option></td>
<td><input type="checkbox" name="ab_selected[adr_one_postalcode]"{adr_one_postalcode_checked}>{adr_one_postalcode}</option></td>
</tr>
<tr bgcolor="DDDDDD">
<tr bgcolor="{row_off}">
<td><input type="checkbox" name="ab_selected[adr_one_countryname]"{adr_one_countryname_checked}>{adr_one_countryname}</option></td>
<td><input type="checkbox" name="ab_selected[adr_two_type]"{adr_one_type_checked}>{adr_one_type}</option></td>
<td><input type="checkbox" name="ab_selected[tel_work]"{tel_work_checked}>{tel_work}</option></td>
@ -64,12 +56,10 @@
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><font color="#000000" face="">{lang_home}:</font></td>
<td></td>
<td></td>
<tr bgcolor="{row_on}">
<td colspan="6"><font color="#000000" face="">{lang_home}:</font></td>
</tr>
<tr bgcolor="EEEEEE">
<tr bgcolor="{row_off}">
<td><input type="checkbox" name="ab_selected[adr_two_street]"{adr_two_street_checked}>{adr_two_street}</option></td>
<td><input type="checkbox" name="ab_selected[adr_two_locality]"{adr_two_locality_checked}>{adr_two_locality}</option></td>
<td><input type="checkbox" name="ab_selected[adr_two_region]"{adr_two_region_checked}>{adr_two_region}</option></td>
@ -77,7 +67,7 @@
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr bgcolor="DDDDDD">
<tr bgcolor="{row_off}">
<td><input type="checkbox" name="ab_selected[adr_two_countryname]"{adr_two_countryname_checked}>{adr_two_countryname}</option></td>
<td><input type="checkbox" name="ab_selected[adr_two_type]"{adr_two_type_checked}>{adr_two_type}</option></td>
<td><input type="checkbox" name="ab_selected[tel_home]"{tel_home_checked}>{tel_home}</option></td>
@ -87,12 +77,10 @@
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><font color="#000000" face="">{lang_phones}:</font></td>
<td></td>
<td></td>
<tr bgcolor="{row_on}">
<td colspan="6"><font color="#000000" face="">{lang_phones}:</font></td>
</tr>
<tr bgcolor="EEEEEE">
<tr bgcolor="{row_off}">
<td><input type="checkbox" name="ab_selected[tel_voice]"{tel_voice_checked}>{tel_voice}</option></td>
<td><input type="checkbox" name="ab_selected[tel_fax]"{tel_fax_checked}>{tel_fax}</option></td>
<td><input type="checkbox" name="ab_selected[tel_msg]"{tel_msg_checked}>{tel_msg}</option></td>
@ -100,7 +88,7 @@
<td><input type="checkbox" name="ab_selected[tel_pager]"{tel_pager_checked}>{tel_pager}</option></td>
<td><input type="checkbox" name="ab_selected[tel_bbs]"{tel_bbs_checked}>{tel_bbs}</option></td>
</tr>
<tr bgcolor="DDDDDD">
<tr bgcolor="{row_off}">
<td><input type="checkbox" name="ab_selected[tel_modem]"{tel_modem_checked}>{tel_modem}</option></td>
<td><input type="checkbox" name="ab_selected[tel_car]"{tel_car_checked}>{tel_car}</option></td>
<td><input type="checkbox" name="ab_selected[tel_isdn]"{tel_isdn_checked}>{tel_isdn}</option></td>
@ -111,12 +99,10 @@
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><font color="#000000" face="">{lang_other}:</font></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<tr bgcolor="{row_on}">
<td colspan="6"><font color="#000000" face="">{lang_other}:</font></td>
</tr>
<tr bgcolor="EEEEEE">
<tr bgcolor="{row_off}">
<td><input type="checkbox" name="ab_selected[geo]"{geo_checked}>{geo}</option></td>
<td><input type="checkbox" name="ab_selected[url]"{url_checked}>{url}</option></td>
<td><input type="checkbox" name="ab_selected[tz]"{tz_checked}>{tz}</option></td>
@ -131,31 +117,29 @@
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td colspan="2"><font color="#000000" face="">{lang_otherprefs}:</font></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<tr bgcolor="{th_bg}">
<td colspan="6" align="center"><font color="#000000" face="">{lang_otherprefs}:</font></td>
</tr>
<tr bgcolor="EEEEEE">
<td colspan="3">{lang_showbirthday}
<input type="checkbox" name="mainscreen_showbirthdays"{show_birthday}></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<tr bgcolor="{row_off}">
<td colspan="3" align="center">
{lang_default_filter}
{filter_select}
</td>
<td colspan="3" align="center">{lang_showbirthday}
<input type="checkbox" name="mainscreen_showbirthdays"{show_birthday}>
</td>
</tr>
<tr bgcolor="EEEEEE">
<td colspan="3">
<tr bgcolor="{row_off}">
<td colspan="3" align="center">
{lang_defaultcat}
{cat_select}
</td>
<td colspan="3">
<td colspan="3" align="center">
{lang_autosave}
<input type="checkbox" name="autosave_category"{autosave}></td>
</tr>
<tr>
<td colspan="5" align="center">
<td colspan="6" align="center">
<input type="submit" name="submit" value="{lang_submit}">
</td>
</tr>