Moved preferences to ui/bo

This commit is contained in:
Miles Lott 2001-07-13 09:03:31 +00:00
parent 3d005e094e
commit 3daaf14c25
6 changed files with 707 additions and 791 deletions

View File

@ -232,5 +232,58 @@
{
return $this->so->delete_entry($ab_id);
}
function save_preferences($prefs,$other,$qfields,$fcat_id)
{
global $phpgw;
$phpgw->preferences->read_repository();
if (is_array($prefs))
{
/* _debug_array($prefs);exit; */
while (list($pref,$x) = each($qfields))
{
/* echo '<br>checking: ' . $pref . '=' . $prefs[$pref]; */
if ($prefs[$pref] == 'on')
{
$phpgw->preferences->add('addressbook',$pref,'addressbook_on');
}
else
{
$phpgw->preferences->delete('addressbook',$pref);
}
}
}
if(is_array($other))
{
$phpgw->preferences->delete('addressbook','mainscreen_showbirthdays');
if ($other['mainscreen_showbirthdays'])
{
$phpgw->preferences->add('addressbook','mainscreen_showbirthdays');
}
$phpgw->preferences->delete('addressbook','default_filter');
if ($other['default_filter'])
{
$phpgw->preferences->add('addressbook','default_filter');
}
$phpgw->preferences->delete('addressbook','autosave_category');
if ($other['autosave_category'])
{
$phpgw->preferences->add('addressbook','autosave_category',True);
}
}
if($fcat_id)
{
$phpgw->preferences->delete('addressbook','default_category');
$phpgw->preferences->add('addressbook','default_category',$fcat_id);
}
$phpgw->preferences->save_repository(True);
/* _debug_array($prefs);exit; */
Header('Location: ' . $phpgw->link('/preferences/index.php'));
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@
// Only Modify the $file and $title variables.....
$title = $appname;
$file = Array(
'Preferences' => $phpgw->link('/addressbook/preferences.php'),
'Preferences' => $phpgw->link('/index.php','menuaction=addressbook.uiaddressbook.preferences'),
'Grant Access' => $phpgw->link('/preferences/acl_preferences.php','acl_app='.$appname),
'Edit Categories' => $phpgw->link('/preferences/categories.php','cats_app='.$appname . '&cats_level=True&global_cats=True'),
'Edit custom fields' => $phpgw->link('/addressbook/fields.php')

View File

@ -1,230 +0,0 @@
<?php
/**************************************************************************\
* phpGroupWare - Address Book *
* http://www.phpgroupware.org *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
$phpgw_info['flags'] = array(
'currentapp' => 'addressbook',
'noheader' => True,
'nonavbar' => True,
'noappheader' => True,
'noappfooter' => True,
'enable_contacts_class' => True,
'enable_categories_class' => True,
'enable_nextmatchs_class' => True
);
include('../header.inc.php');
$contacts = CreateObject('phpgwapi.contacts');
$extrafields = array(
'ophone' => 'ophone',
'address2' => 'address2',
'address3' => 'address3'
);
$phpgw->preferences->read_repository();
$customfields = array();
if ($phpgw_info['user']['preferences']['addressbook'])
{
while (list($col,$descr) = each($phpgw_info['user']['preferences']['addressbook']))
{
if ( substr($col,0,6) == 'extra_' )
{
$field = ereg_replace('extra_','',$col);
$customfields[$field] = ucfirst($field);
}
}
}
$qfields = $contacts->stock_contact_fields + $extrafields + $customfields;
if ($submit)
{
$totalerrors = 0;
if (! count($ab_selected))
{
$errors[$totalerrors++] = lang('You must select at least 1 column to display');
}
if (! $totalerrors)
{
$phpgw->preferences->read_repository();
while (list($pref[0]) = each($qfields))
{
if ($ab_selected["$pref[0]"])
{
$phpgw->preferences->change('addressbook',$pref[0],'addressbook_' . $ab_selected["$pref[0]"]);
}
else
{
$phpgw->preferences->delete('addressbook',$pref[0],'addressbook_' . $ab_selected["$pref[0]"]);
}
}
if ($mainscreen_showbirthdays)
{
$phpgw->preferences->delete('addressbook','mainscreen_showbirthdays');
$phpgw->preferences->add('addressbook','mainscreen_showbirthdays');
}
else
{
$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');
$phpgw->preferences->add('addressbook','autosave_category',True);
}
else
{
$phpgw->preferences->delete('addressbook','autosave_category');
}
if ($cat_id)
{
$phpgw->preferences->delete('addressbook','default_category');
$phpgw->preferences->add('addressbook','default_category',$cat_id);
}
else
{
$phpgw->preferences->delete('addressbook','default_category');
}
$phpgw->preferences->save_repository(True);
Header('Location: ' . $phpgw->link('/preferences/index.php'));
}
}
$phpgw->common->phpgw_header();
echo parse_navbar();
if ($totalerrors)
{
echo '<p><center>' . $phpgw->common->error_list($errors) . '</center>';
}
$t = new Template(PHPGW_APP_TPL);
$t->set_file(array(
'preferences' => 'preferences.tpl'
));
$t->set_var(action_url,$phpgw->link('/addressbook/preferences.php'));
$i = 0; $j = 0;
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
while (list($col, $descr) = each($qfields))
{
// echo "<br>test: $col - $i $j - " . count($abc);
$i++; $j++;
$showcol = display_name($col);
if (!$showcol) { $showcol = $col; }
// yank the *'s prior to testing for a valid column description
$coltest = ereg_replace("\*","",$showcol);
if ($coltest)
{
$t->set_var($col,$showcol);
if ($phpgw_info['user']['preferences']['addressbook'][$col])
{
$t->set_var($col.'_checked',' checked');
}
else
{
$t->set_var($col.'_checked','');
}
}
}
if ($customfields)
{
$custom_var = '
<tr>
<td><font color="#000000" face="">'.lang('Custom').' '.lang('Fields').':</font></td>
<td></td>
<td></td>
</tr>
';
while( list($cf) = each($customfields) )
{
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
$custom_var .= "\n" . '<tr bgcolor="' . $tr_color . '">';
$custom_var .= ' <td><input type="checkbox" name="ab_selected['
. strtolower($cf) . ']"'
. ($phpgw_info['user']['preferences']['addressbook'][$cf]?' checked':'')
. '>' . $cf . '</option></td>' . "\n"
. '</tr>' . "\n";
}
$t->set_var('custom_fields',$custom_var);
}
else
{
$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'));
if ($phpgw_info['user']['preferences']['addressbook']['mainscreen_showbirthdays'])
{
$t->set_var('show_birthday',' checked');
}
else
{
$t->set_var('show_birthday','');
}
$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');
}
else
{
$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']));
$t->set_var('lang_abprefs',lang('Addressbook').' '.lang('Preferences'));
$t->set_var('lang_fields',lang('Fields to show in address list'));
$t->set_var('lang_personal',lang('Personal'));
$t->set_var('lang_business',lang('Business'));
$t->set_var('lang_home',lang('Home'));
$t->set_var('lang_phones',lang('Extra').' '.lang('Phone Numbers'));
$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

@ -9,17 +9,17 @@
<td colspan="6"><font color="#000000" face="">{lang_personal}:</font></td>
</tr>
<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>
<td><input type="checkbox" name="ab_selected[n_middle]"{n_middle_checked}>{n_middle}</option></td>
<td><input type="checkbox" name="prefs[fn]"{fn_checked}>{fn}</option></td>
<td><input type="checkbox" name="prefs[n_given]"{n_given_checked}>{n_given}</option></td>
<td><input type="checkbox" name="prefs[n_family]"{n_family_checked}>{n_family}</option></td>
<td><input type="checkbox" name="prefs[n_middle]"{n_middle_checked}>{n_middle}</option></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<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>
<td><input type="checkbox" name="prefs[n_prefix]"{n_prefix_checked}>{n_prefix}</option></td>
<td><input type="checkbox" name="prefs[n_suffix]"{n_suffix_checked}>{n_suffix}</option></td>
<td><input type="checkbox" name="prefs[bday]"{bday_checked}>{bday}</option></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
@ -31,27 +31,27 @@
<td colspan="6"><font color="#000000" face="">{lang_business}:</font></td>
</tr>
<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>
<td><input type="checkbox" name="prefs[org_name]"{org_name_checked}>{org_name}</option></td>
<td><input type="checkbox" name="prefs[org_unit]"{org_unit_checked}>{org_unit}</option></td>
<td><input type="checkbox" name="prefs[title]"{title_checked}>{title}</option></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<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>
<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_postalcode]"{adr_one_postalcode_checked}>{adr_one_postalcode}</option></td>
<td><input type="checkbox" name="prefs[adr_one_street]"{adr_one_street_checked}>{adr_one_street}</option></td>
<td><input type="checkbox" name="prefs[address2]"{address2_checked}>{address2}</option></td>
<td><input type="checkbox" name="prefs[address3]"{address3_checked}>{address3}</option></td>
<td><input type="checkbox" name="prefs[adr_one_locality]"{adr_one_locality_checked}>{adr_one_locality}</option></td>
<td><input type="checkbox" name="prefs[adr_one_region]"{adr_one_region_checked}>{adr_one_region}</option></td>
<td><input type="checkbox" name="prefs[adr_one_postalcode]"{adr_one_postalcode_checked}>{adr_one_postalcode}</option></td>
</tr>
<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>
<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><input type="checkbox" name="prefs[adr_one_countryname]"{adr_one_countryname_checked}>{adr_one_countryname}</option></td>
<td><input type="checkbox" name="prefs[adr_two_type]"{adr_one_type_checked}>{adr_one_type}</option></td>
<td><input type="checkbox" name="prefs[tel_work]"{tel_work_checked}>{tel_work}</option></td>
<td><input type="checkbox" name="prefs[email]"{email_checked}>{email}</option></td>
<td colspan="2"><input type="checkbox" name="prefs[email_type]"{email_type_checked}>{email_type}</option></td>
</tr>
<tr>
<td>&nbsp;</td>
@ -60,19 +60,19 @@
<td colspan="6"><font color="#000000" face="">{lang_home}:</font></td>
</tr>
<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>
<td><input type="checkbox" name="ab_selected[adr_two_postalcode]"{adr_two_postalcode_checked}>{adr_two_postalcode}</option></td>
<td><input type="checkbox" name="prefs[adr_two_street]"{adr_two_street_checked}>{adr_two_street}</option></td>
<td><input type="checkbox" name="prefs[adr_two_locality]"{adr_two_locality_checked}>{adr_two_locality}</option></td>
<td><input type="checkbox" name="prefs[adr_two_region]"{adr_two_region_checked}>{adr_two_region}</option></td>
<td><input type="checkbox" name="prefs[adr_two_postalcode]"{adr_two_postalcode_checked}>{adr_two_postalcode}</option></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<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>
<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><input type="checkbox" name="prefs[adr_two_countryname]"{adr_two_countryname_checked}>{adr_two_countryname}</option></td>
<td><input type="checkbox" name="prefs[adr_two_type]"{adr_two_type_checked}>{adr_two_type}</option></td>
<td><input type="checkbox" name="prefs[tel_home]"{tel_home_checked}>{tel_home}</option></td>
<td><input type="checkbox" name="prefs[email_home]"{email_home_checked}>{email_home}</option></td>
<td colspan="2"><input type="checkbox" name="prefs[email_home_type]"{email_home_type_checked}>{email_home_type}</option></td>
</tr>
<tr>
<td>&nbsp;</td>
@ -81,19 +81,19 @@
<td colspan="6"><font color="#000000" face="">{lang_phones}:</font></td>
</tr>
<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>
<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_bbs]"{tel_bbs_checked}>{tel_bbs}</option></td>
<td><input type="checkbox" name="prefs[tel_voice]"{tel_voice_checked}>{tel_voice}</option></td>
<td><input type="checkbox" name="prefs[tel_fax]"{tel_fax_checked}>{tel_fax}</option></td>
<td><input type="checkbox" name="prefs[tel_msg]"{tel_msg_checked}>{tel_msg}</option></td>
<td><input type="checkbox" name="prefs[tel_cell]"{tel_cell_checked}>{tel_cell}</option></td>
<td><input type="checkbox" name="prefs[tel_pager]"{tel_pager_checked}>{tel_pager}</option></td>
<td><input type="checkbox" name="prefs[tel_bbs]"{tel_bbs_checked}>{tel_bbs}</option></td>
</tr>
<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>
<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="prefs[tel_modem]"{tel_modem_checked}>{tel_modem}</option></td>
<td><input type="checkbox" name="prefs[tel_car]"{tel_car_checked}>{tel_car}</option></td>
<td><input type="checkbox" name="prefs[tel_isdn]"{tel_isdn_checked}>{tel_isdn}</option></td>
<td><input type="checkbox" name="prefs[tel_video]"{tel_video_checked}>{tel_video}</option></td>
<td><input type="checkbox" name="prefs[ophone]"{ophone_checked}>{ophone}</option></td>
<td>&nbsp;</td>
</tr>
<tr>
@ -103,9 +103,9 @@
<td colspan="6"><font color="#000000" face="">{lang_other}:</font></td>
</tr>
<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>
<td><input type="checkbox" name="prefs[geo]"{geo_checked}>{geo}</option></td>
<td><input type="checkbox" name="prefs[url]"{url_checked}>{url}</option></td>
<td><input type="checkbox" name="prefs[tz]"{tz_checked}>{tz}</option></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
@ -126,7 +126,7 @@
{filter_select}
</td>
<td colspan="3" align="center">{lang_showbirthday}
<input type="checkbox" name="mainscreen_showbirthdays"{show_birthday}>
<input type="checkbox" name="other[mainscreen_showbirthdays]"{show_birthday}>
</td>
</tr>
<tr bgcolor="{row_off}">
@ -136,7 +136,7 @@
</td>
<td colspan="3" align="center">
{lang_autosave}
<input type="checkbox" name="autosave_category"{autosave}></td>
<input type="checkbox" name="other[autosave_category]"{autosave}></td>
</tr>
<tr>
<td colspan="6" align="center">

View File

@ -31,21 +31,21 @@
<!-- END view_footer -->
<!-- BEGIN view_buttons -->
<center>
<TABLE border="0" cellpadding="1" cellspacing="1">
<TR>
<TD>
<table border="0" cellpadding="1" cellspacing="1">
<tr>
<td>
{edit_button}
</TD>
<TD>
</td>
<td>
{copy_button}
</TD>
<TD>
</td>
<td>
{vcard_button}
</TD>
<TD>
</td>
<td>
{done_button}
</TD>
</TR>
</TABLE>
</td>
</tr>
</table>
</center>
<!-- END view_buttons -->