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') function read_custom_fields($start='',$limit='',$query='',$sort='ASC')
{ {
global $phpgw,$phpgw_info; global $phpgw,$phpgw_info;

View File

@ -115,13 +115,25 @@
$offset = 30; $offset = 30;
} }
// Set qfilter to display entries where tid=n (normal contact entry), if (!$filter)
// else they may be accounts, etc. {
if (!$filter) { $filter = 'none'; } $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'; $qfilter = 'tid=n';
switch ($filter)
switch ($filter) { {
case 'blank':
$nosearch = True;
break;
case 'none': case 'none':
break; break;
case 'private': case 'private':
@ -132,7 +144,8 @@
default: default:
$qfilter .= ',owner='.$filter; $qfilter .= ',owner='.$filter;
} }
if ($cat_id) { if ($cat_id)
{
$qfilter .= ',cat_id='.$cat_id; $qfilter .= ',cat_id='.$cat_id;
} }
@ -164,8 +177,16 @@
if (!$userid) { $userid = $phpgw_info['user']['account_id']; } if (!$userid) { $userid = $phpgw_info['user']['account_id']; }
// read the entry list if ($nosearch && !$query)
$entries = addressbook_read_entries($start,$offset,$qcols,$query,$qfilter,$sort,$order,$userid); {
$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', $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%", $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'); $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) if ($autosave_category)
{ {
$phpgw->preferences->delete('addressbook','autosave_category'); $phpgw->preferences->delete('addressbook','autosave_category');
@ -163,34 +171,42 @@
. '>' . $cf . '</option></td>' . "\n" . '>' . $cf . '</option></td>' . "\n"
. '</tr>' . "\n"; . '</tr>' . "\n";
} }
$t->set_var(custom_fields,$custom_var); $t->set_var('custom_fields',$custom_var);
} }
else else
{ {
$t->set_var(custom_fields,''); $t->set_var('custom_fields','');
} }
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color); $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
$t->set_var(tr_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']) if ($phpgw_info['user']['preferences']['addressbook']['mainscreen_showbirthdays'])
{ {
$t->set_var(show_birthday,' checked'); $t->set_var('show_birthday',' checked');
} }
else 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']) if ($phpgw_info['user']['preferences']['addressbook']['autosave_category'])
{ {
$t->set_var(autosave,' checked'); $t->set_var('autosave',' checked');
} }
else else
{ {
$t->set_var(autosave,''); $t->set_var('autosave','');
} }
$t->set_var('lang_defaultcat',lang('Default Category')); $t->set_var('lang_defaultcat',lang('Default Category'));
$t->set_var('cat_select',cat_option($phpgw_info['user']['preferences']['addressbook']['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_other',lang('Other').' '.lang('Fields'));
$t->set_var('lang_otherprefs',lang('Other').' '.lang('Preferences')); $t->set_var('lang_otherprefs',lang('Other').' '.lang('Preferences'));
$t->set_var('lang_submit',lang('submit')); $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'); $t->pparse('out','preferences');
$phpgw->common->phpgw_footer(); $phpgw->common->phpgw_footer();

View File

@ -2,128 +2,114 @@
<p><b>{lang_abprefs}:</b><hr><p> <p><b>{lang_abprefs}:</b><hr><p>
<form method="POST" action="{action_url}"> <form method="POST" action="{action_url}">
<table border="0" align="center" cellspacing="1" cellpadding="1"> <table border="0" align="center" cellspacing="1" cellpadding="1">
<tr> <tr bgcolor="{th_bg}">
<td>&nbsp;</td> <td colspan="6" align="center"><font color="#000000" face="">{lang_fields}:</font></td>
<td>&nbsp;</td>
<td colspan="2"><font color="#000000" face="">{lang_fields}:</font></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr> </tr>
<tr> <tr bgcolor="{row_on}">
<td><font color="#000000" face="">{lang_personal}:</font></td> <td colspan="6"><font color="#000000" face="">{lang_personal}:</font></td>
<td></td>
<td></td>
</tr> </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[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_given]"{n_given_checked}>{n_given}</option></td>
<td><input type="checkbox" name="ab_selected[n_family]"{n_family_checked}>{n_family}</option></td> <td><input type="checkbox" name="ab_selected[n_family]"{n_family_checked}>{n_family}</option></td>
<td><input type="checkbox" name="ab_selected[n_middle]"{n_middle_checked}>{n_middle}</option></td> <td><input type="checkbox" name="ab_selected[n_middle]"{n_middle_checked}>{n_middle}</option></td>
<td>&nbsp;</td> <td>&nbsp;</td>
<td>&nbsp;</td> <td>&nbsp;</td>
</tr> </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_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[n_suffix]"{n_suffix_checked}>{n_suffix}</option></td>
<td><input type="checkbox" name="ab_selected[bday]"{bday_checked}>{bday}</option></td> <td><input type="checkbox" name="ab_selected[bday]"{bday_checked}>{bday}</option></td>
<td>&nbsp;</td> <td>&nbsp;</td>
<td>&nbsp;</td> <td>&nbsp;</td>
<td>&nbsp;</td> <td>&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td>&nbsp;</td> <td>&nbsp;</td>
</tr> </tr>
<tr> <tr bgcolor="{row_on}">
<td><font color="#000000" face="">{lang_business}:</font></td> <td colspan="6"><font color="#000000" face="">{lang_business}:</font></td>
<td></td>
<td></td>
</tr> </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_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[org_unit]"{org_unit_checked}>{org_unit}</option></td>
<td><input type="checkbox" name="ab_selected[title]"{title_checked}>{title}</option></td> <td><input type="checkbox" name="ab_selected[title]"{title_checked}>{title}</option></td>
<td>&nbsp;</td> <td>&nbsp;</td>
<td>&nbsp;</td> <td>&nbsp;</td>
<td>&nbsp;</td> <td>&nbsp;</td>
</tr> </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[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[address2]"{address2_checked}>{address2}</option></td>
<td><input type="checkbox" name="ab_selected[address3]"{address3_checked}>{address3}</option></td> <td><input type="checkbox" name="ab_selected[address3]"{address3_checked}>{address3}</option></td>
<td><input type="checkbox" name="ab_selected[adr_one_locality]"{adr_one_locality_checked}>{adr_one_locality}</option></td> <td><input type="checkbox" name="ab_selected[adr_one_locality]"{adr_one_locality_checked}>{adr_one_locality}</option></td>
<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_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> <td><input type="checkbox" name="ab_selected[adr_one_postalcode]"{adr_one_postalcode_checked}>{adr_one_postalcode}</option></td>
</tr> </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_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[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> <td><input type="checkbox" name="ab_selected[tel_work]"{tel_work_checked}>{tel_work}</option></td>
<td><input type="checkbox" name="ab_selected[email]"{email_checked}>{email}</option></td> <td><input type="checkbox" name="ab_selected[email]"{email_checked}>{email}</option></td>
<td colspan="2"><input type="checkbox" name="ab_selected[email_type]"{email_type_checked}>{email_type}</option></td> <td colspan="2"><input type="checkbox" name="ab_selected[email_type]"{email_type_checked}>{email_type}</option></td>
</tr> </tr>
<tr> <tr>
<td>&nbsp;</td> <td>&nbsp;</td>
</tr> </tr>
<tr> <tr bgcolor="{row_on}">
<td><font color="#000000" face="">{lang_home}:</font></td> <td colspan="6"><font color="#000000" face="">{lang_home}:</font></td>
<td></td>
<td></td>
</tr> </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_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_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> <td><input type="checkbox" name="ab_selected[adr_two_region]"{adr_two_region_checked}>{adr_two_region}</option></td>
<td><input type="checkbox" name="ab_selected[adr_two_postalcode]"{adr_two_postalcode_checked}>{adr_two_postalcode}</option></td> <td><input type="checkbox" name="ab_selected[adr_two_postalcode]"{adr_two_postalcode_checked}>{adr_two_postalcode}</option></td>
<td>&nbsp;</td> <td>&nbsp;</td>
<td>&nbsp;</td> <td>&nbsp;</td>
</tr> </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_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[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> <td><input type="checkbox" name="ab_selected[tel_home]"{tel_home_checked}>{tel_home}</option></td>
<td><input type="checkbox" name="ab_selected[email_home]"{email_home_checked}>{email_home}</option></td> <td><input type="checkbox" name="ab_selected[email_home]"{email_home_checked}>{email_home}</option></td>
<td colspan="2"><input type="checkbox" name="ab_selected[email_home_type]"{email_home_type_checked}>{email_home_type}</option></td> <td colspan="2"><input type="checkbox" name="ab_selected[email_home_type]"{email_home_type_checked}>{email_home_type}</option></td>
</tr> </tr>
<tr> <tr>
<td>&nbsp;</td> <td>&nbsp;</td>
</tr> </tr>
<tr> <tr bgcolor="{row_on}">
<td><font color="#000000" face="">{lang_phones}:</font></td> <td colspan="6"><font color="#000000" face="">{lang_phones}:</font></td>
<td></td>
<td></td>
</tr> </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_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_fax]"{tel_fax_checked}>{tel_fax}</option></td>
<td><input type="checkbox" name="ab_selected[tel_msg]"{tel_msg_checked}>{tel_msg}</option></td> <td><input type="checkbox" name="ab_selected[tel_msg]"{tel_msg_checked}>{tel_msg}</option></td>
<td><input type="checkbox" name="ab_selected[tel_cell]"{tel_cell_checked}>{tel_cell}</option></td> <td><input type="checkbox" name="ab_selected[tel_cell]"{tel_cell_checked}>{tel_cell}</option></td>
<td><input type="checkbox" name="ab_selected[tel_pager]"{tel_pager_checked}>{tel_pager}</option></td> <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> <td><input type="checkbox" name="ab_selected[tel_bbs]"{tel_bbs_checked}>{tel_bbs}</option></td>
</tr> </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_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_car]"{tel_car_checked}>{tel_car}</option></td>
<td><input type="checkbox" name="ab_selected[tel_isdn]"{tel_isdn_checked}>{tel_isdn}</option></td> <td><input type="checkbox" name="ab_selected[tel_isdn]"{tel_isdn_checked}>{tel_isdn}</option></td>
<td><input type="checkbox" name="ab_selected[tel_video]"{tel_video_checked}>{tel_video}</option></td> <td><input type="checkbox" name="ab_selected[tel_video]"{tel_video_checked}>{tel_video}</option></td>
<td><input type="checkbox" name="ab_selected[ophone]"{ophone_checked}>{ophone}</option></td> <td><input type="checkbox" name="ab_selected[ophone]"{ophone_checked}>{ophone}</option></td>
<td>&nbsp;</td> <td>&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td>&nbsp;</td> <td>&nbsp;</td>
</tr> </tr>
<tr> <tr bgcolor="{row_on}">
<td><font color="#000000" face="">{lang_other}:</font></td> <td colspan="6"><font color="#000000" face="">{lang_other}:</font></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr> </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[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[url]"{url_checked}>{url}</option></td>
<td><input type="checkbox" name="ab_selected[tz]"{tz_checked}>{tz}</option></td> <td><input type="checkbox" name="ab_selected[tz]"{tz_checked}>{tz}</option></td>
<td>&nbsp;</td> <td>&nbsp;</td>
<td>&nbsp;</td> <td>&nbsp;</td>
<td>&nbsp;</td> <td>&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td>&nbsp;</td> <td>&nbsp;</td>
</tr> </tr>
@ -131,33 +117,31 @@
<tr> <tr>
<td>&nbsp;</td> <td>&nbsp;</td>
</tr> </tr>
<tr> <tr bgcolor="{th_bg}">
<td>&nbsp;</td> <td colspan="6" align="center"><font color="#000000" face="">{lang_otherprefs}:</font></td>
<td>&nbsp;</td>
<td colspan="2"><font color="#000000" face="">{lang_otherprefs}:</font></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr> </tr>
<tr bgcolor="EEEEEE"> <tr bgcolor="{row_off}">
<td colspan="3">{lang_showbirthday} <td colspan="3" align="center">
<input type="checkbox" name="mainscreen_showbirthdays"{show_birthday}></td> {lang_default_filter}
<td>&nbsp;</td> {filter_select}
<td>&nbsp;</td> </td>
<td>&nbsp;</td> <td colspan="3" align="center">{lang_showbirthday}
</tr> <input type="checkbox" name="mainscreen_showbirthdays"{show_birthday}>
<tr bgcolor="EEEEEE"> </td>
<td colspan="3"> </tr>
<tr bgcolor="{row_off}">
<td colspan="3" align="center">
{lang_defaultcat} {lang_defaultcat}
{cat_select} {cat_select}
</td> </td>
<td colspan="3"> <td colspan="3" align="center">
{lang_autosave} {lang_autosave}
<input type="checkbox" name="autosave_category"{autosave}></td> <input type="checkbox" name="autosave_category"{autosave}></td>
</tr> </tr>
<tr> <tr>
<td colspan="5" align="center"> <td colspan="6" align="center">
<input type="submit" name="submit" value="{lang_submit}"> <input type="submit" name="submit" value="{lang_submit}">
</td> </td>
</tr> </tr>
</table> </table>
</form> </form>