egroupware/calendar/preferences.php
2001-03-10 04:52:12 +00:00

166 lines
6.1 KiB
PHP

<?php
/**************************************************************************\
* phpGroupWare - Calendar *
* 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_flags = Array(
'currentapp' => 'calendar',
'enable_nextmatchs_class' => True,
'noheader' => True,
'nonavbar' => True,
'noappheader' => True,
'noappfooter' => True
);
$phpgw_info['flags'] = $phpgw_flags;
include('../header.inc.php');
if ($submit)
{
$phpgw->preferences->read_repository();
$phpgw->preferences->add('calendar','weekdaystarts');
$phpgw->preferences->add('calendar','workdaystarts');
$phpgw->preferences->add('calendar','workdayends');
$phpgw->preferences->add('calendar','defaultcalendar');
$phpgw->preferences->add('calendar','defaultfilter');
if ($mainscreen_showevents)
{
$phpgw->preferences->add('calendar','mainscreen_showevents');
}
else
{
$phpgw->preferences->delete('calendar','mainscreen_showevents');
}
if ($send_updates)
{
$phpgw->preferences->add('calendar','send_updates');
}
else
{
$phpgw->preferences->delete('calendar','send_updates');
}
$phpgw->preferences->save_repository(True);
Header('Location: '.$phpgw->link('/preferences/index.php'));
$phpgw->common->phpgw_exit();
}
function display_item($field,$data)
{
global $phpgw, $p, $tr_color;
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
$var = Array(
'bg_color' => $tr_color,
'field' => $field,
'data' => $data
);
$p->set_var($var);
$p->parse('row','pref_list',True);
}
$phpgw->common->phpgw_header();
echo parse_navbar();
$p = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('calendar'));
$templates = Array(
'pref' => 'pref.tpl',
'pref_colspan' => 'pref_colspan.tpl',
'pref_list' => 'pref_list.tpl',
);
$p->set_file($templates);
$var = Array(
'title' => lang('Calendar preferences'),
'action_url' => $phpgw->link('/'.$phpgw_info['flags']['currentapp'].'/preferences.php'),
'bg_color' => $phpgw_info['theme']['th_bg'],
'submit_lang' => lang('submit')
);
$p->set_var($var);
$p->set_var('text','&nbsp;');
$p->parse('row','pref_colspan',True);
// if ($totalerrors)
// {
// echo '<p><center>' . $phpgw->common->error_list($errors) . '</center>';
// }
$str = '<input type="checkbox" name="mainscreen_showevents" value="Y"'.($phpgw_info['user']['preferences']['calendar']['mainscreen_showevents'] == 'Y'?' checked':'').'>';
display_item(lang('show day view on main screen'),$str);
$t_weekday[$phpgw_info['user']['preferences']['calendar']['weekdaystarts']] = ' selected';
$str = '<select name="weekdaystarts">'
. '<option value="Monday"'.$t_weekday['Monday'].'>'.lang('Monday').'</option>'
. '<option value="Sunday"'.$t_weekday['Sunday'].'>'.lang('Sunday').'</option>'
. '</select>';
display_item(lang('weekday starts on'),$str);
$t_workdaystarts[$phpgw_info['user']['preferences']['calendar']['workdaystarts']] = ' selected';
$str = '<select name="workdaystarts">';
for ($i=0; $i<24; $i++)
{
$str .= '<option value="'.$i.'"'.$t_workdaystarts[$i].'>'
. $phpgw->common->formattime($i+1,'00') . '</option>';
}
$str .= '</select>';
display_item(lang('work day starts on'),$str);
$t_workdayends[$phpgw_info['user']['preferences']['calendar']['workdayends']] = ' selected';
$str = '<select name="workdayends">';
for ($i=0; $i<24; $i++)
{
$str .= '<option value="'.$i.'"'.$t_workdayends[$i].'>'
. $phpgw->common->formattime($i+1,'00') . '</option>';
}
$str .= '</select>';
display_item(lang('work day ends on'),$str);
$selected[$phpgw_info['user']['preferences']['calendar']['defaultcalendar']] = ' selected';
if (!isset($phpgw_info['user']['preferences']['calendar']['defaultcalendar']))
{
$selected['month.php'] = ' selected';
}
$str = '<select name="defaultcalendar">'
. '<option value="year.php"'.$selected['year.php'].'>'.lang('Yearly').'</option>'
. '<option value="month.php"'.$selected['month.php'].'>'.lang('Monthly').'</option>'
. '<option value="week.php"'.$selected['week.php'].'>'.lang('Weekly').'</option>'
. '<option value="day.php"'.$selected['day.php'].'>'.lang('Daily').'</option>'
. '</select>';
display_item(lang('default calendar view'),$str);
$selected = array();
$selected[$phpgw_info['user']['preferences']['calendar']['defaultfilter']] = ' selected';
if (! isset($phpgw_info['user']['preferences']['calendar']['defaultfilter']) || $phpgw_info['user']['preferences']['calendar']['defaultfilter'] == 'private')
{
$selected['private'] = ' selected';
}
$str = '<select name="defaultfilter">'
. '<option value="all"'.$selected['all'].'>'.lang('all').'</option>'
. '<option value="private"'.$selected['private'].'>'.lang('private only').'</option>'
. '<option value="public"'.$selected['public'].'>'.lang('global public only').'</option>'
. '<option value="group"'.$selected['group'].'>'.lang('group public only').'</option>'
. '<option value="private+public"'.$selected['private+public'].'>'.lang('private and global public').'</option>'
. '<option value="private+group"'.$selected['private+group'].'>'.lang('private and group public').'</option>'
. '<option value="public+group"'.$selected['public+group'].'>'.lang('global public and group public').'</option>'
. '</select>';
display_item(lang('default calendar filter'),$str);
$str = '<input type="checkbox" name="send_updates" value="Y"'.($phpgw_info['user']['preferences']['calendar']['send_updates'] == 'Y'?' checked':'').'>';
display_item(lang('send updates via email'),$str);
$p->pparse('out','pref');
$phpgw->common->phpgw_footer();
?>