[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] calendar/inc hook_deleteaccount.inc.php, 1.7 hook_adm
From: |
skwashd |
Subject: |
[Phpgroupware-cvs] calendar/inc hook_deleteaccount.inc.php, 1.7 hook_admin.inc.php, 1.15 hook_add_def_pref.inc.php, 1.4 hook_email.inc.php, 1.8 hook_home.inc.php, 1.42 hook_home_month.inc.php, 1.6 hook_home_day.inc.php, 1.6 class.uiicalendar.inc.php, 1.9 class.uiholiday.inc.php, 1.9 class.socalendar_sql.inc.php, 1.37 class.socalendar__.inc.php, 1.16 class.soholiday.inc.php, 1.6 class.uialarm.inc.php, 1.9 class.uicalendar.inc.php, 1.108 hook_home_planner.inc.php, 1.5 hook_home_week.inc.php, 1.6 hook_manual.inc.php, 1.7 hook_home_year.inc.php, 1.6 hook_preferences.inc.php, 1.26 hook_settings.inc.php, 1.5 class.socalendar_.inc.php, 1.7 class.socalendar.inc.php, 1.29 class.calendar_holiday.inc.php, 1.26 class.boicalendar.inc.php, 1.25 class.calendar_icap.inc.php, 1.18 class.holidaycalc.inc.php, 1.8 class.html.inc.php, 1.5 class.holidaycalc_US.inc.php, 1.10 class.boholiday.inc.php, 1.14 class.bocalendar.inc.php, 1.93 class.boalarm.inc.php, 1.7 class.holidaycalc_JP.inc.php, 1.6 class.uicustom_fields.inc.php, 1.2 hook_sidebo x_menu.inc.php,1.2 class.bocustom_fields.inc.php,1.2 |
Date: |
Sun, 15 May 2005 08:57:00 +0200 |
Update of calendar/inc
Modified Files:
Branch: MAIN
hook_deleteaccount.inc.php lines: +0 -0
hook_admin.inc.php lines: +11 -11
hook_add_def_pref.inc.php lines: +0 -0
hook_email.inc.php lines: +28 -26
hook_home.inc.php lines: +37 -8
hook_home_month.inc.php lines: +4 -5
hook_home_day.inc.php lines: +4 -5
class.uiicalendar.inc.php lines: +22 -21
class.uiholiday.inc.php lines: +13 -9
class.socalendar_sql.inc.php lines: +289 -41
class.socalendar__.inc.php lines: +3 -6
class.soholiday.inc.php lines: +10 -16
class.uialarm.inc.php lines: +106 -45
class.uicalendar.inc.php lines: +970 -1140
hook_home_planner.inc.php lines: +2 -2
hook_home_week.inc.php lines: +4 -5
hook_manual.inc.php lines: +0 -0
hook_home_year.inc.php lines: +4 -5
hook_preferences.inc.php lines: +1 -1
hook_settings.inc.php lines: +128 -49
class.socalendar_.inc.php lines: +0 -0
class.socalendar.inc.php lines: +57 -39
class.calendar_holiday.inc.php lines: +6 -6
class.boicalendar.inc.php lines: +88 -58
class.calendar_icap.inc.php lines: +1 -1
class.holidaycalc.inc.php lines: +0 -0
class.html.inc.php lines: +280 -59
class.holidaycalc_US.inc.php lines: +7 -7
class.boholiday.inc.php lines: +30 -38
class.bocalendar.inc.php lines: +994 -294
class.boalarm.inc.php lines: +154 -16
class.holidaycalc_JP.inc.php lines: +71 -23
Added Files:
Branch: MAIN
class.uicustom_fields.inc.php lines: +202 -0
hook_sidebox_menu.inc.php lines: +79 -0
class.bocustom_fields.inc.php lines: +97 -0
Log Message:
merge changes from 16
====================================================
====================================================
Index: calendar/inc/hook_admin.inc.php
diff -u calendar/inc/hook_admin.inc.php:1.14
calendar/inc/hook_admin.inc.php:1.15
--- calendar/inc/hook_admin.inc.php:1.14 Sun May 15 05:48:35 2005
+++ calendar/inc/hook_admin.inc.php Sun May 15 06:57:37 2005
@@ -9,18 +9,18 @@
* Free Software Foundation; either version 2 of the License, or (at
your *
* option) any later version.
*
\**************************************************************************/
- /* $Id$ */
- {
+ /* $Id$ */
+{
// Only Modify the $file and $title variables.....
-
- $file = Array
- (
- 'Site Configuration' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiconfig.index&appname='
. $appname),
- 'Calendar Holiday Management' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uiholiday.admin'),
- 'Global categories' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uicategories.index&appname='
. $appname . '&global_cats=True')
- );
+ $title = $appname;
+ $file = Array(
+ 'Site Configuration' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiconfig.index&appname='
. $appname),
+ 'Custom fields and sorting' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicustom_fields.index'),
+ 'Calendar Holiday Management' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uiholiday.admin'),
+ 'Global Categories' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uicategories.index&appname=calendar')
+ );
//Do not modify below this line
- display_section($appname,$file);
- }
+ display_section($appname,$title,$file);
+}
?>
====================================================
====================================================
Index: calendar/inc/hook_email.inc.php
diff -u calendar/inc/hook_email.inc.php:1.7 calendar/inc/hook_email.inc.php:1.8
--- calendar/inc/hook_email.inc.php:1.7 Sun May 15 05:48:35 2005
+++ calendar/inc/hook_email.inc.php Sun May 15 06:57:37 2005
@@ -19,34 +19,36 @@
$d1 =
strtolower(substr($GLOBALS['phpgw_info']['server']['app_inc'],0,3));
if($d1 == 'htt' || $d1 == 'ftp')
{
- echo 'Failed attempt to break in via an old Security
Hole!<br>'."\n";
- $GLOBALS['phpgw_info']['flags']['nodisplay'] = True;
- exit;
+ echo 'Failed attempt to break in via an old Security Hole!<br
/>'."\n";
+ $phpgw->common->phpgw_exit();
}
unset($d1);
- $GLOBALS['phpgw']->translation->add_app('calendar');
-
- $cal = CreateObject('calendar.uicalendar');
- //echo "Event ID: $calendar_id<br>\n";
-
- $event = $cal->bo->read_entry($calendar_id);
-
- echo $cal->timematrix(
- Array(
- 'date' =>
$GLOBALS['phpgw']->datetime->localdates(mktime(0,0,0,$event['start']['month'],$event['start']['mday'],$event['start']['year'])
- $phpgw->calendar->tz_offset),
- 'starttime' => $cal->bo->splittime('000000',False),
- 'endtime' => 0,
- 'participants' => $event['participants'])
- ) .
-
- '</td></tr><tr><td>' .
-
- $cal->view_event($event) .
-
- '</td></tr><tr><td align="center">' .
-
- $cal->get_response($calendar_id);
-
- unset($cal); unset($event);
+ if ($calendar_id)
+ {
+ $GLOBALS['phpgw']->translation->add_app('calendar');
+
+ $cal = CreateObject('calendar.uicalendar');
+ //echo "Event ID: $calendar_id<br />\n";
+
+ if ($event = $cal->bo->read_entry($calendar_id))
+ {
+ echo $cal->timematrix(
+ Array(
+ 'date' =>
$GLOBALS['phpgw']->datetime->localdates(mktime(0,0,0,$event['start']['month'],$event['start']['mday'],$event['start']['year'])
- $phpgw->calendar->tz_offset),
+ 'starttime' =>
$cal->bo->splittime('000000',False),
+ 'endtime' => 0,
+ 'participants' =>
$event['participants'])
+ ) .
+
+ '</td></tr><tr><td>' .
+
+ $cal->view_event($event) .
+
+ '</td></tr><tr><td align="center">' .
+
+ $cal->get_response($calendar_id);
+ }
+ unset($cal); unset($event);
+ }
?>
====================================================
Index: calendar/inc/hook_home.inc.php
diff -u calendar/inc/hook_home.inc.php:1.41 calendar/inc/hook_home.inc.php:1.42
--- calendar/inc/hook_home.inc.php:1.41 Sun May 15 05:48:35 2005
+++ calendar/inc/hook_home.inc.php Sun May 15 06:57:37 2005
@@ -17,9 +17,8 @@
$d1 = strtolower(substr(PHPGW_APP_INC,0,3));
if($d1 == 'htt' || $d1 == 'ftp' )
{
- echo 'Failed attempt to break in via an old Security
Hole!<br>'."\n";
- $GLOBALS['phpgw_info']['flags']['nodisplay'] = True;
- exit;
+ echo 'Failed attempt to break in via an old Security Hole!<br
/>'."\n";
+ $GLOBALS['phpgw']->common->phpgw_exit();
}
unset($d1);
@@ -36,6 +35,8 @@
$GLOBALS['g_month'] = substr($GLOBALS['date'],4,2);
$GLOBALS['g_day'] = substr($GLOBALS['date'],6,2);
$GLOBALS['owner'] =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $GLOBALS['css'] = "\n".'<STYLE
type="text/css">'."\n".'<!--'."\n"
+ .
ExecMethod('calendar.uicalendar.css').'-->'."\n".'</style>';
$page_ =
explode('.',$GLOBALS['phpgw_info']['user']['preferences']['calendar']['defaultcalendar']);
$_page = substr($page_[0],0,7); // makes planner from
planner_{user|category}
@@ -52,11 +53,39 @@
}
include(PHPGW_INCLUDE_ROOT.'/calendar/inc/hook_home_'.$_page.'.inc.php');
+ $title = '<font color="#FFFFFF">'.lang('Calendar').'</font>';
+
+ $portalbox = CreateObject('phpgwapi.listbox',
+ Array(
+ 'title' => $title,
+ 'primary' =>
$GLOBALS['phpgw_info']['theme']['navbar_bg'],
+ 'secondary' =>
$GLOBALS['phpgw_info']['theme']['navbar_bg'],
+ 'tertiary' =>
$GLOBALS['phpgw_info']['theme']['navbar_bg'],
+ 'width' => '100%',
+ 'outerborderwidth' => '0',
+ 'header_background_image' =>
$GLOBALS['phpgw']->common->image('phpgwapi','bg_filler', '.png', False)
+ )
+ );
+
$app_id = $GLOBALS['phpgw']->applications->name2id('calendar');
$GLOBALS['portal_order'][] = $app_id;
+ $var = Array(
+ 'up' => Array('url' => '/set_box.php', 'app'
=> $app_id),
+ 'down' => Array('url' => '/set_box.php', 'app'
=> $app_id),
+ 'close' => Array('url' => '/set_box.php', 'app'
=> $app_id),
+ 'question' => Array('url' => '/set_box.php',
'app' => $app_id),
+ 'edit' => Array('url' => '/set_box.php', 'app'
=> $app_id)
+ );
- $GLOBALS['phpgw']->portalbox->set_params(array('app_id' =>
$app_id,
-
'title' => lang('calendar')));
- $GLOBALS['phpgw']->portalbox->draw($GLOBALS['extra_data']);
- }
+ while(list($key,$value) = each($var))
+ {
+ $portalbox->set_controls($key,$value);
+ }
+
+ $portalbox->data = Array();
+
+ echo "\n".'<!-- BEGIN Calendar info
-->'."\n".$portalbox->draw($GLOBALS['extra_data'])."\n".'<!-- END Calendar info
-->'."\n";
+ unset($cal);
+ }
+ flush();
?>
====================================================
Index: calendar/inc/hook_home_month.inc.php
diff -u calendar/inc/hook_home_month.inc.php:1.5
calendar/inc/hook_home_month.inc.php:1.6
--- calendar/inc/hook_home_month.inc.php:1.5 Sun May 15 05:48:35 2005
+++ calendar/inc/hook_home_month.inc.php Sun May 15 06:57:37 2005
@@ -17,13 +17,12 @@
$d1 = strtolower(substr(PHPGW_APP_INC,0,3));
if($d1 == 'htt' || $d1 == 'ftp' )
{
- echo 'Failed attempt to break in via an old Security
Hole!<br>'."\n";
- $GLOBALS['phpgw_info']['flags']['nodisplay'] = True;
- exit;
+ echo 'Failed attempt to break in via an old Security Hole!<br
/>'."\n";
+ $GLOBALS['phpgw']->common->phpgw_exit();
}
unset($d1);
- $GLOBALS['extra_data'] = '<td>'."\n".'<table border="0"
cols="3"><tr><td align="center" width="100%" valign="top">'
+ $GLOBALS['extra_data'] = $GLOBALS['css']."\n".'<td>'."\n".'<table
border="0" cols="3"><tr><td align="center" width="100%" valign="top">'
. ExecMethod('calendar.uicalendar.get_month')
.'</td>'."\n".'</tr>'."\n".'</table>'."\n".'</td>'."\n";
?>
====================================================
Index: calendar/inc/hook_home_day.inc.php
diff -u calendar/inc/hook_home_day.inc.php:1.5
calendar/inc/hook_home_day.inc.php:1.6
--- calendar/inc/hook_home_day.inc.php:1.5 Sun May 15 05:48:35 2005
+++ calendar/inc/hook_home_day.inc.php Sun May 15 06:57:37 2005
@@ -17,13 +17,12 @@
$d1 = strtolower(substr(PHPGW_APP_INC,0,3));
if($d1 == 'htt' || $d1 == 'ftp' )
{
- echo 'Failed attempt to break in via an old Security
Hole!<br>'."\n";
- $GLOBALS['phpgw_info']['flags']['nodisplay'] = True;
- exit;
+ echo 'Failed attempt to break in via an old Security Hole!<br
/>'."\n";
+ $GLOBALS['phpgw']->common->phpgw_exit();
}
unset($d1);
- $GLOBALS['extra_data'] = '<td>'."\n".'<table border="0"
cols="3"><tr><td align="center" width="35%" valign="top">'
+ $GLOBALS['extra_data'] = $GLOBALS['css']."\n".'<td>'."\n".'<table
border="0" cols="3"><tr><td align="center" width="35%" valign="top">'
. ExecMethod('calendar.uicalendar.mini_calendar',
Array(
'day' => $GLOBALS['g_day'],
====================================================
Index: calendar/inc/class.uiicalendar.inc.php
diff -u calendar/inc/class.uiicalendar.inc.php:1.8
calendar/inc/class.uiicalendar.inc.php:1.9
--- calendar/inc/class.uiicalendar.inc.php:1.8 Sun May 15 05:48:35 2005
+++ calendar/inc/class.uiicalendar.inc.php Sun May 15 06:57:37 2005
@@ -35,7 +35,7 @@
function print_test($val,$title,$x_pre='')
{
-// echo 'VAL = '._debug_array($val,False)."<br>\n";
+// echo 'VAL = '._debug_array($val,False)."<br />\n";
if(is_array($val))
{
@reset($val);
@@ -66,13 +66,13 @@
{
$v_value = $value;
}
- echo $title.' ('.$key.') =
'.$v_value."<br>\n";
+ echo $title.' ('.$key.') =
'.$v_value."<br />\n";
}
}
}
elseif($val != '')
{
- echo $title.' = '.$val."<br>\n";
+ echo $title.' = '.$val."<br />\n";
}
}
@@ -84,10 +84,10 @@
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
$GLOBALS['phpgw']->common->phpgw_header();
- echo "Start Time :
".$GLOBALS['phpgw']->common->show_date()."<br>\n";
+ echo "Start Time :
".$GLOBALS['phpgw']->common->show_date()."<br />\n";
@set_time_limit(0);
- $icsfile=PHPGW_APP_INC.'/events.vcs';
+ $icsfile=PHPGW_APP_INC.'/events.ics';
$fp=fopen($icsfile,'rt');
$contents = explode("\n",fread($fp,
filesize($icsfile)));
fclose($fp);
@@ -104,8 +104,8 @@
{
$event = $vcalendar['event'][$i];
- echo "<br>\nEVENT<br>\n";
-// echo 'TEST Debug :
'._debug_array($event,False)."<br>\n";
+ echo "<br />\nEVENT<br />\n";
+// echo 'TEST Debug :
'._debug_array($event,False)."<br />\n";
$this->print_test($event['uid'],'UID','X-');
$this->print_test($event['valscale'],'Calscale','X-');
$this->print_test($event['description'],'Description','X-');
@@ -119,7 +119,7 @@
$this->print_test($event['dtstamp'],'Date Stamp','X-');
$this->print_test($event['rrule'],'Recurrence','X-');
- echo "Class =
".$this->bo->switch_class($event['class'])."<br>\n";
+ echo "Class =
".$this->bo->switch_class($event['class'])."<br />\n";
$this->print_test($event['organizer'],'Organizer','X-');
$this->print_test($event['attendee'],'Attendee','X-');
@@ -131,26 +131,26 @@
/*
for($i=0;$i<count($vcalendar->todo);$i++)
{
- echo "<br>\nTODO<br>\n";
+ echo "<br />\nTODO<br />\n";
if($vcalendar['todo'][$i]['summary']['value'])
{
- echo "Summary =
".$vcalendar['todo'][$i]['summary']['value']."<br>\n";
+ echo "Summary =
".$vcalendar['todo'][$i]['summary']['value']."<br />\n";
}
if($vcalendar['todo'][$i]['description']['value'])
{
- echo "Description (Value) =
".$vcalendar['todo'][$i]['description']['value']."<br>\n";
+ echo "Description (Value) =
".$vcalendar['todo'][$i]['description']['value']."<br />\n";
}
if($vcalendar['todo'][$i]['description']['altrep'])
{
- echo "Description (Alt Rep) =
".$vcalendar['todo'][$i]['description']['altrep']."<br>\n";
+ echo "Description (Alt Rep) =
".$vcalendar['todo'][$i]['description']['altrep']."<br />\n";
}
if($vcalendar['todo'][$i]['location']['value'])
{
- echo "Location =
".$vcalendar['todo'][$i]['location']['value']."<br>\n";
+ echo "Location =
".$vcalendar['todo'][$i]['location']['value']."<br />\n";
}
- echo "Sequence =
".$vcalendar['todo'][$i]['sequence']."<br>\n";
- echo "Date Start :
".$GLOBALS['phpgw']->common->show_date(mktime($vcalendar['todo'][$i]['dtstart']['hour'],$vcalendar['todo'][$i]['dtstart']['min'],$vcalendar['todo'][$i]['dtstart']['sec'],$vcalendar['todo'][$i]['dtstart']['month'],$vcalendar['todo'][$i]['dtstart']['mday'],$vcalendar['todo'][$i]['dtstart']['year'])
- $this->datatime->tz_offset)."<br>\n";
- echo "Class =
".$vcalendar['todo'][$i]['class']['value']."<br>\n";
+ echo "Sequence =
".$vcalendar['todo'][$i]['sequence']."<br />\n";
+ echo "Date Start :
".$GLOBALS['phpgw']->common->show_date(mktime($vcalendar['todo'][$i]['dtstart']['hour'],$vcalendar['todo'][$i]['dtstart']['min'],$vcalendar['todo'][$i]['dtstart']['sec'],$vcalendar['todo'][$i]['dtstart']['month'],$vcalendar['todo'][$i]['dtstart']['mday'],$vcalendar['todo'][$i]['dtstart']['year'])
- $this->datatime->tz_offset)."<br />\n";
+ echo "Class =
".$vcalendar['todo'][$i]['class']['value']."<br />\n";
}
*/
@@ -159,9 +159,9 @@
$this->bo->set_var($vcalendar['prodid'],'value','-//phpGroupWare//phpGroupWare
'.$setup_info['calendar']['version'].'
MIMEDIR//'.strtoupper($GLOBALS['phpgw_info']['user']['preferences']['common']['lang']));
$this->bo->set_var($vcalendar['version'],'value','2.0');
$this->bo->set_var($vcalendar['method'],'value',strtoupper('publish'));
- echo "<br><br><br>\n";
+ echo "<br /><br /><br />\n";
echo nl2br($this->bo->build_ical($vcalendar));
- echo "End Time :
".$GLOBALS['phpgw']->common->show_date()."<br>\n";
+ echo "End Time :
".$GLOBALS['phpgw']->common->show_date()."<br />\n";
}
function import()
@@ -179,9 +179,10 @@
echo '<body bgcolor="' .
$GLOBALS['phpgw_info']['theme']['bg_color'] . '">';
- if ($GLOBALS['HTTP_GET_VARS']['action'] == 'GetFile')
+ $action = strtoupper(get_var('action', Array('GET')));
+ if ($action == 'GETFILE')
{
- echo '<b><center>' . lang('You must select a
[iv]Cal. (*.[iv]cs)') . '</b></center><br><br>';
+ echo '<b><center>' . lang('You must select a
[iv]Cal. (*.[iv]cs)') . '</b></center><br /><br />';
}
$this->template->set_file(
====================================================
Index: calendar/inc/class.uiholiday.inc.php
diff -u calendar/inc/class.uiholiday.inc.php:1.8
calendar/inc/class.uiholiday.inc.php:1.9
--- calendar/inc/class.uiholiday.inc.php:1.8 Sun May 15 05:48:35 2005
+++ calendar/inc/class.uiholiday.inc.php Sun May 15 06:57:37 2005
@@ -81,7 +81,7 @@
@reset($locales);
if (!$locales)
{
- $p->set_var('message',lang('No matches
found.'));
+ $p->set_var('message',lang('no matches found'));
$p->parse('rows','row_empty',True);
}
else
@@ -118,6 +118,10 @@
function edit_locale($locale='')
{
+ if ($locale === '')
+ {
+ $locale = $this->bo->locale;
+ }
if ($locale)
{
$this->bo->locales = array($locale);
@@ -128,7 +132,7 @@
$link_params = Array(
'menuaction' =>
'calendar.uiholiday.admin'
);
- Header('Location: ' .
$GLOBALS['phpgw']->link($this->base_url,$link_params));
+
$GLOBALS['phpgw']->redirect_link($this->base_url,$link_params);
}
unset($GLOBALS['phpgw_info']['flags']['noheader']);
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
@@ -165,7 +169,7 @@
if (!count($holidays))
{
- $p->set_var('message',lang('No matches
found.'));
+ $p->set_var('message',lang('no matches found'));
$p->parse('rows','row_empty',True);
}
else
@@ -228,9 +232,9 @@
{
$holiday = $this->bo->read_entry($this->bo->id);
}
- if ($GLOBALS['HTTP_GET_VARS']['locale'])
+ if ($this->locale)
{
- $holiday['locale'] =
$GLOBALS['HTTP_GET_VARS']['locale'];
+ $holiday['locale'] = $this->locale;
}
unset($GLOBALS['phpgw_info']['flags']['noheader']);
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
@@ -373,7 +377,7 @@
$p =
CreateObject('phpgwapi.Template',$this->template_dir);
$p->set_file(Array('form'=>'delete_common.tpl','form_button'=>'form_button_script.tpl'));
- $p->set_var('messages',lang('Are you sure you want to
delete this Country ?')."<br>".$this->bo->locales[0]);
+ $p->set_var('messages',lang('Are you sure you want to
delete this Country ?')."<br />".$this->bo->locales[0]);
$var = Array(
'action_url_button' =>
$GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.admin')),
@@ -413,7 +417,7 @@
$p =
CreateObject('phpgwapi.Template',$this->template_dir);
$p->set_file(Array('form'=>'delete_common.tpl','form_button'=>'form_button_script.tpl'));
- $p->set_var('messages',lang('Are you sure you want to
delete this holiday ?')."<br>".$holiday['name'].' ('.$this->bo->locales[0].')
'.$this->bo->rule_string($holiday));
+ $p->set_var('messages',lang('Are you sure you want to
delete this holiday ?')."<br />".$holiday['name'].' ('.$this->bo->locales[0].')
'.$this->bo->rule_string($holiday));
$var = Array(
'action_url_button' =>
$GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.edit_locale','locale'=>$this->bo->locales[0],'year'=>$this->bo->year)),
@@ -445,7 +449,7 @@
$this->bo->year = 0; // for a complete list with all
years
$holidays = $this->bo->get_holiday_list();
- if (isset($GLOBALS['HTTP_GET_VARS']['download']))
+ if (isset($_GET['download']))
{
$locale = $this->bo->locales[0];
$browser = CreateObject('phpgwapi.browser');
====================================================
Index: calendar/inc/class.socalendar_sql.inc.php
diff -u calendar/inc/class.socalendar_sql.inc.php:1.36
calendar/inc/class.socalendar_sql.inc.php:1.37
--- calendar/inc/class.socalendar_sql.inc.php:1.36 Sun May 15 05:48:34 2005
+++ calendar/inc/class.socalendar_sql.inc.php Sun May 15 06:57:37 2005
@@ -31,6 +31,12 @@
function socalendar_()
{
$this->socalendar__();
+
+ if (!is_object($GLOBALS['phpgw']->asyncservice))
+ {
+ $GLOBALS['phpgw']->asyncservice =
CreateObject('phpgwapi.asyncservice');
+ }
+ $this->async = &$GLOBALS['phpgw']->asyncservice;
}
function open($calendar='',$user='',$passwd='',$options='')
@@ -96,6 +102,111 @@
return $calendar;
}
+ /*!
+ @function read_alarms
+ @abstract read the alarms of a calendar-event specified by $cal_id
+ @returns array of alarms with alarm-id as key
+ @note the alarm-id is a string of 'cal:'.$cal_id.':'.$alarm_nr, it is
used as the job-id too
+ */
+ function read_alarms($cal_id)
+ {
+ $alarms = array();
+
+ if ($jobs = $this->async->read('cal:'.intval($cal_id).':%'))
+ {
+ foreach($jobs as $id => $job)
+ {
+ $alarm = $job['data']; // text, enabled
+ $alarm['id'] = $id;
+ $alarm['time'] = $job['next'];
+
+ $alarms[$id] = $alarm;
+ }
+ }
+ return $alarms;
+ }
+
+ /*!
+ @function read_alarm
+ @abstract read a single alarm specified by it's $id
+ @returns array with data of the alarm
+ @note the alarm-id is a string of 'cal:'.$cal_id.':'.$alarm_nr, it is
used as the job-id too
+ */
+ function read_alarm($id)
+ {
+ if (!($jobs = $this->async->read($id)))
+ {
+ return False;
+ }
+ list($id,$job) = each($jobs);
+ $alarm = $job['data']; // text, enabled
+ $alarm['id'] = $id;
+ $alarm['time'] = $job['next'];
+
+ //echo "<p>read_alarm('$id')="; print_r($alarm); echo "</p>\n";
+ return $alarm;
+ }
+
+ /*!
+ @function save_alarm
+ @abstract saves a new or updated alarm
+ @syntax save_alarm($cal_id,$alarm,$id=False)
+ @param $cal_id Id of the calendar-entry
+ @param $alarm array with fields: text, owner, enabled, ..
+ */
+ function save_alarm($cal_id,$alarm)
+ {
+ //echo "<p>save_alarm(cal_id=$cal_id, alarm="; print_r($alarm);
echo ")</p>\n";
+ if (!($id = $alarm['id']))
+ {
+ $alarms = $this->read_alarms($cal_id); // find a free
alarm#
+ $n = count($alarms);
+ do
+ {
+ $id = 'cal:'.intval($cal_id).':'.$n;
+ ++$n;
+ }
+ while (@isset($alarms[$id]));
+ }
+ else
+ {
+ $this->async->cancel_timer($id);
+ }
+ $alarm['cal_id'] = $cal_id; // we need the
back-reference
+
+ if
(!$this->async->set_timer($alarm['time'],$id,'calendar.bocalendar.send_alarm',$alarm))
+ {
+ return False;
+ }
+ return $id;
+ }
+
+ /*!
+ @function delete_alarms($cal_id)
+ @abstract delete all alarms of a calendar-entry
+ @returns the number of alarms deleted
+ */
+ function delete_alarms($cal_id)
+ {
+ $alarms = $this->read_alarms($cal_id);
+
+ foreach($alarms as $id => $alarm)
+ {
+ $this->async->cancel_timer($id);
+ }
+ return count($alarms);
+ }
+
+ /*!
+ @function delete_alarm($id)
+ @abstract delete one alarms identified by its id
+ @returns the number of alarms deleted
+ */
+ function delete_alarm($id)
+ {
+ return $this->async->cancel_timer($id);
+ }
+
function fetch_event($event_id,$options='')
{
if(!isset($this->stream))
@@ -103,7 +214,9 @@
return False;
}
-
$this->stream->lock(array('phpgw_cal','phpgw_cal_user','phpgw_cal_repeats','phpgw_cal_alarm'));
+ $event_id = intval($event_id);
+
+
$this->stream->lock(array('phpgw_cal','phpgw_cal_user','phpgw_cal_repeats','phpgw_cal_extra'/*
OLD-ALARM,'phpgw_cal_alarm'*/));
$this->stream->query('SELECT * FROM phpgw_cal WHERE
cal_id='.$event_id,__LINE__,__FILE__);
@@ -179,7 +292,7 @@
$this->add_attribute('recur_enddate',0,'alarm');
if($this->debug)
{
- echo 'Event ID#'.$this->event['id'].' :
Enddate = '.$enddate."<br>\n";
+ echo 'Event ID#'.$this->event['id'].' :
Enddate = '.$enddate."<br />\n";
}
$this->add_attribute('recur_data',$this->stream->f('recur_data'));
@@ -210,8 +323,20 @@
}
}
+ // Custom fields
+ $this->stream->query('SELECT * FROM phpgw_cal_extra
WHERE cal_id='.$event_id,__LINE__,__FILE__);
+ if($this->stream->num_rows())
+ {
+ while($this->stream->next_record())
+ {
+
$this->add_attribute('#'.$this->stream->f('cal_extra_name'),$this->stream->f('cal_extra_value'));
+ }
+ }
+
+/* OLD-ALARM
if($this->event['reference'])
{
+ // What is event['reference']???
$alarm_cal_id =
$event_id.','.$this->event['reference'];
}
else
@@ -219,7 +344,9 @@
$alarm_cal_id = $event_id;
}
- $this->stream->query('SELECT * FROM phpgw_cal_alarm
WHERE cal_id in ('.$alarm_cal_id.') AND
cal_owner='.$this->user,__LINE__,__FILE__);
+ //echo '<!-- cal_id='.$alarm_cal_id.' -->'."\n";
+ //$this->stream->query('SELECT * FROM phpgw_cal_alarm
WHERE cal_id in ('.$alarm_cal_id.') AND
cal_owner='.$this->user,__LINE__,__FILE__);
+ $this->stream->query('SELECT * FROM phpgw_cal_alarm
WHERE cal_id='.$event_id.' AND cal_owner='.$this->user,__LINE__,__FILE__);
if($this->stream->num_rows())
{
while($this->stream->next_record())
@@ -232,6 +359,7 @@
);
}
}
+*/
}
else
{
@@ -240,6 +368,15 @@
$this->stream->unlock();
+ if ($this->event)
+ {
+ $this->event['alarm'] = $this->read_alarms($event_id);
+
+ if($this->event['reference'])
+ {
+ $this->event['alarm'] +=
$this->read_alarms($event_id);
+ }
+ }
return $this->event;
}
@@ -297,7 +434,7 @@
$order_by = 'ORDER BY phpgw_cal.datetime ASC,
phpgw_cal.edatetime ASC, phpgw_cal.priority ASC';
if($this->debug)
{
- echo "SQL :
".$user_where.$startDate.$endDate.$extra."<br>\n";
+ echo "SQL :
".$user_where.$startDate.$endDate.$extra."<br />\n";
}
return
$this->get_event_ids(False,$user_where.$startDate.$endDate.$extra.$order_by);
}
@@ -311,7 +448,7 @@
function store_event()
{
- return $this->save_event($this->event);
+ return $this->save_event(&$this->event);
}
function delete_event($event_id)
@@ -340,7 +477,6 @@
function expunge()
{
- reset($this->deleted_events);
if(count($this->deleted_events) <= 0)
{
return 1;
@@ -350,47 +486,55 @@
'phpgw_cal',
'phpgw_cal_user',
'phpgw_cal_repeats',
- 'phpgw_cal_alarm'
+ 'phpgw_cal_extra'
+// OLD-ALARM 'phpgw_cal_alarm'
);
$this->stream->lock($locks);
- for($i=0;$i<count($this->deleted_events);$i++)
+ foreach($this->deleted_events as $cal_id)
{
- for($k=0;$k<count($locks);$k++)
+ foreach ($locks as $table)
{
- $this->stream->query('DELETE FROM
'.$locks[$k].' WHERE cal_id='.$this->deleted_events[$i],__LINE__,__FILE__);
+ $this->stream->query('DELETE FROM '.$table.'
WHERE cal_id='.$cal_id,__LINE__,__FILE__);
}
}
$this->stream->unlock();
+
+ foreach($this->deleted_events as $cal_id)
+ {
+ $this->delete_alarms($cal_id);
+ }
+ $this->deleted_events = array();
+
$this->event = $this_event;
return 1;
}
/***************** Local functions for SQL based Calendar
*****************/
- function get_event_ids($search_repeats=False,$extra='')
+ function
get_event_ids($search_repeats=False,$extra='',$search_extra=False)
{
- if($search_repeats == True)
+ $from = $where = ' ';
+ if($search_repeats)
{
- $repeats_from = ', phpgw_cal_repeats ';
- $repeats_where = 'AND (phpgw_cal_repeats.cal_id =
phpgw_cal.cal_id) ';
+ $from = ', phpgw_cal_repeats ';
+ $where = 'AND (phpgw_cal_repeats.cal_id =
phpgw_cal.cal_id) ';
}
- else
+ if($search_extra)
{
- $repeats_from = ' ';
- $repeats_where = '';
+ $from .= 'LEFT JOIN phpgw_cal_extra ON
phpgw_cal_extra.cal_id = phpgw_cal.cal_id ';
}
-
+
$sql = 'SELECT DISTINCT phpgw_cal.cal_id,'
. 'phpgw_cal.datetime,phpgw_cal.edatetime,'
. 'phpgw_cal.priority '
- . 'FROM phpgw_cal, phpgw_cal_user'
- . $repeats_from
+ . 'FROM phpgw_cal LEFT JOIN phpgw_cal_user on
(phpgw_cal_user.cal_id = phpgw_cal.cal_id) '
+ . $from
. 'WHERE (phpgw_cal_user.cal_id =
phpgw_cal.cal_id) '
- . $repeats_where . $extra;
+ . $where . $extra;
if($this->debug)
{
- echo "FULL SQL : ".$sql."<br>\n";
+ echo "FULL SQL : ".$sql."<br />\n";
}
$this->stream->query($sql,__LINE__,__FILE__);
@@ -400,7 +544,7 @@
{
if($this->debug)
{
- echo "No records found!<br>\n";
+ echo "No records found!<br />\n";
}
return $retval;
}
@@ -411,7 +555,7 @@
}
if($this->debug)
{
- echo "Records found!<br>\n";
+ echo "Records found!<br />\n";
}
return $retval;
}
@@ -421,7 +565,9 @@
$locks = Array(
'phpgw_cal',
'phpgw_cal_user',
- 'phpgw_cal_repeats'
+ 'phpgw_cal_repeats',
+ 'phpgw_cal_extra'
+// OLD-ALARM 'phpgw_cal_alarm'
);
$this->stream->lock($locks);
if($event['id'] == 0)
@@ -446,19 +592,11 @@
$part[$key] =
substr($GLOBALS['phpgw']->crypto->encrypt($event[$field]),0,20);
if(!$GLOBALS['phpgw']->crypto->enabled)
{
- $part[$key] =
bin2hex(unserialize($part[$key]));
+ $part[$key] = md5($part[$key]);
}
}
$event['uid'] =
$part[0].'-'.$part[1].'@'.$id_suffix;
}
-/* makes problems if tempnam is to long for title column, see bug #3162
- $temp_name =
tempnam($GLOBALS['phpgw_info']['server']['temp_dir'],'cal');
- $this->stream->query('INSERT INTO
phpgw_cal(uid,title,owner,priority,is_public,category) '
- .
"values('".$event['uid']."','".$temp_name."',".$event['owner'].','.$event['priority'].','.$event['public'].",'".$event['category']."')");
- $this->stream->query("SELECT cal_id FROM phpgw_cal
WHERE title='".$temp_name."'");
- $this->stream->next_record();
- $event['id'] = $this->stream->f('cal_id');
-*/
$this->stream->query('INSERT INTO
phpgw_cal(uid,title,owner,priority,is_public,category) '
.
"values('".$event['uid']."','".$this->stream->db_addslashes($event['title'])
.
"',".$event['owner'].','.$event['priority'].','.$event['public'].",'"
@@ -490,7 +628,7 @@
. 'is_public='.$event['public'].', '
.
"title='".$this->stream->db_addslashes($event['title'])."', "
.
"description='".$this->stream->db_addslashes($event['description'])."', "
- . "location='".$event['location']."', "
+ .
"location='".$this->stream->db_addslashes($event['location'])."', "
.
($event['groups']?"groups='".(count($event['groups'])>1?implode(',',$event['groups']):','.$event['groups'][0].',')."',
":'')
. 'reference='.$event['reference'].' '
. 'WHERE cal_id='.$event['id'];
@@ -502,13 +640,12 @@
@reset($event['participants']);
while (list($key,$value) = @each($event['participants']))
{
-// if(intval($key) == intval($this->user))
if(intval($key) == $event['owner'])
{
$value = 'A';
}
- $this->stream->query('INSERT INTO
phpgw_cal_user(cal_id,cal_login,cal_status) '
- .
'VALUES('.$event['id'].','.intval($key).",'".$value."')",__LINE__,__FILE__);
+ $this->stream->query('INSERT INTO
phpgw_cal_user(cal_id,cal_login,cal_status,cal_type) '
+ .
'VALUES('.$event['id'].','.intval($key).",'".$value."','".$type."')",__LINE__,__FILE__);
}
if($event['recur_type'] != MCAL_RECUR_NONE)
@@ -545,16 +682,59 @@
{
$this->stream->query('DELETE FROM phpgw_cal_repeats
WHERE cal_id='.$event['id'],__LINE__,__FILE__);
}
+ // Custom fields
+ $this->stream->query('DELETE FROM phpgw_cal_extra WHERE
cal_id='.$event['id'],__LINE__,__FILE__);
+
+ foreach($event as $name => $value)
+ {
+ if ($name[0] == '#' && strlen($value))
+ {
+ $this->stream->query('INSERT INTO
phpgw_cal_extra (cal_id,cal_extra_name,cal_extra_value) '
+ .
'VALUES('.$event['id'].",'".addslashes(substr($name,1))."','".addslashes($value)."')",__LINE__,__FILE__);
+ }
+ }
+/*
+ $alarmcount = count($event['alarm']);
+ if ($alarmcount > 1)
+ {
+ // this should never happen, $event['alarm'] should
only be set
+ // if creating a new event and uicalendar only sets up
1 alarm
+ // the user must use "Alarm Management" to
create/establish multiple
+ // alarms or to edit/change an alarm
+ echo '<!-- how did this happen, too many alarms
-->'."\n";
+ $this->stream->unlock();
+ return True;
+ }
+ if ($alarmcount == 1)
+ {
+
+ list($key,$alarm) = @each($event['alarm']);
+
+ $this->stream->query('INSERT INTO
phpgw_cal_alarm(cal_id,cal_owner,cal_time,cal_text,alarm_enabled)
VALUES('.$event['id'].','.$event['owner'].','.$alarm['time'].",'".$alarm['text']."',".$alarm['enabled'].')',__LINE__,__FILE__);
+ $this->stream->query('SELECT LAST_INSERT_ID()');
+ $this->stream->next_record();
+ $alarm['id'] = $this->stream->f(0);
+ }
+*/
print_debug('Event Saved: ID #',$event['id']);
$this->stream->unlock();
- $GLOBALS['phpgw_info']['cal_new_event_id'] = $event['id'];
+
+ if (is_array($event['alarm']))
+ {
+ foreach ($event['alarm'] as $alarm) // this are all
new alarms
+ {
+ $this->save_alarm($event['id'],$alarm);
+ }
+ }
+ $GLOBALS['phpgw_info']['cal_new_event_id'] = $event['id'];
return True;
}
- function get_alarm($id)
+ function get_alarm($cal_id)
{
+/* OLD-ALARM
$this->stream->query('SELECT cal_time, cal_text FROM
phpgw_cal_alarm WHERE cal_id='.$id.' AND
cal_owner='.$this->user,__LINE__,__FILE__);
if($this->stream->num_rows())
{
@@ -569,6 +749,18 @@
{
return False;
}
+*/
+ $alarms = $this->read_alarms($cal_id);
+ $ret = False;
+
+ foreach($alarms as $alarm)
+ {
+ if ($alarm['owner'] == $this->user || !$alarm['owner'])
+ {
+ $ret[$alarm['time']] = $alarm['text'];
+ }
+ }
+ return $ret;
}
function set_status($id,$owner,$status)
@@ -581,6 +773,12 @@
);
$this->stream->query("UPDATE phpgw_cal_user SET
cal_status='".$status_code_short[$status]."' WHERE cal_id=".$id." AND
cal_login=".$owner,__LINE__,__FILE__);
+/* OLD-ALARM
+ if ($status == 'R')
+ {
+ $this->stream->query('UPDATE phpgw_cal_alarm set
alarm_enabled=0 where cal_id='.$id.' and cal_owner='.$owner,__LINE__,__FILE__);
+ }
+*/
return True;
}
@@ -619,4 +817,54 @@
{
return
$this->localdates(mktime(0,0,0,intval(substr($d,4,2)),intval(substr($d,6,2)),intval(substr($d,0,4))));
}
+
+ function list_dirty_events($lastmod=-1,$repeats=false)
+ {
+ if(!isset($this->stream))
+ {
+ return False;
+ }
+ $repeats = (bool) $repeats;
+
+ $user_where = ' AND phpgw_cal_user.cal_login = ' .
intval($this->user);
+
+ $member_groups =
$GLOBALS['phpgw']->accounts->membership($this->user);
+ @reset($member_groups);
+ while($member_groups != False && list($key,$group_info) =
each($member_groups))
+ {
+ $member[] = intval($group_info['account_id']);
+ }
+ @reset($member);
+
+ if($this->debug)
+ {
+ echo '<!-- '.$user_where.' -->'."\n";
+ }
+
+ if($lastmod > 0)
+ {
+ $wheremod = ' AND mdatetime > ' . intval($lastmod);
+ }
+
+ $order_by = ' ORDER BY phpgw_cal.cal_id ASC';
+ if($this->debug)
+ {
+ echo "SQL : ".$user_where.$wheremod.$extra."<br />\n";
+ }
+ return
$this->get_event_ids($repeats,$user_where.$wheremod.$extra.$order_by);
+ }
+
+/* OLD-ALARM
+ function add_alarm($eventid,$alarm,$owner)
+ {
+ $this->stream->query('INSERT INTO
phpgw_cal_alarm(cal_id,cal_owner,cal_time,cal_text,alarm_enabled)
VALUES('.$eventid.','.$owner.','.$alarm['time'].",'".$alarm['text']."',1)",__LINE__,__FILE__);
+ $this->stream->query('SELECT LAST_INSERT_ID()');
+ $this->stream->next_record();
+ return($this->stream->f(0));
+ }
+ function delete_alarm($alarmid)
+ {
+ $this->stream->query('DELETE FROM phpgw_cal_alarm WHERE
alarm_id='.$alarmid,__LINE__,__FILE__);
+ }
+*/
}
====================================================
Index: calendar/inc/class.socalendar__.inc.php
diff -u calendar/inc/class.socalendar__.inc.php:1.15
calendar/inc/class.socalendar__.inc.php:1.16
--- calendar/inc/class.socalendar__.inc.php:1.15 Sun May 15 05:48:34 2005
+++ calendar/inc/class.socalendar__.inc.php Sun May 15 06:57:37 2005
@@ -40,7 +40,7 @@
define('MCAL_M_FRIDAY',32);
define('MCAL_M_SATURDAY',64);
- define('MCAL_M_WEEKDAYS',63);
+ define('MCAL_M_WEEKDAYS',62);
define('MCAL_M_WEEKEND',65);
define('MCAL_M_ALLDAYS',127);
}
@@ -51,6 +51,7 @@
define('MSG_REJECTED',3);
define('MSG_TENTATIVE',4);
define('MSG_ACCEPTED',5);
+define('MSG_ALARM',6);
define('REJECTED',0);
define('NO_RESPONSE',1);
@@ -68,10 +69,6 @@
function socalendar__()
{
- if(!is_object($GLOBALS['phpgw']->datetime))
- {
- $GLOBALS['phpgw']->datetime =
createobject('phpgwapi.datetime');
- }
}
function maketime($time)
====================================================
Index: calendar/inc/class.soholiday.inc.php
diff -u calendar/inc/class.soholiday.inc.php:1.5
calendar/inc/class.soholiday.inc.php:1.6
--- calendar/inc/class.soholiday.inc.php:1.5 Sun May 15 05:48:34 2005
+++ calendar/inc/class.soholiday.inc.php Sun May 15 06:57:37 2005
@@ -19,9 +19,7 @@
function soholiday()
{
- global $phpgw;
-
- $this->db = $phpgw->db;
+ $this->db = $GLOBALS['phpgw']->db;
}
/* Begin Holiday functions */
@@ -31,7 +29,7 @@
{
if($this->debug)
{
- echo "Updating
LOCALE='".$holiday['locale']."' NAME='".$holiday['name']."'
extra=(".$holiday['mday'].'/'.$holiday['month_num'].'/'.$holiday['occurence'].'/'.$holiday['dow'].'/'.$holiday['observance_rule'].")<br>\n";
+ echo "Updating
LOCALE='".$holiday['locale']."' NAME='".$holiday['name']."'
extra=(".$holiday['mday'].'/'.$holiday['month_num'].'/'.$holiday['occurence'].'/'.$holiday['dow'].'/'.$holiday['observance_rule'].")<br
/>\n";
}
$sql = "UPDATE phpgw_cal_holidays SET
name='".$holiday['name']."', mday=".$holiday['mday'].',
month_num='.$holiday['month_num'].', occurence='.$holiday['occurence'].',
dow='.$holiday['dow'].',
observance_rule='.intval($holiday['observance_rule']).' WHERE
hol_id='.$holiday['hol_id'];
}
@@ -39,7 +37,7 @@
{
if($this->debug)
{
- echo "Inserting
LOCALE='".$holiday['locale']."' NAME='".$holiday['name']."'
extra=(".$holiday['mday'].'/'.$holiday['month_num'].'/'.$holiday['occurence'].'/'.$holiday['dow'].'/'.$holiday['observance_rule'].")<br>\n";
+ echo "Inserting
LOCALE='".$holiday['locale']."' NAME='".$holiday['name']."'
extra=(".$holiday['mday'].'/'.$holiday['month_num'].'/'.$holiday['occurence'].'/'.$holiday['dow'].'/'.$holiday['observance_rule'].")<br
/>\n";
}
$sql = 'INSERT INTO
phpgw_cal_holidays(locale,name,mday,month_num,occurence,dow,observance_rule) '
.
"VALUES('".strtoupper($holiday['locale'])."','".$holiday['name']."',".$holiday['mday'].','.$holiday['month_num'].','.$holiday['occurence'].','.$holiday['dow'].','.intval($holiday['observance_rule']).")";
@@ -49,14 +47,12 @@
function store_to_array(&$holidays)
{
- global $phpgw;
-
while($this->db->next_record())
{
$holidays[] = Array(
'index' =>
$this->db->f('hol_id'),
'locale' =>
$this->db->f('locale'),
- 'name' =>
$phpgw->strip_html($this->db->f('name')),
+ 'name' =>
$GLOBALS['phpgw']->strip_html($this->db->f('name')),
'day' =>
intval($this->db->f('mday')),
'month' =>
intval($this->db->f('month_num')),
'occurence' =>
intval($this->db->f('occurence')),
@@ -65,15 +61,13 @@
);
if($this->debug)
{
- echo "Holiday ID:
".$this->db->f("hol_id")."<br>\n";
+ echo 'Holiday ID:
'.$this->db->f('hol_id').'<br />'."\n";
}
}
}
function read_holidays($locales='',$query='',$order='',$year=0)
{
- global $phpgw;
-
$holidays = Array();
if($locales == '')
@@ -85,7 +79,7 @@
if($this->debug)
{
- echo "Read Holidays : ".$sql."<br>\n";
+ echo 'Read Holidays : '.$sql.'<br />'."\n";
}
$this->db->query($sql,__LINE__,__FILE__);
@@ -98,7 +92,7 @@
$holidays = Array();
if($this->debug)
{
- echo "Reading Holiday ID : ".$id."<br>\n";
+ echo 'Reading Holiday ID : '.$id.'<br />'."\n";
}
$this->db->query('SELECT * FROM phpgw_cal_holidays
WHERE hol_id='.$id,__LINE__,__FILE__);
$this->store_to_array($holidays);
@@ -186,7 +180,7 @@
if($this->debug)
{
- echo "HOLIDAY_TOTAL : ".$sql."<br>\n";
+ echo 'HOLIDAY_TOTAL : '.$sql.'<br />'."\n";
}
$this->db->query($sql,__LINE__,__FILE__);
@@ -194,7 +188,7 @@
$retval = intval($this->db->f(0));
if($this->debug)
{
- echo 'Total Holidays for : '.$locale.' :
'.$retval."<br>\n";
+ echo 'Total Holidays for : '.$locale.' :
'.$retval."<br />\n";
}
return $retval;
}
====================================================
Index: calendar/inc/class.uialarm.inc.php
diff -u calendar/inc/class.uialarm.inc.php:1.8
calendar/inc/class.uialarm.inc.php:1.9
--- calendar/inc/class.uialarm.inc.php:1.8 Sun May 15 05:48:34 2005
+++ calendar/inc/class.uialarm.inc.php Sun May 15 06:57:37 2005
@@ -44,29 +44,27 @@
if($this->debug)
{
- echo "BO Owner : ".$this->bo->owner."<br>\n";
+ echo "BO Owner : ".$this->bo->owner."<br />\n";
}
-
$this->template_dir =
$GLOBALS['phpgw']->common->get_tpl_dir('calendar');
+
+ $this->html = CreateObject('calendar.html');
}
function prep_page()
{
$this->event = $this->bo->read_entry($this->bo->cal_id);
-
- $can_edit =
$this->bo->cal->check_perms(PHPGW_ACL_EDIT,$this->event);
+/*
+ $can_edit =
$this->bo->bo->check_perms(PHPGW_ACL_EDIT,$this->event);
if(!$can_edit)
{
- Header('Location :
'.$GLOBALS['phpgw']->link('/index.php',
- Array(
- 'menuaction' =>
'calendar.uicalendar.view',
- 'cal_id'
=> $this->bo->cal_id
- )
- )
- );
+
$GLOBALS['phpgw']->redirect_link('/index.php',Array(
+ 'menuaction' =>
'calendar.uicalendar.view',
+ 'cal_id' =>
$this->bo->cal_id
+ ));
}
-
+*/
unset($GLOBALS['phpgw_info']['flags']['noheader']);
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
$GLOBALS['phpgw_info']['flags']['app_header'] =
$GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Alarm
Management');
@@ -74,7 +72,7 @@
$this->template =
CreateObject('phpgwapi.Template',$this->template_dir);
- $this->template->set_unknowns('keep');
+ $this->template->set_unknowns('remove');
$this->template->set_file(
Array(
'alarm' => 'alarm.tpl'
@@ -84,10 +82,15 @@
$this->template->set_block('alarm','alarm_headers','alarm_headers');
$this->template->set_block('alarm','list','list');
$this->template->set_block('alarm','hr','hr');
+ $this->template->set_block('alarm','buttons','buttons');
}
function output_template_array($row,$list,$var)
{
+ if (!isset($var['tr_color']))
+ {
+ $var['tr_color'] =
$GLOBALS['phpgw']->nextmatchs->alternate_row_color();
+ }
$this->template->set_var($var);
$this->template->parse($row,$list,True);
}
@@ -96,48 +99,106 @@
function manager()
{
+ if ($_POST['delete'] && count($_POST['alarm']))
+ {
+ if ($this->bo->delete($_POST['alarm']) < 0)
+ {
+ echo '<center>'.lang('You do not have
permission to delete this alarm !!!').'</center>';
+
$GLOBALS['phpgw']->common->phpgw_exit(True);
+ }
+ }
+ if (($_POST['enable'] || $_POST['disable']) &&
count($_POST['alarm']))
+ {
+ if
($this->bo->enable($_POST['alarm'],$_POST['enable']) < 0)
+ {
+ echo '<center>'.lang('You do not have
permission to enable/disable this alarm !!!').'</center>';
+
$GLOBALS['phpgw']->common->phpgw_exit(True);
+ }
+ }
$this->prep_page();
-
ExecMethod('calendar.uicalendar.view_event',$this->event);
- echo "<br>\n";
- $GLOBALS['phpgw']->template->set_var(array(
- 'hr_text' => lang('Alarms').':',
- 'button_left' => '',
- 'button_center' => '',
- 'button_right' => ''
- ));
+
+ if ($_POST['add'])
+ {
+ $time = intval($_POST['time']['days'])*24*3600 +
+ intval($_POST['time']['hours'])*3600 +
+ intval($_POST['time']['mins'])*60;
+
+ if ($time > 0 &&
!$this->bo->add($this->event,$time,$_POST['owner']))
+ {
+ echo '<center>'.lang('You do not have
permission to add alarms to this event !!!').'</center>';
+
$GLOBALS['phpgw']->common->phpgw_exit(True);
+ }
+ }
+ if
(!ExecMethod('calendar.uicalendar.view_event',$this->event))
+ {
+ echo '<center>'.lang('You do not have
permission to read this record!').'</center>';
+ $GLOBALS['phpgw']->common->phpgw_exit(True);
+ }
+ echo "<br />\n";
+
$GLOBALS['phpgw']->template->set_var('th_bg',$this->theme['th_bg']);
+
$GLOBALS['phpgw']->template->set_var('hr_text',lang('Alarms').':');
$GLOBALS['phpgw']->template->fp('row','hr',True);
-
$GLOBALS['phpgw']->template->fp('phpgw_body','view_event');
+
$GLOBALS['phpgw']->template->pfp('phpgw_body','view_event');
-
$var = Array(
- 'action_url' =>
$GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uialarm.form_handler')),
- 'time_lang' => lang('Time'),
- 'text_lang' => lang('Text'),
- 'enabled_pict' =>
$GLOBALS['phpgw']->common->image('calendar','enabled.gif'),
- 'disabled_pict' =>
$GLOBALS['phpgw']->common->image('calendar','disabled.gif')
+ 'tr_color' =>
$this->theme['th_bg'],
+ 'action_url' =>
$GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uialarm.manager')),
+ 'hidden_vars' =>
$this->html->input_hidden('cal_id',$this->bo->cal_id),
+ 'lang_select' => lang('Select'),
+ 'lang_time' => lang('Time'),
+ 'lang_text' => lang('Text'),
+ 'lang_owner' => lang('Owner'),
+ 'lang_enabled' => lang('enabled'),
+ 'lang_disabled' => lang('disabled'),
+ 'lang_enabled' => lang('enabled'),
+ 'lang_disabled' => lang('disabled')
);
-
$this->output_template_array('row','alarm_headers',$var);
-
if($this->event['alarm'])
{
- @reset($this->event['alarm']);
- while(list($key,$alarm) =
each($this->event['alarm']))
+
$this->output_template_array('rows','alarm_headers',$var);
+
+ foreach($this->event['alarm'] as $key => $alarm)
{
+ if
(!$this->bo->check_perms(PHPGW_ACL_READALARM,$alarm['owner']))
+ {
+ continue;
+ }
$var = Array(
- 'edit_box' => '<input
type="checkbox" name="alarm[id]" value="'.$alarm['id'].'">',
- 'field' =>
$icon.$GLOBALS['phpgw']->common->show_date($alarm['time']),
- 'data' => $alarm['text'],
- 'alarm_enabled' =>
($alarm['enabled']?'<img
src="'.$GLOBALS['phpgw']->common->image('calendar','enabled.gif').'" width="13"
height="13" alt="enabled">':' '),
- 'alarm_disabled' =>
(!$alarm['enabled']?'<img
src="'.$GLOBALS['phpgw']->common->image('calendar','disabled.gif').'"
width="13" height="13" alt="disabled">':' ')
+ 'field' =>
$GLOBALS['phpgw']->common->show_date($alarm['time']),
+ //'data' => $alarm['text'],
+ 'data' => 'Email
Notification',
+ 'owner' =>
$GLOBALS['phpgw']->common->grab_owner_name($alarm['owner']),
+ 'enabled' =>
($alarm['enabled']?'<img
src="'.$GLOBALS['phpgw']->common->image('calendar','enabled.gif').'" width="13"
height="13" title="'.lang('enabled').'">':
+ '<img
src="'.$GLOBALS['phpgw']->common->image('calendar','disabled.gif').'"
width="13" height="13" title="'.lang('disabled').'">'),
+ 'select' => '<input
type="checkbox" name="alarm['.$alarm['id'].']">'
);
-
$this->output_template_array('row','list',$var);
+ if
($this->bo->check_perms(PHPGW_ACL_DELETEALARM,$alarm['owner']))
+ {
+ ++$to_delete;
+ }
+
$this->output_template_array('rows','list',$var);
}
+
$this->template->set_var('enable_button',$this->html->submit_button('enable','Enable'));
+
$this->template->set_var('disable_button',$this->html->submit_button('disable','Disable'));
+ if ($to_delete)
+ {
+
$this->template->set_var('delete_button',$this->html->submit_button('delete','Delete',"return
confirm('".lang("Are you sure\\nyou want to\\ndelete these alarms?")."')"));
+ }
+ $this->template->parse('rows','buttons',True);
}
- $this->template->fp('phpgw_body','alarm_management');
- }
-
- function add_alarm()
- {
- $this->prep_page();
+ if
(isset($this->event['participants'][intval($GLOBALS['phpgw_info']['user']['account_id'])]))
+ {
+ $this->template->set_var(Array(
+ 'input_text' => lang('Email
reminder'),
+ 'input_days' =>
$this->html->select('time[days]',$_POST['time']['days'],range(0,31),True).'
'.lang('days'),
+ 'input_hours' =>
$this->html->select('time[hours]',$_POST['time']['hours'],range(0,24),True).'
'.lang('hours'),
+ 'input_minutes' =>
$this->html->select('time[mins]',$_POST['time']['mins'],range(0,60),True).'
'.lang('minutes').' '.lang('before the event'),
+ 'input_owner' =>
$this->html->select('owner',$GLOBALS['phpgw_info']['user']['account_id'],$this->bo->participants($this->event,True),True),
+ 'input_add' =>
$this->html->submit_button('add','Add Alarm')
+ ));
+ }
+//echo
"<p>alarm_management='".htmlspecialchars($this->template->get_var('alarm_management'))."'</p>\n";
+ $this->template->pfp('out','alarm_management');
}
}
+?>
====================================================
Index: calendar/inc/class.uicalendar.inc.php
diff -u calendar/inc/class.uicalendar.inc.php:1.107
calendar/inc/class.uicalendar.inc.php:1.108
--- calendar/inc/class.uicalendar.inc.php:1.107 Sun May 15 05:48:34 2005
+++ calendar/inc/class.uicalendar.inc.php Sun May 15 06:57:37 2005
@@ -24,7 +24,7 @@
var $holidays;
var $holiday_color;
-
+
var $debug = False;
// var $debug = True;
@@ -77,12 +77,14 @@
'edit_status' => True,
'set_action' => True,
'planner' => True,
+ 'modify_ext_partlist' => True,
'matrixselect' => True,
'viewmatrix' => True,
'search' => True,
'header' => True,
'footer' => True,
- 'css' => True
+ 'css' => True,
+ 'accounts_popup' => True
);
function uicalendar()
@@ -93,12 +95,12 @@
$this->theme = $GLOBALS['phpgw_info']['theme'];
$this->bo = CreateObject('calendar.bocalendar',1);
+ $this->cat = &$this->bo->cat;
print_debug('BO Owner',$this->bo->owner);
$this->template = $GLOBALS['phpgw']->template;
$this->template_dir =
$GLOBALS['phpgw']->common->get_tpl_dir('calendar');
- $this->cat = CreateObject('phpgwapi.categories');
$this->holiday_color =
(substr($this->theme['bg06'],0,1)=='#'?'':'#').$this->theme['bg06'];
@@ -120,39 +122,17 @@
if($this->bo->use_session)
{
// save return-fkt for add, view, ...
- list(,,$fkt) =
explode('.',$GLOBALS['HTTP_GET_VARS']['menuaction']);
+ list(,,$fkt) =
explode('.',$GLOBALS['phpgw_info']['menuaction']);
if ($fkt == 'day' || $fkt == 'week' || $fkt ==
'month' || $fkt == 'year' || $fkt == 'planner')
{
- $this->bo->return_to =
$GLOBALS['HTTP_GET_VARS']['menuaction'].
+ $this->bo->return_to =
$GLOBALS['phpgw_info']['menuaction'].
sprintf('&date=%04d%02d%02d',$this->bo->year,$this->bo->month,$this->bo->day);
}
$this->bo->save_sessiondata();
}
- print_debug('UI',$this->_debug_sqsof());
- }
+ $this->always_app_header =
$this->bo->prefs['common']['template_set'] == 'idots';
- /*!
- @function error_exit
- @abstract shows $msg centered on the screen and exit
- @syntax error_exit($msg)
- @param $msg lang()'ed msg-text or one of the predefined
messages (see below)
- */
- function error_exit($msg)
- {
- switch($msg)
- {
- case 'invalid_id':
- $msg = lang('Invalid entry id.');
- break;
- case 'no_read_perm':
- $msg = lang('You do not have permission
to read this record!');
- break;
- case 'not_exist':
- $msg = lang('Sorry, this event does not
exist');
- break;
- }
- $GLOBALS['phpgw']->template->set_var('phpgw_body','<div
style="text-align: center">'.$msg."</div>\n");
- exit;
+ print_debug('UI',$this->_debug_sqsof());
}
/* Public functions */
@@ -205,7 +185,6 @@
{
$mini_cal_tpl =
CreateObject('phpgwapi.Template',$this->template_dir);
$mini_cal_tpl->set_unknowns('remove');
-
$mini_cal_tpl->set_file(
Array(
'mini_calendar' =>
'mini_cal.tpl'
@@ -216,6 +195,7 @@
$mini_cal_tpl->set_block('mini_calendar','mini_day','mini_day');
}
+
if($this->bo->printer_friendly == False)
{
$month = '<a href="' .
$this->page('month','&month='.$GLOBALS['phpgw']->common->show_date($date['raw'],'m').'&year='.$GLOBALS['phpgw']->common->show_date($date['raw'],'Y')).
'" class="minicalendar">' .
lang($GLOBALS['phpgw']->common->show_date($date['raw'],'F')).'
'.$GLOBALS['phpgw']->common->show_date($date['raw'],'Y').'</a>';
@@ -269,7 +249,7 @@
for($i=0;$i<7;$i++)
{
$var = Array(
- 'dayname' => '<b>' .
substr(lang($GLOBALS['phpgw']->datetime->days[$i]['name']),0,2) . '</b>',
+ 'dayname' => '<b>' .
substr(lang($GLOBALS['phpgw']->datetime->days[$i]),0,2) . '</b>',
'day_image' => ''
);
$this->output_template_array($mini_cal_tpl,'daynames','mini_day',$var);
@@ -281,8 +261,7 @@
{
unset($var);
$daily = $this->set_week_array($i -
$GLOBALS['phpgw']->datetime->tz_offset,$cellcolor,$weekly);
- @reset($daily);
- while(list($date,$day_params) = each($daily))
+ foreach($daily as $date => $day_params)
{
print_debug('Mini-Cal Date',$date);
$year = intval(substr($date,0,4));
@@ -321,309 +300,53 @@
$return_value = $mini_cal_tpl->fp('out','mini_cal');
$mini_cal_tpl->set_var('display_monthweek','');
+// $mini_cal_tpl->set_var('daynames','');
+// unset($p);
return $return_value;
}
function index($params='')
{
- Header('Location: '. $this->page('',$params));
- $GLOBALS['phpgw_info']['flags']['nodisplay'] = True;
- exit;
+ $GLOBALS['phpgw']->redirect($this->page('',$params));
}
- /*!
- @function cal_header
- @abstract call common::phpgw_header and shows the
application-header
- @syntax cal_header($func_header,$big_header)
- @param $func_header function name to display beside
calendar-title
- @param $always_show_header or only for selected templates
- */
- function cal_header($func_header = '',$always_show_header =
False)
+ function printer_friendly($body,$app_header='')
{
- unset($GLOBALS['phpgw_info']['flags']['noheader']);
- unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
- unset($GLOBALS['phpgw_info']['flags']['noappheader']);
- unset($GLOBALS['phpgw_info']['flags']['noappfooter']);
- if (!empty($func_header) && ($always_show_header ||
$GLOBALS['phpgw_info']['user']['preferences']['common']['template'] == 'idots'))
- {
- $GLOBALS['phpgw_info']['flags']['app_header'] =
$GLOBALS['phpgw_info']['apps']['calendar']['title'] .
- ' - ' . $func_header;
- }
-
- function add_col(&$tpl,$str)
- {
- $tpl->set_var('str',$str);
- $tpl->parse('header_column','head_col',True);
- }
-
- function add_image_ahref($link,$image,$alt)
- {
- return '<a href="'.$link.'"><img
src="'.$GLOBALS['phpgw']->common->image('calendar',$image).'" alt="'.$alt.'"
title="'.$alt.'" border="0"></a>';
- }
-
- list(,,$referrer) = explode('.',MENUACTION);
-
- $templates = Array(
- 'head_tpl' => 'head.tpl',
- 'form_button_dropdown' =>
'form_button_dropdown.tpl',
- 'form_button_script' =>
'form_button_script.tpl'
- );
- $tpl = &$GLOBALS['phpgw']->template;
- $tpl->set_file($templates);
- $tpl->set_block('head_tpl','head','head');
- $tpl->set_block('head_tpl','head_table','head_table');
- $tpl->set_block('head_tpl','head_col','head_col');
- $tpl->set_block('form_button_script','form_button');
-
- if(floor(phpversion()) >= 4)
+ if($this->bo->printer_friendly)
{
- $tpl->set_var('cols',8);
+ $new_body = '<html>'."\n"
+ .'<head>'."\n"
+ .'<STYLE type="text/css">'."\n"
+ .'<!--'."\n"
+ .' body { margin-top: 0px;
margin-right: 0px; margin-left: 0px; font-family:
"'.$GLOBALS['phpgw_info']['theme']['font'].'" }'."\n"
+ .' .tablink { color: #000000; }'."\n"
+ .' '.$this->css()."\n"
+ .'-->'."\n"
+ .'</STYLE>'."\n"
+ .'</head>'."\n"
+ .$this->bo->debug_string.$body
+ .'</body>'."\n"
+ .'</html>'."\n";
}
else
{
- $tpl->set_var('cols',7);
- }
-
- $today =
date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime);
-
- $col_width = 12;
-
- add_col($tpl,' <td width="2%"> </td>');
-
- add_col($tpl,' <td
width="2%">'.add_image_ahref($this->page('day','&date='.$today),'today',lang('Today')).'</td>');
-
- add_col($tpl,' <td width="2%"
align="left">'.add_image_ahref($this->page('week','&date='.$today),'week',lang('This
week')).'</td>');
-
- add_col($tpl,' <td width="2%"
align="left">'.add_image_ahref($this->page('month','&date='.$today),'month',lang('This
month')).'</td>');
-
- add_col($tpl,' <td width="2%"
align="left">'.add_image_ahref($this->page('year','&date='.$today),'year',lang('This
Year')).'</td>');
-
- if(floor(phpversion()) >= 4)
- {
- add_col($tpl,' <td width="2%"
align="left">'.add_image_ahref($this->page('planner','&date='.$today),'planner',lang('Planner')).'</td>');
- $col_width += 2;
- }
-
- add_col($tpl,' <td width="2%"
align="left">'.add_image_ahref($this->page('matrixselect'),'view',lang('Daily
Matrix View')).'</td>');
-
- add_col($tpl,' <td width="'.(100 - $col_width).'%"
align="left"'.(floor(phpversion()) < 4?' colspan="2"':'').'> </td>');
-
- $tpl->parse('phpgw_body','head_table',True);
-
- $tpl->set_var('header_column','');
- $tpl->set_var('cols',$cols);
-
- if($referrer!='view')
- {
- $remainder = 72;
- $cal_id =
get_var('cal_id',Array('GET','DEFAULT'),0);
- $keywords =
get_var('keywords',Array('POST','DEFAULT'),'');
- $matrixtype =
get_var('matrixtype',Array('POST','DEFAULT'),'');
- $participants =
get_var('participants',Array('POST'));
- $date =
get_var('date',Array('GET','POST'));
- $year = $this->bo->year;
- $month = $this->bo->month;
- $day = $this->bo->day;
- $var_list = Array(
- 'cal_id',
- 'keywords',
- 'matrixtype',
- 'date',
- 'year',
- 'month',
- 'day'
- );
-
- $base_hidden_vars = '<input type="hidden"
name="from" value="'.MENUACTION.'">'."\n";
- for($i=0;$i<count($var_list);$i++)
- {
- if($$var_list[$i])
- {
- $base_hidden_vars .= '
<input type="hidden" name="'.$var_list[$i].'" value="'.$$var_list[$i].'">'."\n";
- }
- }
- $hidden_vars = '';
- if($participants)
- {
- for ($i=0;$i<count($participants);$i++)
- {
- $hidden_vars .= ' <input
type="hidden" name="participants[]" value="'.$participants[$i].'">'."\n";
- }
- }
-
- $var = Array(
- 'form_width' => '28',
- 'form_link' =>
$this->page($referrer),
- 'form_name' => 'cat_id',
- 'title' => lang('Category'),
- 'hidden_vars' =>
$base_hidden_vars.$hidden_vars,
- 'form_options' => '<option
value="0">All</option>'.$this->cat->formatted_list('select','all',$this->bo->cat_id,'True'),
- 'button_value' => lang('Go!')
- );
- $tpl->set_var($var);
-
$tpl->set_var('str',$tpl->fp('out','form_button_dropdown'));
- $tpl->parse('header_column','head_col',True);
-
- if(MENUACTION == 'calendar.uicalendar.planner')
- {
- $remainder -= 28;
- print_debug('Sort
By',$this->bo->sortby);
-
- $form_options = '<option
value="user"'.($this->bo->sortby=='user'?'
selected':'').'>'.lang('User').'</option>'."\n";
- $form_options .= ' <option
value="category"'.((!isset($this->bo->sortby) || !$this->bo->sortby) ||
$this->bo->sortby=='category'?'
selected':'').'>'.lang('Category').'</option>'."\n";
-
- $var = Array(
- 'form_width' => '28',
- 'form_link' =>
$this->page($referrer),
- 'form_name' => 'sortby',
- 'title' => lang('Sort By'),
- 'hidden_vars' =>
$base_hidden_vars,
- 'form_options' =>
$form_options,
- 'button_value' => lang('Go!')
- );
- $tpl->set_var($var);
-
$tpl->set_var('str',$tpl->fp('out','form_button_dropdown'));
-
$tpl->parse('header_column','head_col',True);
- }
-
- if($this->bo->check_perms(PHPGW_ACL_PRIVATE))
+
unset($GLOBALS['phpgw_info']['flags']['noheader']);
+
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
+
unset($GLOBALS['phpgw_info']['flags']['noappheader']);
+
unset($GLOBALS['phpgw_info']['flags']['noappfooter']);
+ if ($app_header && $this->always_app_header)
{
- $remainder -= 28;
- $hidden_vars = '';
- if($participants)
- {
- for
($i=0;$i<count($participants);$i++)
- {
- $hidden_vars .= '
<input type="hidden" name="participants[]" value="'.$participants[$i].'">'."\n";
- }
- }
- $form_options = '<option value=" all
"'.($this->bo->filter==' all '?' selected':'').'>'.lang('All').'</option>'."\n";
- $form_options .= ' <option value="
private "'.((!isset($this->bo->filter) || !$this->bo->filter) ||
$this->bo->filter==' private '?' selected':'').'>'.lang('Private
Only').'</option>'."\n";
-
- $var = Array(
- 'form_width' => '28',
- 'form_link' =>
$this->page($referrer),
- 'form_name' => 'filter',
- 'title' => lang('Filter'),
- 'hidden_vars' =>
$base_hidden_vars.$hidden_vars,
- 'form_options' =>
$form_options,
- 'button_value' => lang('Go!')
- );
- $tpl->set_var($var);
-
$tpl->set_var('str',$tpl->fp('out','form_button_dropdown'));
-
$tpl->parse('header_column','head_col',True);
- }
-
-
if((!isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) ||
!$GLOBALS['phpgw_info']['server']['deny_user_grants_access']) &&
count($this->bo->grants) > 0)
- {
- $form_options = '';
- reset($this->bo->grants);
- while(list($grantor,$temp_rights) =
each($this->bo->grants))
- {
-
$GLOBALS['phpgw']->accounts->get_account_name($grantor,$lid,$fname,$lname);
- $drop_down[$lname.' '.$fname] =
Array(
- 'grantor' =>
$grantor,
- 'value' =>
($GLOBALS['phpgw']->accounts->get_type($grantor)=='g'?'g_':'').$grantor,
- 'name' =>
$GLOBALS['phpgw']->common->display_fullname($lid,$fname,$lname)
- );
- }
- $memberships =
$GLOBALS['phpgw']->accounts->membership($GLOBALS['phpgw_info']['user']['account_id']);
- while($memberships != False &&
list($key,$group_info) = each($memberships))
- {
-
$GLOBALS['phpgw']->accounts->get_account_name($group_info['account_id'],$lid,$fname,$lname);
- $drop_down[$lname.' '.$fname] =
Array(
- 'grantor' =>
$group_info['account_id'],
- 'value' =>
($GLOBALS['phpgw']->accounts->get_type($group_info['account_id'])=='g'?'g_':'').$group_info['account_id'],
- 'name' =>
$GLOBALS['phpgw']->common->display_fullname($lid,$fname,$lname)
- );
-
- $account_perms =
$GLOBALS['phpgw']->acl->get_ids_for_location($group_info['account_id'],PHPGW_ACL_READ,'calendar');
- while($account_perms &&
list($key,$group_id) = each($account_perms))
- {
-
$GLOBALS['phpgw']->accounts->get_account_name($group_id,$lid,$fname,$lname);
- $drop_down[$lname.'
'.$fname] = Array(
- 'grantor'
=> $group_id,
- 'value'
=> ($GLOBALS['phpgw']->accounts->get_type($group_id)=='g'?'g_':'').$group_id,
- 'name'
=> $GLOBALS['phpgw']->common->display_fullname($lid,$fname,$lname)
- );
- }
- }
-
- @reset($drop_down);
- @ksort($drop_down);
- while(list($key,$grant) =
each($drop_down))
- {
- $form_options .= ' <option
value="'.$grant['value'].'"'.($grant['grantor']==$this->bo->owner?'
selected':'').'>'.$grant['name'].'</option>'."\n";
- }
- reset($this->bo->grants);
-
- $var = Array(
- 'form_width' => $remainder,
- 'form_link' =>
$this->page($referrer),
- 'form_name' => 'owner',
- 'title' => lang('User'),
- 'hidden_vars' =>
$base_hidden_vars,
- 'form_options' =>
$form_options,
- 'button_value' => lang('Go!')
- );
- $tpl->set_var($var);
-
$tpl->set_var('str',$tpl->fp('out','form_button_dropdown'));
-
$tpl->parse('header_column','head_col',True);
+
$GLOBALS['phpgw_info']['flags']['app_header'] =
$GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.$app_header;
}
+ $GLOBALS['phpgw']->common->phpgw_header();
+ $new_body = $this->bo->debug_string.$body;
}
-
- $hidden_vars = ' <input type="hidden" name="from"
value="'.MENUACTION.'">'."\n";
- $date = get_var('date',Array('GET'));
- if($date)
- {
- $hidden_vars .= ' <input type="hidden"
name="date" value="'.$date.'">'."\n";
- }
- $hidden_vars .= ' <input type="hidden" name="month"
value="'.$this->bo->month.'">'."\n";
- $hidden_vars .= ' <input type="hidden" name="day"
value="'.$this->bo->day.'">'."\n";
- $hidden_vars .= ' <input type="hidden" name="year"
value="'.$this->bo->year.'">'."\n";
- if(isset($this->bo->filter) && $this->bo->filter)
- {
- $hidden_vars .= ' <input type="hidden"
name="filter" value="'.$this->bo->filter.'">'."\n";
- }
- if(isset($this->bo->sortby) && $this->bo->sortby)
- {
- $hidden_vars .= ' <input type="hidden"
name="sortby" value="'.$this->bo->sortby.'">'."\n";
- }
- if(isset($this->bo->num_months) &&
$this->bo->num_months)
- {
- $hidden_vars .= ' <input type="hidden"
name="num_months" value="'.$this->bo->num_months.'">'."\n";
- }
- $hidden_vars .= ' <input
name="keywords"'.($keywords?' value="'.$keywords.'"':'').'>';
-
- $var = Array(
- 'action_url_button' =>
$this->page('search'),
- 'action_text_button' => lang('Search'),
- 'action_confirm_button' => '',
- 'action_extra_field' => $hidden_vars
- );
- $tpl->set_var($var);
- $button = $tpl->fp('out','form_button');
- $tpl->set_var('str','<td align="right"
valign="bottom">'.$button.'</td>');
- $tpl->parse('header_column','head_col',True);
- $tpl->parse('phpgw_body','head_table',True);
- }
-
- function printer_friendly($body,$func_header='')
- {
- if($this->bo->printer_friendly)
- {
- $GLOBALS['phpgw_info']['flags']['headonly'] =
True;
- }
- else
- {
- $this->cal_header($func_header &&
$GLOBALS['phpgw_info']['user']['template'] == 'idots' ? $func_header : '');
- }
- return $this->bo->debug_string . $body;
+ return $new_body;
}
function month()
{
-
$GLOBALS['phpgw']->template->set_var('phpgw_body',$this->printer_friendly($this->get_month(),lang('Monthview')));
+ echo
$this->printer_friendly($this->get_month(),lang('Monthview'));
}
function get_month()
@@ -695,7 +418,7 @@
function week()
{
-
$GLOBALS['phpgw']->template->set_var('phpgw_body',$this->printer_friendly($this->get_week(),lang('Weekview')));
+ echo
$this->printer_friendly($this->get_week(),lang('Weekview'));
}
function get_week()
@@ -762,23 +485,23 @@
}
$var = Array(
- 'printer_friendly' => $printer,
+ 'printer_friendly' => $printer,
'bg_text' =>
$this->theme['bg_text'],
- 'small_calendar_prev' => $minical_prev,
- 'prev_week_link' => $prev_week_link,
- 'small_calendar_this' => $minical_this,
- 'week_identifier' =>
$this->bo->get_week_label(),
- 'next_week_link' => $next_week_link,
- 'username' =>
$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner),
- 'small_calendar_next' => $minical_next,
- 'week_display' =>
$this->display_weekly(
+ 'small_calendar_prev' => $minical_prev,
+ 'prev_week_link' => $prev_week_link,
+ 'small_calendar_this' => $minical_this,
+ 'week_identifier' =>
$this->bo->get_week_label(),
+ 'next_week_link' => $next_week_link,
+ 'username' =>
$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner),
+ 'small_calendar_next' => $minical_next,
+ 'week_display' =>
$this->display_weekly(
Array(
'date' =>
sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day),
'showyear' => true,
'owners' =>
$this->bo->owner
)
),
- 'print' => $print
+ 'print' => $print
);
$p =
CreateObject('phpgwapi.Template',$this->template_dir);
@@ -866,7 +589,7 @@
{
$GLOBALS['phpgw_info']['flags']['nofooter'] =
True;
}
-
$GLOBALS['phpgw']->template->set_var('phpgw_body',$this->printer_friendly($this->get_year(),lang('Yearview')));
+ echo
$this->printer_friendly($this->get_year(),lang('Yearview'));
}
function get_year()
@@ -906,10 +629,6 @@
$p->set_block('year_t','year','year');
$p->set_block('year_t','month','month_handle');
$p->set_block('year_t','month_sep','month_sep_handle');
- $p->set_var(array(
- 'month_handle' => '',
- 'month_sep_handle' => ''
- ));
$p->set_var($var);
for($i=1;$i<=12;$i++)
@@ -937,27 +656,35 @@
function view($vcal_id=0,$cal_date=0)
{
- $this->cal_header(lang('View'),True);
+ unset($GLOBALS['phpgw_info']['flags']['noheader']);
+ unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
$GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('View');
+ $GLOBALS['phpgw']->common->phpgw_header();
+
+ $cal_id =
get_var('cal_id',array('GET','POST'),$vcal_id);
+
+ $date = $cal_date?$cal_date:0;
+ $date = $date?$date:intval($_GET['date']);
- $cal_id =
get_var('cal_id',Array('GET','POST','DEFAULT'),$vcal_id);
- $date =
get_var('date',Array('GET','DEFAULT'),$cal_date);
-
// First, make sure they have permission to this entry
if ($cal_id < 1)
{
- $this->error_exit('invalid_id');
+ echo '<center>'.lang('Invalid entry
id.').'</center>'."\n";
+ $GLOBALS['phpgw']->common->phpgw_exit(True);
}
- $event = $this->bo->read_entry($cal_id);
-
- if(!isset($event['id']))
+ if(!$this->bo->check_perms(PHPGW_ACL_READ,$cal_id))
{
- $this->error_exit('not_exist');
+ echo '<center>'.lang('You do not have
permission to read this record!').'</center>'."\n";
+ $GLOBALS['phpgw']->common->phpgw_exit(True);
}
- if(!$this->bo->check_perms(PHPGW_ACL_READ,$event))
+ $event = $this->bo->read_entry($cal_id);
+
+ if(!isset($event['id']))
{
- $this->error_exit('no_read_perm');
+ echo '<center>'.lang('Sorry, this event does
not exist').'.'.'</center>'."\n";
+ $GLOBALS['phpgw']->common->phpgw_exit(True);
}
$this->bo->repeating_events = Array();
@@ -982,10 +709,11 @@
if(!$this->view_event($event,True))
{
- $this->error_exit('no_read_perm');
+ echo '<center>'.lang('You do not have
permission to read this record!').'</center>';
+ $GLOBALS['phpgw']->common->phpgw_exit(True);
}
- $p = &$GLOBALS['phpgw']->template;
+ $p = $GLOBALS['phpgw']->template;
$p->set_file(
Array(
'form_button' =>
'form_button_script.tpl'
@@ -993,6 +721,7 @@
);
$button_left = $button_center = $button_right = '';
+
if($this->bo->check_perms(PHPGW_ACL_EDIT,$event))
{
if($event['recur_type'] != MCAL_RECUR_NONE)
@@ -1085,6 +814,26 @@
$button_right .=
'<td>'.$p->fp('button','form_button').'</td>';
}
}
+ else
+ {
+ // allow me (who I am logged in as) to set up
an alarm
+ // if I am a participant, but not the owner
+ reset($event['participants']);
+ while (list($user,$short_status) =
each($event['participants']))
+ {
+ if
($GLOBALS['phpgw_info']['user']['account_id'] == $user)
+ {
+ $var = Array(
+ 'action_url_button'
=> $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uialarm.manager'),
+ 'action_text_button'
=> lang('Alarm Management'),
+ 'action_confirm_button'
=> '',
+ 'action_extra_field'
=> '<input type="hidden" name="cal_id" value="'.$cal_id.'">'
+ );
+ $p->set_var($var);
+ echo
$p->fp('out','form_button');
+ }
+ }
+ }
$var = Array(
'action_url_button' =>
$this->page('export'),
@@ -1111,7 +860,7 @@
'button_center' => $button_center,
'button_right' => $button_right
));
- $p->fp('phpgw_body','view_event',True);
+ $p->pfp('phpgw_body','view_event');
$GLOBALS['phpgw']->hooks->process(array(
'location' => 'calendar_view',
@@ -1127,9 +876,9 @@
echo '<!-- params[cd] = '.$params['cd'].'
-->'."\n";
}
- if(isset($GLOBALS['HTTP_GET_VARS']['readsess']))
+ if(isset($_GET['readsess']))
{
- $params['readsess'] =
$GLOBALS['HTTP_GET_VARS']['readsess'];
+ $params['readsess'] = $_GET['readsess'];
$params['cd'] = 0;
}
@@ -1149,19 +898,20 @@
)
);
}
- elseif(isset($GLOBALS['HTTP_GET_VARS']['cal_id']))
+ elseif(isset($_GET['cal_id']))
{
- $cal_id =
intval($GLOBALS['HTTP_GET_VARS']['cal_id']);
+ $cal_id = intval($_GET['cal_id']);
$event = $this->bo->read_entry($cal_id);
if(!$this->bo->check_perms(PHPGW_ACL_EDIT,$event))
{
-
$GLOBALS['phpgw']->redirect($this->page('view','&cal_id='.$cal_id));
+ Header('Location:
'.$this->page('view','&cal_id='.$cal_id));
+ $GLOBALS['phpgw']->common->phpgw_exit();
}
-
if(@isset($GLOBALS['HTTP_POST_VARS']['edit_type']) &&
$GLOBALS['HTTP_POST_VARS']['edit_type'] == 'single')
+ if(@isset($_POST['edit_type']) &&
$_POST['edit_type'] == 'single')
{
$event['id'] = 0;
-
$this->bo->set_recur_date($event,$GLOBALS['HTTP_POST_VARS']['date']);
+
$this->bo->set_recur_date($event,$_POST['date']);
$event['recur_type'] = MCAL_RECUR_NONE;
$event['recur_interval'] = 0;
$event['recur_data'] = 0;
@@ -1181,15 +931,14 @@
function export($vcal_id=0)
{
- if(!isset($GLOBALS['HTTP_POST_VARS']['cal_id']) ||
!$GLOBALS['HTTP_POST_VARS']['cal_id'])
+ if(!isset($_POST['cal_id']) || !$_POST['cal_id'])
{
Header('Location: '.$this->index());
- $GLOBALS['phpgw_info']['flags']['nodisplay'] =
True;
- exit;
+ $GLOBALS['phpgw']->common->phpgw_exit();
}
$GLOBALS['phpgw_info']['flags']['noappheader'] = True;
$GLOBALS['phpgw_info']['flags']['noappfooter'] = True;
- if(!isset($GLOBALS['HTTP_POST_VARS']['output_file']) ||
!$GLOBALS['HTTP_POST_VARS']['output_file'])
+ if(!isset($_POST['output_file']) ||
!$_POST['output_file'])
{
unset($GLOBALS['phpgw_info']['flags']['noheader']);
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
@@ -1207,21 +956,27 @@
'action_text_button' =>
lang('Submit'),
'action_confirm_button' => '',
'action_extra_field' =>
"\n".lang('Enter Output Filename: ( .vcs appended )')."\n".' <input
name="output_file" size="25" maxlength="80" value="">'."\n"
- . ' <input type="hidden"
name="cal_id" value="'.$GLOBALS['HTTP_POST_VARS']['cal_id'].'">'
+ . ' <input type="hidden"
name="cal_id" value="'.$_POST['cal_id'].'">'
);
$p->set_var($var);
echo $p->fp('out','form_button');
}
else
{
- $output_file =
$GLOBALS['HTTP_POST_VARS']['output_file'].'.vcs';
+ $output_file = $_POST['output_file'].'.vcs';
$vfs = CreateObject('phpgwapi.vfs');
//
if(!$vfs->file_exists('.calendar',array(RELATIVE_USER)))
// {
//
$vfs->mkdir('.calendar',array(RELATIVE_USER));
// }
- $content =
ExecMethod('calendar.boicalendar.export',$GLOBALS['HTTP_POST_VARS']['cal_id']);
+ $content =
ExecMethod('calendar.boicalendar.export',
+
Array(
+
'l_event_id' => $_POST['cal_id'],
+
'chunk_split' => False,
+
)
+
);
+
$vfs->cd(array('string' => '/',
'relatives' =>
array(RELATIVE_USER)
));
@@ -1229,7 +984,7 @@
'relatives' => array
(RELATIVE_USER),
'content' => $content
));
-// $vfs->write($output_file, array
(RELATIVE_USER_APP), $content);
+
if($this->debug)
{
echo '<!-- DEBUG: Output Filename =
'.$output_file.' -->'."\n";
@@ -1244,8 +999,7 @@
{
Header('Location: '.$this->index());
}
- $GLOBALS['phpgw_info']['flags']['nodisplay'] =
True;
- exit;
+ $GLOBALS['phpgw']->common->phpgw_exit();
}
}
@@ -1269,28 +1023,33 @@
if ($cal_id < 1)
{
- $this->error_exit('invalid_id');
+ echo '<center>'.lang('Invalid entry
id.').'</center>'."\n";
+ $GLOBALS['phpgw']->common->phpgw_exit(True);
}
- if(!$this->bo->check_perms(PHPGW_ACL_READ,$cal_id))
+ if(!$this->bo->check_perms(PHPGW_ACL_READ))
{
- $this->error_exit('no_read_perm');
+ echo '<center>'.lang('You do not have
permission to read this record!').'</center>'."\n";
+ $GLOBALS['phpgw']->common->phpgw_exit(True);
}
$event = $this->bo->read_entry($cal_id);
if(!isset($event['id']))
{
- $this->error_exit('not_exist');
+ echo '<center>'.lang('Sorry, this event does
not exist').'.'.'</center>'."\n";
+ $GLOBALS['phpgw']->common->phpgw_exit(True);
}
elseif(!isset($event['recur_exception']))
{
- $this->error_exit(lang('Sorry, this event does
not have exceptions defined'));
+ echo '<center>'.lang('Sorry, this event does
not have exceptions defined').'.'.'</center>'."\n";
+ $GLOBALS['phpgw']->common->phpgw_exit(True);
}
if(!$this->view_event($event,True))
{
- $this->error_exit('no_read_perm');
+ echo '<center>'.lang('You do not have
permission to read this record!').'</center>';
+ $GLOBALS['phpgw']->common->phpgw_exit(True);
}
$p = &$GLOBALS['phpgw']->template;
@@ -1344,10 +1103,10 @@
$this->index();
}
$cal_id =
(isset($params['cal_id'])?intval($params['cal_id']):'');
- $cal_id =
($cal_id==''?intval($GLOBALS['HTTP_GET_VARS']['cal_id']):$cal_id);
+ $cal_id = ($cal_id==''?intval($_GET['cal_id']):$cal_id);
$reinstate_index =
(isset($params['reinstate_index'])?intval($params['reinstate_index']):'');
- $reinstate_index =
($reinstate_index==''?intval($GLOBALS['HTTP_POST_VARS']['reinstate_index']):$reinstate_index);
+ $reinstate_index =
($reinstate_index==''?intval($_POST['reinstate_index']):$reinstate_index);
if($this->debug)
{
echo '<!-- Calling bo->reinstate -->'."\n";
@@ -1370,8 +1129,7 @@
{
Header('Location:
'.$this->page('',($cd?'&cd='.$cd:'')));
}
- $GLOBALS['phpgw_info']['flags']['nodisplay'] = True;
- exit;
+ $GLOBALS['phpgw']->common->phpgw_exit();
}
function add($cd=0,$readsess=0)
@@ -1397,10 +1155,13 @@
$can_edit = True;
- $thishour =
(isset($GLOBALS['HTTP_GET_VARS']['hour'])?intval($GLOBALS['HTTP_GET_VARS']['hour']):0);
- $thisminute =
(isset($GLOBALS['HTTP_GET_VARS']['minute'])?intval($GLOBALS['HTTP_GET_VARS']['minute']):0);
-
$this->bo->set_start($this->bo->year,$this->bo->month,$this->bo->day,$thishour,$thisminute,0);
-
$this->bo->set_end($this->bo->year,$this->bo->month,$this->bo->day,$thishour,$thisminute,0);
+ $starthour =
intval(get_var('hour',array('GET'),$this->bo->prefs['calendar']['workdaystarts']));
+ $startmin =
intval(get_var('minute',array('GET'),0));
+ $endmin = $startmin +
intval($this->bo->prefs['calendar']['defaultlength']);
+ $endhour = $starthour +
$this->bo->normalizeminutes($endmin);
+ ;
+
$this->bo->set_start($this->bo->year,$this->bo->month,$this->bo->day,$starthour,$startmin,0);
+
$this->bo->set_end($this->bo->year,$this->bo->month,$this->bo->day,$endhour,$endmin,0);
$this->bo->set_title('');
$this->bo->set_description('');
$this->bo->add_attribute('location','');
@@ -1428,33 +1189,30 @@
function delete()
{
- $cal_id = get_var('cal_id',Array('GET'));
- if(!$cal_id)
+ if(!isset($_GET['cal_id']))
{
Header('Location:
'.$this->page('','&date='.sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day)));
- $GLOBALS['phpgw_info']['flags']['nodisplay'] =
True;
- exit;
+ $GLOBALS['phpgw']->common->phpgw_exit();
}
$date =
sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day);
- if($this->bo->check_perms(PHPGW_ACL_DELETE,$cal_id))
+
if($this->bo->check_perms(PHPGW_ACL_DELETE,$cal_id=intval($_GET['cal_id'])))
{
- $delete_type =
get_var('delete_type',Array('POST'));
- if($deleted_type && $delete_type == 'single')
+ if(isset($_POST['delete_type']) &&
$_POST['delete_type'] == 'single')
{
- $date =
$GLOBALS['HTTP_POST_VARS']['date'];
+ $date = $_POST['date'];
$cd = $this->bo->delete_single(
Array(
- 'id' =>
intval($cal_id),
+ 'id' => $cal_id,
'year' =>
substr($date,0,4),
'month' =>
substr($date,4,2),
'day' =>
substr($date,6,2)
)
);
}
- else
+ elseif((isset($_POST['delete_type']) &&
$_POST['delete_type'] == 'series') || !isset($_POST['delete_type']))
{
- $cd =
$this->bo->delete_entry(intval($cal_id));
+ $cd = $this->bo->delete_entry($cal_id);
$this->bo->expunge();
}
}
@@ -1470,8 +1228,7 @@
{
Header('Location:
'.$this->page('','&date='.$date.($cd?'&cd='.$cd:'')));
}
- $GLOBALS['phpgw_info']['flags']['nodisplay'] = True;
- exit;
+ $GLOBALS['phpgw']->common->phpgw_exit();
}
function day()
@@ -1520,16 +1277,16 @@
$p->set_block('day_t','day_event','day_event');
$var = Array(
- 'printer_friendly' => $printer,
+ 'printer_friendly' => $printer,
'bg_text' =>
$this->theme['bg_text'],
- 'daily_events' =>
$this->print_day(
+ 'daily_events' => $this->print_day(
Array(
'year' => $this->bo->year,
'month' => $this->bo->month,
'day' => $this->bo->day
)
),
- 'small_calendar' => $minical,
+ 'small_calendar' => $minical,
'date' =>
$this->bo->long_date($now),
'username' =>
$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner),
'print' => $print
@@ -1537,7 +1294,7 @@
$p->set_var($var);
$p->parse('day_events','day_event');
-
$GLOBALS['phpgw']->template->set_var('phpgw_body',$this->printer_friendly($p->fp('out','day'),lang('Dayview')));
+ echo
$this->printer_friendly($p->fp('out','day'),lang('Dayview'));
}
function edit_status()
@@ -1549,13 +1306,14 @@
$GLOBALS['phpgw_info']['flags']['app_header'] =
$GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Change Status');
$GLOBALS['phpgw']->common->phpgw_header();
- $event =
$this->bo->read_entry($GLOBALS['HTTP_GET_VARS']['cal_id']);
+ $event = $this->bo->read_entry($_GET['cal_id']);
reset($event['participants']);
if(!$event['participants'][$this->bo->owner])
{
- $this->error_exit(lang('The user %1 is not
participating in this
event!',$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner)));
+ echo '<center>'.lang('The user %1 is not
participating in this
event!',$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner)).'</center>';
+ return;
}
if(!$this->bo->check_perms(PHPGW_ACL_EDIT))
@@ -1572,16 +1330,11 @@
'endtime' => 0,
'participants' =>
$event['participants']
)
- ).'<br>';
+ ).'<br />';
- $event =
$this->bo->read_entry($GLOBALS['HTTP_GET_VARS']['cal_id']);
+ $event = $this->bo->read_entry($_GET['cal_id']);
$this->view_event($event);
- $GLOBALS['phpgw']->template->set_var(array(
- 'button_left' => '',
- 'button_center' => '',
- 'button_right' => ''
- ));
-
$GLOBALS['phpgw']->template->fp('phpgw_body','view_event',True);
+
$GLOBALS['phpgw']->template->pfp('phpgw_body','view_event');
echo $this->get_response($event['id']);
}
@@ -1594,7 +1347,7 @@
return;
}
-
$this->bo->set_status(intval($GLOBALS['HTTP_GET_VARS']['cal_id']),intval($GLOBALS['HTTP_GET_VARS']['action']));
+
$this->bo->set_status(intval($_GET['cal_id']),intval($_GET['action']));
if ($this->bo->return_to)
{
@@ -1604,17 +1357,17 @@
{
Header('Location: '.$this->page('',''));
}
- $GLOBALS['phpgw_info']['flags']['nodisplay'] = True;
- exit;
+ $GLOBALS['phpgw']->common->phpgw_exit();
}
+
function planner()
{
if(floor(phpversion()) < 4)
{
return;
}
- $home = strstr($GLOBALS['PHP_SELF'],'home') !== False;
+ $home = strstr($_SERVER['PHP_SELF'],'home') !== False;
// generate header and set global/member variables
//
$this->planner_prepare($home);
@@ -1674,7 +1427,10 @@
//
if (!$no_header)
{
- $this->cal_header(lang('Group Planner'));
+
unset($GLOBALS['phpgw_info']['flags']['noheader']);
+
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
+ if ($this->always_app_header)
$GLOBALS['phpgw_info']['flags']['app_header'] =
$GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Group Planner');
+ $GLOBALS['phpgw']->common->phpgw_header();
}
// intervals_per_day can be configured in preferences
now :-)
@@ -1729,10 +1485,10 @@
$d = mktime(0,0,0,$m,1,$y);
$month = lang(date('F', $d)).strftime(' %Y',
$d);
- $class = $m % 2 || $this->bo->num_months == 1 ?
'th' : 'row_on';
+ $color = $this->theme[$m % 2 ||
$this->bo->num_months == 1 ? 'th_bg' : 'row_on'];
$cols = $days * $intervals_per_day;
- $hdr[0]['.'.$i] = 'class="'.$class.'"
colspan="'.$cols.'" align="center"';
+ $hdr[0]['.'.$i] = 'bgcolor="'.$color.'"
colspan="'.$cols.'" align="center"';
$prev_month =
sprintf('%04d%02d01',$y-($m==1),$m > 1?$m-1:12);
$next_month =
sprintf('%04d%02d01',$y+($m==12),$m < 12?$m+1:1);
$prev_link =
$GLOBALS['phpgw']->link('/index.php',"menuaction=calendar.uicalendar.planner&date=$prev_month");
@@ -1756,31 +1512,31 @@
// highlight today, saturday, sunday
and holidays
//
- $class = 'row_off';
+ $color = $this->theme['row_off'];
$dow =
$GLOBALS['phpgw']->datetime->day_of_week($y,$m,$d);
$date =
sprintf("%04d%02d%02d",$y,$m,$d);
if ($date == date('Ymd'))
{
- $class = 'cal_today';
+ $color =
$GLOBALS['phpgw_info']['theme']['cal_today'];
}
elseif
($this->bo->cached_holidays[$date])
{
- $class = 'cal_holiday';
+ $color =
$this->bo->holiday_color;
$hdr[2]['.'.$index] .= '
title="'.$this->bo->cached_holidays[$date][0]['name'].'"';
}
elseif ($dow == 0 || $dow == 6)
{
- $class = 'th';
+ $color =
$this->bo->theme['th_bg'];
}
- $hdr[2]['.'.$index] .= "
class=\"$class\"";
+ $hdr[2]['.'.$index] .= "
bgcolor=\"$color\"";
$hdr[2][$index] = '<a
href="'.$this->planner_html->link('/index.php',
array(
'menuaction' => 'calendar.uicalendar.add',
'date'
=> $date
) + $add_owner
-
).'">'.$dayname.'<br>'.$d.'</a>';
+ ).'">'.$dayname.'<br
/>'.$d.'</a>';
}
$this->planner_days += $days;
}
@@ -1803,9 +1559,9 @@
}
$offset = (7-date("w", $d)+1)%7;
$offset = $offset == 0 ? 7 : $offset;
- $class = $w % 2 ? 'th' : 'row_on';
+ $color = $this->theme[$w % 2 ? 'th_bg' : 'row_on'];
- $hdr[1]['.'.$w] = 'class="'.$class.'"
colspan="'.$intervals_per_day * $offset.'" align="left"';
+ $hdr[1]['.'.$w] = 'bgcolor="'.$color.'"
colspan="'.$intervals_per_day * $offset.'" align="left"';
$hdr[1][$w] = '';
if ($offset >= 3)
{
@@ -1825,8 +1581,8 @@
}
$w += (isset($hdr[1][$w]))?1:0; // bug in
"date('W')" ?
- $class = $w % 2 ? 'th' : 'row_on';
- $hdr[1]['.'.$w] = 'class="'.$class.'"
colspan="'.$colspan.'" align="left"';
+ $color = $this->theme[$w % 2 ? 'th_bg' :
'row_on'];
+ $hdr[1]['.'.$w] = 'bgcolor="'.$color.'"
colspan="'.$colspan.'" align="left"';
$hdr[1][$w] = '';
if ($days_left >= 3)
{
@@ -1907,18 +1663,17 @@
if (!$is_private)
{
- $max_chars =
6*$colspan/$intervals_per_day-5;
- $max_chars /= ($colspan<9 ? 2 : 1);
+ $max_chars =
intval(6*$colspan/$intervals_per_day-2);
$min_chars = 3; // minimum for
max_chars to display -> this should be configurable
if ($max_chars >= $min_chars)
{
$len_title =
strlen($event['title']);
- if ($len_title < $max_chars)
+ if ($len_title <= $max_chars)
{
$title =
$event['title'];
- $max_chars -=
$len_title - 3; // 3 chars for separator: " - "
+ $max_chars -=
$len_title + 3; // 3 chars for separator: " - "
$len_descr =
strlen($event['description']);
if ($len_descr > 0 &&
$len_descr <= $max_chars)
@@ -1928,7 +1683,8 @@
}
else
{
- $title =
substr($event['title'], 0 , $max_chars).'...';
+ $has_amp =
strpos($event['title'],'&');
+ $title =
substr($event['title'], 0 ,
$max_chars-1+($has_amp!==False&&$has_amp<$max_chars?4:0)).'...';
}
$event['print_title'] = 'yes';
}
@@ -1963,7 +1719,7 @@
if (!$is_private)
{
- $opt .= "\" onClick=\"location='".$view."'\"";
+ $opt .= '" onClick="location=\''.$view.'\'"
class="planner-cell"';
$cel = '<a href="'.$view.'">';
}
else
@@ -1991,6 +1747,7 @@
{
$cel .= '<font size="-2"> -
'.$event['description'].' </font>';
}
+
$akt_cell = $end_cell + 1;
return $rows;
@@ -2117,7 +1874,7 @@
{
if (is_array($r))
{
- $rows['.'.$k] =
'class="'.$GLOBALS['phpgw']->nextmatchs->alternate_row_color().'"';
+ $rows['.'.$k] =
'bgcolor="'.$GLOBALS['phpgw']->nextmatchs->alternate_row_color().'"';
$row = &$rows[$k];
$akt_cell = &$rows['.nr_'.$k];
if ($akt_cell < $last_cell)
@@ -2131,7 +1888,7 @@
function planner_print_rows()
{
- $class = 'class="th"';
+ $bgcolor = 'bgcolor="'.$this->theme['th_bg'].'"';
$intervals_per_day =
$this->bo->prefs['calendar']['planner_intervals_per_day'];
if ($this->debug)
@@ -2142,11 +1899,11 @@
return $this->planner_html->table(
array(
'_hdr0' => $this->planner_header[0],
- '._hdr0' => $class,
+ '._hdr0' => $bgcolor,
'_hdr1' => $this->planner_header[1],
- '._hdr1' => $class,
+ '._hdr1' => $bgcolor,
'_hdr2' => $this->planner_header[2],
- '._hdr2' => $class
+ '._hdr2' => $bgcolor
)+$this->planner_rows,
'width="100%"
cols="'.(1+$this->planner_days_in_end_month*$intervals_per_day).'"');
}
@@ -2169,23 +1926,25 @@
// process all events within observed interval
//
- for($v=$this->planner_firstday; $v <=
$this->planner_lastday; $v += 1)
+
for($v=$this->planner_firstday;$v<=$this->planner_lastday;$v++)
{
$daily = $this->bo->cached_events[$v];
- @reset($daily);
print_debug('For Date',$v);
print_debug('Count of items',count($daily));
// process all events on day $v
//
- while (list(,$event) = @each($daily))
+ if (is_array($daily)) foreach($daily as $event)
{
if ($event['recur_type']) //
calculate start- + end-datetime for recuring events
{
$this->bo->set_recur_date($event,$v);
}
- $this->planner_process_event($event);
+ if
(!$this->bo->rejected_no_show($event))
+ {
+
$this->planner_process_event($event);
+ }
}
}
$this->planner_pad_rows();
@@ -2197,7 +1956,10 @@
$sb = CreateObject('phpgwapi.sbox');
- $this->cal_header(lang('Matrixview'));
+ unset($GLOBALS['phpgw_info']['flags']['noheader']);
+ unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
+ if ($this->always_app_header)
$GLOBALS['phpgw_info']['flags']['app_header'] =
$GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Matrixview');
+ $GLOBALS['phpgw']->common->phpgw_header();
$p = &$GLOBALS['phpgw']->template;
$p->set_file(
@@ -2211,6 +1973,7 @@
$p->set_var(array(
'title' => lang('Daily Matrix
View'),
+ 'th_bg' =>
$this->theme['th_bg'],
'action_url' => $this->page('viewmatrix')
));
@@ -2308,51 +2071,54 @@
function viewmatrix()
{
- $participants =
$GLOBALS['HTTP_POST_VARS']['participants'];
+ if ($_POST['cancel'])
+ {
+ $this->index();
+ }
+ $participants = $_POST['participants'];
$parts = Array();
$acct =
CreateObject('phpgwapi.accounts',$this->bo->owner);
- $c_participants = count($participants);
- for($i=0;$i<$c_participants;$i++)
+
+ if (is_array($participants))
{
- switch
($GLOBALS['phpgw']->accounts->get_type($participants[$i]))
+ foreach($participants as $participant)
{
- case 'g':
- $members =
$acct->member(intval($participants[$i]));
- while($members != False &&
list($index,$member) = each($members))
- {
-
if($this->bo->check_perms(PHPGW_ACL_READ,0,$member['account_id']) &&
!isset($parts[$member['account_id']]))
+ switch
($GLOBALS['phpgw']->accounts->get_type($participant))
+ {
+ case 'g':
+ if ($members =
$acct->member(intval($participant)))
{
-
$parts[$member['account_id']] = 1;
+
foreach($members as $member)
+ {
+
if($this->bo->check_perms(PHPGW_ACL_READ,0,$member['account_id']))
+ {
+
$parts[$member['account_id']] = True;
+ }
+ }
}
- }
- break;
- case 'u':
-
if($this->bo->check_perms(PHPGW_ACL_READ,0,$participants[$i]) &&
!isset($parts[$participants[$i]]))
- {
-
$parts[$participants[$i]] = 1;
- }
- break;
+ break;
+ case 'u':
+
if($this->bo->check_perms(PHPGW_ACL_READ,0,$participant))
+ {
+
$parts[$participant] = 1;
+ }
+ break;
+ }
}
+ unset($acct);
}
- unset($acct);
-
- $participants = Array();
- reset($parts);
- while(list($key,$value) = each($parts))
- {
- $participants[] = $key;
- }
+ $participants = array_keys($parts); // get id's as
values and a numeric index
- reset($participants);
-
- $this->cal_header(lang('Matrixview'));
+ unset($GLOBALS['phpgw_info']['flags']['noheader']);
+ unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
+ if ($this->always_app_header)
$GLOBALS['phpgw_info']['flags']['app_header'] =
$GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Matrixview');
+ $GLOBALS['phpgw']->common->phpgw_header();
- $matrixtype = get_var('matrixtype',Array('POST'));
- switch($matrixtype)
+ switch($_POST['matrixtype'])
{
case 'free/busy':
$freetime =
$GLOBALS['phpgw']->datetime->gmtdate(mktime(0,0,0,$this->bo->month,$this->bo->day,$this->bo->year));
- $html = '<br>'.$this->timematrix(
+ echo '<br />'.$this->timematrix(
Array(
'date' =>
$freetime,
'starttime' =>
$this->bo->splittime('000000',False),
@@ -2362,7 +2128,7 @@
);
break;
case 'weekly':
- $html = '<br>'.$this->display_weekly(
+ echo '<br />'.$this->display_weekly(
Array(
'date' =>
sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day),
'showyear' => true,
@@ -2371,36 +2137,34 @@
);
break;
}
- $html .= "\n".'<br><center>'."\n";
- $html .= ' <form action="'.$this->page('viewmatrix').'"
method="post" name="matrixform" target="viewmatrix">'."\n";
- $html .= ' <input type="hidden" name="year"
value="'.$this->bo->year.'">'."\n";
- $html .= ' <input type="hidden" name="month"
value="'.$this->bo->month.'">'."\n";
- $html .= ' <input type="hidden" name="day"
value="'.$this->bo->day.'">'."\n";
-
- foreach($parts as $key => $value)
- {
- $html .= ' <input type="hidden"
name="participants[]" value="'.$key.'">'."\n";
- }
- $html .= ' <input type="submit"
value="'.lang('refresh').'">'."\n";
- $html .= ' </form>'."\n";
- $html .= '</center>'."\n";
-
-
$GLOBALS['phpgw']->template->set_var('phpgw_body',$html);
+ echo "\n<br />\n".'<form
action="'.$this->page('viewmatrix').'" method="post" name="matrixform">'."\n";
+ echo ' <table cellpadding="5"><tr><td>'."\n";
+ echo ' <input type="hidden" name="year"
value="'.$this->bo->year.'">'."\n";
+ echo ' <input type="hidden" name="month"
value="'.$this->bo->month.'">'."\n";
+ echo ' <input type="hidden" name="day"
value="'.$this->bo->day.'">'."\n";
+ echo ' <input type="hidden" name="matrixtype"
value="'.$_POST['matrixtype'].'">'."\n";
+ foreach($participants as $part)
+ {
+ echo ' <input type="hidden"
name="participants[]" value="'.$part.'">'."\n";
+ }
+ echo ' <input type="submit" name="refresh"
value="'.lang('Refresh').'">'."\n";
+ echo ' </td><td>'."\n";
+ echo ' <input type="submit" name="cancel"
value="'.lang('Cancel').'">'."\n";
+ echo ' </td></tr></table>'."\n";
+ echo '</form>'."\n";
}
function search()
{
- $keywords = get_var('keywords',Array('POST'));
- if (empty($keywords))
+ if (empty($_POST['keywords']))
{
// If we reach this, it is because they didn't
search for anything,
// attempt to send them back to where they
where.
Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',array(
- 'menuaction' =>
$GLOBALS['HTTP_POST_VARS']['from'],
- 'date' =>
$GLOBALS['HTTP_POST_VARS']['year'].$GLOBALS['HTTP_POST_VARS']['month'].$GLOBALS['HTTP_POST_VARS']['day']
+ 'menuaction' => $_POST['from'],
+ 'date' =>
$_POST['year'].$_POST['month'].$_POST['day']
)));
- $GLOBALS['phpgw_info']['flags']['nodisplay'] =
True;
- exit;
+ $GLOBALS['phpgw']->common->phpgw_exit();
}
unset($GLOBALS['phpgw_info']['flags']['noheader']);
@@ -2418,8 +2182,7 @@
// This has been solved by the little icon indicator
for recurring events.
- $event_ids = $this->bo->search_keywords($keywords);
- $ids = Array();
+ $event_ids =
$this->bo->search_keywords($_POST['keywords']);
foreach($event_ids as $key => $id)
{
$event = $this->bo->read_entry($id);
@@ -2431,7 +2194,6 @@
$datetime =
$this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset;
- $ids[strval($event['id'])]++;
$info[strval($event['id'])] = array(
'tr_color' =>
$GLOBALS['phpgw']->nextmatchs->alternate_row_color(),
'date' =>
$GLOBALS['phpgw']->common->show_date($datetime),
@@ -2441,11 +2203,6 @@
}
$matches = count($event_ids);
- if ($matches > 0)
- {
- $matches = count($ids);
- }
-
if ($matches == 1)
{
$quantity = lang('1 match found').'.';
@@ -2456,7 +2213,8 @@
}
else
{
- $this->error_exit(lang('no matches found.'));
+ echo '<b>'.lang('Error').':</b>'.lang('no
matches found');
+ return;
}
$p = $GLOBALS['phpgw']->template;
@@ -2471,6 +2229,7 @@
$p->set_block('search_form','search_list_footer','search_list_footer');
$var = Array(
+ 'th_bg' => $this->theme['th_bg'],
'search_text' => lang('Search Results'),
'quantity' => $quantity
);
@@ -2480,14 +2239,12 @@
{
$p->parse('rows','search_list_header',True);
}
- // now sort by number of hits
- arsort($ids);
- foreach($ids as $key => $nul)
+ foreach($info as $id => $data)
{
- $p->set_var($info[$key]);
+ $p->set_var($data);
$p->parse('rows','search_list',True);
}
-
+
if($matches > 0)
{
$p->parse('rows','search_list_footer',True);
@@ -2509,7 +2266,7 @@
'sortby' => $this->bo->sortby,
'num_months' => $this->bo->num_months
);
- return _debug_array($data,False);
+ Return _debug_array($data,False);
}
function output_template_array(&$p,$row,$list,$var)
@@ -2532,6 +2289,7 @@
{
$page_ =
explode('.',$this->bo->prefs['calendar']['defaultcalendar']);
$_page = $page_[0];
+
if ($_page=='planner_cat' ||
$_page=='planner_user')
{
$_page = 'planner';
@@ -2566,7 +2324,11 @@
$tpl = $GLOBALS['phpgw']->template;
$tpl->set_unknowns('remove');
- include($this->template_dir.'/header.inc.php');
+ if (!file_exists($file =
$this->template_dir.'/header.inc.php'))
+ {
+ $file = PHPGW_SERVER_ROOT .
'/calendar/templates/default/header.inc.php';
+ }
+ include($file);
$header = $tpl->fp('out','head');
unset($tpl);
echo $header;
@@ -2574,14 +2336,15 @@
function footer()
{
- list(,,$method) = explode('.',MENUACTION);
-
+ $menuaction = $GLOBALS['phpgw_info']['menuaction'];
+ list(,,$method) = explode('.',$menuaction);
+
if (@$this->bo->printer_friendly)
{
return;
}
- $p = &$GLOBALS['phpgw']->template;
+ $p = $GLOBALS['phpgw']->template;
$p->set_file(
Array(
@@ -2624,7 +2387,7 @@
);
$this->output_template_array($p,'table_row','footer_row',$var);
- if(MENUACTION == 'calendar.uicalendar.week')
+ if($menuaction == 'calendar.uicalendar.week')
{
unset($thisdate);
$thisdate =
mktime(0,0,0,$this->bo->month,$this->bo->day,$this->bo->year) -
$GLOBALS['phpgw']->datetime->tz_offset;
@@ -2635,7 +2398,7 @@
{
$begin = $sun + (7*24*60*60 * $i) +
12*60*60; // we use midday, that changes in daylight-saveing does not effect
us
$end = $begin + 6*24*60*60;
-// echo "<br>$i: ".date('d.m.Y
H:i',$begin).' - '.date('d.m.Y H:i',$end);
+// echo "<br />$i: ".date('d.m.Y
H:i',$begin).' - '.date('d.m.Y H:i',$end);
$str .= '<option value="' .
$GLOBALS['phpgw']->common->show_date($begin,'Ymd') . '"'.($begin <= $thisdate
&& $end >= $thisdate?' selected':'').'>'
.
$GLOBALS['phpgw']->common->show_date($begin,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'])
. ' - '
.
$GLOBALS['phpgw']->common->show_date($end,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
@@ -2671,15 +2434,14 @@
);
$this->output_template_array($p,'table_row','footer_row',$var);
- if(MENUACTION == 'calendar.uicalendar.planner')
+ if($menuaction == 'calendar.uicalendar.planner')
{
$str = '';
$date_str = '';
-
- $date = get_var('date',Array('GET'));
- if($date)
+
+ if(isset($_GET['date']) && $_GET['date'])
{
- $date_str .= ' <input type="hidden"
name="date" value="'.$date.'">'."\n";
+ $date_str .= ' <input type="hidden"
name="date" value="'.$_GET['date'].'">'."\n";
}
$date_str .= ' <input type="hidden"
name="month" value="'.$this->bo->month.'">'."\n";
$date_str .= ' <input type="hidden"
name="day" value="'.$this->bo->day.'">'."\n";
@@ -2714,7 +2476,8 @@
$this->output_template_array($p,'b_row','form_button',$var);
$p->parse('table_row','blank_row',True);
- $p->parse('phpgw_body','footer_table',True);
+ $p->pparse('out','footer_table');
+ unset($p);
}
function css()
@@ -2726,26 +2489,23 @@
}
else
{
- $time_width =
(intval($this->bo->prefs['common']['time_format']) == 12?10:7);
+ $time_width =
(intval($this->bo->prefs['common']['time_format']) == 12?10:7);
}
- $GLOBALS['phpgw_info']['flags']['css_url'] =
'cal_'.$time_width.'.css';
-
- return '';
-
return 'A.minicalendar { color: #000000; font: xx-small
'.$this->theme['font'].' }'."\n"
. ' A.bminicalendar { color: #336699; font:
italic bold xx-small '.$this->theme['font'].' }'."\n"
. ' A.minicalendargrey { color: #999999; font:
xx-small '.$this->theme['font'].' }'."\n"
. ' A.bminicalendargrey { color: #336699;
font: italic bold xx-small '.$this->theme['font'].' }'."\n"
- . ' A.minicalhol { padding-left:3px;
padding-right:3px; background: '.$this->holiday_color.'; color: #000000; font:
xx-small '.$this->theme['font'].' }'."\n"
- . ' A.bminicalhol { padding-left:3px;
padding-right:3px; background: '.$this->holiday_color.'; color: #336699; font:
italic bold xx-small '.$this->theme['font'].' }'."\n"
- . ' A.minicalgreyhol { padding-left:3px;
padding-right:3px; background: '.$this->holiday_color.'; color: #999999; font:
xx-small '.$this->theme['font'].' }'."\n"
- . ' A.bminicalgreyhol { padding-left:3px;
padding-right:3px; background: '.$this->holiday_color.'; color: #999999; font:
italic bold xx-small '.$this->theme['font'].' }'."\n"
- . ' .event-on { background:
'.$this->theme['row_on'].'; color: '.$this->theme['bg_text'].'; font: 100
80%/110% '.$this->theme['font'].'; vertical-align: middle }'."\n"
- . ' .event-off { background:
'.$this->theme['row_off'].'; color: '.$this->theme['bg_text'].'; font: 100
80%/110% '.$this->theme['font'].'; vertical-align: middle }'."\n"
- . ' .event-holiday { background:
'.$this->theme['bg04'].'; color: '.$this->theme['bg_text'].'; font: 100
80%/110% '.$this->theme['font'].'; vertical-align: middle }'."\n"
- . ' .time { background:
'.$this->theme['navbar_bg'].'; color: '.$this->theme['bg_text'].'; font:
65%/100% '.$this->theme['font'].'; width: '.$time_width.'%; border: 1px
'.$this->theme['navbar_text'].'; vertical-align: middle }'."\n"
- . ' .tablecell { width: 80px; height: 80px }';
+ . ' A.minicalhol { padding-left:3px;
padding-right:3px; background-color: '.$this->holiday_color.'; color: #000000;
font: xx-small '.$this->theme['font'].' }'."\n"
+ . ' A.bminicalhol { padding-left:3px;
padding-right:3px; background-color: '.$this->holiday_color.'; color: #336699;
font: italic bold xx-small '.$this->theme['font'].' }'."\n"
+ . ' A.minicalgreyhol { padding-left:3px;
padding-right:3px; background-color: '.$this->holiday_color.'; color: #999999;
font: xx-small '.$this->theme['font'].' }'."\n"
+ . ' A.bminicalgreyhol { padding-left:3px;
padding-right:3px; background-color: '.$this->holiday_color.'; color: #999999;
font: italic bold xx-small '.$this->theme['font'].' }'."\n"
+ . ' .event-on { background-color:
'.$this->theme['row_on'].'; color: '.$this->theme['bg_text'].'; font: 100
80%/110% '.$this->theme['font'].'; vertical-align: middle }'."\n"
+ . ' .event-off { background-color:
'.$this->theme['row_off'].'; color: '.$this->theme['bg_text'].'; font: 100
80%/110% '.$this->theme['font'].'; vertical-align: middle }'."\n"
+ . ' .event-holiday { background-color:
'.$this->theme['bg04'].'; color: '.$this->theme['bg_text'].'; font: 100
80%/110% '.$this->theme['font'].'; vertical-align: middle }'."\n"
+ . ' .time { background-color:
'.$this->theme['navbar_bg'].'; color: '.$this->theme['bg_text'].'; font:
80%/110% '.$this->theme['font'].'; width: '.$time_width.'%; border: 1px
'.$this->theme['navbar_text'].'; vertical-align: middle }'."\n"
+ . ' .tablecell { width: 80px; height: 80px
}'."\n"
+ . ' .planner-cell { cursor:pointer;
cursor:hand; border: thin solid black; }';
}
function no_edit()
@@ -2812,8 +2572,16 @@
{
$text .=
$this->bo->display_status($event['users_status']);
}
-// $text = '<font size="-2"
face="'.$this->theme['font'].'"><nobr>'.$time.'</nobr>
'.$this->bo->get_short_field($event,$is_private,'title').$text.'</font>'.$GLOBALS['phpgw']->browser->br;
- $text = '<font size="-2"
face="'.$this->theme['font'].'"><nobr> '.$time.' </nobr>
'.$this->bo->get_short_field($event,$is_private,'title').$text.':
<I>'.$this->bo->get_short_field($event,$is_private,'description').'</I></font>'.$GLOBALS['phpgw']->browser->br;
+
+ $text = '<font size="-2"
face="'.$this->theme['font'].'"><nobr> '.$time.' </nobr> '
+ .
wordwrap($this->bo->get_short_field($event,$is_private,'title'), 30,
$GLOBALS['phpgw']->browser->br, True)
+ . $text.': <I>'
+ .
wordwrap($this->bo->get_short_field($event,$is_private,'description'), 30,
$GLOBALS['phpgw']->browser->br, True)
+ . '</I></font>'
+ . $GLOBALS['phpgw']->browser->br;
+
+
+ //$text = '<font size="-2"
face="'.$this->theme['font'].'"><nobr> '.$time.' </nobr>
'.$this->bo->get_short_field($event,$is_private,'title').$text.':
<I>'.$this->bo->get_short_field($event,$is_private,'description').'</I></font>'.$GLOBALS['phpgw']->browser->br;
if ($editable)
{
@@ -2886,6 +2654,9 @@
}
if(@isset($event['alarm']) &&
count($event['alarm']) >= 1)
{
+ // if the alarm is to go off the day
before the event
+ // the icon does not show up because of
'alarm_today'
+ // - TOM
if($this->bo->alarm_today($event,$rawdate_offset,$starttime))
{
$picture[] = Array(
@@ -2903,7 +2674,7 @@
{
$var = Array(
'pic_image' =>
$picture[$i]['pict'],
- 'width' =>
$picture[$i]['width'],
+ 'width' =>
$picture[$i]['width'],
'height' =>
$picture[$i]['height'],
'alt' =>
$picture[$i]['alt'],
'title' =>
$picture[$i]['title']
@@ -3026,29 +2797,29 @@
function planner_category($ids)
{
static $cats;
-
if(!is_array($ids))
{
if (strpos($ids,','))
{
- $ids = explode(',',$ids);
+ $id_array = explode(',',$ids);
}
else
{
- $ids = array( 0 => $ids);
+ $id_array[0] = $ids;
}
}
- @reset($ids);
+ @reset($id_array);
$ret_val = Array();
- while(list(,$id) = each($ids))
+ while(list($index,$id) = each($id_array))
{
if (!isset($cats[$id]))
{
- $cats[$id] = $this->cat->return_single(
$id );
- $cats[$id]['color'] =
strstr($cats[$id]['descr'],'#');
+ $cat_arr = $this->cat->return_single(
$id );
+ $cats[$id] = $cat_arr[0];
+ $cats[$id]['color'] =
strstr($cats[$id]['description'],'#');
}
$ret_val[] = $cats[$id];
- }
+ }
return $ret_val;
}
@@ -3067,49 +2838,30 @@
$p->set_block('month_header','column_title','column_title');
$var = Array(
- 'class' => 'th',
+ 'bgcolor' => $this->theme['th_bg'],
'font_color' => $this->theme['th_text']
);
if($this->bo->printer_friendly &&
@$this->bo->prefs['calendar']['print_black_white'])
{
$var = Array(
- 'class' => '',
+ 'bgcolor' => '',
'font_color' => ''
);
}
$p->set_var($var);
- $col_width = 14;
$p->set_var('col_width','14');
if($display_name == True)
{
$p->set_var('col_title',lang('name'));
$p->parse('column_header','column_title',True);
- $col_width = 12;
- }
-
- if($GLOBALS['phpgw']->datetime->days[$i]['weekday'])
- {
- switch($col_width)
- {
- case 12:
- $col_width = 16;
- break;
- case 14:
- $col_width = 20;
- break;
- }
+ $p->set_var('col_width','12');
}
- $p->set_var('col_width',$col_width);
-
for($i=0;$i<7;$i++)
{
-
if(!$this->bo->prefs['calendar']['weekdays_only'] ||
$GLOBALS['phpgw']->datetime->days[$i]['weekday'])
- {
-
$p->set_var('col_title',lang($GLOBALS['phpgw']->datetime->days[$i]['name']));
-
$p->parse('column_header','column_title',True);
- }
+
$p->set_var('col_title',lang($GLOBALS['phpgw']->datetime->days[$i]));
+ $p->parse('column_header','column_title',True);
}
return $p->fp('out','monthly_header');
}
@@ -3126,19 +2878,19 @@
$str = '';
$p =
CreateObject('phpgwapi.Template',$this->template_dir);
$p->set_unknowns('keep');
-
+
$p->set_file(
- Array (
+ Array(
'month_header' => 'month_header.tpl',
- 'month_day' => 'month_day.tpl'
- )
+ 'month_day' => 'month_day.tpl'
+ )
);
$p->set_block('month_header','monthly_header','monthly_header');
$p->set_block('month_header','month_column','month_column');
$p->set_block('month_day','month_daily','month_daily');
$p->set_block('month_day','day_event','day_event');
$p->set_block('month_day','event','event');
-
+
$p->set_var('extra','');
$p->set_var('col_width','14');
if($display_name)
@@ -3149,17 +2901,11 @@
}
$today =
date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime);
$daily = $this->set_week_array($startdate -
$GLOBALS['phpgw']->datetime->tz_offset,$cellcolor,$weekly);
- @reset($daily);
- while(list($date,$day_params) = each($daily))
+ foreach($daily as $date => $day_params)
{
$year = intval(substr($date,0,4));
$month = intval(substr($date,4,2));
$day = intval(substr($date,6,2));
- $dow =
$GLOBALS['phpgw']->datetime->day_of_week($year,$month,$day);
-
if($this->bo->prefs['calendar']['weekdays_only'] && ($dow == 0 || $dow == 6))
- {
- continue;
- }
$var = Array(
'column_data' => '',
'extra' => ''
@@ -3195,8 +2941,7 @@
if(@$day_params['holidays'])
{
- reset($day_params['holidays']);
- while(list($key,$value) =
each($day_params['holidays']))
+ foreach($day_params['holidays']
as $key => $value)
{
$var = Array(
'day_events' =>
'<font face="'.$this->theme['font'].'"
size="-1">'.$value.'</font>'.$GLOBALS['phpgw']->browser->br
@@ -3212,12 +2957,14 @@
'events'
=> ''
);
$p->set_var($var);
- $rep_events =
$this->bo->cached_events[$date];
- $c_rep_events =
count($rep_events);
- for ($k=0;$k<$c_rep_events;$k++)
+ $events =
$this->bo->cached_events[$date];
+ foreach($events as $event)
{
- $lr_events =
$rep_events[$k];
-
$p->set_var('day_events',$this->link_to_entry($lr_events,$month,$day,$year));
+ if
($this->bo->rejected_no_show($event))
+ {
+ continue;
// user does not want to see rejected events
+ }
+
$p->set_var('day_events',$this->link_to_entry($event,$month,$day,$year));
$p->parse('events','event',True);
$p->set_var('day_events','');
}
@@ -3324,7 +3071,7 @@
$p->set_block('week','m_w_table','m_w_table');
$p->set_block('week','event','event');
- $start =
$GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, $day);
+ $start =
$GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, $day) +
$GLOBALS['phpgw']->datetime->tz_offset;
$cellcolor = $this->theme['row_off'];
@@ -3344,25 +3091,27 @@
$owners_array[0] = $owners;
$cols = 7;
}
- if($this->bo->prefs['calendar']['weekdays_only'])
- {
- $cols -= 2;
- }
$var = Array(
'cols' => $cols,
'day_events' =>
$this->week_header($month,$year,$display_name)
);
$this->output_template_array($p,'row','event',$var);
+ $tstart = $start -
$GLOBALS['phpgw']->datetime->tz_offset;
+ $tstop = $tstart + 604800;
$original_owner = $this->bo->so->owner;
for($i=0;$i<$counter;$i++)
{
$this->bo->so->owner = $owners_array[$i];
+ $this->bo->so->open_box($owners_array[$i]);
$this->bo->store_to_cache(
Array(
- 'syear' => $year,
- 'smonth'=> $month,
- 'sday' => 1
+ 'syear' => date('Y',$tstart),
+ 'smonth' => date('m',$tstart),
+ 'sday' => date('d',$tstart),
+ 'eyear' => date('Y',$tstop),
+ 'emonth' => date('m',$tstop),
+ 'eday' => date('d',$tstop)
)
);
$p->set_var('day_events',$this->display_week($start,True,$cellcolor,$display_name,$owners_array[$i]));
@@ -3373,15 +3122,6 @@
return $p->fp('out','m_w_table');
}
- function view_add_day($day,&$repeat_days)
- {
- if($repeat_days)
- {
- $repeat_days .= ', ';
- }
- $repeat_days .= $day.' ';
- }
-
function view_event($event,$alarms=False)
{
if((!$event['participants'][$this->bo->owner] &&
!$this->bo->check_perms(PHPGW_ACL_READ,$event)))
@@ -3389,223 +3129,41 @@
return False;
}
- $pri = Array(
- 1 => lang('Low'),
- 2 => lang('Normal'),
- 3 => lang('High')
- );
-
$p = &$GLOBALS['phpgw']->template;
$p->set_file(
Array(
- 'view' => 'view.tpl'
- )
+ 'view' => 'view.tpl'
+ )
);
$p->set_block('view','view_event','view_event');
$p->set_block('view','list','list');
$p->set_block('view','hr','hr');
- $var[] = Array(
- 'tr_color' => 'th',
- 'field' => lang('Title'),
- 'data' => $event['title']
- );
+ $vars = $this->bo->event2array($event);
+
+ $vars['title']['tr_color'] = $this->theme['th_bg'];
- // Some browser add a \n when its entered in the
database. Not a big deal
- // this will be printed even though its not needed.
- if ($event['description'])
+ foreach($vars['participants']['data'] as $user => $str)
{
- $var[] = Array(
- 'field' => lang('Description'),
- 'data' => $event['description']
- );
- }
-
- if ($event['category'])
- {
- $category = Array();
-
$this->cat->categories($this->bo->owner,'calendar');
- if(strpos($event['category'],','))
+ if
($this->bo->check_perms(PHPGW_ACL_EDIT,0,$user) && ereg('^(.*)
\((.*)\)$',$str,$parts))
{
- $category =
explode(',',$event['category']);
+ $vars['participants']['data'][$user] =
$parts[1].' (<a
href="'.$this->page('edit_status','&cal_id='.$event['id'].'&owner='.$user).'">'.$parts[2].'</a>)';
}
- else
- {
- $category[] = $event['category'];
- }
- @reset($category);
- while(list($key,$cat) = each($category))
- {
- $_cat = $this->cat->return_single($cat);
- $cat_string[] = $_cat[0]['name'];
- }
- @reset($cat_string);
- $var[] = Array(
- 'field' => lang('Category'),
- 'data' => implode(',',$cat_string)
- );
}
-
- if ($event['location'])
- {
- $var[] = Array(
- 'field' => lang('Location'),
- 'data' => $event['location']
- );
- }
- $var[] = Array(
- 'field' => lang('Start Date/Time'),
- 'data' =>
$GLOBALS['phpgw']->common->show_date($this->bo->maketime($event['start']) -
$GLOBALS['phpgw']->datetime->tz_offset)
- );
-
- $var[] = Array(
- 'field' => lang('End Date/Time'),
- 'data' =>
$GLOBALS['phpgw']->common->show_date($this->bo->maketime($event['end']) -
$GLOBALS['phpgw']->datetime->tz_offset)
- );
-
- $var[] = Array(
- 'field' => lang('Priority'),
- 'data' => $pri[$event['priority']]
- );
-
- $var[] = Array(
- 'field' => lang('Created By'),
- 'data' =>
$GLOBALS['phpgw']->common->grab_owner_name($event['owner'])
- );
-
- $var[] = Array(
- 'field' => lang('Updated'),
- 'data' =>
$GLOBALS['phpgw']->common->show_date($this->bo->maketime($event['modtime']) -
$GLOBALS['phpgw']->datetime->tz_offset)
- );
-
- $var[] = Array(
- 'field' => lang('Access'),
- 'data' =>
$event['public']==True?lang('Public'):lang('Privat')
- );
-
- if(@isset($event['groups'][0]))
- {
- $cal_grps = '';
- for($i=0;$i<count($event['groups']);$i++)
- {
-
if($GLOBALS['phpgw']->accounts->exists($event['groups'][$i]))
- {
- $cal_grps .=
($i>0?'<br>':'').$GLOBALS['phpgw']->accounts->id2name($event['groups'][$i]);
- }
- }
-
- $var[] = Array(
- 'field' => lang('Groups'),
- 'data' => $cal_grps
- );
- }
-
- $str = '';
- reset($event['participants']);
- while (list($user,$short_status) =
each($event['participants']))
- {
- if($GLOBALS['phpgw']->accounts->exists($user))
- {
- $str .=
($str?'<br>':'').$GLOBALS['phpgw']->common->grab_owner_name($user).'
('.($this->bo->check_perms(PHPGW_ACL_EDIT,0,$user)?'<a
href="'.$this->page('edit_status','&cal_id='.$event['id'].'&owner='.$user).'">'.$this->bo->get_long_status($short_status).'</a>':$this->bo->get_long_status($short_status)).')'."\n";
- }
- }
- $var[] = Array(
- 'field' => lang('Participants'),
- 'data' => $str
- );
-
- // Repeated Events
- $rpt_type = Array(
- MCAL_RECUR_NONE => 'none',
- MCAL_RECUR_DAILY => 'daily',
- MCAL_RECUR_WEEKLY => 'weekly',
- MCAL_RECUR_MONTHLY_WDAY => 'monthlybyday',
- MCAL_RECUR_MONTHLY_MDAY => 'monthlybydate',
- MCAL_RECUR_YEARLY => 'yearly'
- );
- $str = lang($rpt_type[$event['recur_type']]);
- if($event['recur_type'] <> MCAL_RECUR_NONE)
+ $vars['participants']['data'] = implode("<br
/>\n",$vars['participants']['data']);
+
+ foreach($vars as $var)
{
- $str_extra = '';
- if ($event['recur_enddate']['mday'] != 0 &&
$event['recur_enddate']['month'] != 0 && $event['recur_enddate']['year'] != 0)
- {
- $recur_end =
$this->bo->maketime($event['recur_enddate']);
- if($recur_end != 0)
- {
- $recur_end -=
$GLOBALS['phpgw']->datetime->tz_offset;
- $str_extra .= lang('ends').':
'.lang($GLOBALS['phpgw']->common->show_date($recur_end,'l')).',
'.lang($GLOBALS['phpgw']->common->show_date($recur_end,'F')).'
'.$GLOBALS['phpgw']->common->show_date($recur_end,'d, Y').' ';
- }
- }
- if($event['recur_type'] == MCAL_RECUR_WEEKLY ||
$event['recur_type'] == MCAL_RECUR_DAILY)
- {
- $repeat_days = '';
-
if($this->bo->prefs['calendar']['weekdaystarts'] == 'Sunday')
- {
- if (!!($event['recur_data'] &
MCAL_M_SUNDAY) == True)
- {
-
$this->view_add_day(lang('Sunday'),$repeat_days);
- }
- }
- if (!!($event['recur_data'] &
MCAL_M_MONDAY) == True)
- {
-
$this->view_add_day(lang('Monday'),$repeat_days);
- }
- if (!!($event['recur_data'] &
MCAL_M_TUESDAY) == True)
- {
-
$this->view_add_day(lang('Tuesday'),$repeat_days);
- }
- if (!!($event['recur_data'] &
MCAL_M_WEDNESDAY) == True)
- {
-
$this->view_add_day(lang('Wednesday'),$repeat_days);
- }
- if (!!($event['recur_data'] &
MCAL_M_THURSDAY) == True)
- {
-
$this->view_add_day(lang('Thursday'),$repeat_days);
- }
- if (!!($event['recur_data'] &
MCAL_M_FRIDAY) == True)
- {
-
$this->view_add_day(lang('Friday'),$repeat_days);
- }
- if (!!($event['recur_data'] &
MCAL_M_SATURDAY) == True)
- {
-
$this->view_add_day(lang('Saturday'),$repeat_days);
- }
-
if($this->bo->prefs['calendar']['weekdaystarts'] == 'Monday')
- {
- if (!!($event['recur_data'] &
MCAL_M_SUNDAY) == True)
- {
-
$this->view_add_day(lang('Sunday'),$repeat_days);
- }
- }
- if($repeat_days <> '')
- {
- $str_extra .= lang('days
repeated').': '.$repeat_days;
- }
- }
- if($event['recur_interval'] != 0)
+ if (strlen($var['data']))
{
- $str_extra .= lang('Interval').':
'.$event['recur_interval'];
- }
-
- if($str_extra)
- {
- $str .= ' ('.$str_extra.')';
+
$this->output_template_array($p,'row','list',$var);
}
-
- $var[] = Array(
- 'field' => lang('Repetition'),
- 'data' => $str
- );
- }
-
- for($i=0;$i<count($var);$i++)
- {
-
$this->output_template_array($p,'row','list',$var[$i]);
}
- if($alarms && @isset($event['alarm']))
+ if($alarms && count($event['alarm']))
{
+ $p->set_var('th_bg',$this->theme['th_bg']);
$p->set_var('hr_text',lang('Alarms'));
$p->parse('row','hr',True);
@@ -3614,7 +3172,7 @@
$icon = '<img
src="'.$GLOBALS['phpgw']->common->image('calendar',($alarm['enabled']?'enabled':'disabled')).'"
width="13" height="13">';
$var = Array(
'field' =>
$icon.$GLOBALS['phpgw']->common->show_date($alarm['time']),
- 'data' => $alarm['text']
+ 'data' => 'Email Notification'
);
$this->output_template_array($p,'row','list',$var);
}
@@ -3624,13 +3182,30 @@
function nm_on_off()
{
- if($GLOBALS['phpgw']->nextmatchs->alternate_row_color()
== 'row_on')
+ if($GLOBALS['phpgw']->nextmatchs->alternate_row_color()
== $this->theme['row_on'])
{
return '_on';
}
return '_off';
}
+ function slot_num($time,$set_day_start=0,$set_day_end=0)
+ {
+ static $day_start, $day_end, $interval=0;
+
+ if ($set_day_start) $day_start = $set_day_start;
+ if ($set_day_end) $day_end = $set_day_end;
+ if (!$interval) $interval =
60*$this->bo->prefs['calendar']['interval'];
+
+ if ($time > $day_end)
+ {
+ $time = $day_end;
+ }
+ $slot = intval(($time - $day_start) / $interval);
+
+ return $slot < 0 ? 0 : 1+$slot;
+ }
+
function print_day($params)
{
if(!is_array($params))
@@ -3642,12 +3217,12 @@
$this->bo->store_to_cache(
Array(
- 'syear' => $params['year'],
- 'smonth' => $params['month'],
- 'sday' => $params['day'],
- 'eyear' => $params['year'],
- 'emonth' => $params['month'],
- 'eday' => $params['day']
+ 'syear' => $params['year'],
+ 'smonth' => $params['month'],
+ 'sday' => $params['day'],
+ 'eyear' => $params['year'],
+ 'emonth' => $params['month'],
+ 'eday' => $params['day']
)
);
@@ -3664,142 +3239,53 @@
$p->set_block('day_cal','day_event_off','day_event_off');
$p->set_block('day_cal','day_event_holiday','day_event_holiday');
$p->set_block('day_cal','day_time','day_time');
-
- if (! $this->bo->prefs['calendar']['workdaystarts'] &&
- ! $this->bo->prefs['calendar']['workdayends'])
- {
-
-
$GLOBALS['phpgw']->preferences->add('calendar','workdaystarts',8);
-
$GLOBALS['phpgw']->preferences->add('calendar','workdayends',16);
-
$GLOBALS['phpgw']->preferences->save_repository();
- $this->bo->prefs['calendar']['workdaystarts'] =
8;
- $this->bo->prefs['calendar']['workdayends'] =
16;
- }
-
- if(!isset($this->bo->prefs['calendar']['interval']))
- {
-
$GLOBALS['phpgw']->preferences->add('calendar','interval',60);
-
$GLOBALS['phpgw']->preferences->save_repository();
- $this->bo->prefs['calendar']['interval'] = 60;
- }
-
- print_debug('Interval set
to',intval($this->bo->prefs['calendar']['interval']));
-
- for ($i=0;$i<24;$i++)
- {
- for($j=0;$j<(60 /
intval($this->bo->prefs['calendar']['interval']));$j++)
- {
- $rowspan_arr[$i][$j] = 0;
- $time[$ind][$j] = '';
- }
- }
-
+
$date_to_eval =
sprintf("%04d%02d%02d",$params['year'],$params['month'],$params['day']);
-
- $time = Array();
+ $day_start =
mktime(intval($this->bo->prefs['calendar']['workdaystarts']),0,0,$params['month'],$params['day'],$params['year']);
+ $day_end =
mktime(intval($this->bo->prefs['calendar']['workdayends']),0,1,$params['month'],$params['day'],$params['year']);
$daily =
$this->set_week_array($GLOBALS['phpgw']->datetime->get_weekday_start($params['year'],$params['month'],$params['day']),$this->theme['row_on'],True);
print_debug('Date to Eval',$date_to_eval);
if($daily[$date_to_eval]['appts'])
{
- $day_start =
mktime(intval($this->bo->prefs['calendar']['workdaystarts']),-intval($this->bo->prefs['calendar']['interval']),0,$params['month'],$params['day'],$params['year']);
- $day_end =
mktime(intval($this->bo->prefs['calendar']['workdayends']),0,1,$params['month'],$params['day'],$params['year']);
- $last_starttime = $starttime = 0;
- $last_endtime = $endtime = 0;
$events =
$this->bo->cached_events[$date_to_eval];
print_debug('Date',$date_to_eval);
print_debug('Count',count($events));
- $last_ind = -1;
+ $last_slot_end = -1;
foreach($events as $event)
{
+ if ($this->bo->rejected_no_show($event))
+ {
+ continue; // user does
not want to see rejected events
+ }
if ($event['recur_type']) //
calculate start- + end-datetime for recuring events
{
$this->bo->set_recur_date($event,$date_to_eval);
}
$starttime =
$this->bo->maketime($event['start']);
$endtime =
$this->bo->maketime($event['end']);
-
- $interval_start = 0;
- if ($starttime < $day_start)
- {
- $ind = 0;
- }
- elseif ($starttime >= $day_end)
- {
- $ind = 99;
- }
- else
- {
- $ind =
intval($event['start']['hour']);
- $interval_start =
intval($event['start']['min'] /
intval($this->bo->prefs['calendar']['interval']));
- print_debug('Start Time
Minutes',$event['start']['min']);
-
print_debug('Interval',$interval_start);
- }
- if(($ind <
intval($this->bo->prefs['calendar']['workdaystarts'])) || ($ind >
intval($this->bo->prefs['calendar']['workdayends'])))
- {
- $ind = $ind <
intval($this->bo->prefs['calendar']['workdaystarts']) ? 0 : 99;
- $interval_start = 0;
- }
+ $slot =
$this->slot_num($starttime,$day_start,$day_end);
+ $slot_end =
$this->slot_num($endtime-1); // -1 to no occupy eg. the 18.00 slot for a
17-18h date
- print_debug('IND before',$ind);
- if($ind <= date('H',$last_endtime-1) &&
$last_ind >= 0) // -1 to allow events to end on a full hour, without blocking
the next hour-slot
+ if ($slot <= $last_slot_end)
{
- $ind = $last_ind;
- $interval_start =
$last_interval_start;
+ $slot = $last_slot;
+ $slot_end =
max($last_slot_end,$slot_end);
}
- print_debug('IND after',$ind);
-
- $time[$ind][$interval_start] .=
$this->link_to_entry($event,$params['month'],$params['day'],$params['year']);
+ $rows[$slot] .=
$this->link_to_entry($event,$params['month'],$params['day'],$params['year']);
- print_debug('IND',$ind);
-
print_debug('TIME',$time[$ind][$interval_start]);
+ print_debug('slot',$slot);
+ print_debug('row',$rows[$slot]);
- if ($starttime < $day_start)
- {
- $starttime = $day_start;
- }
- if ($endtime > $day_end)
- {
- $endtime = $day_end;
- }
- if ($starttime != $endtime)
- {
- $rowspan =
$rowspan_arr[$ind][$interval_start];
- if($rowspan == 0 ||
$last_endtime <= $starttime)
- {
- $rowspan =
intval(round(($endtime - $starttime) / (60 *
intval($this->bo->prefs['calendar']['interval']))));
- }
- elseif($last_endtime < $endtime
&& $last_starttime)
- {
- $rowspan =
intval(round(($endtime - $last_starttime) / (60 *
intval($this->bo->prefs['calendar']['interval']))));
- }
- $mins = (int)((($endtime -
$starttime) / 60) % 60);
-
- if($mins != 0 && $mins <=
intval(60 / intval($this->bo->prefs['calendar']['interval'])) ||
- $mins == 0 &&
date('i',$endtime) > intval($this->bo->prefs['calendar']['interval']))
- {
- $rowspan += 1;
- }
- print_debug('Rowspan being set
to',$rowspan);
-
- if ($rowspan >
$rowspan_arr[$ind][$interval_start])
- {
-
$rowspan_arr[$ind][$interval_start] = $rowspan;
- }
- }
- $last_ind = $ind;
- $last_interval_start = $interval_start;
- $last_starttime = $starttime;
- $last_endtime = $endtime;
+ $row_span[$slot] = 1 + $slot_end -
$slot;
+
+ $last_slot = $slot;
+ $last_slot_end = $slot_end;
print_debug('Time',$GLOBALS['phpgw']->common->show_date($this->bo->maketime($events[$i]['start'])
- $GLOBALS['phpgw']->datetime->tz_offset).' -
'.$GLOBALS['phpgw']->common->show_date($this->bo->maketime($events[$i]['end'])
- $GLOBALS['phpgw']->datetime->tz_offset));
- print_debug('Start',$ind);
- print_debug('Interval
#',$interval_start);
+ print_debug('Slot',$slot);
}
+ //echo "rows=<pre>"; print_r($rows); echo "<br
/>row_span="; print_r($row_span); echo "</pre>\n";
}
-
- // squish events that use the same cell into the same
cell.
- // For example, an event from 8:00-9:15 and another
from 9:30-9:45 both
- // want to show up in the 8:00-9:59 cell.
$holiday_names = $daily[$date_to_eval]['holidays'];
if(!$holiday_names)
{
@@ -3808,104 +3294,65 @@
else
{
$row_to_print = '_holiday';
- while(list($index,$name) = each($holiday_names))
+ foreach($holiday_names as $name)
{
- $time[0][0] =
'<center>'.$name.'</center>'.$time[0][0];
+ $rows[0] = '<center>'.$name.'</center>'
. $rows[0];
}
}
-
+ $last_slot =
$this->slot_num($day_end,$day_start,$day_end);
$rowspan = 0;
- $i = isset($time[0][0]) ? 0 :
(int)$this->bo->prefs['calendar']['workdaystarts'];
- $i_end = isset($time[99][0]) ? 99 :
(int)$this->bo->prefs['calendar']['workdayends'];
- while ($i <= $i_end)
- {
- $j_end = $i ? 60 /
intval($this->bo->prefs['calendar']['interval']) : 1;
- for($j = 0; $j < $j_end; $j++)
- {
- $dtime =
$this->bo->build_time_for_display(($i * 10000) + (($j
*intval($this->bo->prefs['calendar']['interval'])) * 100));
- $p->set_var('extras','');
- $p->set_var('event',' ');
- if ($rowspan > 1)
- {
- // this might mean there's an
overlap, or it could mean one event
- // ends at 11:15 and another
starts at 11:30.
- if (isset($time[$i][$j]))
- {
-
$p->set_var('event',$time[$i][$j]);
- $row_to_print =
$this->nm_on_off();
-
$p->parse('item','day_event'.$row_to_print,False);
- }
- $rowspan--;
- }
- elseif (!isset($time[$i][$j]))
- {
- $p->set_var('event',' ');
- $row_to_print =
$this->nm_on_off();
-
$p->parse('item','day_event'.$row_to_print,False);
- }
- else
- {
- $rowspan =
intval($rowspan_arr[$i][$j]);
- if ($rowspan > 1)
- {
- $p->set_var('extras','
rowspan="'.$rowspan.'"');
- }
-
$p->set_var('event',$time[$i][$j]);
- $row_to_print =
$this->nm_on_off();
-
$p->parse('item','day_event'.$row_to_print,False);
- }
-
- if (0 < $i && $i < 99)
- {
- $open_link = ' - ';
- $close_link = '';
-
- if(!$this->bo->printer_friendly
&& $this->bo->check_perms(PHPGW_ACL_ADD))
- {
- $new_hour =
intval(substr($dtime,0,strpos($dtime,':')));
- if
($this->bo->prefs['common']['timeformat'] == '12' && $i > 12)
- {
- $new_hour += 12;
- }
-
- $open_link .= '<a
href="'.$this->page('add','&date='.$date_to_eval.'&hour='.$new_hour.'&minute='.substr($dtime,strpos($dtime,':')+1,2)).'">';
-
- $close_link = '</a>';
- }
-
- $var = Array(
- 'open_link' =>
$open_link,
- 'time' =>
(intval(substr($dtime,0,strpos($dtime,':')))<10?'0'.$dtime:$dtime),
- 'close_link' =>
$close_link
- );
- }
- else
- {
- $var = Array(
- 'open_link' => '',
- 'time' =>
' ',
- 'close_link' => ''
- );
- }
- $var['tr_color'] = ''; // dummy to
stop output_template_array to set it
-
$this->output_template_array($p,'item','day_time',$var);
- $p->parse('row','day_row',True);
- $p->set_var('event','');
+ for ($slot = 0; $slot <= $last_slot; ++$slot)
+ {
+ $p->set_var('extras','');
+ if ($rowspan > 1)
+ {
$p->set_var('item','');
+ $rowspan--;
}
- if ($i == 0)
+ elseif (!isset($rows[$slot]))
{
- $i =
(int)$this->bo->prefs['calendar']['workdaystarts'];
+ $p->set_var('event',' ');
+ $row_to_print = $this->nm_on_off();
+
$p->parse('item','day_event'.$row_to_print,False);
}
- elseif ($i ==
(int)$this->bo->prefs['calendar']['workdayends'])
+ else
{
- $i = 99;
+ $rowspan = intval($row_span[$slot]);
+ if ($rowspan > 1)
+ {
+ $p->set_var('extras','
rowspan="'.$rowspan.'"');
+ }
+ $p->set_var('event',$rows[$slot]);
+ $row_to_print = $this->nm_on_off();
+
$p->parse('item','day_event'.$row_to_print,False);
}
- else
+ $open_link = $close_link = '';
+ $time = ' ';
+
+ if (0 < $slot && $slot < $last_slot) //
normal time-slot not before or after day_start/end
{
- ++$i;
+ $time = $day_start + ($slot-1) * 60 *
$this->bo->prefs['calendar']['interval'];
+ $hour = date('H',$time);
+ $min = date('i',$time);
+ $time =
$GLOBALS['phpgw']->common->formattime($hour,$min);
+
+ $open_link = ' - ';
+ if(!$this->bo->printer_friendly &&
$this->bo->check_perms(PHPGW_ACL_ADD))
+ {
+ $open_link .= '<a
href="'.$this->page('add',"&date=$date_to_eval&hour=$hour&minute=$min").'">';
+ $close_link = '</a>';
+ }
}
- } // end for
+ $var = Array(
+ 'open_link' => $open_link,
+ 'time' => $time,
+ 'close_link' => $close_link,
+ 'tr_color' => '' // dummy to
stop output_template_array to set it
+ );
+
$this->output_template_array($p,'item','day_time',$var);
+
+ $p->parse('row','day_row',True);
+ }
return $p->fp('out','day');
} // end function
@@ -3920,6 +3367,11 @@
$starttime = $param['starttime'];
$endtime = $param['endtime'];
$participants = $param['participants'];
+ foreach($participants as $part => $nul)
+ {
+ $participants[$part] =
$GLOBALS['phpgw']->common->grab_owner_name($part);
+ }
+ uasort($participants,'strnatcasecmp'); // sort them
after their fullname
if(!isset($this->bo->prefs['calendar']['interval']))
{
@@ -3928,13 +3380,12 @@
$GLOBALS['phpgw']->preferences->save_repository();
}
$increment = $this->bo->prefs['calendar']['interval'];
-// $increment = 15;
$interval = (int)(60 / $increment);
$pix =
$GLOBALS['phpgw']->common->image('calendar','pix');
$str =
'<center>'.lang($GLOBALS['phpgw']->common->show_date($date['raw'],'l'))
- . ', '.$this->bo->long_date($date).'<br>'
+ . ', '.$this->bo->long_date($date).'<br />'
. '<table width="85%" border="0"
cellspacing="0" cellpadding="0" cols="'.((24 * $interval) + 1).'">'
. '<tr><td height="1" colspan="'.((24 *
$interval) + 1).'" bgcolor="black"><img src="'.$pix.'"></td></tr>'
. '<tr><td width="15%"><font
color="'.$this->theme['bg_text'].'" face="'.$this->theme['font'].'"
size="-2">'.lang('Participant').'</font></td>';
@@ -3942,35 +3393,11 @@
{
for($j=0;$j<$interval;$j++)
{
- switch($j)
- {
- case 0:
- case 1:
- switch($j)
- {
- case 0:
- $pre =
'0';
- break;
- case 1:
- $pre =
substr(strval($i),0,1);
- break;
- }
-
- $k =
($i<=9?$pre:substr($i,$j,$j+1));
- if($increment == 60)
- {
- $k .=
substr(strval($i),strlen(strval($i)) - 1,1);
- }
- $str .= '<td
align="left" bgcolor="'.$this->theme['bg_color'].'"><font
color="'.$phpgw_info['theme']['bg_text'].'" face="'.$this->theme['font'].'"
size="-2">'
- . '<a
href="'.$this->page('add','&date='.$date['full'].'&hour='.$i.'&minute='.(interval
* $j))."\" onMouseOver=\"window.status='".$i.':'.(($increment *
$j)<=9?'0':'').($increment * $j)."'; return true;\">"
- .
$k.'</a></font></td>';
- break;
- default:
- $str .= '<td
align="left" bgcolor="'.$this->theme['bg_color'].'"><font
color="'.$phpgw_info['theme']['bg_text'].'" face="'.$this->theme['font'].'"
size="-2">'
- . '<a
href="'.$this->page('add','&date='.$date['full'].'&hour='.$i.'&minute='.(interval
* $j))."\" onMouseOver=\"window.status='".$i.':'.($increment * $j)."'; return
true;\">"
- .
' </a></font></td>';
- break;
- }
+ $k = ($j == 0 ? sprintf('%02d',$i).'<br
/>':'').sprintf('%02d',$j*$increment);
+
+ $str .= '<td align="left"
bgcolor="'.$this->theme['bg_color'].'"><font
color="'.$phpgw_info['theme']['bg_text'].'" face="'.$this->theme['font'].'"
size="-2">'
+ . '<a
href="'.$this->page('add','&date='.$date['full'].'&hour='.$i.'&minute='.(interval
* $j))."\" onMouseOver=\"window.status='".$i.':'.(($increment *
$j)<=9?'0':'').($increment * $j)."'; return true;\">"
+ . $k."</a> </font></td>\n";
}
}
$str .= '</tr>'
@@ -3980,13 +3407,12 @@
$endtime = $starttime;
}
$owner = $this->bo->owner;
- while(list($part,$status) = each($participants))
+ foreach($participants as $part => $fullname)
{
- $str .= '<tr>'
- . '<td width="15%"><font
color="'.$this->theme['bg_text'].'" face="'.$this->theme['font'].'"
size="-2">'.$this->bo->get_fullname($part).'</font></td>';
+ $str .= '<tr align="center">'
+ . '<td width="15%" align="left"><font
color="'.$this->theme['bg_text'].'" face="'.$this->theme['font'].'"
size="-2">'.$fullname.'</font></td>';
$this->bo->cached_events = Array();
- $this->bo->owner = $part;
$this->bo->so->owner = $part;
$this->bo->so->open_box($part);
$this->bo->store_to_cache(
@@ -4008,11 +3434,12 @@
{
$str .= '<td height="1"
align="left" bgcolor="'.$this->theme['bg_color'].'"
color="#999999"> </td>';
}
+ $str .= "\n";
}
}
else
{
- $time_slice =
$this->bo->prepare_matrix($interval,$increment,$part,$status,$date['full']);
+ $time_slice =
$this->bo->prepare_matrix($interval,$increment,$part,$date['full']);
for($h=0;$h<24;$h++)
{
$hour = $h * 10000;
@@ -4023,13 +3450,17 @@
{
case ' ':
$time_slice[$index]['color'] = $this->theme['bg_color'];
+ $extra
= '';
break;
case '-':
$time_slice[$index]['color'] = $this->theme['bg01'];
+ $link =
$this->page('view','&cal_id='.$time_slice[$index]['id'].'&date='.$date['full']);
+ $extra
=' title="'.$time_slice[$index]['description'].'"
onClick="location.href=\''.$link.'\';" style="cursor:pointer; cursor:hand;"';
break;
}
- $str .= '<td height="1"
align="left" bgcolor="'.$time_slice[$index]['color']."\" color=\"#999999\"
onMouseOver=\"window.status='".$time_slice[$index]['description']."'; return
true;\">".'<font color="'.$this->theme['bg_text'].'"
face="'.$this->theme['font'].'"
size="-2">'.$time_slice[$index]['marker'].'</font></td>';
+ $str .= '<td
bgcolor="'.$time_slice[$index]['color'].'" color="#999999"'.$extra.'><font
color="'.$this->theme['bg_text'].'" face="'.$this->theme['font'].'"
size="-2">'.$time_slice[$index]['marker'].'</font></td>';
}
+ $str .= "\n";
}
}
$str .= '</tr>'
@@ -4085,6 +3516,11 @@
return '<table width="100%"><tr
align="center">'."\n".$str.'</tr></table>'."\n";
}
+ function accounts_popup()
+ {
+ $GLOBALS['phpgw']->accounts->accounts_popup('calendar');
+ }
+
function edit_form($param)
{
if(!is_array($param))
@@ -4099,7 +3535,9 @@
$hourformat = substr($this->bo->users_timeformat,0,1);
- $sb = CreateObject('phpgwapi.sbox');
+ // $sb = CreateObject('phpgwapi.sbox');
+ $sb = CreateObject('phpgwapi.sbox2');
+ $jscal = CreateObject('phpgwapi.jscalendar'); //
before phpgw_header() !!!
unset($GLOBALS['phpgw_info']['flags']['noheader']);
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
@@ -4118,15 +3556,23 @@
$p->set_block('edit','edit_entry','edit_entry');
$p->set_block('edit','list','list');
$p->set_block('edit','hr','hr');
+
+// Recurrence Exeptions
+ if ($event[recur_exception]>0)
+ {
+ $recur_exception = implode (",",
$event[recur_exception]);
+ }
$vars = Array(
'font' => $this->theme['font'],
'bg_color' =>
$this->theme['bg_text'],
'action_url' =>
$GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.bocalendar.update')),
+ 'accounts_link' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.accounts_popup'),
'common_hidden' => '<input type="hidden"
name="cal[id]" value="'.$event['id'].'">'."\n"
. '<input type="hidden" name="cal[owner]" value="'.$event['owner'].'">'."\n"
. '<input type="hidden" name="cal[uid]" value="'.$event['uid'].'">'."\n"
-
. ($GLOBALS['HTTP_GET_VARS']['cal_id'] && $event['id'] == 0?'<input
type="hidden" name="cal[reference]"
value="'.$GLOBALS['HTTP_GET_VARS']['cal_id'].'">'."\n":
+
. '<input type="hidden" name="recur_exception"
value="'.$recur_exception.'">'."\n"
+
. ($_GET['cal_id'] && $event['id'] == 0?'<input type="hidden"
name="cal[reference]" value="'.$_GET['cal_id'].'">'."\n":
(@isset($event['reference'])?'<input type="hidden" name="cal[reference]"
value="'.$event['reference'].'">'."\n":''))
. (@isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) &&
$GLOBALS['phpgw_info']['server']['deny_user_grants_access']?
'<input type="hidden" name="participants[]"
value="'.$this->bo->owner.'">'."\n":''),
@@ -4135,14 +3581,14 @@
$p->set_var($vars);
// Brief Description
- $var[] = Array(
- 'tr_color' => 'th',
+ $var['title'] = Array(
+ 'tr_color' => $this->theme['th_bg'],
'field' => lang('Title'),
'data' => '<input name="cal[title]" size="45"
maxlength="80" value="'.$event['title'].'">'
);
// Full Description
- $var[] = Array(
+ $var['description'] = Array(
'field' => lang('Full Description'),
'data' => '<textarea name="cal[description]"
rows="5" cols="40" wrap="virtual"
maxlength="2048">'.$event['description'].'</textarea>'
);
@@ -4165,26 +3611,30 @@
{
$check_cats[] = 0;
}
- $var[] = Array(
+ $var['category'] = Array(
'field' => lang('Category'),
- 'data' => '<select name="categories[]"
multiple size="5"><option value="0">'.lang('Choose the
category').'</option>'.$this->cat->formatted_list('select','all',$check_cats,True).'</select>'
+ 'data' => '<select name="categories[]"
multiple
size="5">'.$this->cat->formated_list('select','all',$check_cats,True).'</select>'
);
// Location
- $var[] = Array(
+ $var['location'] = Array(
'field' => lang('Location'),
'data' => '<input name="cal[location]"
size="45" maxlength="255" value="'.$event['location'].'">'
);
// Date
+
$start = $this->bo->maketime($event['start']) -
$GLOBALS['phpgw']->datetime->tz_offset;
- $var[] = Array(
+ $var['startdate'] = Array(
'field' => lang('Start Date'),
+/*
'data' =>
$GLOBALS['phpgw']->common->dateformatorder(
$sb->getYears('start[year]',intval($GLOBALS['phpgw']->common->show_date($start,'Y'))),
$sb->getMonthText('start[month]',intval($GLOBALS['phpgw']->common->show_date($start,'n'))),
$sb->getDays('start[mday]',intval($GLOBALS['phpgw']->common->show_date($start,'d')))
- )
+ )
+*/
+ 'data' => $jscal->input('start[str]',$start)
);
// Time
@@ -4193,20 +3643,23 @@
$str .= '<input type="radio" name="start[ampm]"
value="am"'.($event['start']['hour'] >= 12?'':' checked').'>am'."\n"
. '<input type="radio"
name="start[ampm]" value="pm"'.($event['start']['hour'] >= 12?'
checked':'').'>pm'."\n";
}
- $var[] = Array(
+ $var['starttime'] = Array(
'field' => lang('Start Time'),
'data' => '<input name="start[hour]" size="2"
VALUE="'.$GLOBALS['phpgw']->common->show_date($start,$hourformat).'"
maxlength="2">:<input name="start[min]" size="2"
value="'.$GLOBALS['phpgw']->common->show_date($start,'i').'"
maxlength="2">'."\n".$str
);
// End Date
$end = $this->bo->maketime($event['end']) -
$GLOBALS['phpgw']->datetime->tz_offset;
- $var[] = Array(
+ $var['enddate'] = Array(
'field' => lang('End Date'),
+/*
'data' =>
$GLOBALS['phpgw']->common->dateformatorder(
$sb->getYears('end[year]',intval($GLOBALS['phpgw']->common->show_date($end,'Y'))),
$sb->getMonthText('end[month]',intval($GLOBALS['phpgw']->common->show_date($end,'n'))),
$sb->getDays('end[mday]',intval($GLOBALS['phpgw']->common->show_date($end,'d')))
)
+*/
+ 'data' => $jscal->input('end[str]',$end)
);
// End Time
@@ -4215,19 +3668,19 @@
$str = '<input type="radio" name="end[ampm]"
value="am"'.($event['end']['hour'] >= 12?'':' checked').'>am'."\n"
. '<input type="radio" name="end[ampm]"
value="pm"'.($event['end']['hour'] >= 12?' checked':'').'>pm'."\n";
}
- $var[] = Array(
+ $var['endtime'] = Array(
'field' => lang('End Time'),
'data' => '<input name="end[hour]" size="2"
VALUE="'.$GLOBALS['phpgw']->common->show_date($end,$hourformat).'"
maxlength="2">:<input name="end[min]" size="2"
value="'.$GLOBALS['phpgw']->common->show_date($end,'i').'"
maxlength="2">'."\n".$str
);
// Priority
- $var[] = Array(
+ $var['priority'] = Array(
'field' => lang('Priority'),
'data' =>
$sb->getPriority('cal[priority]',$event['priority'])
);
// Access
- $var[] = Array(
+ $var['access'] = Array(
'field' => lang('Private'),
'data' => '<input type="checkbox"
name="cal[private]" value="private"'.(!$event['public']?' checked':'').'>'
);
@@ -4242,18 +3695,84 @@
$str = '';
@asort($users);
@reset($users);
- while (list($id,$user_array) = each($users))
+
+
switch($GLOBALS['phpgw_info']['user']['preferences']['common']['account_selection'])
{
- if($id != intval($event['owner']))
- {
- $str .= ' <option value="' .
$id.$event['participants'][$id] . '"'.($event['participants'][$id]?'
selected':'').'>('.$user_array['type'].')
'.$user_array['name'].'</option>'."\n";
- }
+ case 'popup':
+ while
(is_array($event['participants']) && list($id) = each($event['participants']))
+ {
+ if($id !=
intval($event['owner']))
+ {
+ $str .=
'<option value="' . $id.$event['participants'][$id] .
'"'.($event['participants'][$id]?'
selected':'').'>('.$GLOBALS['phpgw']->accounts->get_type($id)
+
.') ' . $GLOBALS['phpgw']->common->grab_owner_name($id) . '</option>' . "\n";
+ }
+ }
+ $var['participants'] = array
+ (
+ 'field' => '<input
type="button" value="' . lang('Participants') . '"
onClick="accounts_popup();">' . "\n"
+ .
'<input type="hidden" name="accountid" value="' . $accountid . '">',
+ 'data' => "\n".'
<select name="participants[]" multiple size="7">' . "\n" . $str . '</select>'
+ );
+ break;
+ default:
+ foreach($users as $id =>
$user_array)
+ {
+ if($id !=
intval($event['owner']))
+ {
+ $str .= '
<option value="' . $id.$event['participants'][$id] .
'"'.($event['participants'][$id]?' selected':'').'>('.$user_array['type'].')
'.$user_array['name'].'</option>'."\n";
+ }
+ }
+ $var['participants'] = array
+ (
+ 'field' =>
lang('Participants'),
+ 'data' => "\n".'
<select name="participants[]" multiple size="7">'."\n".$str.' </select>'
+ );
+ break;
}
+/*
+// External Participants
+
+ // FIXME: where does the list of external
participants come from?
+ //
+ $id = '1_h';
+ $test_contact[$id] = array();
+ $test_contact[$id]['name'] = "Stephan Cremer";
+ $id = '3_b';
+ $test_contact[$id] = array();
+ $test_contact[$id]['name'] = "Stephan_Uni
Cremer_Uni";
+
+ $part = "";
+ $ext_disp = '<textarea
name="external_participants" rows="5" cols="40" readonly="readonly">'."\n";
+ while(list($id,$contact) = each($test_contact))
{
+ $part .= $part!= '' ? ',' : '';
+ $part .= $id;
+ $ext_disp .= '(FIXME:
b_OR_h)'.$contact['name']."\n";
+ }
+ $ext_disp .= '</textarea>'."\n".'<br />';
+
+ $url = $GLOBALS['phpgw']->link('/index.php',
array('menuaction' => 'calendar.uiextpartlist.modify'));
+ // $url = $GLOBALS['phpgw']->link('/index.php',
array('menuaction' => 'calendar.uicalendar.modify_ext_partlist'));
+ $mod_ext = '<script language="JavaScript">'."\n"
+ . 'function
modify_window(url) {'."\n"
+ . '
document.addform.ext_part_id.value="";'."\n"
+ . ' awin =
window.open(url,"modify","width=500,height=400,toolbar=no,resizable=yes");'."\n"
+// DEBUG START
+. '}'."\n".'function show() {'."\n"
+. ' alert("Participants: " + document.addform.ext_part_id.value);'."\n"
+// DEBUG END
+ .
'}'."\n</script>\n".$ext_disp."\n"
+// DEBUG START
+. '<input type="button" value="Status" onClick="javascript:show()">'."\n"
+// DEBUG END
+ . '<input type="button"
onClick="javascript:modify_window(\''.$url.'&part='.$part
+ . '\')"
value="'.lang('Modify List of External Participants').'">'."\n"
+ . '<input type="hidden"
name="ext_part_id" value="'.$part.'">'."\n";
+
$var[] = Array(
- 'field' => lang('Participants'),
- 'data' => "\n".' <select
name="participants[]" multiple size="5">'."\n".$str.' </select>'
+ 'field' => "\n".lang('External
Participants'),
+ 'data' => "\n".$mod_ext."\n"
);
-
+*/
// I Participate
if((($event['id'] > 0) &&
isset($event['participants'][$event['owner']])) || !$event['id'])
{
@@ -4263,45 +3782,78 @@
{
$checked = '';
}
- $var[] = Array(
+ $var['owner'] = Array(
'field' =>
$GLOBALS['phpgw']->common->grab_owner_name($event['owner']).'
'.lang('Participates'),
'data' => '<input type="checkbox"
name="participants[]"
value="'.$event['owner'].$event['participants'][$event['owner']].'"'.$checked.'>'
);
}
- for($i=0;$i<count($var);$i++)
- {
-
$this->output_template_array($p,'row','list',$var[$i]);
- }
+// Reminder
+ // The user must use "Alarm Management" to
change/modify an alarm
+ // so only display the email reminder fields if this is
a new event
+ // i.e. not editing an existing event
+
+ if ($event['id'] == 0) {
+ // get defaults
+ $days =
$this->bo->prefs['calendar']['default_email_days'];
+ $hours =
$this->bo->prefs['calendar']['default_email_hours'];
+ $min =
$this->bo->prefs['calendar']['default_email_min'];
+ if (count($event['alarm']) > 1)
+ {
+ // this should not happen because when
creating a new event
+ // only 1 alarm is displayed on the
screen
+ // if the user wants more than 1 alarm
they should
+ // use "Alarm Management"
+ echo '<!-- how did this happen, too
many alarms -->'."\n";
+ }
+ // if there was an error pick up what the user
entered
+ if (@isset($event['alarm']))
+ {
+ @reset($event['alarm']);
+ // just get the first one see above!!!
+ list($key,$alarm) =
@each($event['alarm']);
+ $diff = $start - $alarm['time'];
+ $days = intval($diff / (24*3600));
+ $hours = intval(($diff - ($days * 24 *
3600))/3600);
+ $min = intval(($diff - ($days * 24 *
3600) - ($hours * 3600))/60);
+ }
+
+ // days
+ $dout = '<select name="cal[alarmdays]">'."\n";
+ for($i=0;$i<32;$i++)
+ {
+ $dout .= '<option
value="'.$i.'"'.($i==$days?' selected':'').'>'.$i.'</option>'."\n";
+ }
+ $dout .= '</select>'."\n".' '.lang('days').' ';
+ // hours
+ $hout = '<select name="cal[alarmhours]">'."\n";
+ for($i=0;$i<25;$i++)
+ {
+ $hout .= '<option
value="'.$i.'"'.($i==$hours?' selected':'').'>'.$i.'</option>'."\n";
+ }
+ $hout .= '</select>'."\n".' '.lang('hours').' ';
+ // minutes
+ $mout = '<select
name="cal[alarmminutes]">'."\n";
+ for($i=0;$i<61;$i++)
+ {
+ $mout .= '<option
value="'.$i.'"'.($i==$min?' selected':'').'>'.$i.'</option>'."\n";
+ }
+ $mout .= '</select>'."\n".' '.lang('minutes').'
';
+
+ $var['alarm'] = Array(
+ 'field' => lang('Alarm'),
+ 'data' =>
$dout.$hout.$mout.lang('before the event')
+ );
- unset($var);
+ }
// Repeat Type
- $p->set_var('tr_color','th');
- $p->set_var('hr_text','<center><b>'.lang('Repeating
Event Information').'</b></center>');
- $p->parse('row','hr',True);
- $rpt_type = Array(
- MCAL_RECUR_NONE,
- MCAL_RECUR_DAILY,
- MCAL_RECUR_WEEKLY,
- MCAL_RECUR_MONTHLY_WDAY,
- MCAL_RECUR_MONTHLY_MDAY,
- MCAL_RECUR_YEARLY
- );
- $rpt_type_out = Array(
- MCAL_RECUR_NONE => 'None',
- MCAL_RECUR_DAILY => 'Daily',
- MCAL_RECUR_WEEKLY => 'Weekly',
- MCAL_RECUR_MONTHLY_WDAY => 'Monthly (by day)',
- MCAL_RECUR_MONTHLY_MDAY => 'Monthly (by date)',
- MCAL_RECUR_YEARLY => 'Yearly'
- );
$str = '';
- for($l=0;$l<count($rpt_type);$l++)
+ foreach($this->bo->rpt_type as $type => $label)
{
- $str .= '<option
value="'.$rpt_type[$l].'"'.($event['recur_type']==$rpt_type[$l]?'
selected':'').'>'.lang($rpt_type_out[$rpt_type[$l]]).'</option>';
+ $str .= '<option
value="'.$type.'"'.($event['recur_type']==$type?'
selected':'').'>'.lang($label).'</option>';
}
- $var[] = Array(
+ $var['recure_type'] = Array(
'field' => lang('Repeat Type'),
'data' => '<select
name="cal[recur_type]">'."\n".$str.'</select>'."\n"
);
@@ -4317,37 +3869,123 @@
$recur_end =
$this->bo->maketime($event['start']) + 86400 -
$GLOBALS['phpgw']->datetime->tz_offset;
}
- $var[] = Array(
+ $var['recure_enddate'] = Array(
'field' => lang('Repeat End Date'),
- 'data' => '<input type="checkbox"
name="cal[rpt_use_end]" value="y"'.$checked.'>'.lang('Use End Date').' '
- .$GLOBALS['phpgw']->common->dateformatorder(
-
$sb->getYears('recur_enddate[year]',intval($GLOBALS['phpgw']->common->show_date($recur_end,'Y'))),
-
$sb->getMonthText('recur_enddate[month]',intval($GLOBALS['phpgw']->common->show_date($recur_end,'n'))),
-
$sb->getDays('recur_enddate[mday]',intval($GLOBALS['phpgw']->common->show_date($recur_end,'d')))
- )
+ 'data' => '<input type="checkbox"
name="cal[rpt_use_end]" value="y"'.$checked.'>'.lang('Use End Date').' '.
+/*
+
$GLOBALS['phpgw']->common->dateformatorder(
+
$sb->getYears('recur_enddate[year]',intval($GLOBALS['phpgw']->common->show_date($recur_end,'Y'))),
+
$sb->getMonthText('recur_enddate[month]',intval($GLOBALS['phpgw']->common->show_date($recur_end,'n'))),
+
$sb->getDays('recur_enddate[mday]',intval($GLOBALS['phpgw']->common->show_date($recur_end,'d')))
+ )
+*/
+
$jscal->input('recur_enddate[str]',$recur_end)
);
- $var[] = Array(
- 'field' => lang('Repeat Day').'<br>'.lang('(for
weekly)'),
- 'data' => '<input type="checkbox"
name="cal[rpt_sun]" value="'.MCAL_M_SUNDAY.'"'.(($event['recur_data'] &
MCAL_M_SUNDAY) ?' checked':'').'> '.lang('Sunday').' '
- . '<input type="checkbox"
name="cal[rpt_mon]" value="'.MCAL_M_MONDAY.'"'.(($event['recur_data'] &
MCAL_M_MONDAY) ?' checked':'').'> '.lang('Monday').' '
- . '<input type="checkbox" name="cal[rpt_tue]"
value="'.MCAL_M_TUESDAY.'"'.(($event['recur_data'] & MCAL_M_TUESDAY) ?'
checked':'').'> '.lang('Tuesday').' '
- . '<input type="checkbox" name="cal[rpt_wed]"
value="'.MCAL_M_WEDNESDAY.'"'.(($event['recur_data'] & MCAL_M_WEDNESDAY) ?'
checked':'').'> '.lang('Wednesday').' <br>'
- . '<input type="checkbox" name="cal[rpt_thu]"
value="'.MCAL_M_THURSDAY.'"'.(($event['recur_data'] & MCAL_M_THURSDAY) ?'
checked':'').'> '.lang('Thursday').' '
- . '<input type="checkbox" name="cal[rpt_fri]"
value="'.MCAL_M_FRIDAY.'"'.(($event['recur_data'] & MCAL_M_FRIDAY) ?'
checked':'').'> '.lang('Friday').' '
- . '<input type="checkbox" name="cal[rpt_sat]"
value="'.MCAL_M_SATURDAY.'"'.(($event['recur_data'] & MCAL_M_SATURDAY) ?'
checked':'').'> '.lang('Saturday').' '
+ $i = 0; $boxes = '';
+ foreach ($this->bo->rpt_day as $mask => $name)
+ {
+ $boxes .= '<input type="checkbox"
name="cal[rpt_day][]" value="'.$mask.'"'.($event['recur_data'] & $mask ? '
checked' : '').'> '.lang($name)."\n";
+ if (++$i == 5) $boxes .= '<br />';
+ }
+ $var['recure_day'] = Array(
+ 'field' => lang('Repeat Day').'<br
/>'.lang('(for weekly)'),
+ 'data' => $boxes
);
- $var[] = Array(
+ $var['recure_interval'] = Array(
'field' => lang('Interval'),
'data' => '<input name="cal[recur_interval]"
size="4" maxlength="4" value="'.$event['recur_interval'].'">'
);
- for($i=0;$i<count($var);$i++)
+ if (!isset($this->fields))
{
-
$this->output_template_array($p,'row','list',$var[$i]);
+ $this->custom_fields =
CreateObject('calendar.bocustom_fields');
+ $this->fields = &$this->custom_fields->fields;
+ $this->stock_fields =
&$this->custom_fields->stock_fields;
+ }
+ $preserved = False;
+ foreach($this->fields as $field => $data)
+ {
+ if (!$data['disabled'])
+ {
+ if (isset($var[$field]))
+ {
+ switch($field)
+ {
+ case 'startdate':
+
$this->output_template_array($p,'row','list',$var['startdate']);
+
$this->output_template_array($p,'row','list',$var['starttime']);
+ break;
+ case 'enddate':
+
$this->output_template_array($p,'row','list',$var['enddate']);
+
$this->output_template_array($p,'row','list',$var['endtime']);
+ break;
+ case 'recure_type':
+
$p->set_var('tr_color',$this->theme['th_bg']);
+
$p->set_var('hr_text','<center><b>'.lang('Repeating Event
Information').'</b></center>');
+
$p->parse('row','hr',True);
+
$this->output_template_array($p,'row','list',$var['recure_type']);
+
$this->output_template_array($p,'row','list',$var['recure_enddate']);
+
$this->output_template_array($p,'row','list',$var['recure_day']);
+
$this->output_template_array($p,'row','list',$var['recure_interval']);
+ break;
+ default:
+
$this->output_template_array($p,'row','list',$var[$field]);
+ }
+ }
+ elseif
(!isset($this->stock_fields[$field])) // Custom field
+ {
+ $lang = lang($name =
substr($field,1));
+ $size = 'SIZE='.($data['shown']
? $data['shown'] : ($data['length'] ? $data['length'] : 30)).
+ '
MAXLENGTH='.($data['length'] ? $data['length'] : 255);
+ $v = array(
+ 'field' => $lang ==
$name.'*' ? $name : $lang,
+ 'data' => '<input
name="cal['.htmlspecialchars($field).']" '.$size.'
value="'.$event['#'.$name].'">'
+ );
+ if ($data['title'])
+ {
+ $v['tr_color'] =
$this->theme['th_bg'];
+ }
+ if (!$data['length'] &&
$data['title'])
+ {
+
$p->set_var('tr_color',$this->theme['th_bg']);
+
$p->set_var('hr_text','<center><b>'.$v['field'].'</b></center>');
+
$p->parse('row','hr',True);
+ }
+ else
+ {
+
$this->output_template_array($p,'row','list',$v);
+ }
+ }
+ }
+ else // preserve disabled fields
+ {
+ switch ($field)
+ {
+ case 'owner':
+ $preserved[$field] =
$event['id'] ? $event['participants'][$event['owner']] : 'A';
+ break;
+ case 'recure_type':
+
foreach(array('recur_type','recur_enddate','recur_data','recur_interval') as
$field)
+ {
+
$preserved[$field] = $event[$field];
+ }
+ break;
+ case 'startdate':
+ case 'enddate':
+ $field =
substr($field,0,-4);
+ default:
+ $preserved[$field] =
$event[$field];
+ }
+ }
+ }
+ unset($var);
+ if (is_array($preserved))
+ {
+ //echo "preserving<pre>"; print_r($preserved);
echo "</pre>\n";
+
$p->set_var('common_hidden',$p->get_var('common_hidden').'<input type="hidden"
name="preserved" value="'.htmlspecialchars(serialize($preserved)).'">'."\n");
}
-
$p->set_var('submit_button',lang('Save'));
$delete_button = $cancel_button = '';
@@ -4379,50 +4017,242 @@
$p->pparse('out','edit_entry');
}
+ // modify list of an event's external participants (i.e. non
pgpgw users)
+ //
+ function modify_ext_partlist()
+ {
+ $GLOBALS['phpgw_info']['flags']['noheader'] = True;
+ $GLOBALS['phpgw_info']['flags']['nonavbar'] = True;
+ $GLOBALS['phpgw_info']['flags']['noappheader'] = True;
+ $GLOBALS['phpgw_info']['flags']['noappfooter'] = True;
+
+ $total_contacts = 0;
+ $participant = array();
+ $control_data= array();
+
+ $control_data['action'] = '';
+ $control_data['delete'] = array();
+ $control_data['part'] = array();
+
+ $p =
CreateObject('phpgwapi.Template',$this->template_dir);
+ $p->set_file(
+ Array(
+ 'T_edit_partlist' =>
'edit_partlist.tpl',
+ 'T_edit_partlist_blocks' =>
'edit_partlist_blocks.tpl'
+ )
+ );
+
+
$p->set_block('T_edit_partlist_blocks','B_alert_msg','V_alert_msg');
+
$p->set_block('T_edit_partlist_blocks','B_partlist','V_partlist');
+
$p->set_block('T_edit_partlist_blocks','B_participants_none','V_participants_none');
+
$p->set_block('T_edit_partlist_blocks','B_delete_btn','V_delete_btn');
+
+ global $query_addr;
+ $sb = CreateObject('phpgwapi.sbox2');
+ $addy = $sb->getAddress('addr','',$query_addr);
+
+ $add_ext = $addy['doSearchFkt'];
+ $add_ext .= $addy['addr_title']!=lang('Address
Book')?$addy['addr_title']:'';
+ $add_ext .= " ".$addy['addr'].$addy['addr_nojs'];
+
+ $p->set_var('text_add_name',$add_ext);
+
+ if(isset($_GET['part']) && $_GET['part'])
+ {
+ $control_data['part'] = split(",",
$_GET['part']);
+ }
+ else
+ {
+ $control_data['part'] = $_POST['participant'];
+ $control_data['action'] = $_POST['action'];
+ $control_data['delete'] = $_POST['delete'];
+ }
+
+ for ($i=0; $i<count($control_data['part']); $i++)
+ {
+ $id = $control_data['part'][$i];
+ list($contact) = $this->read_contact($id);
+
+ $participant[$id] = array();
+ $participant[$id]['name'] = $contact['n_given'].'
'.$contact['n_family'];
+ }
+
+ if ($control_data['action'] == lang('Delete selected
contacts'))
+ {
+ for ($i=0; $i<count($control_data['delete']);
$i++)
+ {
+ $id = $control_data['delete'][$i];
+ unset($participant[$id]);
+ }
+ }
+
+ if ($control_data['action'] == lang('Add Contact'))
+ {
+ $id = $_POST['id_addr'];
+ if (isset($id) && intval($id) != 0)
+ {
+ list($contact) =
$this->read_contact($id);
+ $participant[$id] = array();
+ $participant[$id]['name'] =
$contact['n_given'].' '.$contact['n_family'];
+ }
+ }
+
+ // create list of currently selected contacts
+ //
+ while(list($id,$contact) = each($participant))
+ {
+
$p->set_var('hidden_delete_name','participant[]');
+ $p->set_var('hidden_delete_value',$id);
+ $p->set_var('ckbox_delete_name','delete[]');
+ $p->set_var('ckbox_delete_value',$id);
+
$p->set_var('ckbox_delete_participant',$contact['name']);
+ $p->parse('V_partlist','B_partlist',True);
+ $total_contacts++;
+ }
+
+ if ($total_contacts == 0)
+ {
+ // no contacts have been selected
+ // => clear the delete form, remove delete
button and show the none block
+ //
+ $p->set_var('V_partlist','');
+ $p->set_var('V_delete_btn','');
+ $p->set_var('text_none',lang('None'));
+
$p->parse('V_participants_none','B_participants_none');
+ }
+ else
+ {
+ // at least one contact has been selected
+ // => clear the none block, fill the delete
form and add delete button
+ //
+ $p->set_var('V_participants_none','');
+ $p->set_var('btn_delete_name','action');
+ $p->set_var('btn_delete_value',lang('Delete
selected contacts'));
+ $p->parse('V_delete_btn','B_delete_btn');
+ }
+
+ $body_tags =
'bgcolor="'.$GLOBALS['phpgw_info']['theme']['bg_color']
+ . '"
alink="'.$GLOBALS['phpgw_info']['theme']['alink']
+ . '"
link="'.$GLOBALS['phpgw_info']['theme']['link']
+ .'"
vlink="'.$GLOBALS['phpgw_info']['theme']['vlink'].'"';
+
+ $form_action = $GLOBALS['phpgw']->link('/index.php',
array('menuaction' => 'calendar.uicalendar.modify'));
+
+ $charset = lang('charset');
+ $p->set_var('charset',$charset);
+
$p->set_var('page_title',$GLOBALS['phpgw_flags']['currentapp']
+
. ' - ' .lang('External
Participants'));
+
$p->set_var('font_family',$GLOBALS['phpgw_info']['theme']['font']);
+ $p->set_var('body_tags',$body_tags);
+ $p->set_var('form_method','POST');
+ $p->set_var('form_action',$form_action);
+ $p->set_var('text_add_contact',lang('External
Participants'));
+ $p->set_var('text_contacts_selected',lang('Selected
contacts (%1)',$total_contacts));
+ $p->set_var('btn_add_name','action');
+ $p->set_var('btn_add_value',lang('Add Contact'));
+ $p->set_var('btn_done_name','done');
+ $p->set_var('btn_done_value',lang('Done'));
+ $p->set_var('btn_done_js','copyback()');
+ $p->set_var('form1_name','ext_form');
+
+ $p->pfp('out','T_edit_partlist');
+ }
+
+ function read_contact($id)
+ {
+ $query_fields = Array(
+ 'n_given' => 'n_given',
+ 'n_family' => 'n_family',
+ 'email' => 'email',
+ 'email_home' => 'email_home'
+ );
+
+ /*
+ if ($this->rights & PHPGW_ACL_READ)
+ {
+ return
$this->contacts->read_single_entry($id,$fields);
+ }
+ else
+ {
+ $rtrn = array(0 => array('No access' => 'No
access'));
+ return $rtrn;
+ }
+ */
+
+ $contacts = CreateObject('phpgwapi.contacts', False);
+ return $contacts->read_single_entry($id,$query_fields);
+ }
+
function build_part_list(&$users,$accounts,$owner)
{
- if($accounts == False)
+ if(!is_array($accounts))
{
return;
}
- @reset($accounts);
- while(list($index,$id) = each($accounts))
+ foreach($accounts as $id)
{
- $i_id = intval($id);
- if($i_id == $owner)
+ $id = intval($id);
+ if($id == $owner)
{
continue;
}
- elseif(!isset($users[$i_id]))
+ elseif(!isset($users[$id]))
{
-
if($GLOBALS['phpgw']->accounts->exists($i_id) == True)
+
if($GLOBALS['phpgw']->accounts->exists($id) == True)
{
- $users[$i_id] = Array(
- 'name' =>
$GLOBALS['phpgw']->common->grab_owner_name($i_id),
- 'type' =>
$GLOBALS['phpgw']->accounts->get_type($i_id)
+ $users[$id] = Array(
+ 'name' =>
$GLOBALS['phpgw']->common->grab_owner_name($id),
+ 'type' =>
$GLOBALS['phpgw']->accounts->get_type($id)
);
}
-
if($GLOBALS['phpgw']->accounts->get_type($i_id) == 'g')
+
if($GLOBALS['phpgw']->accounts->get_type($id) == 'g')
+ {
+
$this->build_part_list($users,$GLOBALS['phpgw']->acl->get_ids_for_location($id,1,'phpgw_group'),$owner);
+ }
+ }
+ }
+ if (!function_exists('strcmp_name'))
+ {
+ function strcmp_name($arr1,$arr2)
+ {
+ if ($diff =
strcmp($arr1['type'],$arr2['type']))
{
-
$this->build_part_list($users,$GLOBALS['phpgw']->acl->get_ids_for_location($i_id,1,'phpgw_group'),$owner);
+ return $diff; // groups
before users
}
+ return
strnatcasecmp($arr1['name'],$arr2['name']);
}
}
+ uasort($users,'strcmp_name');
}
function set_week_array($startdate,$cellcolor,$weekly)
{
for ($j=0,$datetime=$startdate;$j<7;$j++,$datetime +=
86400)
{
- $date = date('Ymd',$datetime + (60 * 60 * 2));
-
- print_debug('set_week_array:Date',$date);
+ $date = date('Ymd',$datetime + (60 * 60 * 2));
// +2h to be save when switching to and from dst, $datetime is alreay +
TZ-Offset
+ print_debug('set_week_array : Date ',$date);
- if($this->bo->cached_events[$date])
+ if($events = $this->bo->cached_events[$date])
{
print_debug('Date',$date);
- print_debug('Appointments
Found',count($this->bo->cached_events[$date]));
- $appts = True;
+ print_debug('Appointments
Found',count($events));
+
+ if
(!$this->bo->prefs['calendar']['show_rejected'])
+ {
+ $appts = False;
+ foreach($events as $event)
// check for a not-rejected event
+ {
+ if
(!$this->bo->rejected_no_show($event))
+ {
+ $appts = True;
+ break;
+ }
+ }
+ }
+ else
+ {
+ $appts = True;
+ }
}
else
{
@@ -4438,21 +4268,21 @@
$day_image = '';
if($holidays)
{
- $extra = ' class="cal_holiday"';
+ $extra = '
bgcolor="'.$this->bo->holiday_color.'"';
$class = ($appts?'b':'').'minicalhol';
-// if ($date == $this->bo->today)
-// {
-// $day_image = '
background="'.$GLOBALS['phpgw']->common->image('calendar','mini_day_block').'"';
-// }
+ if ($date == $this->bo->today)
+ {
+ $day_image = '
background="'.$GLOBALS['phpgw']->common->image('calendar','mini_day_block').'"';
+ }
}
elseif ($date != $this->bo->today)
{
- $extra = ' class="'.$cellcolor.'"';
+ $extra = ' bgcolor="'.$cellcolor.'"';
$class = ($appts?'b':'').'minicalendar';
}
else
{
- $extra = ' class="cal_today"';
+ $extra = '
bgcolor="'.$GLOBALS['phpgw_info']['theme']['cal_today'].'"';
$class = ($appts?'b':'').'minicalendar';
$day_image = '
background="'.$GLOBALS['phpgw']->common->image('calendar','mini_day_block').'"';
}
====================================================
Index: calendar/inc/hook_home_planner.inc.php
diff -u calendar/inc/hook_home_planner.inc.php:1.4
calendar/inc/hook_home_planner.inc.php:1.5
--- calendar/inc/hook_home_planner.inc.php:1.4 Sun May 15 05:48:35 2005
+++ calendar/inc/hook_home_planner.inc.php Sun May 15 06:57:37 2005
@@ -17,7 +17,7 @@
$d1 = strtolower(substr(PHPGW_APP_INC,0,3));
if($d1 == 'htt' || $d1 == 'ftp' )
{
- echo 'Failed attempt to break in via an old Security
Hole!<br>'."\n";
+ echo 'Failed attempt to break in via an old Security Hole!<br
/>'."\n";
$GLOBALS['phpgw']->common->phpgw_exit();
}
unset($d1);
====================================================
Index: calendar/inc/hook_home_week.inc.php
diff -u calendar/inc/hook_home_week.inc.php:1.5
calendar/inc/hook_home_week.inc.php:1.6
--- calendar/inc/hook_home_week.inc.php:1.5 Sun May 15 05:48:35 2005
+++ calendar/inc/hook_home_week.inc.php Sun May 15 06:57:37 2005
@@ -17,13 +17,12 @@
$d1 = strtolower(substr(PHPGW_APP_INC,0,3));
if($d1 == 'htt' || $d1 == 'ftp' )
{
- echo 'Failed attempt to break in via an old Security
Hole!<br>'."\n";
- $GLOBALS['phpgw_info']['flags']['nodisplay'] = True;
- exit;
+ echo 'Failed attempt to break in via an old Security Hole!<br
/>'."\n";
+ $GLOBALS['phpgw']->common->phpgw_exit();
}
unset($d1);
- $GLOBALS['extra_data'] = '<td>'."\n".'<table border="0"
cols="3"><tr><td align="center" width="100%" valign="top">'
+ $GLOBALS['extra_data'] = $GLOBALS['css']."\n".'<td>'."\n".'<table
border="0" cols="3"><tr><td align="center" width="100%" valign="top">'
. ExecMethod('calendar.uicalendar.get_week')
.'</td>'."\n".'</tr>'."\n".'</table>'."\n".'</td>'."\n";
?>
====================================================
====================================================
Index: calendar/inc/hook_home_year.inc.php
diff -u calendar/inc/hook_home_year.inc.php:1.5
calendar/inc/hook_home_year.inc.php:1.6
--- calendar/inc/hook_home_year.inc.php:1.5 Sun May 15 05:48:35 2005
+++ calendar/inc/hook_home_year.inc.php Sun May 15 06:57:37 2005
@@ -17,13 +17,12 @@
$d1 = strtolower(substr(PHPGW_APP_INC,0,3));
if($d1 == 'htt' || $d1 == 'ftp' )
{
- echo 'Failed attempt to break in via an old Security
Hole!<br>'."\n";
- $GLOBALS['phpgw_info']['flags']['nodisplay'] = True;
- exit;
+ echo 'Failed attempt to break in via an old Security Hole!<br
/>'."\n";
+ $GLOBALS['phpgw']->common->phpgw_exit();
}
unset($d1);
- $GLOBALS['extra_data'] = '<td>'."\n".'<table border="0"
cols="3"><tr><td align="center" width="100%" valign="top">'
+ $GLOBALS['extra_data'] = $GLOBALS['css']."\n".'<td>'."\n".'<table
border="0" cols="3"><tr><td align="center" width="100%" valign="top">'
. ExecMethod('calendar.uicalendar.get_year')
.'</td>'."\n".'</tr>'."\n".'</table>'."\n".'</td>'."\n";
?>
====================================================
====================================================
Index: calendar/inc/hook_settings.inc.php
diff -u calendar/inc/hook_settings.inc.php:1.4
calendar/inc/hook_settings.inc.php:1.5
--- calendar/inc/hook_settings.inc.php:1.4 Sun May 15 05:48:35 2005
+++ calendar/inc/hook_settings.inc.php Sun May 15 06:57:37 2005
@@ -15,52 +15,103 @@
/* $Id$ */
- create_check_box('show default view on main
screen','mainscreen_showevents');
-
- create_select_box('weekday starts on','weekdaystarts',array(
+ ExecMethod('calendar.bocalendar.check_set_default_prefs');
+
+ $default = array(
+ 'day' => lang('Daily'),
+ 'week' => lang('Weekly'),
+ 'month' => lang('Monthly'),
+ 'year' => lang('Yearly'),
+ 'planner_cat' => lang('Planner by category'),
+ 'planner_user' => lang('Planner by user'),
+ );
+ create_select_box('default calendar view','defaultcalendar',$default,
+ 'Which of calendar view do you want to see, when you start
calendar ?');
+
+ create_check_box('show default view on main
screen','mainscreen_showevents',
+ 'Displays your default calendar view on the startpage (page you
get when you enter phpGroupWare or click on the homepage icon)?');
+/*
+ $summary = array(
+ 'no' => lang('Never'),
+ 'daily' => lang('Daily'),
+ 'weekly' => lang('Weekly')
+ );
+ create_select_box('Receive summary of appointments','summary',$summary,
+ 'Do you want to receive a regulary summary of your
appointsments via email?<br />The summary is sent to your standard
email-address on the morning of that day or on Monday for weekly summarys.<br
/>It is only sent when you have any appointments on that day or week.');
+*/
+ $updates = array(
+ 'no' => lang('Never'),
+ 'add_cancel' => lang('on invitation / cancelation only'),
+ 'time_change_4h' => lang('on time change of more than 4 hours
too'),
+ 'time_change' => lang('on any time change too'),
+ 'modifications' => lang('on all modification, but responses'),
+ 'responses' => lang('on participant responses too')
+ );
+ create_select_box('Receive email updates','receive_updates',$updates,
+ "Do you want to be notified about new or changed appointments?
You be notified about changes you make yourself.<br />You can limit the
notifications to certain changes only. Each item includes all the notification
listed above it. All modifications include changes of title, description,
participants, but no participant responses. If the owner of an event requested
any notifcations, he will always get the participant responses like acceptions
and rejections too.");
+
+ $update_formats = array(
+ 'none' => lang('None'),
+ 'extended' => lang('Extended'),
+ 'ical' => lang('iCal / rfc2445')
+ );
+ create_select_box('Format of event
updates','update_format',$update_formats,
+ 'Extended updates always include the complete event-details.
iCal\'s can be imported by certain other calendar-applications.');
+
+ $event_details = array(
+ 'to-fullname' => lang('Fullname of person to notify'),
+ 'to-firstname'=> lang('Firstname of person to notify'),
+ 'to-lastname' => lang('Lastname of person to notify'),
+ 'title' => lang('Title of the event'),
+ 'description' => lang('Description'),
+ 'startdate' => lang('Start Date/Time'),
+ 'enddate' => lang('End Date/Time'),
+ 'olddate' => lang('Old Startdate'),
+ 'category' => lang('Category'),
+ 'location' => lang('Location'),
+ 'priority' => lang('Priority'),
+ 'participants'=> lang('Participants'),
+ 'owner' => lang('Owner'),
+ 'repetition' => lang('Repetitiondetails (or empty)'),
+ 'action' => lang('Action that caused the notify: Added,
Canceled, Accepted, Rejected, ...')
+ );
+ create_notify('Notification messages for added events
','notifyAdded',5,50,
+ 'This message is sent to every participant of events you own,
who has requested notifcations about new events.<br />You can use certain
variables which get substituted with the data of the event. The first line is
the subject of the email.',
+ '',$event_details);
+ create_notify('Notification messages for canceled events
','notifyCanceled',5,50,
+ 'This message is sent for canceled or deleted
events.','',$event_details,False);
+ create_notify('Notification messages for modified events
','notifyModified',5,50,
+ 'This message is sent for modified or moved
events.','',$event_details,False);
+ create_notify('Notification messages for your responses
','notifyResponse',5,50,
+ 'This message is sent when you accept, tentative accept or
reject an event.',
+ '',$event_details,False);
+ create_notify('Notification messages for your
alarms','notifyAlarm',5,50,
+ 'This message is sent when you set an Alarm for a certain
event. Include all information you might need.',
+ '',$event_details,False);
+
+ create_check_box('Show invitations you rejected','show_rejected',
+ 'Should invitations you rejected still be shown in your
calendar ?<br />You can only accept them later (eg. when your scheduling
conflict is removed), if they are still shown in your calendar!');
+
+ create_check_box('Display status of events','display_status',
+ 'Should the status of the event-participants (accept, reject,
...) be shown in brakets after each participants name ?');
+
+ $weekdaystarts = array(
'Monday' => lang('Monday'),
'Sunday' => lang('Sunday'),
'Saturday' => lang('Saturday')
- ));
+ );
+ create_select_box('weekday starts on','weekdaystarts',$weekdaystarts,
+ 'This day is shown as first day in the week or month view.');
for ($i=0; $i < 24; ++$i)
{
$options[$i] = $GLOBALS['phpgw']->common->formattime($i,'00');
}
- create_select_box('work day starts on','workdaystarts',$options);
- create_select_box('work day ends on','workdayends',$options);
- unset($options);
-
- create_select_box('default calendar view','defaultcalendar',array(
- 'planner_cat' => lang('Planner by category'),
- 'planner_user' => lang('Planner by user'),
- 'year' => lang('Yearly'),
- 'month' => lang('Monthly'),
- 'week' => lang('Weekly'),
- 'day' => lang('Daily')
- ));
- $groups =
$GLOBALS['phpgw']->accounts->membership($GLOBALS['phpgw_info']['user']['account_id']);
- $options = array(-1 => lang('none'));
- foreach($groups as $group)
- {
- $options[$group['account_id']] =
$GLOBALS['phpgw']->common->grab_owner_name($group['account_id']);
- }
- create_select_box('Preselected group for entering the
planner','planner_start_with_group',$options);
- unset($groups);
- unset($options);
- unset($group);
-
- create_select_box('Default calendar filter','defaultfilter',array(
- 'all' => lang('all'),
- 'private' => lang('private only'),
-// 'public' => lang('global public only'),
-// 'group' => lang('group public only'),
-// 'private+public' => lang('private and global public'),
-// 'private+group' => lang('private and group public'),
-// 'public+group' => lang('global public and group public')
- ));
-
- create_select_box('Display interval in Day View','interval',array(
+ create_select_box('work day starts on','workdaystarts',$options,
+ 'This defines the start of your dayview. Events before this
time, are shown above the dayview.<br />This time is also used as a default
starttime for new events.');
+ create_select_box('work day ends on','workdayends',$options,
+ 'This defines the end of your dayview. Events after this time,
are shown below the dayview.');
+ $intervals = array(
5 => '5',
10 => '10',
15 => '15',
@@ -68,22 +119,50 @@
30 => '30',
45 => '45',
60 => '60'
- ));
+ );
+ create_select_box('Intervals in day view','interval',$intervals,
+ 'Defines the size in minutes of the lines in the day view.');
+ create_input_box('default appointment length (in
minutes)','defaultlength',
+ 'Default length of newly created events. The length is in
minutes, eg. 60 for 1 hour.','',3);
+
+ $groups =
$GLOBALS['phpgw']->accounts->membership($GLOBALS['phpgw_info']['user']['account_id']);
+ $options = array(-1 => lang('none'));
+ if (is_array($groups))
+ {
+ foreach($groups as $group)
+ {
+ $options[$group['account_id']] =
$GLOBALS['phpgw']->common->grab_owner_name($group['account_id']);
+ }
+ }
+ create_select_box('Preselected group for entering the
planner','planner_start_with_group',$options,
+ 'This group that is preselected when you enter the planner. You
can change it in the planner anytime you want.');
- create_select_box('Number of Intervals per Day in Planner
View','planner_intervals_per_day',array(
+ $planner_intervals = array(
1 => '1',
2 => '2',
3 => '3',
4 => '4',
- ));
-
- create_check_box('Send/receive updates via email','send_updates');
- create_check_box('Receive extra information in event
mails','send_extra');
+ );
+ create_select_box('Intervals per day in planner
view','planner_intervals_per_day',
+ $planner_intervals,'Specifies the the number of intervals shown
in the planner view.');
- create_check_box('Display status of events','display_status');
+ $defaultfilter = array(
+ 'all' => lang('all'),
+ 'private' => lang('private only'),
+// 'public' => lang('global public only'),
+// 'group' => lang('group public only'),
+// 'private+public' => lang('private and global public'),
+// 'private+group' => lang('private and group public'),
+// 'public+group' => lang('global public and group public')
+ );
+ create_select_box('Default calendar
filter','defaultfilter',$defaultfilter,
+ 'Which events do you want to see when you enter the calendar.');
- create_check_box('When creating new events default set to
private','default_private');
+ create_check_box('Set new events to private','default_private',
+ 'Should new events created as private by default ?');
- create_check_box('Display mini calendars when
printing','display_minicals');
+ create_check_box('Print the mini calendars','display_minicals',
+ 'Should the mini calendars by printed / displayed in the
printer friendly views ?');
- create_check_box('Print calendars in black &
white','print_black_white');
+ create_check_box('Print calendars in black & white','print_black_white',
+ 'Should the printer friendly view be in black & white or in
color (as in normal view)?');
====================================================
====================================================
Index: calendar/inc/class.socalendar.inc.php
diff -u calendar/inc/class.socalendar.inc.php:1.28
calendar/inc/class.socalendar.inc.php:1.29
--- calendar/inc/class.socalendar.inc.php:1.28 Sun May 15 05:48:34 2005
+++ calendar/inc/class.socalendar.inc.php Sun May 15 06:57:37 2005
@@ -23,6 +23,7 @@
var $owner;
var $g_owner;
var $is_group = False;
+ var $datetime;
var $filter;
var $cat_id;
@@ -93,23 +94,25 @@
// $starttime = mktime(0,0,0,$smonth,$sday,$syear);
// $endtime = mktime(23,59,59,$emonth,$eday,$eyear);
$sql = "AND (phpgw_cal.cal_type='M') "
- . 'AND (phpgw_cal_user.cal_login in (';
+ . 'AND (phpgw_cal_user.cal_login IN (';
if($owner_id)
{
if(is_array($owner_id))
{
- $sql .= implode(',',$owner_id);
+ $ids = $owner_id;
}
else
{
- $sql .= $owner_id;
+ $ids[] = $owner_id;
}
}
else
{
- $sql .=
(!$this->is_group?$this->owner:implode(',',$this->g_owner));
+ $ids = (!$this->is_group ? array($this->owner)
: $this->g_owner);
}
+ $sql .= (is_array($ids) && count($ids) ? implode(',',
$ids) : 0);
+
// $member_groups =
$GLOBALS['phpgw']->accounts->membership($this->user);
// @reset($member_groups);
// while(list($key,$group_info) = each($member_groups))
@@ -133,43 +136,31 @@
return $this->get_event_ids(True,$sql);
}
- function list_events_keyword($keywords)
+ function list_events_keyword($keywords,$members='')
{
-// $sql = 'AND (phpgw_cal_user.cal_login='.$this->owner.')
';
- $o = $this->owner;
- $type = $GLOBALS['phpgw']->accounts->get_type($o);
-
- if($type == 'g')
- {
- $members =
$GLOBALS['phpgw']->acl->get_ids_for_location($o, 1, 'phpgw_group');
- }
- else
- {
- $members[0] = $o;
- }
-
- $sql = 'AND (phpgw_cal_user.cal_login='.$members[0];
-
- for($i=1; $i<count($members); $i++)
+ if (!$members)
{
- $sql .= ' OR phpgw_cal_user.cal_login='.$members[$i];
+ $members[] = $this->owner;
}
- $sql .= ') ';
+ $sql = 'AND (phpgw_cal_user.cal_login IN
('.implode(',',$members).')) AND '.
+
'(phpgw_cal_user.cal_login='.intval($this->owner).' OR phpgw_cal.is_public=1)
AND (';
$words = split(' ',$keywords);
- for ($i=0;$i<count($words);$i++)
+ foreach($words as $i => $word)
{
- $sql .= ($i==0?' AND (':'');
- $sql .= ($i>0?' OR ':'');
- $sql .= "(UPPER(phpgw_cal.title) LIKE
UPPER('%".$words[$i]."%') OR "
- . "UPPER(phpgw_cal.description)
LIKE UPPER('%".$words[$i]."%'))";
- $sql .= ($i==count($words) - 1?') ':'');
+ $sql .= $i > 0 ? ' OR ' : '';
+ $sql .= "(UPPER(phpgw_cal.title) LIKE
UPPER('%".addslashes($word)."%') OR "
+ . "UPPER(phpgw_cal.description)
LIKE UPPER('%".addslashes($word)."%') OR "
+ . "UPPER(phpgw_cal.location)
LIKE UPPER('%".addslashes($word)."%') OR "
+ .
"UPPER(phpgw_cal_extra.cal_extra_value) LIKE UPPER('%".addslashes($word)."%'))";
}
+ $sql .= ') ';
$sql .= (strpos($this->filter,'private')?'AND
phpgw_cal.is_public=0 ':'');
- $sql .= ($this->cat_id?"AND phpgw_cal.category like
'%".$this->cat_id."%' ":'');
- $sql .= 'ORDER BY phpgw_cal.datetime ASC,
phpgw_cal.edatetime ASC, phpgw_cal.priority ASC';
- return $this->get_event_ids(False,$sql);
+ $sql .= ($this->cat_id? "AND
(phpgw_cal.category='$this->cat_id' OR phpgw_cal.category like
'%,".$this->cat_id.",%') ":'');
+ $sql .= 'ORDER BY phpgw_cal.datetime DESC,
phpgw_cal.edatetime DESC, phpgw_cal.priority ASC';
+
+ return $this->get_event_ids(False,$sql,True);
}
function
read_from_store($startYear,$startMonth,$startDay,$endYear='',$endMonth='',$endDay='')
@@ -183,9 +174,9 @@
return $events_cached;
}
- function get_event_ids($include_repeats=False, $sql='')
+ function get_event_ids($search_repeats=False,
$sql='',$search_extra=False)
{
- return $this->cal->get_event_ids($include_repeats,$sql);
+ return
$this->cal->get_event_ids($search_repeats,$sql,$search_extra);
}
function find_uid($uid)
@@ -212,6 +203,16 @@
$this->cal->store_event($event);
}
+ function save_alarm($cal_id,$alarm,$id=0)
+ {
+ $this->cal->save_alarm($cal_id,$alarm,$id);
+ }
+
+ function delete_alarm($id)
+ {
+ $this->cal->delete_alarm($id);
+ }
+
function delete_entry($id)
{
$this->cal->delete_event($id);
@@ -237,6 +238,7 @@
{
$id = $this->cal->stream->f('cal_id');
$db2->query('SELECT count(*) FROM
phpgw_cal_user WHERE cal_id='.$id.' AND
cal_login='.$new_owner,__LINE__,__FILE__);
+ $db2->next_record();
if($db2->f(0) == 0)
{
$db2->query('UPDATE
phpgw_cal_user SET cal_login='.$new_owner.' WHERE cal_id='.$id.' AND
cal_login='.$account_id,__LINE__,__FILE__);
@@ -255,15 +257,31 @@
$this->cal->set_status($id,$this->owner,$status);
}
- function get_alarm($id)
+ function get_alarm($cal_id)
{
- if($GLOBALS['phpgw_info']['server']['calendar_type'] ==
'sql')
+ if (!method_exists($this->cal,'get_alarm'))
{
- return $this->cal->get_alarm($id);
+ return False;
}
- else
+ return $this->cal->get_alarm($cal_id);
+ }
+
+ function read_alarm($id)
+ {
+ if (!method_exists($this->cal,'read_alarm'))
{
+ return False;
+ }
+ return $this->cal->read_alarm($id);
+ }
+
+ function read_alarms($cal_id)
+ {
+ if (!method_exists($this->cal,'read_alarms'))
+ {
+ return False;
}
+ return $this->cal->read_alarms($cal_id);
}
function find_recur_exceptions($event_id)
====================================================
Index: calendar/inc/class.calendar_holiday.inc.php
diff -u calendar/inc/class.calendar_holiday.inc.php:1.25
calendar/inc/class.calendar_holiday.inc.php:1.26
--- calendar/inc/class.calendar_holiday.inc.php:1.25 Sun May 15 05:48:34 2005
+++ calendar/inc/class.calendar_holiday.inc.php Sun May 15 06:57:37 2005
@@ -76,12 +76,12 @@
{
if(isset($holiday['hol_id']) && $holiday['hol_id'])
{
-// echo "Updating LOCALE='".$holiday['locale']."'
NAME='".$holiday['name']."'
extra=(".$holiday['mday'].'/'.$holiday['month_num'].'/'.$holiday['occurence'].'/'.$holiday['dow'].'/'.$holiday['observance_rule'].")<br>\n";
+// echo "Updating LOCALE='".$holiday['locale']."'
NAME='".$holiday['name']."'
extra=(".$holiday['mday'].'/'.$holiday['month_num'].'/'.$holiday['occurence'].'/'.$holiday['dow'].'/'.$holiday['observance_rule'].")<br
/>\n";
$sql = "UPDATE phpgw_cal_holidays SET
name='".$holiday['name']."', mday=".$holiday['mday'].',
month_num='.$holiday['month_num'].', occurence='.$holiday['occurence'].',
dow='.$holiday['dow'].',
observance_rule='.intval($holiday['observance_rule']).' WHERE
hol_id='.$holiday['hol_id'];
}
else
{
-// echo "Inserting LOCALE='".$holiday['locale']."'
NAME='".$holiday['name']."'
extra=(".$holiday['mday'].'/'.$holiday['month_num'].'/'.$holiday['occurence'].'/'.$holiday['dow'].'/'.$holiday['observance_rule'].")<br>\n";
+// echo "Inserting LOCALE='".$holiday['locale']."'
NAME='".$holiday['name']."'
extra=(".$holiday['mday'].'/'.$holiday['month_num'].'/'.$holiday['occurence'].'/'.$holiday['dow'].'/'.$holiday['observance_rule'].")<br
/>\n";
$sql = 'INSERT INTO
phpgw_cal_holidays(locale,name,mday,month_num,occurence,dow,observance_rule) '
.
"VALUES('".strtoupper($holiday['locale'])."','".$holiday['name']."',".$holiday['mday'].','.$holiday['month_num'].','.$holiday['occurence'].','.$holiday['dow'].','.intval($holiday['observance_rule']).")";
}
@@ -135,13 +135,13 @@
}
$load_from = $server_host.'/calendar/setup';
}
-// echo 'Loading from:
'.$load_from.'/holidays.'.strtoupper($locale)."<br>\n";
+// echo 'Loading from:
'.$load_from.'/holidays.'.strtoupper($locale)."<br />\n";
$lines =
$network->gethttpsocketfile($load_from.'/holidays.'.strtoupper($locale));
if (!$lines) return false;
$c_lines = count($lines);
for($i=0;$i<$c_lines;$i++)
{
-// echo 'Line #'.$i.' : '.$lines[$i]."<br>\n";
+// echo 'Line #'.$i.' : '.$lines[$i]."<br />\n";
$holiday = explode("\t",$lines[$i]);
if(count($holiday) == 7)
{
@@ -297,7 +297,7 @@
$return_value[] = $i;
}
}
-// echo 'Searching for '.$phpgw->common->show_date($date).' Found
= '.count($return_value)."<br>\n";
+// echo 'Searching for '.$phpgw->common->show_date($date).' Found
= '.count($return_value)."<br />\n";
if(isset($return_value))
{
return $return_value;
====================================================
Index: calendar/inc/class.boicalendar.inc.php
diff -u calendar/inc/class.boicalendar.inc.php:1.24
calendar/inc/class.boicalendar.inc.php:1.25
--- calendar/inc/class.boicalendar.inc.php:1.24 Sun May 15 05:48:34 2005
+++ calendar/inc/class.boicalendar.inc.php Sun May 15 06:57:37 2005
@@ -40,9 +40,9 @@
/*
* Class
*/
-define('CAL_PRIVATE',0);
-define('CAL_PUBLIC',1);
-define('CAL_CONFIDENTIAL',3);
+define('PRIVATE',0);
+define('PUBLIC',1);
+define('CONFIDENTIAL',3);
/*
* Transparency
@@ -97,6 +97,7 @@
var $parameter = Array();
var $debug_str = False;
var $api = True;
+ var $chunk_split = True;
/*
* Base Functions
@@ -966,7 +967,7 @@
'dtstart' => True
)
),
- 'enocding' => Array(
+ 'encoding' => Array( // "future bug" fix
'type' => 'function',
'function' => 'switch_encoding',
'quoted' => False,
@@ -1253,7 +1254,7 @@
);
if(!is_object($GLOBALS['phpgw']->datetime))
{
- $GLOBALS['phpgw']->datetime =
createobject('phpgwaqpi.datetime');
+ $GLOBALS['phpgw']->datetime =
createobject('phpgwapi.datetime');
}
}
@@ -1293,12 +1294,12 @@
function fold($str)
{
- return chunk_split($str,FOLD_LENGTH,"\r\n");
+ return $this->chunk_split==True ?
chunk_split($str,FOLD_LENGTH,"\r\n") : $str."\r\n";
}
function strip_quotes($str)
{
- return str_replace('\"','',$str);
+ return str_replace('"','',$str);
}
function from_text($str)
@@ -1563,7 +1564,7 @@
$quote = '';
if($seperator == '=')
{
- $quote = '\"';
+ $quote = '"';
}
$return_value =
$this->fold('X-'.$x_type['name'].$seperator.$quote.$x_type['value'].$quote);
@@ -1612,7 +1613,7 @@
$include_datetime = True;
continue;
}
- $quote =
(@$this->parameter[$key]['quoted']?'\"':'');
+ $quote =
(@$this->parameter[$key]['quoted']?'"':'');
if(isset($event[$key]) &&
@$this->parameter[$key]['properties'][$property])
{
$change_text =
@$this->parameter[$key]['to_text'];
@@ -1792,7 +1793,7 @@
case 'function':
$str .=
';'.str_replace('_','-',strtoupper($value)).'=';
$function =
@$this->parameter[$key]['function'];
- $str .=
(@$this->parameter[$key]['quoted']?'\"':'').$this->$function($event[$key]).(@$this->parameter[$key]['quoted']?'\"':'');
+ $str .=
(@$this->parameter[$key]['quoted']?'"':'').$this->$function($event[$key]).(@$this->parameter[$key]['quoted']?'"':'');
break;
case 'float':
if(!empty($event[$value]))
@@ -1900,24 +1901,27 @@
switch($var)
{
case 'PRIVATE':
- return CAL_PRIVATE;
+ return PRIVATE;
+ break;
case 'PUBLIC':
- return CAL_PUBLIC;
+ return PUBLIC;
+ break;
case 'CONFIDENTIAL':
- return CAL_CONFIDENTIAL;
+ return CONFIDENTIAL;
+ break;
}
}
elseif(is_int($var))
{
switch(intval($var))
{
- case CAL_PRIVATE:
+ case PRIVATE:
return 'PRIVATE';
break;
- case CAL_PUBLIC:
+ case PUBLIC:
return 'PUBLIC';
break;
- case CAL_CONFIDENTIAL:
+ case CONFIDENTIAL:
return 'CONFIDENTIAL';
break;
}
@@ -2009,7 +2013,7 @@
{
if($this->api)
{
- $dtime['hour'] -=
$GLOBALS['phpgw_info']['users']['common']['tz_offset'];
+ $dtime['hour'] -=
$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset'];
if($dtime['hour'] < 0)
{
$dtime['mday']
-= 1;
@@ -2032,7 +2036,7 @@
*/
// if($this->api)
// {
-// $dtime['hour'] -=
$GLOBALS['phpgw_info']['users']['common']['tz_offset'];
+// $dtime['hour'] -=
$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset'];
// if($dtime['hour'] < 0)
// {
// $dtime['mday'] -= 1;
@@ -2053,7 +2057,7 @@
$this->set_var($dtime,'sec',0);
if($this->api)
{
- $dtime['hour'] -=
$GLOBALS['phpgw_info']['users']['common']['tz_offset'];
+ $dtime['hour'] -=
$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset'];
if($dtime['hour'] < 0)
{
$dtime['mday'] -= 1;
@@ -2271,28 +2275,28 @@
switch($var)
{
case 'NEEDS-ACTION':
- return NEEDS_ACTION;
+ return 0; // NEEDS_ACTION;
break;
case 'ACCEPTED':
- return ACCEPTED;
+ return 1; // ACCEPTED;
break;
case 'DECLINED':
- return DECLINED;
+ return 2; // DECLINED;
break;
case 'TENTATIVE':
- return TENTATIVE;
+ return 3; // TENTATIVE;
break;
case 'DELEGATED':
- return DELEGATED;
+ return 4; // DELEGATED;
break;
case 'COMPLETED':
- return COMPLETED;
+ return 5; // COMPLETED;
break;
case 'IN-PROCESS':
- return IN_PROCESS;
+ return 6; // IN_PROCESS;
break;
default:
- return OTHER;
+ return 99; // OTHER;
break;
}
}
@@ -2300,25 +2304,25 @@
{
switch(intval($var))
{
- case NEEDS_ACTION:
+ case 0: // NEEDS_ACTION:
return 'NEEDS-ACTION';
break;
- case ACCEPTED:
+ case 1: // ACCEPTED:
return 'ACCEPTED';
break;
- case DECLINED:
+ case 2: // DECLINED:
return 'DECLINED';
break;
- case TENTATIVE:
+ case 3: // TENTATIVE:
return 'TENTATIVE';
break;
- case DELEGATED:
+ case 4: // DELEGATED:
return 'DELEGATED';
break;
- case COMPLETED:
+ case 5: // COMPLETED:
return 'COMPLETED';
break;
- case IN_PROCESS:
+ case 6: // IN_PROCESS:
return 'IN-PROCESS';
break;
default:
@@ -2891,7 +2895,7 @@
function import_file()
{
- if($GLOBALS['uploadedfile'] == 'none' ||
$GLOBALS['uploadedfile'] == '')
+ if( ! is_array($_FILES['uploadedfile']) ||
$_FILES['uploadedfile']['tmp_name'] == '' /*||
$_FILES['uploadedfile']['tmp_name'] = 'none'*/)
{
Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',
Array(
@@ -2900,19 +2904,27 @@
)
)
);
- $GLOBALS['phpgw_info']['flags']['nodisplay'] =
True;
- exit;
+ $GLOBALS['phpgw']->common->phpgw_exit();
}
$uploaddir =
$GLOBALS['phpgw_info']['server']['temp_dir'] . SEP;
srand((double)microtime()*1000000);
$random_number = rand(100000000,999999999);
- $newfilename = md5($GLOBALS['uploadedfile'].",
".$uploadedfile_name.", "
+ $newfilename = md5($_FILES['uploadedfile']['name'].",
".$uploadedfile_name.", "
. time() . getenv("REMOTE_ADDR") .
$random_number );
$filename = $uploaddir . $newfilename;
-
- copy($GLOBALS['uploadedfile'], $filename);
+ if (
!move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $filename) )
+ {
+ Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',
+ Array(
+ 'menuaction' =>
'calendar.uiicalendar.import',
+ 'action' => 'GetFile'
+ )
+ )
+ );
+ $GLOBALS['phpgw']->common->phpgw_exit();
+ }
// $ftp = fopen($uploaddir . $newfilename . '.info','wb');
//
fputs($ftp,$uploadedfile_type."\n".$uploadedfile_name."\n");
// fclose($ftp);
@@ -2921,7 +2933,7 @@
function import($mime_msg='')
{
- if($GLOBALS['uploadedfile'] != 'none' &&
$GLOBALS['uploadedfile'] != '')
+ if( is_array($_FILES['uploadedfile']) &&
$_FILES['uploadedfile']['name'] != '')
{
$filename = $this->import_file();
$fp=fopen($filename,'rt');
@@ -2938,8 +2950,7 @@
)
)
);
- $GLOBALS['phpgw_info']['flags']['nodisplay'] =
True;
- exit;
+ $GLOBALS['phpgw']->common->phpgw_exit();
}
if(!is_object($GLOBALS['uicalendar']))
@@ -3091,7 +3102,7 @@
);
}
// $temp_id =
$cats->name2id($cat);
-// echo 'Category Name :
'.$cat.' : Category ID :'.$temp_id."<br>\n";
+// echo 'Category Name :
'.$cat.' : Category ID :'.$temp_id."<br />\n";
// $cat_id_nums[] =
$temp_id;
$cat_id_nums[] =
$cats->name2id($cat);
}
@@ -3201,13 +3212,14 @@
)
)
);
- $GLOBALS['phpgw_info']['flags']['nodisplay'] = True;
- exit;
+ $GLOBALS['phpgw']->common->phpgw_exit();
}
- function export($l_event_id=0)
+ function export($params)
{
- $event_id =
($l_event_id?$l_event_id:$GLOBALS['HTTP_GET_VARS']['cal_id']);
+ $event_id =
get_var('cal_id',Array('GET','DEFAULT'),$params['l_event_id']);
+ $this->chunk_split = $params['chunk_split'];
+ $method =
($params['method']?$params['method']:"publish");
$string_array = Array(
'summary' => 'description',
@@ -3232,7 +3244,7 @@
$this->set_var($ical['prodid'],'value','-//phpGroupWare//phpGroupWare
'.$setup_info['calendar']['version'].'
MIMEDIR//'.strtoupper($GLOBALS['phpgw_info']['user']['preferences']['common']['lang']));
$this->set_var($ical['version'],'value','2.0');
-
$this->set_var($ical['method'],'value',strtoupper('publish'));
+
$this->set_var($ical['method'],'value',strtoupper($method));
if(!$GLOBALS['phpgw_info']['flags']['included_classes']['uicalendar'])
{
@@ -3273,13 +3285,24 @@
}
}
+ // use system's date info for caluculating
local timezone's offset in minutes
+ //
+ $gmt_offset =
date('O',$GLOBALS['phpgw']->datetime->users_localtime); // offset to GMT
+ $offset = intval(substr($gmt_offset, 1, 2)) *
60 + intval(substr($gmt_offset, 3, 2));
+ if ($offset > 0)
+ {
+ $event['start']['min'] -= $offset;
+ $event['end']['min'] -= $offset;
+ $event['modtime']['min'] -= $offset;
+ }
+
$ical_event['priority'] = $event['priority'];
$ical_event['class'] = intval($event['public']);
- $dtstart_mktime =
$so_event->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset;
+ $dtstart_mktime =
$so_event->maketime($event['start']);
$this->parse_value($ical_event,'dtstart',date('Ymd\THis\Z',$dtstart_mktime),'vevent');
- $dtend_mktime =
$so_event->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset;
+ $dtend_mktime =
$so_event->maketime($event['end']);
$this->parse_value($ical_event,'dtend',date('Ymd\THis\Z',$dtend_mktime),'vevent');
- $mod_mktime =
$so_event->maketime($event['modtime']) - $GLOBALS['phpgw']->datetime->tz_offset;
+ $mod_mktime =
$so_event->maketime($event['modtime']);
$this->parse_value($ical_event,'last_modified',date('Ymd\THis\Z',$mod_mktime),'vevent');
@reset($string_array);
while(list($ical_value,$event_value) =
each($string_array))
@@ -3313,11 +3336,15 @@
@reset($event['participants']);
while(list($part,$status) =
each($event['participants']))
{
-
$GLOBALS['phpgw']->accounts->get_account_name($accountid,$lid,$fname,$lname);
+
$GLOBALS['phpgw']->accounts->get_account_name($part,$lid,$fname,$lname);
$name = $fname.' '.$lname;
+
$owner_status =
$this->switch_partstat(intval($this->switch_phpgw_status($event['participants'][$part])));
- $owner_mailto =
'address@hidden';
- $str =
'CN="'.$name.'";PARTSTAT='.$owner_status.':'.$owner_mailto;
+
+ $mail_prefs =
$GLOBALS['phpgw']->preferences->create_email_preferences($part);
+ $mailto =
$mail_prefs['email']['address'];
+
+ $str =
'CN="'.$name.'";PARTSTAT='.$owner_status.':'.$mailto;
if($part == $event['owner'])
{
$str =
'ROLE=CHAIR;'.$str;
@@ -3326,7 +3353,10 @@
{
$str =
'ROLE=REQ-PARTICIPANT;'.$str;
}
-
$this->parse_value($ical_event,'attendee',$str,'vevent');
+ if ($method != 'reply' || $part
== $GLOBALS['phpgw_info']['user']['account_id'])
+ {
+
$this->parse_value($ical_event,'attendee',$str,'vevent');
+ }
if($part == $event['owner'])
{
$this->parse_value($ical_event,'organizer',$str,'vevent');
@@ -3419,7 +3449,7 @@
{
if($this->debug_str)
{
- echo $str."<br>\n";
+ echo $str."<br />\n";
}
}
}
====================================================
====================================================
====================================================
Index: calendar/inc/class.html.inc.php
diff -u calendar/inc/class.html.inc.php:1.4 calendar/inc/class.html.inc.php:1.5
--- calendar/inc/class.html.inc.php:1.4 Sun May 15 05:48:34 2005
+++ calendar/inc/class.html.inc.php Sun May 15 06:57:37 2005
@@ -1,9 +1,8 @@
<?php
/**************************************************************************\
- * phpGroupWare - InfoLog
*
+ * phpGroupWare - HTML creation class
*
* http://www.phpgroupware.org
*
* Written by Ralf Becker <address@hidden> *
- * originaly based on todo written by Joseph Engo <address@hidden> *
* --------------------------------------------
*
* 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 *
@@ -15,60 +14,169 @@
class html
{
+ var $user_agent,$ua_version; // 'mozilla','msie','konqueror'
+ var $prefered_img_title;
+
function html()
+ {
// should be Ok for all
HTML 4 compatible browsers
+ if (!eregi('compatible; ([a-z_]+)[/
]+([0-9.]+)',$_SERVER['HTTP_USER_AGENT'],$parts))
+ {
+
eregi('^([a-z_]+)/([0-9.]+)',$_SERVER['HTTP_USER_AGENT'],$parts);
+ }
+ list(,$this->user_agent,$this->ua_version) = $parts;
+ $this->user_agent = strtolower($this->user_agent);
+
+ $this->prefered_img_title = $this->user_agent == 'mozilla' &&
$this->ua_version < 5 ? 'ALT' : 'TITLE';
+ //echo "<p>HTTP_USER_AGENT='$GLOBALS[HTTP_USER_AGENT]',
UserAgent: '$this->user_agent', Version: '$this->ua_version', img_title:
'$this->prefered_img_title'</p>\n";
+ }
+
+ /*
+ * Function: Allows to show and select one item from an array
+ * Parameters: $name string with name of the
submitted var which holds the key of the selected item form array
+ * $key key(s)
of already selected item(s) from $arr, eg. '1' or '1,2' or array with keys
+ * $arr array
with items to select, eg. $arr = array ( 'y' => 'yes','n' => 'no','m' =>
'maybe');
+ * $no_lang if
!$no_lang send items through lang()
+ * $options
additional options (e.g. 'multiple')
+ * On submit $XXX is the key of the selected item
(XXX is the content of $name)
+ * Returns: string to set for a template or to echo
into html page
+ */
+ function select($name, $key, $arr=0,$no_lang=0,$options='',$multiple=0)
{
+ // should be in class common.sbox
+ if (!is_array($arr))
+ {
+ $arr = array('no','yes');
+ }
+ if (intval($multiple) > 0)
+ {
+ $options .= ' MULTIPLE SIZE="'.intval($multiple).'"';
+ if (substr($name,-2) != '[]')
+ {
+ $name .= '[]';
+ }
+ }
+ $out = "<select name=\"$name\" $options>\n";
+
+ if (is_array($key))
+ {
+ $key = implode(',',$key);
+ }
+ foreach($arr as $k => $text)
+ {
+ $out .= '<option value="'.htmlspecialchars($k).'"';
+
+ if("$k" == "$key" || strstr(",$key,",",$k,"))
+ {
+ $out .= " SELECTED";
+ }
+ $out .= ">" . ($no_lang || $text == '' ? $text :
lang($text)) . "</option>\n";
+ }
+ $out .= "</select>\n";
+
+ return $out;
}
- function input_hidden($vars,$value='')
+ function div($content,$options='')
+ {
+ return "<DIV $options>\n$content</DIV>\n";
+ }
+
+ function input_hidden($vars,$value='',$ignore_empty=True)
{
if (!is_array($vars))
{
$vars = array( $vars => $value );
}
- while (list($name,$value) = each($vars))
+ foreach($vars as $name => $value)
{
- if ($value && !($name == 'filter' && $value == 'none'))
// dont need to send all the empty vars
+ if (is_array($value))
{
- $html .= "<input type=hidden name=\"$name\"
value=\"$value\">\n";
+ $value = serialize($value);
+ }
+ if (!$ignore_empty || $value && !($name == 'filter' &&
$value == 'none')) // dont need to send all the empty vars
+ {
+ $html .= "<INPUT TYPE=\"HIDDEN\" NAME=\"$name\"
VALUE=\"".htmlspecialchars($value)."\">\n";
}
}
return $html;
}
- function input($name,$value='',$type='',$options='' )
+ function textarea($name,$value='',$options='' )
{
- if ($type) $type = "type=$type";
-
- return "<input $type name=\"$name\" value=\"$value\"
$options>\n";
+ return "<TEXTAREA name=\"$name\"
$options>".htmlspecialchars($value)."</TEXTAREA>\n";
}
- function submit_button($name,$lang,$onClick='')
+ function input($name,$value='',$type='',$options='' )
{
- return $this->input($name,lang($lang),'submit',$onClick ?
"onClick=\"$onClick\"" : '');
+ if ($type)
+ {
+ $type = 'TYPE="'.$type.'"';
+ }
+ return "<INPUT $type NAME=\"$name\"
VALUE=\"".htmlspecialchars($value)."\" $options>\n";
}
- /*
- * create absolute link: $url: phpgw-relative link, may include query
- * $vars:
query or array with query
- */
- function link($url,$vars='')
+ function
submit_button($name,$lang,$onClick='',$no_lang=0,$options='',$image='',$app='')
{
- if (is_array( $vars ))
+ if ($image != '')
{
- $v = array( );
- while(list($name,$value) = each($vars))
+ if (strpos($image,'.'))
{
- if ($value && !($name == 'filter' && $value ==
'none')) // dont need to send all the empty vars
- {
- $v[] = "$name=$value";
- }
+ $image = substr($image,0,strpos($image,'.'));
}
- $vars = implode('&',$v);
+ if (!($path =
$GLOBALS['phpgw']->common->image($app,$image)) &&
+ !($path =
$GLOBALS['phpgw']->common->image('phpgwapi',$image)))
+ {
+ $path = $image; // name may already
contain absolut path
+ }
+ $image = ' SRC="'.$path.'"';
+ }
+ if (!$no_lang)
+ {
+ $lang = lang($lang);
+ }
+ if (($accesskey = strstr($lang,'&')) && $accesskey[1] != ' ' &&
+ (($pos = strpos($accesskey,';')) === False || $pos > 5))
+ {
+ $lang_u =
str_replace('&'.$accesskey[1],'<u>'.$accesskey[1].'</u>',$lang);
+ $lang = str_replace('&','',$lang);
+ $options = 'ACCESSKEY="'.$accesskey[1].'" '.$options;
+ }
+ else
+ {
+ $accesskey = '';
+ $lang_u = $lang;
+ }
+ if ($onClick) $options .= " onClick=\"$onClick\"";
+
+ // <button> is not working in all cases if ($this->user_agent
== 'mozilla' && $this->ua_version < 5 || $image)
+ {
+ return $this->input($name,$lang,$image != '' ? 'IMAGE'
: 'SUBMIT',$options.$image);
+ }
+ return '<button TYPE="submit" NAME="'.$name.'"
VALUE="'.$lang.'" '.$options.'>'.
+ ($image != '' ? "<img$image
$this->prefered_img_title=\"$lang\"> " : '').
+ ($image == '' || $accesskey ? $lang_u : '').'</button>';
+ }
+
+ /*!
+ @function link
+ @abstract creates an absolut link + the query / get-variables
+ @param $url phpgw-relative link, may include query / get-vars
+ @parm $vars query or array ('name' => 'value', ...) with query
+ @example
link('/index.php?menuaction=infolog.uiinfolog.get_list',array('info_id' => 123))
+ @example =
'http://domain/phpgw-path/index.php?menuaction=infolog.uiinfolog.get_list&info_id=123'
+ @result absolut link already run through $phpgw->link
+ */
+ function link($url,$vars='')
+ {
+ if (!is_array($vars))
+ {
+ $vars = explode('&',$vars);
}
list($url,$v) = explode('?',$url); // url may contain
additional vars
if ($v)
- $vars .= ($vars ? '&' : '') . $v;
-
+ {
+ $vars += explode('&',$v);
+ }
return $GLOBALS['phpgw']->link($url,$vars);
}
@@ -77,49 +185,74 @@
return "<input type=\"checkbox\" name=\"$name\" value=\"True\""
.($value ? ' checked' : '') . ">\n";
}
- function form($content,$hidden_vars,$url,$url_vars='',$method='POST')
+ function
form($content,$hidden_vars,$url,$url_vars='',$name='',$options='',$method='POST')
{
- $html = "<form method=\"$method\"
action=\"".$this->link($url,$url_vars)."\">\n";
+ $html = "<form method=\"$method\" ".($name != '' ?
"name=\"$name\" " : '')."action=\"".$this->link($url,$url_vars)."\"
$options>\n";
$html .= $this->input_hidden($hidden_vars);
- if ($content) {
+ if ($content)
+ {
$html .= $content;
$html .= "</form>\n";
}
return $html;
}
- function form_1button($name,$lang,$hidden_vars,$url,$url_vars='',
- $method='POST')
+ function
form_1button($name,$lang,$hidden_vars,$url,$url_vars='',$form_name='',$method='POST')
{
return $this->form($this->submit_button($name,$lang),
-
$hidden_vars,$url,$url_vars,$method);
+ $hidden_vars,$url,$url_vars,$form_name,'',$method);
}
- /*
- * Example: $rows = array ( '1' => array( 1 => 'cell1', '.1' =>
'colspan=3',
- *
2 => 'cell2',
- *
3 => '3,, '.3' => 'width="10%"' ),
- *
'.1' => 'bgcolor="#0000FF"' );
- * table($rows,'width="100%"');
- */
- function table($rows,$params = '')
+ /*!
+ @function table
+ @abstracts creates table from array with rows
+ @discussion abstract the html stuff
+ @param $rows array with rows, each row is an array of the cols
+ @param $options options for the table-tag
+ @example $rows = array ( '1' => array( 1 => 'cell1', '.1' =>
'colspan=3',
+ @example 2 => 'cell2', 3 => 'cell3',
'.3' => 'width="10%"' ),
+ @example '.1' => 'BGCOLOR="#0000FF"' );
+ @example table($rows,'WIDTH="100%"') = '<table WIDTH="100%"><tr><td
colspan=3>cell1</td><td>cell2</td><td width="10%">cell3</td></tr></table>'
+ @result string with html-code of the table
+ */
+ function table($rows,$options = '',$no_table_tr=False)
{
- $html = "<table $params>\n";
+ $html = $no_table_tr ? '' : "<TABLE $options>\n";
- while (list($key,$row) = each($rows)) {
+ foreach($rows as $key => $row)
+ {
if (!is_array($row))
+ {
continue;
// parameter
- $html .= "\t<tr ".$rows['.'.$key].">\n";
- while (list($key,$cell) = each($row)) {
+ }
+ $html .= $no_table_tr && $key == 1 ? '' : "\t<TR
".$rows['.'.$key].">\n";
+
+ foreach($row as $key => $cell)
+ {
if ($key[0] == '.')
+ {
continue;
// parameter
- $html .= "\t\t<td
".$row['.'.$key].">$cell</td>\n";
+ }
+ $table_pos = strpos($cell,'<TABLE');
+ $td_pos = strpos($cell,'<TD');
+ if ($td_pos !== False && ($table_pos === False
|| $td_pos < $table_pos))
+ {
+ $html .= $cell;
+ }
+ else
+ {
+ $html .= "\t\t<TD
".$row['.'.$key].">$cell</TD>\n";
+ }
}
- $html .= "\t</tr>\n";
+ $html .= "\t</TR>\n";
+ }
+ $html .= "</TABLE>\n";
+
+ if ($no_table_tr)
+ {
+ $html = substr($html,0,-16);
}
- $html .= "</table>\n";
-
return $html;
}
@@ -134,28 +267,116 @@
return $html;
}
- function image( $app,$name,$title='',$opts='' )
+ function image( $app,$name,$title='',$options='' )
{
- $html = '<img
src="'.$GLOBALS['phpgw']->common->image($app,$name).'"';
-
- if ($title)
+ if (strstr($name,'.') === False)
+ {
+ $name .= '.gif';
+ }
+ if (!($path = $GLOBALS['phpgw']->common->image($app,$name)))
+ {
+ $path = $name; // name may already contain
absolut path
+ }
+ if (address@hidden($_SERVER['DOCUMENT_ROOT'] . $path))
{
- $html .= " alt=\"$title\" title=\"$title\"";
+ return $title;
}
- if ($opts)
+ if ($title)
{
- $html .= " $opts";
+ $options .= "
$this->prefered_img_title=\"".htmlspecialchars($title).'"';
}
- return $html . '>';
+ return "<IMG SRC=\"$path\" $options>";
}
function a_href( $content,$url,$vars='',$options='')
{
+ if (!strstr($url,'/') && count(explode('.',$url)) == 3)
+ {
+ $url = "/index.php?menuaction=$url";
+ }
+ if (is_array($url))
+ {
+ $vars = $url;
+ $url = '/index.php';
+ }
return '<a href="'.$this->link($url,$vars).'"
'.$options.'>'.$content.'</a>';
}
-
+
function bold($content)
{
return '<b>'.$content.'</b>';
}
+
+ function italic($content)
+ {
+ return '<i>'.$content.'</i>';
+ }
+
+ function hr($width,$options='')
+ {
+ if ($width)
+ $options .= " WIDTH=$width";
+ return "<hr $options>\n";
+ }
+
+ /*!
+ @function formatOptions
+ @abstract formats option-string for most of the above functions
+ @param $options String (or Array) with option-values eg. '100%,,1'
+ @param $names String (or Array) with the option-names eg.
'WIDTH,HEIGHT,BORDER'
+ @example formatOptions('100%,,1','WIDTH,HEIGHT,BORDER') = '
WIDTH="100%" BORDER="1"'
+ @result option string
+ */
+ function formatOptions($options,$names)
+ {
+ if (!is_array($options)) $options = explode(',',$options);
+ if (!is_array($names)) $names = explode(',',$names);
+
+ while (list($n,$val) = each($options))
+ if ($val != '' && $names[$n] != '')
+ $html .= ' '.$names[$n].'="'.$val.'"';
+
+ return $html;
+ }
+
+ /*!
+ @function themeStyles
+ @abstract returns simple stylesheet (incl. <STYLE> tags) for nextmatch
row-colors
+ @result the classes 'th' = nextmatch header, 'row_on'+'row_off' =
alternating rows
+ */
+ function themeStyles()
+ {
+ return $this->style($this->theme2css());
+ }
+
+ /*!
+ @function theme2css
+ @abstract returns simple stylesheet for nextmatch row-colors
+ @result the classes 'th' = nextmatch header, 'row_on'+'row_off' =
alternating rows
+ */
+ function theme2css()
+ {
+ return
+ ".th { background:
".$GLOBALS['phpgw_info']['theme']['th_bg']."; font-weight: bold; }\n".
+ ".row_on,.th_bright { background:
".$GLOBALS['phpgw_info']['theme']['row_on']."; }\n".
+ ".row_off { background:
".$GLOBALS['phpgw_info']['theme']['row_off']."; }\n";
+ }
+
+ function style($styles)
+ {
+ return $styles ? "<STYLE
type=\"text/css\">\n<!--\n$styles\n-->\n</STYLE>" : '';
+ }
+
+ function label($content,$id='',$accesskey='',$options='')
+ {
+ if ($id != '')
+ {
+ $id = " FOR=\"$id\"";
+ }
+ if ($accesskey != '')
+ {
+ $accesskey = " ACCESSKEY=\"$accesskey\"";
+ }
+ return "<LABEL$id$accesskey $options>$content</LABEL>";
+ }
}
====================================================
Index: calendar/inc/class.holidaycalc_US.inc.php
diff -u calendar/inc/class.holidaycalc_US.inc.php:1.9
calendar/inc/class.holidaycalc_US.inc.php:1.10
--- calendar/inc/class.holidaycalc_US.inc.php:1.9 Sun May 15 05:48:34 2005
+++ calendar/inc/class.holidaycalc_US.inc.php Sun May 15 06:57:37 2005
@@ -15,14 +15,14 @@
class holidaycalc {
- function calculate_date($holiday, &$holidays, $year, $datetime, &$i)
+ function calculate_date($holiday, &$holidays, $year, &$i)
{
// if($holiday['day'] == 0 && $holiday['dow'] != 0 &&
$holiday['occurence'] != 0)
if($holiday['day'] == 0 && $holiday['occurence'] != 0)
{
if($holiday['occurence'] != 99)
{
- $dow =
$datetime->day_of_week($year,$holiday['month'],1);
+ $dow =
$GLOBALS['phpgw']->datetime->day_of_week($year,$holiday['month'],1);
$day = (((7 * $holiday['occurence']) - 6) +
((($holiday['dow'] + 7) - $dow) % 7));
$day += ($day < 1 ? 7 : 0);
// What is the point of this?
@@ -31,7 +31,7 @@
// Sometimes the 5th occurance of a weekday (ie
the 5th monday)
// can spill over to the next month. This
prevents that.
- $ld =
$datetime->days_in_month($holiday['month'],$year);
+ $ld =
$GLOBALS['phpgw']->datetime->days_in_month($holiday['month'],$year);
if ($day > $ld)
{
return;
@@ -39,8 +39,8 @@
}
else
{
- $ld =
$datetime->days_in_month($holiday['month'],$year);
- $dow =
$datetime->day_of_week($year,$holiday['month'],$ld);
+ $ld =
$GLOBALS['phpgw']->datetime->days_in_month($holiday['month'],$year);
+ $dow =
$GLOBALS['phpgw']->datetime->day_of_week($year,$holiday['month'],$ld);
$day = $ld - (($dow + 7) - $holiday['dow']) % 7
;
}
}
@@ -49,7 +49,7 @@
$day = $holiday['day'];
if($holiday['observance_rule'] == True)
{
- $dow =
$datetime->day_of_week($year,$holiday['month'],$day);
+ $dow =
$GLOBALS['phpgw']->datetime->day_of_week($year,$holiday['month'],$day);
// This now calulates Observed holidays and
creates a new entry for them.
if($dow == 0)
{
====================================================
Index: calendar/inc/class.boholiday.inc.php
diff -u calendar/inc/class.boholiday.inc.php:1.13
calendar/inc/class.boholiday.inc.php:1.14
--- calendar/inc/class.boholiday.inc.php:1.13 Sun May 15 05:48:34 2005
+++ calendar/inc/class.boholiday.inc.php Sun May 15 06:57:37 2005
@@ -46,21 +46,18 @@
function boholiday()
{
- $this->so = CreateObject('calendar.soholiday');
-
- if(isset($GLOBALS['locale'])) { $this->locales[] =
$GLOBALS['locale']; }
-
- if(isset($GLOBALS['start'])) { $this->start =
intval($GLOBALS['start']); } else { $this->start = 0; }
-
- if(isset($GLOBALS['query'])) { $this->query =
$GLOBALS['query']; }
-
- if(isset($GLOBALS['sort'])) { $this->sort =
$GLOBALS['sort']; }
-
- if(isset($GLOBALS['order'])) { $this->order =
$GLOBALS['order']; }
-
- if(isset($GLOBALS['id'])) { $this->id =
$GLOBALS['id']; }
-
- if(isset($GLOBALS['year'])) { $this->year =
$GLOBALS['year']; } else { $this->year = date('Y'); }
+ $this->so = CreateObject('calendar.soholiday');
+ $this->start =
get_var('start',Array('POST','GET','DEFAULT'),0);
+ $this->query = get_var('query',Array('POST','GET'));
+ $this->sort = get_var('sort',Array('POST','GET'));
+ $this->order = get_var('order',Array('POST','GET'));
+ $this->id = get_var('id',array('POST','GET'));
+ $this->year =
get_var('year',array('POST','GET','DEFAULT'),date('Y'));
+ $this->locale = get_var('locale',array('POST','GET'));
+ if ($this->locale)
+ {
+ $this->locales[] = $this->locale;
+ }
if($this->debug)
{
@@ -75,7 +72,7 @@
{
if($this->debug)
{
- echo "BO : Reading Holiday ID : ".$id."<br>\n";
+ echo "BO : Reading Holiday ID : ".$id."<br
/>\n";
}
if(!$id)
@@ -135,7 +132,7 @@
function accept_holiday()
{
- $send_back_to =
str_replace('submitlocale','holiday_admin',$GLOBALS['HTTP_REFERER']);
+ $send_back_to =
str_replace('submitlocale','holiday_admin',$_SERVER['HTTP_REFERER']);
if(address@hidden>locales[0])
{
Header('Location: '.$send_back_to);
@@ -143,13 +140,13 @@
$send_back_to =
str_replace('&locale='.$this->locales[0],'',$send_back_to);
$file = './holidays.'.$this->locales[0];
- if(!file_exists($file) &&
count($GLOBALS['HTTP_POST_VARS']['name']))
+ if(!file_exists($file) && count($_POST['name']))
{
- $c_holidays =
count($GLOBALS['HTTP_POST_VARS']['name']);
+ $c_holidays = count($_POST['name']);
$fp = fopen($file,'w');
for($i=0;$i<$c_holidays;$i++)
{
-
fwrite($fp,$this->locales[0]."\t".$GLOBALS['HTTP_POST_VARS']['name'][$i]."\t".$GLOBALS['HTTP_POST_VARS']['day'][$i]."\t".$GLOBALS['HTTP_POST_VARS']['month'][$i]."\t".$GLOBALS['HTTP_POST_VARS']['occurence'][$i]."\t".$GLOBALS['HTTP_POST_VARS']['dow'][$i]."\t".$GLOBALS['HTTP_POST_VARS']['observance'][$i]."\n");
+
fwrite($fp,$this->locales[0]."\t".$_POST['name'][$i]."\t".$_POST['day'][$i]."\t".$_POST['month'][$i]."\t".$_POST['occurence'][$i]."\t".$_POST['dow'][$i]."\t".$_POST['observance'][$i]."\n");
}
fclose($fp);
}
@@ -176,13 +173,12 @@
function prepare_read_holidays($year=0,$owner=0)
{
- $datetime = CreateObject('phpgwapi.datetime');
- $this->year = (isset($year) && $year >
0?$year:$GLOBALS['phpgw']->common->show_date(time() -
$datetime->tz_offset,'Y'));
+ $this->year = (isset($year) && $year >
0?$year:$GLOBALS['phpgw']->common->show_date(time() -
$GLOBALS['phpgw']->datetime->tz_offset,'Y'));
$this->owner =
($owner?$owner:$GLOBALS['phpgw_info']['user']['account_id']);
if($this->debug)
{
- echo 'Setting Year to :
'.$this->year.'<br>'."\n";
+ echo 'Setting Year to : '.$this->year.'<br
/>'."\n";
}
if(@$GLOBALS['phpgw_info']['user']['preferences']['common']['country'])
@@ -227,8 +223,6 @@
{
if($this->so->holiday_total($locale) == 0)
{
- global $HTTP_HOST, $SERVER_PORT;
-
@set_time_limit(0);
/* get the file that contains the calendar
events for your locale */
@@ -240,10 +234,10 @@
}
else
{
- $pos = strpos('
'.$GLOBALS['phpgw_info']['server']['webserver_url'],$HTTP_HOST);
+ $pos = strpos('
'.$GLOBALS['phpgw_info']['server']['webserver_url'],$GLOBALS['HTTP_HOST']);
if($pos == 0)
{
- switch($SERVER_PORT)
+ switch($GLOBALS['SERVER_PORT'])
{
case 80:
$http_protocol
= 'http://';
@@ -252,16 +246,16 @@
$http_protocol
= 'https://';
break;
}
- $server_host =
$http_protocol.$HTTP_HOST.$GLOBALS['phpgw_info']['server']['webserver_url'];
+ $server_host =
$http_protocol.$GLOBALS['HTTP_HOST'].$GLOBALS['phpgw_info']['server']['webserver_url'];
}
else
{
$server_host =
$GLOBALS['phpgw_info']['server']['webserver_url'];
}
- $load_from =
$server_host.'/calendar/setup';
+ $load_from =
$server_host.'/calendar/phpgroupware.org';
}
-// echo 'Loading from:
'.$load_from.'/holidays.'.strtoupper($locale)."<br>\n";
- $lines =
$network->gethttpsocketfile($load_from.'/holidays.'.strtoupper($locale));
+// echo 'Loading from:
'.$load_from.'/holidays.'.strtoupper($locale).".txt<br />\n";
+ $lines =
$network->gethttpsocketfile($load_from.'/holidays.'.strtoupper($locale).'.txt');
if (!$lines)
{
return false;
@@ -269,7 +263,7 @@
$c_lines = count($lines);
for($i=0;$i<$c_lines;$i++)
{
-// echo 'Line #'.$i.' :
'.$lines[$i]."<br>\n";
+// echo 'Line #'.$i.' : '.$lines[$i]."<br
/>\n";
$holiday = explode("\t",$lines[$i]);
if(count($holiday) == 7)
{
@@ -296,7 +290,7 @@
{
if(@$GLOBALS['HTTP_POST_VARS']['submit'])
{
- $holiday =
$GLOBALS['HTTP_POST_VARS']['holiday'];
+ $holiday = get_var('holiday',Array('POST'));
if(empty($holiday['mday']))
{
@@ -373,7 +367,7 @@
$new_holidays = Array();
for($i=0;$i<count($holidays);$i++)
{
-// echo "Setting Holidays Date :
".date('Ymd',$holidays[$i]['date'])."<br>\n";
+// echo "Setting Holidays Date : ".date('Ymd',$holidays[$i]['date'])."<br
/>\n";
$new_holidays[date('Ymd',$holidays[$i]['date'])][] = $holidays[$i];
}
return $new_holidays;
@@ -393,7 +387,6 @@
}
$temp_locale =
$GLOBALS['phpgw_info']['user']['preferences']['common']['country'];
- $datetime = CreateObject('phpgwapi.datetime');
for($i=0;$i<count($holidays);$i++)
{
$c = $i;
@@ -406,14 +399,13 @@
$GLOBALS['phpgw_info']['user']['preferences']['common']['country'] =
$holidays[$i]['locale'];
$holidaycalc =
CreateObject('calendar.holidaycalc');
}
- $holidays[$i]['date'] =
$holidaycalc->calculate_date($holidays[$i], $holidays, $this->year, $datetime,
$c);
+ $holidays[$i]['date'] =
$holidaycalc->calculate_date($holidays[$i], $holidays, $this->year, $c);
if($c != $i)
{
$i = $c;
}
}
unset($holidaycalc);
- unset($datetime);
$this->holidays =
$this->sort_holidays_by_date($holidays);
$this->cached_holidays =
$this->set_holidays_to_date($this->holidays);
$GLOBALS['phpgw_info']['user']['preferences']['common']['country'] =
$temp_locale;
====================================================
Index: calendar/inc/class.bocalendar.inc.php
diff -u calendar/inc/class.bocalendar.inc.php:1.92
calendar/inc/class.bocalendar.inc.php:1.93
--- calendar/inc/class.bocalendar.inc.php:1.92 Sun May 15 05:48:34 2005
+++ calendar/inc/class.bocalendar.inc.php Sun May 15 06:57:37 2005
@@ -17,15 +17,16 @@
class bocalendar
{
var $public_functions = Array(
- 'read_entry' => True,
- 'delete_entry' => True,
- 'delete_calendar' => True,
- 'change_owner' => True,
- 'update' => True,
- 'preferences' => True,
- 'store_to_cache' => True,
- 'export_event' => True,
- 'reinstate' => True
+ 'read_entry' => True,
+ 'delete_entry' => True,
+ 'delete_calendar' => True,
+ 'change_owner' => True,
+ 'update' => True,
+ 'check_set_default_prefs' => True,
+ 'store_to_cache' => True,
+ 'export_event' => True,
+ 'send_alarm' => True,
+ 'reinstate' => True
);
var $soap_functions = Array(
@@ -92,7 +93,7 @@
);
var $debug = False;
- // var $debug = True;
+// var $debug = True;
var $so;
var $cached_events;
@@ -117,24 +118,38 @@
var $modified;
var $deleted;
var $added;
+
var $is_group = False;
+
var $soap = False;
+
var $use_session = False;
+
var $today;
+ var $debug_string;
var $sortby;
var $num_months;
function bocalendar($session=0)
{
+ $this->cat = CreateObject('phpgwapi.categories');
$this->grants =
$GLOBALS['phpgw']->acl->get_grants('calendar');
@reset($this->grants);
- while(list($grantor,$rights) = each($this->grants))
+ if(DEBUG_APP)
{
- print_debug('Grantor',$grantor);
- print_debug('Rights',$rights);
+ if(floor(phpversion()) >= 4)
+ {
+ $this->debug_string = '';
+ ob_start();
+ }
+
+ foreach($this->grants as $grantor => $rights)
+ {
+ print_debug('Grantor',$grantor);
+ print_debug('Rights',$rights);
+ }
}
- @reset($this->grants);
print_debug('Read use_session',$session);
@@ -147,15 +162,14 @@
print_debug('Owner',$this->owner);
$this->prefs['calendar'] =
$GLOBALS['phpgw_info']['user']['preferences']['calendar'];
+ $this->check_set_default_prefs();
- $owner =
(isset($GLOBALS['owner'])?$GLOBALS['owner']:'');
- $owner =
(isset($GLOBALS['HTTP_GET_VARS']['owner'])?$GLOBALS['HTTP_GET_VARS']['owner']:$owner);
- $owner = ($owner=='' &&
isset($GLOBALS['HTTP_POST_VARS']['owner'])?$GLOBALS['HTTP_POST_VARS']['owner']:$owner);
+ $owner =
get_var('owner',array('GET','POST'),$GLOBALS['owner']);
-
ereg('menuaction=([a-zA-Z.]+)',$GLOBALS['HTTP_REFERER'],$regs);
+
ereg('menuaction=([a-zA-Z.]+)',$_SERVER['HTTP_REFERER'],$regs);
$from = $regs[1];
- if ((substr($GLOBALS['PHP_SELF'],-8) == 'home.php' &&
substr($this->prefs['calendar']['defaultcalendar'],0,7) == 'planner'
- || $GLOBALS['HTTP_GET_VARS']['menuaction'] ==
'calendar.uicalendar.planner' &&
+ if ((substr($_SERVER['PHP_SELF'],-8) == 'home.php' &&
substr($this->prefs['calendar']['defaultcalendar'],0,7) == 'planner'
+ || $GLOBALS['phpgw_info']['menuaction'] ==
'calendar.uicalendar.planner' &&
$from != 'calendar.uicalendar.planner' &&
!$this->save_owner)
&&
intval($this->prefs['calendar']['planner_start_with_group']) > 0)
{
@@ -164,12 +178,12 @@
$this->save_owner = $this->owner;
$owner =
'g_'.$this->prefs['calendar']['planner_start_with_group'];
}
- elseif ($GLOBALS['HTTP_GET_VARS']['menuaction'] !=
'calendar.uicalendar.planner' &&
+ elseif ($GLOBALS['phpgw_info']['menuaction'] !=
'calendar.uicalendar.planner' &&
$this->save_owner)
{
// leaving planner with an unchanged user/owner
==> setting owner back to save_owner
//
- $owner =
intval(isset($GLOBALS['HTTP_GET_VARS']['owner']) ?
$GLOBALS['HTTP_GET_VARS']['owner'] : $this->save_owner);
+ $owner = intval(isset($_GET['owner']) ?
$_GET['owner'] : $this->save_owner);
unset($this->save_owner);
}
elseif (!empty($owner) && $owner != $this->owner &&
$from == 'calendar.uicalendar.planner')
@@ -208,12 +222,21 @@
}
$this->holiday_color =
(substr($GLOBALS['phpgw_info']['theme']['bg07'],0,1)=='#'?'':'#').$GLOBALS['phpgw_info']['theme']['bg07'];
- $this->printer_friendly =
(intval(get_var('friendly',Array('GET','POST','DEFAULT'),0)) == 1?True:False);
+ $friendly =
(isset($_GET['friendly'])?$_GET['friendly']:'');
+ $friendly = ($friendly=='' &&
isset($_POST['friendly'])?$_POST['friendly']:$friendly);
- $this->filter =
get_var('filter',Array('POST','DEFAULT'),'
'.$this->prefs['calendar']['defaultfilter'].' ');
+ $this->printer_friendly = (intval($friendly) ==
1?True:False);
- $this->sortby =
get_var('sortby',Array('POST'),$this->sortby);
- if(empty($this->sortby))
+ if(isset($_POST['filter'])) { $this->filter =
$_POST['filter']; }
+ if(isset($_POST['sortby'])) { $this->sortby =
$_POST['sortby']; }
+ if(isset($_POST['cat_id'])) { $this->cat_id =
$_POST['cat_id']; }
+
+ if(!isset($this->filter))
+ {
+ $this->filter = '
'.$this->prefs['calendar']['defaultfilter'].' ';
+ }
+
+ if(!isset($this->sortby))
{
$this->sortby =
$this->prefs['calendar']['defaultcalendar'] == 'planner_user' ? 'user' :
'category';
}
@@ -223,25 +246,56 @@
$this->filter = ' all ';
}
- $this->cat_id = get_var('cat_id',Array('POST'));
-
$this->so = CreateObject('calendar.socalendar',
Array(
'owner' => $this->owner,
- 'filter' =>
$this->filter,
+ 'filter' => $this->filter,
'category' => $this->cat_id,
'g_owner' => $this->g_owner
)
);
+ $this->rpt_day = array( // need to be after creation of
socalendar
+ MCAL_M_SUNDAY => 'Sunday',
+ MCAL_M_MONDAY => 'Monday',
+ MCAL_M_TUESDAY => 'Tuesday',
+ MCAL_M_WEDNESDAY => 'Wednesday',
+ MCAL_M_THURSDAY => 'Thursday',
+ MCAL_M_FRIDAY => 'Friday',
+ MCAL_M_SATURDAY => 'Saturday'
+ );
+ if($this->bo->prefs['calendar']['weekdaystarts'] !=
'Sunday')
+ {
+ $mcals = array_keys($this->rpt_day);
+ $days = array_values($this->rpt_day);
+ $this->rpt_day = array();
+ list($n) = $found =
array_keys($days,$this->prefs['calendar']['weekdaystarts']);
+ for ($i = 0; $i < 7; ++$i,++$n)
+ {
+ $this->rpt_day[$mcals[$n % 7]] =
$days[$n % 7];
+ }
+ }
+ $this->rpt_type = Array(
+ MCAL_RECUR_NONE => 'None',
+ MCAL_RECUR_DAILY => 'Daily',
+ MCAL_RECUR_WEEKLY => 'Weekly',
+ MCAL_RECUR_MONTHLY_WDAY => 'Monthly (by day)',
+ MCAL_RECUR_MONTHLY_MDAY => 'Monthly (by date)',
+ MCAL_RECUR_YEARLY => 'Yearly'
+ );
+
$localtime =
$GLOBALS['phpgw']->datetime->users_localtime;
- $date = get_var('date',Array('GET','POST','GLOBAL'));
- $year = get_var('year',Array('GET','POST'));
- $month = get_var('month',Array('GET','POST'));
- $day = get_var('day',Array('GET','POST'));
- $num_months = get_var('num_months',Array('GET','POST'));
-
- if(isset($date) && $date!='')
+ $date = intval(get_var('date', array('GET', 'POST'),
0));
+
+ $year = intval(get_var('year', array('GET', 'POST'),
0));
+
+ $month = intval(get_var('month', array('GET', 'POST'),
0));
+
+ $day = intval(get_var('day', array('GET', 'POST'), 0));
+
+ $num_months = intval(get_var('num_months', array('GET',
'POST'), 0));
+
+ if($date !== 0)
{
$this->year = intval(substr($date,0,4));
$this->month = intval(substr($date,4,2));
@@ -249,46 +303,54 @@
}
else
{
- if(isset($year) && $year!='')
+ if($year !== 0)
{
$this->year = $year;
}
else
{
- $this->year =
date('Y',$GLOBALS['phpgw']->datetime->users_localtime);
+ $this->year = date('Y',$localtime);
}
- if(isset($month) && $month!='')
+ if($month !== 0)
{
$this->month = $month;
}
else
{
- $this->month =
date('m',$GLOBALS['phpgw']->datetime->users_localtime);
+ $this->month = date('m',$localtime);
}
- if(isset($day) && $day!='')
+ if($day !== 0)
{
$this->day = $day;
}
else
{
- $this->day =
date('d',$GLOBALS['phpgw']->datetime->users_localtime);
+ $this->day = date('d',$localtime);
}
}
- if(isset($num_months) && $num_months!='')
+ if($num_months !== 0)
{
$this->num_months = $num_months;
}
- elseif($this->num_months == 0)
+ else
{
$this->num_months = 1;
}
-
$this->today =
date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime);
- print_debug('BO Filter','('.$this->filter.')');
- print_debug('Owner',$this->owner);
+ if(DEBUG_APP)
+ {
+ print_debug('BO Filter','('.$this->filter.')');
+ print_debug('Owner',$this->owner);
+ print_debug('Today',$this->today);
+ if(floor(phpversion()) >= 4)
+ {
+ $this->debug_string .=
ob_get_contents();
+ ob_end_clean();
+ }
+ }
}
function list_methods($_type='xmlrpc')
@@ -365,6 +427,7 @@
function set_owner_to_group($owner)
{
+
print_debug('calendar::bocalendar::set_owner_to_group:owner',$owner);
$this->owner = intval($owner);
$this->is_group = True;
settype($this->g_owner,'array');
@@ -410,7 +473,19 @@
'return_to' => $this->return_to
);
}
- print_debug('Save',_debug_array($data,False));
+ if($this->debug)
+ {
+ if(floor(phpversion()) >= 4)
+ {
+ ob_start();
+ }
+ echo '<!--
'."\n".'Save:'."\n"._debug_array($data,False)."\n".' -->'."\n";
+ if(floor(phpversion()) >= 4)
+ {
+ $this->debug_string .=
ob_get_contents();
+ ob_end_clean();
+ }
+ }
$GLOBALS['phpgw']->session->appsession('session_data','calendar',$data);
}
}
@@ -437,6 +512,14 @@
if($this->check_perms(PHPGW_ACL_READ,$id))
{
$event = $this->so->read_entry($id);
+
+ /*FIXME: Test and uncomment
+ if( strpos($event['uid'],'-') === 0)
+ {
+ $event['uid'] = md5($event['title']) .
'-' . md5($event['description']) . '@' . $_SERVER['HOSTNAME'];
+ }
+ */
+
if(!isset($event['participants'][$this->owner])
&& $this->user_is_a_member($event,$this->owner))
{
$this->so->add_attribute('participants','U',intval($this->owner));
@@ -453,12 +536,13 @@
{
$temp_event = $this->get_cached_event();
$event =
$this->read_entry(intval($param['id']));
-
+// if($this->owner == $event['owner'])
+// {
$exception_time =
mktime($event['start']['hour'],$event['start']['min'],0,$param['month'],$param['day'],$param['year'])
- $GLOBALS['phpgw']->datetime->tz_offset;
$event['recur_exception'][] =
intval($exception_time);
$this->so->cal->event = $event;
- print_debug('exception
time',$event['recur_exception'][count($event['recur_exception']) -1]);
- print_debug('count event
exceptions',count($event['recur_exception']));
+// print_debug('exception
time',$event['recur_exception'][count($event['recur_exception']) -1]);
+// print_debug('count event
exceptions',count($event['recur_exception']));
$this->so->add_entry($event);
$cd = 16;
@@ -477,6 +561,9 @@
{
if($this->check_perms(PHPGW_ACL_DELETE,$id))
{
+// $temp_event = $this->read_entry($id);
+// if($this->owner == $temp_event['owner'])
+// {
$this->so->delete_entry($id);
$cd = 16;
}
@@ -484,6 +571,7 @@
{
$cd = 60;
}
+// }
return $cd;
}
@@ -502,7 +590,7 @@
print_debug('exception
time',$event['recur_exception'][intval($value)]);
unset($event['recur_exception'][intval($value)]);
print_debug('count event
exceptions',count($event['recur_exception']));
- }
+ }
}
else
{
@@ -560,17 +648,40 @@
function search_keywords($keywords)
{
- return $this->so->list_events_keyword($keywords);
+ $type =
$GLOBALS['phpgw']->accounts->get_type($this->owner);
+
+ if($type == 'g')
+ {
+ $members =
$GLOBALS['phpgw']->acl->get_ids_for_location($this->owner, 1, 'phpgw_group');
+ }
+ else
+ {
+ $members = array_keys($this->grants);
+
+ if (!in_array($this->owner,$members))
+ {
+ $members[] = $this->owner;
+ }
+ }
+ foreach($members as $n => $uid)
+ {
+ if (!($this->grants[$uid] & PHPGW_ACL_READ))
+ {
+ unset($members[$n]);
+ }
+ }
+ return
$this->so->list_events_keyword($keywords,$members);
}
function update($params='')
{
- $l_cal = (@isset($params['cal']) &&
$params['cal']?$params['cal']:$GLOBALS['HTTP_POST_VARS']['cal']);
- $l_participants =
(@$params['participants']?$params['participants']:$GLOBALS['HTTP_POST_VARS']['participants']);
- $l_categories =
(@$params['categories']?$params['categories']:$GLOBALS['HTTP_POST_VARS']['categories']);
- $l_start = (@isset($params['start']) &&
$params['start']?$params['start']:$GLOBALS['HTTP_POST_VARS']['start']);
- $l_end = (@isset($params['end']) &&
$params['end']?$params['end']:$GLOBALS['HTTP_POST_VARS']['end']);
- $l_recur_enddate = (@isset($params['recur_enddate']) &&
$params['recur_enddate']?$params['recur_enddate']:$GLOBALS['HTTP_POST_VARS']['recur_enddate']);
+ $l_cal = (@isset($params['cal']) &&
$params['cal']?$params['cal']:$_POST['cal']);
+ $l_participants =
(@$params['participants']?$params['participants']:$_POST['participants']);
+ $l_categories =
(@$params['categories']?$params['categories']:$_POST['categories']);
+ $l_start = (@isset($params['start']) &&
$params['start']?$params['start']:$_POST['start']);
+ $l_end = (@isset($params['end']) &&
$params['end']?$params['end']:$_POST['end']);
+ $l_recur_enddate = (@isset($params['recur_enddate']) &&
$params['recur_enddate']?$params['recur_enddate']:$_POST['recur_enddate']);
+ $l_recur_exception = explode (",",
$_POST['recur_exception']);
$send_to_ui = True;
if($this->debug)
@@ -581,10 +692,10 @@
{
$send_to_ui = False;
}
-
+
print_debug('ID',$l_cal['id']);
- if(get_var('readsess',Array('GET')))
+ if(isset($_GET['readsess']))
{
$event = $this->restore_from_appsession();
$event['title'] = stripslashes($event['title']);
@@ -598,7 +709,7 @@
'readsess' => 1
)
);
- exit;
+
$GLOBALS['phpgw']->common->phpgw_exit(True);
}
$overlapping_events = False;
}
@@ -607,11 +718,10 @@
if((!$l_cal['id'] &&
!$this->check_perms(PHPGW_ACL_ADD)) || ($l_cal['id'] &&
!$this->check_perms(PHPGW_ACL_EDIT,$l_cal['id'])))
{
ExecMethod('calendar.uicalendar.index');
-
$GLOBALS['phpgw_info']['flags']['nodisplay'] = True;
- exit;
+ $GLOBALS['phpgw']->common->phpgw_exit();
}
- print_debug('prior to fix_update_time()');
+ print_debug('Prior to fix_update_time()');
$this->fix_update_time($l_start);
$this->fix_update_time($l_end);
@@ -654,6 +764,10 @@
$l_recur_enddate['month'] = 0;
$l_recur_enddate['mday'] = 0;
}
+ elseif (isset($l_recur_enddate['str']))
+ {
+ $l_recur_enddate =
$this->jscal->input2date($l_recur_enddate['str'],False,'mday');
+ }
switch(intval($l_cal['recur_type']))
{
@@ -665,6 +779,13 @@
break;
case MCAL_RECUR_WEEKLY:
$l_cal['recur_data'] =
intval($l_cal['rpt_sun']) + intval($l_cal['rpt_mon']) +
intval($l_cal['rpt_tue']) + intval($l_cal['rpt_wed']) +
intval($l_cal['rpt_thu']) + intval($l_cal['rpt_fri']) +
intval($l_cal['rpt_sat']);
+ if (is_array($l_cal['rpt_day']))
+ {
+ foreach
($l_cal['rpt_day'] as $mask)
+ {
+
$l_cal['recur_data'] |= intval($mask);
+ }
+ }
$this->so->set_recur_weekly(intval($l_recur_enddate['year']),intval($l_recur_enddate['month']),intval($l_recur_enddate['mday']),intval($l_cal['recur_interval']),$l_cal['recur_data']);
break;
case MCAL_RECUR_MONTHLY_MDAY:
@@ -696,7 +817,7 @@
}
elseif($acct_type == 'g')
{
-
$part[intval($parts[$i])] = $accept_type;
+
//$part[intval($parts[$i])] = $accept_type;
$groups[] = $parts[$i];
/* This pulls ALL users
of a group and makes them as participants to the event */
/* I would like to turn
this back into a group thing. */
@@ -748,15 +869,50 @@
$this->so->add_attribute('owner',$l_cal['owner']);
}
$this->so->add_attribute('priority',$l_cal['priority']);
+
+ foreach($l_cal as $name => $value)
+ {
+ if ($name[0] == '#') // Custom field
+ {
+
$this->so->add_attribute($name,stripslashes($value));
+ }
+ }
+ if (isset($_POST['preserved']) &&
is_array($preserved = unserialize(stripslashes($_POST['preserved']))))
+ {
+ foreach($preserved as $name => $value)
+ {
+ switch($name)
+ {
+ case 'owner':
+
$this->so->add_attribute('participants',$value,$l_cal['owner']);
+ break;
+ default:
+
$this->so->add_attribute($name,str_replace(array('&','"','<','>'),array('&','"','<','>'),$value));
+ }
+ }
+ }
$event = $this->get_cached_event();
- $event['title'] =
$GLOBALS['phpgw']->db->db_addslashes($event['title']);
- $event['description'] =
$GLOBALS['phpgw']->db->db_addslashes($event['description']);
- $this->store_to_appsession($event);
- $datetime_check =
$this->validate_update($event);
+ if ($l_cal['alarmdays'] > 0 ||
$l_cal['alarmhours'] > 0 ||
+ $l_cal['alarmminutes'] > 0)
+ {
+ $time =
$this->maketime($event['start']) -
+ ($l_cal['alarmdays'] * 24 *
3600) -
+ ($l_cal['alarmhours'] * 3600) -
+ ($l_cal['alarmminutes'] * 60);
+
+ $event['alarm'][] = Array(
+ 'time' => $time,
+ 'owner' => $this->owner,
+ 'enabled' => 1
+ );
+ }
- print_debug('bo->validate_update()
returnval',$datetime_check);
+ $event[recur_exception] = $l_recur_exception;
+ $this->store_to_appsession($event);
+ $datetime_check =
$this->validate_update($event);
+ print_debug('bo->validated_update()
returnval',$datetime_check);
if($datetime_check)
{
ExecMethod('calendar.uicalendar.edit',
@@ -765,7 +921,7 @@
'readsess' => 1
)
);
- exit;
+
$GLOBALS['phpgw']->common->phpgw_exit(True);
}
if($event['id'])
@@ -785,7 +941,6 @@
$event_ids
);
}
-
if($overlapping_events)
{
if($send_to_ui)
@@ -798,7 +953,7 @@
'this_event' =>
$event
)
);
- exit;
+
$GLOBALS['phpgw']->common->phpgw_exit(True);
}
else
{
@@ -809,7 +964,6 @@
{
if(!$event['id'])
{
- print_debug('Creating a new event.');
$this->so->cal->event = $event;
$this->so->add_entry($event);
$this->send_update(MSG_ADDED,$event['participants'],'',$this->get_cached_event());
@@ -817,12 +971,12 @@
}
else
{
- print_debug('Updating an existing
event.');
+ print_debug('Updating Event
ID',$event['id']);
$new_event = $event;
$old_event =
$this->read_entry($event['id']);
-
$this->prepare_recipients($new_event,$old_event);
$this->so->cal->event = $event;
$this->so->add_entry($event);
+
$this->prepare_recipients($new_event,$old_event);
}
$date =
sprintf("%04d%02d%02d",$event['start']['year'],$event['start']['month'],$event['start']['mday']);
if($send_to_ui)
@@ -830,12 +984,11 @@
$this->read_sessiondata();
if ($this->return_to)
{
- header('Location:
'.$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->return_to));
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->return_to);
$GLOBALS['phpgw']->common->phpgw_exit();
}
Execmethod('calendar.uicalendar.index');
-//
$GLOBALS['phpgw_info']['flags']['nodisplay'] = True;
-// exit;
+// $GLOBALS['phpgw']->common->phpgw_exit();
}
}
}
@@ -922,6 +1075,15 @@
function fix_update_time(&$time_param)
{
+ if (isset($time_param['str']))
+ {
+ if (!is_object($this->jscal))
+ {
+ $this->jscal =
CreateObject('phpgwapi.jscalendar');
+ }
+ $time_param +=
$this->jscal->input2date($time_param['str'],False,'mday');
+ unset($time_param['str']);
+ }
if ($this->prefs['common']['timeformat'] == '12')
{
if ($time_param['ampm'] == 'pm')
@@ -976,6 +1138,25 @@
return $error;
}
+ /*!
+ @function participants_not_rejected($participants,$event)
+ @abstract checks if any of the $particpants participates in
$event and has not rejected it
+ */
+ function participants_not_rejected($participants,$event)
+ {
+ //echo "participants_not_rejected()<br />participants
=<pre>"; print_r($participants); echo "</pre><br />event[participants]=<pre>";
print_r($event['participants']); echo "</pre>\n";
+ foreach($participants as $uid => $status)
+ {
+ //echo "testing event[participants][uid=$uid] =
'".$event['participants'][$uid]."'<br />\n";
+ if (isset($event['participants'][$uid]) &&
$event['participants'][$uid] != 'R' &&
+ $status != 'R')
+ {
+ return True; // found not rejected
participant in event
+ }
+ }
+ return False;
+ }
+
function
overlap($starttime,$endtime,$participants,$owner=0,$id=0,$restore_cache=False)
{
// $retval = Array();
@@ -988,6 +1169,10 @@
$temp_cache_events = $this->cached_events;
}
+// $temp_start =
intval($GLOBALS['phpgw']->common->show_date($starttime,'Ymd'));
+// $temp_start_time =
intval($GLOBALS['phpgw']->common->show_date($starttime,'Hi'));
+// $temp_end =
intval($GLOBALS['phpgw']->common->show_date($endtime,'Ymd'));
+// $temp_end_time =
intval($GLOBALS['phpgw']->common->show_date($endtime,'Hi'));
$temp_start = intval(date('Ymd',$starttime));
$temp_start_time = intval(date('Hi',$starttime));
$temp_end = intval(date('Ymd',$endtime));
@@ -1059,7 +1244,7 @@
}
if($this->debug)
{
- echo '<!-- Item found:
'.$found.' -->'."<br>\n";
+ echo '<!-- Item found:
'.$found.' -->'."<br />\n";
}
if(!$found)
{
@@ -1070,10 +1255,17 @@
$temp_event_start =
sprintf("%d%02d",$event['start']['hour'],$event['start']['min']);
$temp_event_end =
sprintf("%d%02d",$event['end']['hour'],$event['end']['min']);
// if((($temp_start_time
<= $temp_event_start) && ($temp_end_time >= $temp_event_start) &&
($temp_end_time <= $temp_event_end)) ||
- if((($temp_start_time
<= $temp_event_start) && ($temp_end_time > $temp_event_start) &&
($temp_end_time <= $temp_event_end)) ||
-
(($temp_start_time >= $temp_event_start) && ($temp_start_time <
$temp_event_end) && ($temp_end_time >= $temp_event_end)) ||
-
(($temp_start_time <= $temp_event_start) && ($temp_end_time >=
$temp_event_end)) ||
-
(($temp_start_time >= $temp_event_start) && ($temp_end_time <=
$temp_event_end)))
+ if(($temp_start_time <=
$temp_event_start &&
+ $temp_end_time >
$temp_event_start &&
+ $temp_end_time <=
$temp_event_end ||
+ $temp_start_time >=
$temp_event_start &&
+ $temp_start_time <
$temp_event_end &&
+ $temp_end_time >=
$temp_event_end ||
+ $temp_start_time <=
$temp_event_start &&
+ $temp_end_time >=
$temp_event_end ||
+ $temp_start_time >=
$temp_event_start &&
+ $temp_end_time <=
$temp_event_end) &&
+
$this->participants_not_rejected($participants,$event))
{
if($this->debug)
{
@@ -1111,6 +1303,8 @@
@param $needed necessary ACL right: PHPGW_ACL_{READ|EDIT|DELETE}
@param $event event as array or the event-id or 0 for general
check
@param $other uid to check (if event==0) or 0 to check against
$this->owner
+ @note Participating in an event is considered as haveing
read-access on that event, \
+ even if you have no general read-grant from that user.
*/
function check_perms($needed,$event=0,$other=0)
{
@@ -1133,6 +1327,20 @@
}
$user = $GLOBALS['phpgw_info']['user']['account_id'];
$grants = $this->grants[$owner];
+
+ if (is_array($event) &&
is_array($event['participants']) && ($needed == PHPGW_ACL_READ))
+ {
+ // Check if the $user is one of the
participants or has a read-grant from one of them
+ //
+ foreach($event['participants'] as $uid =>
$accept)
+ {
+ if ($this->grants[$uid] &
PHPGW_ACL_READ || $uid == $user)
+ {
+ $grants |= PHPGW_ACL_READ;
+ break;
+ }
+ }
+ }
if ($GLOBALS['phpgw']->accounts->get_type($owner) ==
'g' && $needed == PHPGW_ACL_ADD)
{
@@ -1142,25 +1350,11 @@
{
$access = $user == $owner || $grants & $needed
&& (!$private || $grants & PHPGW_ACL_PRIVATE);
}
+ //echo "<p>rb_check_perms for user $user and needed_acl
$needed: event=$event[title]: owner=$owner, privat=$private, grants=$grants ==>
access=$access</p>\n";
return $access;
}
- function get_fullname($accountid)
- {
- $account_id = get_account_id($accountid);
- if($GLOBALS['phpgw']->accounts->exists($account_id) ==
False)
- {
- return False;
- }
-
$GLOBALS['phpgw']->accounts->get_account_name($account_id,$lid,$fname,$lname);
- $fullname = $lid;
- if($lname && $fname)
- {
- $fullname = $lname.', '.$fname;
- }
- return $fullname;
- }
function display_status($user_status)
{
@@ -1249,6 +1443,18 @@
function long_date($first,$last=0)
{
+ if (!is_array($first))
+ {
+ $first = $this->time2array($raw = $first);
+ $first['raw'] = $raw;
+ $first['day'] = $first['mday'];
+ }
+ if ($last && !is_array($last))
+ {
+ $last = $this->time2array($raw = $last);
+ $last['raw'] = $raw;
+ $last['day'] = $last['mday'];
+ }
$datefmt = $this->prefs['common']['dateformat'];
$month_before_day = $datefmt[0] == 'm' || $datefmt[2]
== 'm' && $datefmt[4] == 'd';
@@ -1331,7 +1537,7 @@
$second = intval(strrev(substr($time,0,2)));
$minute = intval(strrev(substr($time,2,2)));
$hour = intval(strrev(substr($time,4)));
- $hour += $this->normalizeminutes($minute);
+ $hour += $this->normalizeminutes(&$minute);
$temp['second'] = $second;
$temp['minute'] = $minute;
$temp['hour'] = $hour;
@@ -1397,9 +1603,10 @@
$event_time =
mktime($event['start']['hour'],$event['start']['min'],0,intval(substr($date,4,2)),intval(substr($date,6,2)),intval(substr($date,0,4)))
- $GLOBALS['phpgw']->datetime->tz_offset;
while($inserted == False &&
list($key,$exception_time) = each($event['recur_exception']))
{
- print_debug('Checking Exception
DateTime',$exception_time);
- print_debug('Checking Event
DateTime',$event_time);
-
+ if($this->debug)
+ {
+ echo '<!-- checking exception
datetime '.$exception_time.' to event datetime '.$event_time.' -->'."\n";
+ }
if($exception_time == $event_time)
{
$inserted = True;
@@ -1408,22 +1615,29 @@
}
if($this->cached_events[$date] && $inserted == False)
{
-
- print_debug('Cached Events Found',$date);
-
+
+ if($this->debug)
+ {
+ echo '<!-- Cached Events found for
'.$date.' -->'."\n";
+ }
$year = substr($date,0,4);
$month = substr($date,4,2);
$day = substr($date,6,2);
- print_debug('Date',$date);
-
print_debug('Count',count($this->cached_events[$date]));
+ if($this->debug)
+ {
+ echo '<!-- Date : '.$date.' Count :
'.count($this->cached_events[$date]).' -->'."\n";
+ }
for($i=0;$i<count($this->cached_events[$date]);$i++)
{
$events =
$this->cached_events[$date][$i];
if($this->cached_events[$date][$i]['id'] == $event['id'] ||
$this->cached_events[$date][$i]['reference'] == $event['id'])
{
- print_debug('Item Already
Inserted!');
+ if($this->debug)
+ {
+ echo '<!-- Item already
inserted! -->'."\n";
+ }
$inserted = True;
break;
}
@@ -1441,7 +1655,10 @@
{
$this->cached_events[$date][$j] = $this->cached_events[$date][$j-1];
}
- print_debug('Adding to cached
events:ID',$event['id']);
+ if($this->debug)
+ {
+ echo '<!-- Adding event
ID: '.$event['id'].' to cached_events -->'."\n";
+ }
$inserted = True;
$this->cached_events[$date][$i]
= $event;
break;
@@ -1450,7 +1667,10 @@
}
if(!$inserted)
{
- print_debug('Adding to cached
events:ID',$event['id']);
+ if($this->debug)
+ {
+ echo '<!-- Adding event ID:
'.$event['id'].' to cached_events -->'."\n";
+ }
$this->cached_events[$date][] = $event;
}
}
@@ -1464,9 +1684,10 @@
$search_date_day = date('d',$datetime);
$search_date_dow = date('w',$datetime);
$search_beg_day =
mktime(0,0,0,$search_date_month,$search_date_day,$search_date_year);
-
- print_debug('Search Date Full',$search_date_full);
-
+ if($this->debug)
+ {
+ echo '<!-- Search Date Full =
'.$search_date_full.' -->'."\n";
+ }
$repeated = $this->repeating_events;
$r_events = count($repeated);
for ($i=0;$i<$r_events;$i++)
@@ -1485,9 +1706,12 @@
$end_recur_date = date('Ymd',$event_recur_time);
$full_event_date = date('Ymd',$event_beg_day);
- print_debug('check_repeating_events:Processing
ID',$id);
- print_debug('check_repeating_events:Recurring
End Date',$end_recur_date);
-
+ if($this->debug)
+ {
+ echo '<!-- check_repeating_events -
Processing ID - '.$id.' -->'."\n";
+ echo '<!-- check_repeating_events -
Recurring End Date - '.$end_recur_date.' -->'."\n";
+ }
+
// only repeat after the beginning, and if
there is an rpt_end before the end date
if (($search_date_full > $end_recur_date) ||
($search_date_full < $full_event_date))
{
@@ -1601,6 +1825,7 @@
{
return False;
}
+
$syear = $params['syear'];
$smonth = $params['smonth'];
$sday = $params['sday'];
@@ -1612,7 +1837,10 @@
{
unset($owner_id);
$owner_id = $this->g_owner;
- print_debug('owner_id
in','('.implode(',',$owner_id).')');
+ if($this->debug)
+ {
+ echo '<!-- owner_id in
('.implode($owner_id,',').') -->'."\n";
+ }
}
if(!$eyear && !$emonth && !$eday)
@@ -1643,9 +1871,12 @@
}
$edate = mktime(23,59,59,$emonth,$eday,$eyear);
}
-
- print_debug('Start
Date',sprintf("%04d%02d%02d",$syear,$smonth,$sday));
- print_debug('End
Date',sprintf("%04d%02d%02d",$eyear,$emonth,$eday));
+
+ if($this->debug)
+ {
+ echo '<!-- Start Date :
'.sprintf("%04d%02d%02d",$syear,$smonth,$sday).' -->'."\n";
+ echo '<!-- End Date :
'.sprintf("%04d%02d%02d",$eyear,$emonth,$eday).' -->'."\n";
+ }
if($owner_id)
{
@@ -1657,14 +1888,18 @@
$cached_event_ids =
$this->so->list_events($syear,$smonth,$sday,$eyear,$emonth,$eday);
$cached_event_ids_repeating =
$this->so->list_repeated_events($syear,$smonth,$sday,$eyear,$emonth,$eday);
}
+
$c_cached_ids = count($cached_event_ids);
$c_cached_ids_repeating =
count($cached_event_ids_repeating);
-
print_debug('Date',sprintf("%04d%02d%02d",$syear,$smonth,$sday));
- print_debug('Events Cached',$c_cached_ids);
- print_debug('Repeating Events
Cached',$c_cached_ids_repeating);
- $this->cached_events = Array();
+ if($this->debug)
+ {
+ echo '<!-- events cached : '.$c_cached_ids.' :
for : '.sprintf("%04d%02d%02d",$syear,$smonth,$sday).' -->'."\n";
+ echo '<!-- repeating events cached :
'.$c_cached_ids_repeating.' : for :
'.sprintf("%04d%02d%02d",$syear,$smonth,$sday).' -->'."\n";
+ }
+ $this->cached_events = Array();
+
if($c_cached_ids == 0 && $c_cached_ids_repeating == 0)
{
return;
@@ -1690,11 +1925,16 @@
{
$c_evt_day = 0;
}
- print_debug('Date',$j);
-
print_debug('Count',$c_evt_day);
+ if($this->debug)
+ {
+ echo '<!--
Date: '.$j.' Count : '.$c_evt_day.' -->'."\n";
+ }
if($this->cached_events[$j][$c_evt_day]['id'] != $event['id'])
{
-
print_debug('Adding Event For Date',$j);
+ if($this->debug)
+ {
+ echo
'<!-- Adding Event for Date: '.$j.' -->'."\n";
+ }
$this->cached_events[$j][] = $event;
}
}
@@ -1843,7 +2083,7 @@
}
/* End of SO functions */
- function
prepare_matrix($interval,$increment,$part,$status,$fulldate)
+ function prepare_matrix($interval,$increment,$part,$fulldate)
{
for($h=0;$h<24;$h++)
{
@@ -1854,9 +2094,12 @@
$time_slice[$index]['description'] = '';
}
}
- for($k=0;$k<count($this->cached_events[$fulldate]);$k++)
+ foreach($this->cached_events[$fulldate] as $event)
{
- $event = $this->cached_events[$fulldate][$k];
+ if ($event['participants'][$part] == 'R')
+ {
+ continue; // dont show rejected
invitations, as they are free time
+ }
$eventstart =
$GLOBALS['phpgw']->datetime->localdates($this->maketime($event['start']) -
$GLOBALS['phpgw']->datetime->tz_offset);
$eventend =
$GLOBALS['phpgw']->datetime->localdates($this->maketime($event['end']) -
$GLOBALS['phpgw']->datetime->tz_offset);
$start = ($eventstart['hour'] * 10000) +
($eventstart['minute'] * 100);
@@ -1885,68 +2128,137 @@
$end += $addminute;
$starttemp = $this->splittime("$start",False);
$endtemp = $this->splittime("$end",False);
-// Do not display All-Day events in this free/busy time
- if((($starttemp['hour'] == 0) &&
($starttemp['minute'] == 0)) && (($endtemp['hour'] == 23) &&
($endtemp['minute'] == 59)))
- {
- }
- else
+
+
for($h=$starttemp['hour'];$h<=$endtemp['hour'];$h++)
{
-
for($h=$starttemp['hour'];$h<=$endtemp['hour'];$h++)
+ $startminute = 0;
+ $endminute = $interval;
+ $hour = $h * 10000;
+ if($h == intval($starttemp['hour']))
{
- $startminute = 0;
- $endminute = $interval;
- $hour = $h * 10000;
- if($h ==
intval($starttemp['hour']))
- {
- $startminute =
($starttemp['minute'] / $increment);
- }
- if($h ==
intval($endtemp['hour']))
- {
- $endminute =
($endtemp['minute'] / $increment);
- }
- $private =
$this->is_private($event,$part);
- $time_display =
$GLOBALS['phpgw']->common->show_date($eventstart['raw'],$this->users_timeformat).'-'.$GLOBALS['phpgw']->common->show_date($eventend['raw'],$this->users_timeformat);
- $time_description =
'('.$time_display.')
'.$this->get_short_field($event,$private,'title').$this->display_status($event['participants'][$part]);
-
for($m=$startminute;$m<=$endminute;$m++)
- {
- $index = ($hour + (($m
* $increment) * 100));
-
$time_slice[$index]['marker'] = '-';
-
$time_slice[$index]['description'] = $time_description;
- }
+ $startminute =
($starttemp['minute'] / $increment);
+ }
+ if($h == intval($endtemp['hour']))
+ {
+ $endminute =
($endtemp['minute'] / $increment);
+ }
+ $private =
$this->is_private($event,$part);
+ $time_display =
$GLOBALS['phpgw']->common->show_date($eventstart['raw'],$this->users_timeformat).'-'.$GLOBALS['phpgw']->common->show_date($eventend['raw'],$this->users_timeformat);
+ $time_description =
'('.$time_display.')
'.$this->get_short_field($event,$private,'title').$this->display_status($event['participants'][$part]);
+ for($m=$startminute;$m<$endminute;$m++)
+ {
+ $index = ($hour + (($m *
$increment) * 100));
+ $time_slice[$index]['marker'] =
'-';
+
$time_slice[$index]['description'] = $time_description;
+ $time_slice[$index]['id'] =
$event['id'];
}
}
}
return $time_slice;
}
+ /*!
+ @function set_status
+ @abstract set the participant response $status for event
$cal_id and notifies the owner of the event
+ */
function set_status($cal_id,$status)
{
- $old_event = $this->so->read_entry($cal_id);
- switch($status)
+ $status2msg = array(
+ REJECTED => MSG_REJECTED,
+ TENTATIVE => MSG_TENTATIVE,
+ ACCEPTED => MSG_ACCEPTED
+ );
+ if (!isset($status2msg[$status]))
{
- case REJECTED:
-
$this->send_update(MSG_REJECTED,$old_event['participants'],$old_event);
- $this->so->set_status($cal_id,$status);
- break;
- case TENTATIVE:
-
$this->send_update(MSG_TENTATIVE,$old_event['participants'],$old_event);
- $this->so->set_status($cal_id,$status);
+ return False;
+ }
+ $this->so->set_status($cal_id,$status);
+ $event = $this->so->read_entry($cal_id);
+
$this->send_update($status2msg[$status],$event['participants'],$event);
+
+ return True;
+ }
+
+ /*!
+ @function update_requested
+ @abstract checks if $userid has requested (in $part_prefs)
updates for $msg_type
+ @syntax
update_requested($userid,$part_prefs,$msg_type,$old_event,$new_event)
+ @param $userid numerical user-id
+ @param $part_prefs preferces of the user $userid
+ @param $msg_type type of the notification: MSG_ADDED,
MSG_MODIFIED, MSG_ACCEPTED, ...
+ @param $old_event Event before the change
+ @param $new_event Event after the change
+ @returns 0 = no update requested, > 0 update requested
+ */
+ function
update_requested($userid,$part_prefs,$msg_type,$old_event,$new_event)
+ {
+ if ($msg_type == MSG_ALARM)
+ {
+ return True; // always True for now
+ }
+ $want_update = 0;
+
+ // the following switch fall-through all cases, as each
included the following too
+ //
+ $msg_is_response = $msg_type == MSG_REJECTED ||
$msg_type == MSG_ACCEPTED || $msg_type == MSG_TENTATIVE;
+
+ switch($ru = $part_prefs['calendar']['receive_updates'])
+ {
+ case 'responses':
+ if ($msg_is_response)
+ {
+ ++$want_update;
+ }
+ case 'modifications':
+ if ($msg_type == MSG_MODIFIED)
+ {
+ ++$want_update;
+ }
+ case 'time_change_4h':
+ case 'time_change':
+ $diff =
max(abs($this->maketime($old_event['start'])-$this->maketime($new_event['start'])),
+
abs($this->maketime($old_event['end'])-$this->maketime($new_event['end'])));
+ $check = $ru == 'time_change_4h' ? 4 *
60 * 60 - 1 : 0;
+ if ($msg_type == MSG_MODIFIED && $diff
> $check)
+ {
+ ++$want_update;
+ }
+ case 'add_cancel':
+ if ($old_event['owner'] == $userid &&
$msg_is_response ||
+ $msg_type == MSG_DELETED ||
$msg_type == MSG_ADDED)
+ {
+ ++$want_update;
+ }
break;
- case ACCEPTED:
-
$this->send_update(MSG_ACCEPTED,$old_event['participants'],$old_event);
- $this->so->set_status($cal_id,$status);
+ case 'no':
break;
}
- return True;
+ //echo
"<p>bocalendar::update_requested(user=$userid,pref=".$part_prefs['calendar']['receive_updates']
.",msg_type=$msg_type,".($old_event?$old_event['title']:'False').",".($old_event?$old_event['title']:'False').")
= $want_update</p>\n";
+ return $want_update > 0;
}
- function
send_update($msg_type,$participants,$old_event=False,$new_event=False)
+ /*!
+ @function send_update
+ @abstract sends update-messages to certain participants of an
event
+ @syntax
send_update($msg_type,$to_notify,$old_event,$new_event=False)
+ @param $msg_type type of the notification: MSG_ADDED,
MSG_MODIFIED, MSG_ACCEPTED, ...
+ @param $to_notify array with numerical user-ids as keys (!)
(value is not used)
+ @param $old_event Event before the change
+ @param $new_event Event after the change
+ */
+ function
send_update($msg_type,$to_notify,$old_event,$new_event=False,$user=False)
{
- $db = $GLOBALS['phpgw']->db;
- $db->query("SELECT app_version FROM phpgw_applications
WHERE app_name='calendar'",__LINE__,__FILE__);
- $db->next_record();
- $version = $db->f('app_version');
- unset($db);
+ //echo
"<p>bocalendar::send_update(type=$msg_type,to_notify="; print_r($to_notify);
echo ", old_event="; print_r($old_event); echo ", new_event=";
print_r($new_event); echo ", user=$user)</p>\n";
+ if (!is_array($to_notify))
+ {
+ $to_notify = array();
+ }
+ $owner = $old_event ? $old_event['owner'] :
$new_event['owner'];
+ if ($owner && !isset($to_notify[$owner]) && $msg_type
!= MSG_ALARM)
+ {
+ $to_notify[$owner] = 'owner'; // always
include the event-owner
+ }
+ $version =
$GLOBALS['phpgw_info']['apps']['calendar']['version'];
$GLOBALS['phpgw_info']['user']['preferences'] =
$GLOBALS['phpgw']->preferences->create_email_preferences();
$sender =
$GLOBALS['phpgw_info']['user']['preferences']['email']['address'];
@@ -1968,172 +2280,176 @@
$temp_user = $GLOBALS['phpgw_info']['user'];
- if($this->owner != $temp_user['account_id'])
+ if (!$user)
{
$user = $this->owner;
-//
-// $accounts =
CreateObject('phpgwapi.accounts',$user);
-// $phpgw_info['user'] =
$accounts->read_repository();
-//
-// $pref =
CreateObject('phpgwapi.preferences',$user);
-// $GLOBALS['phpgw_info']['user']['preferences'] =
$pref->read_repository();
}
- else
+ $GLOBALS['phpgw_info']['user']['preferences'] =
$GLOBALS['phpgw']->preferences->create_email_preferences($user);
+
+ $event = $msg_type == MSG_ADDED || $msg_type ==
MSG_MODIFIED ? $new_event : $old_event;
+ if($old_event != False)
{
- $user =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $old_starttime = $t_old_start_time -
$GLOBALS['phpgw']->datetime->tz_offset;
}
-
- $GLOBALS['phpgw_info']['user']['preferences'] =
$GLOBALS['phpgw']->preferences->create_email_preferences($user);
+ $starttime = $this->maketime($event['start']) -
$GLOBALS['phpgw']->datetime->tz_offset;
+ $endtime = $this->maketime($event['end']) -
$GLOBALS['phpgw']->datetime->tz_offset;
switch($msg_type)
{
case MSG_DELETED:
- $action = 'Deleted';
- $event_id = $old_event['id'];
+ $action = lang('Canceled');
+ $msg = 'Canceled';
$msgtype = '"calendar";';
+ $method = 'cancel';
break;
case MSG_MODIFIED:
- $action = 'Modified';
- $event_id = $old_event['id'];
+ $action = lang('Modified');
+ $msg = 'Modified';
$msgtype = '"calendar";
Version="'.$version.'"; Id="'.$new_event['id'].'"';
+ $method = 'request';
break;
case MSG_ADDED:
- $action = 'Added';
- $event_id = $new_event['id'];
+ $action = lang('Added');
+ $msg = 'Added';
$msgtype = '"calendar";
Version="'.$version.'"; Id="'.$new_event['id'].'"';
+ $method = 'request';
break;
case MSG_REJECTED:
- $action = 'Rejected';
- $event_id = $old_event['id'];
+ $action = lang('Rejected');
+ $msg = 'Response';
$msgtype = '"calendar";';
+ $method = 'reply';
break;
case MSG_TENTATIVE:
- $action = 'Tentative';
- $event_id = $old_event['id'];
+ $action = lang('Tentative');
+ $msg = 'Response';
$msgtype = '"calendar";';
+ $method = 'reply';
break;
case MSG_ACCEPTED:
- $action = 'Accepted';
- $event_id = $old_event['id'];
+ $action = lang('Accepted');
+ $msg = 'Response';
$msgtype = '"calendar";';
+ $method = 'reply';
break;
+ case MSG_ALARM:
+ $action = lang('Alarm');
+ $msg = 'Alarm';
+ $msgtype = '"calendar";';
+ $method = 'publish'; // duno if
thats right
+ break;
+ default:
+ $method = 'publish';
}
-
- if($old_event != False)
+ $notify_msg = $this->prefs['calendar']['notify'.$msg];
+ if (empty($notify_msg))
{
- $old_event_datetime = $t_old_start_time -
$GLOBALS['phpgw']->datetime->tz_offset;
+ $notify_msg =
$this->prefs['calendar']['notifyAdded']; // use a default
}
-
- if($new_event != False)
+ $details = array( //
event-details for the notify-msg
+ 'id' => $msg_type == MSG_ADDED ?
$new_event['id'] : $old_event['id'],
+ 'action' => $action,
+ );
+ $event_arr = $this->event2array($event);
+ foreach($event_arr as $key => $val)
{
- $new_event_datetime =
$this->maketime($new_event['start']) - $GLOBALS['phpgw']->datetime->tz_offset;
- $new_event_datetime_end =
$this->maketime($new_event['end']) - $GLOBALS['phpgw']->datetime->tz_offset;
+ $details[$key] = $val['data'];
}
+ $details['participants'] =
implode("\n",$details['participants']);
- //Added to construct the participant's list to an event
- $event_participants = '';
- reset($participants);
- $ac=CreateObject('phpgwapi.accounts');
-
- while(list($userid,$statid)=each($participants))
- {
- $event_participants .=
($event_participants?"\n":'');
- $ac->account_id=$userid;
- $ac->read_repository();
- $event_participants .=
'<'.$ac->data['account_lid'].'> '.$ac->data['fullname'];
- }
- //End
-
- reset($participants);
- while($participants && list($userid,$statusid) =
each($participants))
- {
- if((intval($userid) !=
$GLOBALS['phpgw_info']['user']['account_id']) &&
- (
- (
- ($msg_type == MSG_REJECTED || $msg_type ==
MSG_TENTATIVE || $msg_type == MSG_ACCEPTED) &&
- ($old_event['owner'] == $userid)
- ) ||
- ($msg_type == MSG_DELETED || $msg_type ==
MSG_MODIFIED || $msg_type == MSG_ADDED)
- )
- )
+ if(!is_object($GLOBALS['phpgw']->send))
+ {
+ $GLOBALS['phpgw']->send =
CreateObject('phpgwapi.send');
+ }
+ $send = &$GLOBALS['phpgw']->send;
+
+ foreach($to_notify as $userid => $statusid)
+ {
+ $userid = intval($userid);
+
+ if ($statusid == 'R')
+ {
+ continue; // dont notify rejected
participants
+ }
+ if($userid !=
$GLOBALS['phpgw_info']['user']['account_id'] || $msg_type == MSG_ALARM)
{
print_debug('Msg Type',$msg_type);
print_debug('UserID',$userid);
- if(!is_object($send))
- {
- $send =
CreateObject('phpgwapi.send');
- }
- $preferences =
CreateObject('phpgwapi.preferences',intval($userid));
+ $preferences =
CreateObject('phpgwapi.preferences',$userid);
$part_prefs =
$preferences->read_repository();
-
if(!isset($part_prefs['calendar']['send_updates']) ||
!$part_prefs['calendar']['send_updates'])
+
+ if
(!$this->update_requested($userid,$part_prefs,$msg_type,$old_event,$new_event))
{
continue;
}
- $part_prefs =
$preferences->create_email_preferences(intval($userid));
- $to = $part_prefs['email']['address'];
+
$GLOBALS['phpgw']->accounts->get_account_name($userid,$lid,$details['to-firstname'],$details['to-lastname']);
+ $details['to-fullname'] =
$GLOBALS['phpgw']->common->display_fullname('',$details['to-firstname'],$details['to-lastname']);
+ $to =
$preferences->email_address($userid);
+ if (empty($to) || $to[0] == '@' ||
$to[0] == '$') // we have no valid email-address
+ {
+ //echo
"<p>bocalendar::send_update: Empty email adress for user
'".$details['to-fullname']."' ==> ignored !!!</p>\n";
+ continue;
+ }
print_debug('Email being sent to',$to);
$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset'] =
$part_prefs['common']['tz_offset'];
$GLOBALS['phpgw_info']['user']['preferences']['common']['timeformat'] =
$part_prefs['common']['timeformat'];
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'] =
$part_prefs['common']['dateformat'];
-
+
$GLOBALS['phpgw']->datetime->tz_offset
= ((60 * 60) *
intval($GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset']));
- if($old_event != False)
- {
- $old_event_date =
$GLOBALS['phpgw']->common->show_date($old_event_datetime);
- }
-
- if($new_event != False)
+ if($old_starttime)
{
- $new_event_date =
$GLOBALS['phpgw']->common->show_date($new_event_datetime);
- $new_event_end =
$GLOBALS['phpgw']->common->show_date($new_event_datetime_end);
+ $details['olddate'] =
$GLOBALS['phpgw']->common->show_date($old_starttime);
}
+ $details['startdate'] =
$GLOBALS['phpgw']->common->show_date($starttime);
+ $details['enddate'] =
$GLOBALS['phpgw']->common->show_date($endtime);
- switch($msg_type)
- {
- case MSG_DELETED:
- $action_date =
$old_event_date;
- $body = lang ('Your
meeting scheduled for') .' '. $old_event_date .' '. lang('has been canceled');
-
$event_head=$old_event['title'];
-
$event_description=$old_event['description'];
- break;
- case MSG_MODIFIED:
- $action_date =
$new_event_date;
- $body = lang ('Your
meeting that had been scheduled for').' '.$old_event_date.' '. lang('has been
rescheduled to') .' '.$new_event_date;
-
$event_head=$old_event['title'];
-
$event_description=$old_event['description'];
- break;
- case MSG_ADDED:
- $action_date =
$new_event_date;
- $body = lang ('You have
a meeting scheduled for').' '. $new_event_date;
-
$event_head=$new_event['title'];
-
$event_description=$new_event['description'];
+ list($subject,$body) =
split("\n",$GLOBALS['phpgw']->preferences->parse_notify($notify_msg,$details),2);
+ $subject =
trim($send->encode_subject($subject));
+
switch($part_prefs['calendar']['update_format'])
+ {
+ case 'extended':
+ $body .=
"\n\n".lang('Event Details follow').":\n";
+ foreach($event_arr as
$key => $val)
+ {
+ if ($key !=
'access' && $key != 'priority' && strlen($details[$key]))
+ {
+ $body
.= sprintf("%-20s %s\n",$val['field'].':',$details[$key]);
+ }
+ }
break;
- case MSG_REJECTED:
- case MSG_TENTATIVE:
- case MSG_ACCEPTED:
- $action_date =
$old_event_date;
- $body = 'On
'.$GLOBALS['phpgw']->common->show_date(time() -
$GLOBALS['phpgw']->datetime->tz_offset).'
'.$GLOBALS['phpgw']->common->grab_owner_name($GLOBALS['phpgw_info']['user']['account_id']).'
'.$action.' your meeting request for '.$old_event_date;
- $body = lang('On %1 %2
%3 your meeting request for %4',$GLOBALS['phpgw']->common->show_date(time() -
$GLOBALS['phpgw']->datetime->tz_offset),$GLOBALS['phpgw']->common->grab_owner_name($GLOBALS['phpgw_info']['user']['account_id']),lang($action),$old_event_date);
-
$event_head=$old_event['title'];
-
$event_description=$old_event['description'];
+
+ case 'ical':
+ $content_type =
"calendar; method=$method; name=calendar.ics";
+/* would be nice, need to get it working
+ if ($body != '')
+ {
+ $boundary =
'----Message-Boundary';
+ $body .=
"\n\n\n$boundary\nContent-type: text/$content_type\n".
+
"Content-Disposition: inline\nContent-transfer-encoding: 7BIT\n\n";
+ $content_type =
'';
+ }
+*/
+ $body =
ExecMethod('calendar.boicalendar.export',array(
+ 'l_event_id'
=> $event['id'],
+ 'method'
=> $method,
+ 'chunk_split'
=> False
+ ));
break;
}
-
- $subject = lang('Calendar Event') . '
('. lang($action) .') #'.$event_id.': '.$action_date.' (L)';
-
if(isset($part_prefs['calendar']['send_extra']) &&
$part_prefs['calendar']['send_extra'])
- {
- $body .=
"\n\n".'***'.lang('Please confirm,accept,reject or examine changes in the
corresponding entry in your calendar').'***'."\n\n"
- . '----'.lang('Event
Details Follow').'----';
- $body .= ($new_event_date ?
"\n\n".lang('Start- and Enddates').":\n".$new_event_date.' -- '. $new_event_end
: '');
- $body .=
($event_head?"\n\n".lang('TITLE').':'."\n".' '.$event_head:'');
- $body .=
($event_description?"\n\n".lang('DESCRIPTION').':'."\n".'
'.$event_description:'');
- $body .=
($event_participants?"\n\n".lang('Participants').':'."\n".'
'.$event_participants:'');
- }
- $returncode =
$send->msg('email',$to,$subject,$body,$msgtype,'','','',$sender);
+ $returncode =
$send->msg('email',$to,$subject,$body,''/*$msgtype*/,'','','',$sender,
$content_type/*,$boundary*/);
+ //echo "<p>send(to='$to',
sender='$sender'<br />subject='$subject') returncode=$returncode<br
/>".nl2br($body)."</p>\n";
+
+ if (!$returncode) // not nice,
but better than failing silently
+ {
+ echo
'<p><b>bocalendar::send_update</b>: '.lang("Failed sending message to '%1' #%2
subject='%3', sender='%4' !!!",$to,$userid,htmlspecialchars($subject),
$sender)."<br />\n";
+ echo
'<i>'.$send->err['desc']."</i><br />\n";
+ echo lang('This is mostly
caused by a not or wrongly configured SMTP server. Notify your
administrator.')."</p>\n";
+ echo '<p>'.lang('Click %1here%2
to return to the calendar.','<a
href="'.$GLOBALS['phpgw']->link('/calendar/').'">','</a>')."</p>\n";
+ }
}
}
unset($send);
@@ -2145,9 +2461,35 @@
}
$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset'] =
$temp_tz_offset;
- $GLOBALS['phpgw']->datetime->tz_offset = ((60 * 60) *
$temp_tz_offset);
+ $GLBOALS['phpgw']->datetime->tz_offset = ((60 * 60) *
$temp_tz_offset);
$GLOBALS['phpgw_info']['user']['preferences']['common']['timeformat'] =
$temp_timeformat;
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'] =
$temp_dateformat;
+
+ return $returncode;
+ }
+
+ function send_alarm($alarm)
+ {
+ //echo "<p>bocalendar::send_alarm("; print_r($alarm);
echo ")</p>\n";
+ $GLOBALS['phpgw_info']['user']['account_id'] =
$this->owner = $alarm['owner'];
+
+ if (!$alarm['enabled'] || !$alarm['owner'] ||
!$alarm['cal_id'] || !($event = $this->so->read_entry($alarm['cal_id'])))
+ {
+ return False; // event not found
+ }
+ if ($alarm['all'])
+ {
+ $to_notify = $event['participants'];
+ }
+ elseif ($this->check_perms(PHPGW_ACL_READ,$event))
// checks agains $this->owner set to $alarm[owner]
+ {
+ $to_notify[$alarm['owner']] = 'A';
+ }
+ else
+ {
+ return False; // no rights
+ }
+ return
$this->send_update(MSG_ALARM,$to_notify,$event,False,$alarm['owner']);
}
function get_alarms($event_id)
@@ -2172,7 +2514,7 @@
print_debug('T_TIME',$t_time.' :
'.$GLOBALS['phpgw']->common->show_date($t_time));
print_debug('Y_TIME',$y_time.' :
'.$GLOBALS['phpgw']->common->show_date($y_time));
print_debug('TT_TIME',$tt_time.' :
'.$GLOBALS['phpgw']->common->show_date($tt_time));
- while(list($key,$alarm) = each($event['alarm']))
+ while(list($key,$alarm) = @each($event['alarm']))
{
if($alarm['enabled'])
{
@@ -2221,7 +2563,7 @@
$new_event['participants'][$new_userid]
= 'U';
}
}
-
+
if(count($this->added) > 0 || count($this->modified) >
0 || count($this->deleted) > 0)
{
if(count($this->added) > 0)
@@ -2266,11 +2608,369 @@
}
}
}
+
+ function get_dirty_entries($lastmod=-1)
+ {
+ $events = false;
+ $event_ids =
$this->so->cal->list_dirty_events($lastmod);
+ if(is_array($event_ids))
+ {
+ foreach($event_ids as $key => $id)
+ {
+ $events[$id] =
$this->so->cal->fetch_event($id);
+ }
+ }
+ unset($event_ids);
+
+ $rep_event_ids =
$this->so->cal->list_dirty_events($lastmod,$true);
+ if(is_array($rep_event_ids))
+ {
+ foreach($rep_event_ids as $key => $id)
+ {
+ $events[$id] =
$this->so->cal->fetch_event($id);
+ }
+ }
+ unset($rep_event_ids);
+
+ return $events;
+ }
function _debug_array($data)
{
- echo '<br>UI:';
+ echo '<br />UI:';
_debug_array($data);
}
+
+ /*!
+ @function rejected_no_show
+ @abstract checks if event is rejected from user and he's not
the owner and dont want rejected
+ @param $event to check
+ @returns True if event should not be shown
+ */
+ function rejected_no_show($event)
+ {
+ $ret = !$this->prefs['calendar']['show_rejected'] &&
+ $event['owner'] != $this->owner &&
+ $event['participants'][$this->owner] == 'R';
+ //echo "<p>rejected_no_show($event[title])='$ret':
user=$this->owner, event-owner=$event[owner],
status='".$event['participants'][$this->owner]."',
show_rejected='".$this->prefs['calendar']['show_rejected']."'</p>\n";
+ return $ret;
+ }
+
+ /*!
+ @function list_cals
+ @abstract generate list of user- / group-calendars for the
selectbox in the header
+ @returns alphabeticaly sorted array with groups first and then
users
+ */
+ function list_cals()
+ {
+ $users = $groups = array();
+ foreach($this->grants as $id => $rights)
+ {
+ $this->list_cals_add($id,$users,$groups);
+ }
+ if ($memberships =
$GLOBALS['phpgw']->accounts->membership($GLOBALS['phpgw_info']['user']['account_id']))
+ {
+ foreach($memberships as $group_info)
+ {
+
$this->list_cals_add($group_info['account_id'],$users,$groups);
+
+ if ($account_perms =
$GLOBALS['phpgw']->acl->get_ids_for_location($group_info['account_id'],PHPGW_ACL_READ,'calendar'))
+ {
+ foreach($account_perms as $id)
+ {
+
$this->list_cals_add($id,$users,$groups);
+ }
+ }
+ }
+ }
+ uksort($users,'strnatcasecmp');
+ uksort($groups,'strnatcasecmp');
+
+ return $users + $groups; // users first and then
groups, both alphabeticaly
+ }
+
+ /**
+ * Add user or group to the list of available groups/users in
calendar
+ *
+ * @internal moved to seperate method to fix php5 problems -
skwashd
+ * @access private
+ * @param int $id user uid
+ * @param array ref to array of users
+ * @param array ref to array of groups
+ */
+ function list_cals_add($id,&$users,&$groups)
+ {
+ $name = $GLOBALS['phpgw']->common->grab_owner_name($id);
+ if (($type =
$GLOBALS['phpgw']->accounts->get_type($id)) == 'g')
+ {
+ $arr = &$groups;
+ }
+ else
+ {
+ $arr = &$users;
+ }
+ $arr[$name] = Array(
+ 'grantor' => $id,
+ 'value' => ($type == 'g' ? 'g_' : '') .
$id,
+ 'name' => $name
+ );
+ }
+
+ /*!
+ @function event2array
+ @abstract create array with name, translated name and readable
content of each attributes of an event
+ @syntax event2array($event,$sep='<br />')
+ @param $event event to use
+ @returns array of attributes with fieldname as key and array
with the 'field'=translated name \
+ 'data' = readable content (for participants this is an
array !)
+ */
+ function event2array($event)
+ {
+ $var['title'] = Array(
+ 'field' => lang('Title'),
+ 'data' => $event['title']
+ );
+
+ // Some browser add a \n when its entered in the
database. Not a big deal
+ // this will be printed even though its not needed.
+ $var['description'] = Array(
+ 'field' => lang('Description'),
+ 'data' => $event['description']
+ );
+
+ $cats = Array();
+ $this->cat->categories($this->bo->owner,'calendar');
+ if(strpos($event['category'],','))
+ {
+ $cats = explode(',',$event['category']);
+ }
+ else
+ {
+ $cats[] = $event['category'];
+ }
+ foreach($cats as $cat_id)
+ {
+ list($cat) = $this->cat->return_single($cat_id);
+ $cat_string[] = $cat['name'];
+ }
+ $var['category'] = Array(
+ 'field' => lang('Category'),
+ 'data' => implode(', ',$cat_string)
+ );
+
+ $var['location'] = Array(
+ 'field' => lang('Location'),
+ 'data' => $event['location']
+ );
+
+ $var['startdate'] = Array(
+ 'field' => lang('Start Date/Time'),
+ 'data' =>
$GLOBALS['phpgw']->common->show_date($this->maketime($event['start']) -
$GLOBALS['phpgw']->datetime->tz_offset),
+ );
+
+ $var['enddate'] = Array(
+ 'field' => lang('End Date/Time'),
+ 'data' =>
$GLOBALS['phpgw']->common->show_date($this->maketime($event['end']) -
$GLOBALS['phpgw']->datetime->tz_offset)
+ );
+
+ $pri = Array(
+ 1 => lang('Low'),
+ 2 => lang('Normal'),
+ 3 => lang('High')
+ );
+ $var['priority'] = Array(
+ 'field' => lang('Priority'),
+ 'data' => $pri[$event['priority']]
+ );
+
+ $var['owner'] = Array(
+ 'field' => lang('Created By'),
+ 'data' =>
$GLOBALS['phpgw']->common->grab_owner_name($event['owner'])
+ );
+
+ $var['updated'] = Array(
+ 'field' => lang('Updated'),
+ 'data' =>
$GLOBALS['phpgw']->common->show_date($this->maketime($event['modtime']) -
$GLOBALS['phpgw']->datetime->tz_offset)
+ );
+
+ $var['access'] = Array(
+ 'field' => lang('Access'),
+ 'data' => $event['public'] ? lang('Public') :
lang('Privat')
+ );
+
+ if(@isset($event['groups'][0]))
+ {
+ $cal_grps = '';
+ for($i=0;$i<count($event['groups']);$i++)
+ {
+
if($GLOBALS['phpgw']->accounts->exists($event['groups'][$i]))
+ {
+ $cal_grps .= ($i>0?'<br
/>':'').$GLOBALS['phpgw']->accounts->id2name($event['groups'][$i]);
+ }
+ }
+
+ $var['groups'] = Array(
+ 'field' => lang('Groups'),
+ 'data' => $cal_grps
+ );
+ }
+
+ $participants = array();
+ if(is_array($event['participants']) )
+ {
+ foreach($event['participants'] as $user =>
$short_status)
+ {
+
if($GLOBALS['phpgw']->accounts->exists($user))
+ {
+ $participants[$user] =
$GLOBALS['phpgw']->common->grab_owner_name($user).'
('.$this->get_long_status($short_status).')';
+ }
+ }
+ }
+ $var['participants'] = Array(
+ 'field' => lang('Participants'),
+ 'data' => $participants
+ );
+
+ // Repeated Events
+ if($event['recur_type'] != MCAL_RECUR_NONE)
+ {
+ $str =
lang($this->rpt_type[$event['recur_type']]);
+
+ $str_extra = '';
+ if ($event['recur_enddate']['mday'] != 0 &&
$event['recur_enddate']['month'] != 0 && $event['recur_enddate']['year'] != 0)
+ {
+ $recur_end =
$this->maketime($event['recur_enddate']);
+ if($recur_end != 0)
+ {
+ $recur_end -=
$GLOBALS['phpgw']->datetime->tz_offset;
+ $str_extra .= lang('ends').':
'.lang($GLOBALS['phpgw']->common->show_date($recur_end,'l')).',
'.$this->long_date($recur_end).' ';
+ }
+ }
+ if($event['recur_type'] == MCAL_RECUR_WEEKLY ||
$event['recur_type'] == MCAL_RECUR_DAILY)
+ {
+ $repeat_days = array();
+ foreach ($this->rpt_day as $mcal_mask
=> $dayname)
+ {
+ if ($event['recur_data'] &
$mcal_mask)
+ {
+ $repeat_days[] =
lang($dayname);
+ }
+ }
+ if(count($repeat_days))
+ {
+ $str_extra .= lang('days
repeated').': '.implode(', ',$repeat_days);
+ }
+ }
+ if($event['recur_interval'] != 0)
+ {
+ $str_extra .= lang('Interval').':
'.$event['recur_interval'];
+ }
+
+ if($str_extra)
+ {
+ $str .= ' ('.$str_extra.')';
+ }
+
+ $var['recure_type'] = Array(
+ 'field' => lang('Repetition'),
+ 'data' => $str,
+ );
+ }
+
+ if (!isset($this->fields))
+ {
+ $this->custom_fields =
CreateObject('calendar.bocustom_fields');
+ $this->fields = &$this->custom_fields->fields;
+ $this->stock_fields =
&$this->custom_fields->stock_fields;
+ }
+ foreach($this->fields as $field => $data)
+ {
+ if (!$data['disabled'])
+ {
+ if (isset($var[$field]))
+ {
+ $sorted[$field] = $var[$field];
+ }
+ elseif
(!isset($this->stock_fields[$field]) && strlen($event[$field])) // Custom field
+ {
+ $lang = lang($name =
substr($field,1));
+ $sorted[$field] = array(
+ 'field' => $lang ==
$name.'*' ? $name : $lang,
+ 'data' =>
$event[$field]
+ );
+ }
+ }
+ unset($var[$field]);
+ }
+ foreach($var as $name => $v)
+ {
+ $sorted[$name] = $v;
+
+ }
+ return $sorted;
+ }
+
+ /*!
+ @function check_set_default_prefs
+ @abstract sets the default prefs, if they are not already set
(on a per pref. basis)
+ @note It sets a flag in the app-session-data to be called only
once per session
+ */
+ function check_set_default_prefs()
+ {
+ if (($set =
$GLOBALS['phpgw']->session->appsession('default_prefs_set','calendar')))
+ {
+ return;
+ }
+
$GLOBALS['phpgw']->session->appsession('default_prefs_set','calendar','set');
+
+ $default_prefs =
$GLOBALS['phpgw']->preferences->default['calendar'];
+
+ $subject = lang('Calendar Event') . ' - $$action$$:
$$startdate$$ $$title$$'."\n";
+ $defaults = array(
+ 'defaultcalendar' => 'week',
+ 'mainscreen_showevents' => '0',
+ 'summary' => 'no',
+ 'receive_updates' => 'no',
+ 'update_format' => 'extended', //
leave it to extended for now, as iCal kills the message-body
+ 'notifyAdded' => $subject . lang ('You have
a meeting scheduled for %1','$$startdate$$'),
+ 'notifyCanceled' => $subject . lang ('Your
meeting scheduled for %1 has been canceled','$$startdate$$'),
+ 'notifyModified' => $subject . lang ('Your
meeting that had been scheduled for %1 has been rescheduled to
%2','$$olddate$$','$$startdate$$'),
+ 'notifyResponse' => $subject . lang ('On %1 %2
%3 your meeting request for
%4','$$date$$','$$fullname$$','$$action$$','$$startdate$$'),
+ 'notifyAlarm' => lang('Alarm for %1 at %2
in %3','$$title$$','$$startdate$$','$$location$$')."\n".lang ('Here is your
requested alarm.'),
+ 'show_rejected' => '0',
+ 'display_status' => '1',
+ 'weekdaystarts' => 'Monday',
+ 'workdaystarts' => '9',
+ 'workdayends' => '17',
+ 'interval' => '30',
+ 'defaultlength' => '60',
+ 'planner_start_with_group' =>
$GLOBALS['phpgw']->accounts->name2id('Default'),
+ 'planner_intervals_per_day'=> '4',
+ 'defaultfilter' => 'all',
+ 'default_private' => '0',
+ 'display_minicals'=> '1',
+ 'print_black_white'=>'0'
+ );
+ foreach($defaults as $var => $default)
+ {
+ if (!isset($default_prefs[$var]) ||
$default_prefs[$var] == '')
+ {
+
$GLOBALS['phpgw']->preferences->add('calendar',$var,$default,'default');
+ $need_save = True;
+ }
+ }
+ if ($need_save)
+ {
+ $prefs =
$GLOBALS['phpgw']->preferences->save_repository(False,'default');
+ $this->prefs['calendar'] = $prefs['calendar'];
+ }
+ if ($this->prefs['calendar']['send_updates'] &&
!isset($this->prefs['calendar']['receive_updates']))
+ {
+ $this->prefs['calendar']['receive_updates'] =
$this->prefs['calendar']['send_updates'];
+
$GLOBALS['phpgw']->preferences->add('calendar','receive_updates',$this->prefs['calendar']['send_updates']);
+
$GLOBALS['phpgw']->preferences->delete('calendar','send_updates');
+ $prefs =
$GLOBALS['phpgw']->preferences->save_repository();
+ }
+ }
}
?>
====================================================
Index: calendar/inc/class.boalarm.inc.php
diff -u calendar/inc/class.boalarm.inc.php:1.6
calendar/inc/class.boalarm.inc.php:1.7
--- calendar/inc/class.boalarm.inc.php:1.6 Sun May 15 05:48:34 2005
+++ calendar/inc/class.boalarm.inc.php Sun May 15 06:57:37 2005
@@ -14,6 +14,10 @@
/* $Id$ */
+ define('PHPGW_ACL_DELETEALARM',PHPGW_ACL_DELETE); // for now
+ define('PHPGW_ACL_SETALARM',PHPGW_ACL_WRITE);
+ define('PHPGW_ACL_READALARM',PHPGW_ACL_READ);
+
class boalarm
{
var $so;
@@ -26,46 +30,180 @@
// var $debug = True;
var $public_functions = array(
+ 'add' => True,
+ 'delete' => True
);
function boalarm()
{
- $cal_id =
(isset($GLOBALS['HTTP_POST_VARS']['cal_id'])?intval($GLOBALS['HTTP_POST_VARS']['cal_id']):'');
+ $cal_id =
(isset($_POST['cal_id'])?intval($_POST['cal_id']):'');
if($cal_id)
{
$this->cal_id = $cal_id;
}
- $this->cal = CreateObject('calendar.bocalendar',1);
- $this->tz_offset = $this->cal->datetime->tz_offset;
+ $this->bo = CreateObject('calendar.bocalendar',1);
+ $this->so = CreateObject('calendar.socalendar',1);
+ $this->tz_offset = $this->bo->datetime->tz_offset;
if($this->debug)
{
- echo "BO Owner : ".$this->cal->owner."<br>\n";
+ echo "BO Owner : ".$this->bo->owner."<br />\n";
}
- if($this->cal->use_session)
+ if($this->bo->use_session)
{
$this->save_sessiondata();
}
-
}
function save_sessiondata()
{
$data = array(
- 'filter' => $this->cal->filter,
- 'cat_id' => $this->cal->cat_id,
- 'owner' => $this->cal->owner,
- 'year' => $this->cal->year,
- 'month' => $this->cal->month,
- 'day' => $this->cal->day
+ 'filter' => $this->bo->filter,
+ 'cat_id' => $this->bo->cat_id,
+ 'owner' => $this->bo->owner,
+ 'year' => $this->bo->year,
+ 'month' => $this->bo->month,
+ 'day' => $this->bo->day
);
- $this->cal->save_sessiondata($data);
+ $this->bo->save_sessiondata($data);
}
function read_entry($cal_id)
{
- return $this->cal->read_entry($cal_id);
+ return $this->bo->read_entry(intval($cal_id));
+ }
+
+ /*!
+ @function add
+ @abstract adds a new alarm to an event
+ @syntax add(&$event,$time,$login_id)
+ @param &$event event to add the alarm too
+ @param $time for the alarm in sec before the starttime of the
event
+ @param $login_id user to alarm
+ @returns the alarm or False
+ */
+ function add(&$event,$time,$owner)
+ {
+ if (!$this->check_perms(PHPGW_ACL_SETALARM,$owner) ||
!($cal_id = $event['id']))
+ {
+ return False;
+ }
+ $alarm = Array(
+ 'time' =>
($etime=$this->bo->maketime($event['start'])) - $time,
+ 'offset' => $time,
+ 'owner' => $owner,
+ 'enabled' => 1
+ );
+ $alarm['id'] = $this->so->save_alarm($cal_id,$alarm);
+
+ $event['alarm'][$alarm['id']] = $alarm;
+
+ return $alarm;
+ }
+
+ /*!
+ @function check_perms
+ @abstract checks if user has a certain grant from the owner of
an alarm or event
+ @syntax check_perms($grant,$owner)
+ @param $grant PHPGW_ACL_{SET|READ|DELETE}ALARM (defined at the
top of this file)
+ */
+ function check_perms($grant,$owner)
+ {
+ return $this->bo->check_perms($grant,0,$owner);
+ }
+
+ /*!
+ @function participants
+ @abstract get the participants of an event, the user has grants
to alarm
+ @syntax participants($event,$fullnames=True)
+ @param $event or cal_id of an event
+ @param $fullnames if true return array with fullnames as values
+ @returns array with account_ids as keys
+ */
+ function participants($event,$fullnames=True)
+ {
+ if (!is_array($event))
+ {
+ $event = $this->read_entry($event);
+ }
+ if (!$event)
+ {
+ return False;
+ }
+ $participants = array();
+ foreach ($event['participants'] as $uid => $status)
+ {
+ if ($this->check_perms(PHPGW_ACL_SETALARM,$uid))
+ {
+ $participants[$uid] = $fullnames ?
$GLOBALS['phpgw']->common->grab_owner_name($uid) : True;
+ }
+ }
+ return $participants;
+ }
+
+ /*!
+ @function enable
+ @abstract enable or disable one or more alarms identified by
its ids
+ @syntax enable($ids,$enable=True)
+ @param $ids array with alarm ids as keys (!)
+ @returns the number of alarms enabled or -1 for insuficent
permission to do so
+ @note Not found alarms or insuficent perms stop the enableing
of multiple alarms
+ */
+ function enable($alarms,$enable=True)
+ {
+ $enabled = 0;
+ foreach ($alarms as $id => $field)
+ {
+ if (!($alarm = $this->so->read_alarm($id)))
+ {
+ return 0; // alarm not found
+ }
+ if (!$alarm['enabled'] == !$enable)
+ {
+ continue; // nothing to do
+ }
+ if ($enable &&
!$this->check_perms(PHPGW_ACL_SETALARM,$alarm['owner']) ||
+ !$enable &&
!$this->check_perms(PHPGW_ACL_DELETEALARM,$alarm['owner']))
+ {
+ return -1;
+ }
+ $alarm['enabled'] = intval(!$alarm['enabled']);
+ if
($this->so->save_alarm($alarm['cal_id'],$alarm))
+ {
+ ++$enabled;
+ }
+ }
+ return $enabled;
+ }
+
+ /*!
+ @function delete
+ @abstract delete one or more alarms identified by its ids
+ @syntax delete($ids)
+ @param $ids array with alarm ids as keys (!)
+ @returns the number of alarms deleted or -1 for insuficent
permission to do so
+ @note Not found alarms or insuficent perms stop the deleting of
multiple alarms
+ */
+ function delete($alarms)
+ {
+ $deleted = 0;
+ foreach ($alarms as $id => $field)
+ {
+ if (!($alarm = $this->so->read_alarm($id)))
+ {
+ return 0; // alarm not found
+ }
+ if
(!$this->check_perms(PHPGW_ACL_DELETEALARM,$alarm['owner']))
+ {
+ return -1;
+ }
+ if ($this->so->delete_alarm($id))
+ {
+ ++$deleted;
+ }
+ }
+ return $deleted;
}
- /* Public functions */
}
+?>
====================================================
Index: calendar/inc/class.holidaycalc_JP.inc.php
diff -u calendar/inc/class.holidaycalc_JP.inc.php:1.5
calendar/inc/class.holidaycalc_JP.inc.php:1.6
--- calendar/inc/class.holidaycalc_JP.inc.php:1.5 Sun May 15 05:48:34 2005
+++ calendar/inc/class.holidaycalc_JP.inc.php Sun May 15 06:57:37 2005
@@ -15,27 +15,43 @@
class holidaycalc {
- function calculate_date($holiday, &$holidays, $year, $datetime, &$i)
+ function calculate_date($holiday, &$holidays, $year, &$i)
{
+ static $cached_month;
+ static $cached_day;
+ static $cached_observance_rule;
- if($holiday['day'] == 0 && $holiday['dow'] != 0 &&
$holiday['occurence'] != 0)
+ if ($holiday['day'] == 0 && $holiday['dow'] != 0 &&
$holiday['occurence'] != 0)
{
- // for Coming of Age Day and Health and Sports Day
+ $dow = $GLOBALS['phpgw']->datetime->day_of_week($year,
$holiday['month'], 1);
+ $dayshift = (($holiday['dow'] + 7) - $dow) % 7;
+ $day = ($holiday['occurence'] - 1) * 7 + $dayshift + 1;
+
// Happy monday law.
- if ($year >= 2000)
+ if ($holiday['month'] == 1)
+ {
+ if ($year < 2000)
+ {
+ $day = 15;
+ }
+ }
+ elseif ($holiday['month'] == 7)
{
- $dow = $datetime->day_of_week($year,
$holiday['month'], 1);
- $dayshift = (($holiday['dow'] + 7) - $dow) % 7;
- $day = ($holiday['occurence'] - 1) * 7 +
$dayshift + 1;
+ if ($year < 2003)
+ {
+ $day = 20;
+ }
}
- else
+ elseif ($holiday['month'] == 9)
{
- // non Happy monday law.
- if ($holiday['month'] == 1)
+ if ($year < 2003)
{
$day = 15;
}
- elseif ($holiday['month'] == 10)
+ }
+ elseif ($holiday['month'] == 10)
+ {
+ if ($year < 2000)
{
$day = 10;
}
@@ -79,21 +95,53 @@
$day = $holiday['day'];
}
- if($holiday['observance_rule'] == True)
+ if ($year >= 1985 && $holiday['month'] == $cached_month && $day
== $cached_day + 2 && $cached_observance_rule == True &&
$holiday['observance_rule'] == True)
+ {
+ $pdow =
$GLOBALS['phpgw']->datetime->day_of_week($year,$holiday['month'],$day-1);
+ if ($pdow != 0)
+ {
+ $addcnt = count($holidays) + 1;
+ $holidays[$addcnt]['locale'] =
$holiday['locale'];
+ if ($pdow == 1)
+ {
+ $holidays[$addcnt]['name'] =
lang('overlap holiday');
+ }
+ else
+ {
+ $holidays[$addcnt]['name'] =
lang('people holiday');
+ }
+ $holidays[$addcnt]['day'] = $day - 1;
+ $holidays[$addcnt]['month'] = $holiday['month'];
+ $holidays[$addcnt]['occurence'] = 0;
+ $holidays[$addcnt]['dow'] = 0;
+ $holidays[$addcnt]['date'] =
mktime(0,0,0,$holiday['month'],$day-1,$year);
+ $holidays[$addcnt]['observance_rule'] = 0;
+ }
+ }
+
+ $cached_month = $holiday['month'];
+ $cached_day = $day;
+ $cached_observance_rule = $holiday['observance_rule'];
+
+ if ($year >= 1985 && $holiday['month'] == 5 && $day == 3)
+ {
+ ;
+ }
+ elseif ($holiday['observance_rule'] == True)
{
- $dow =
$datetime->day_of_week($year,$holiday['month'],$day);
+ $dow =
$GLOBALS['phpgw']->datetime->day_of_week($year,$holiday['month'],$day);
// This now calulates Observed holidays and creates a
new entry for them.
if($dow == 0)
{
- $i++;
- $holidays[$i]['locale'] = $holiday['locale'].'
(Observed)';
- $holidays[$i]['name'] = lang('overlap holiday');
- $holidays[$i]['day'] = $holiday['day'] + 1;
- $holidays[$i]['month'] = $holiday['month'];
- $holidays[$i]['occurence'] =
$holiday['occurence'];
- $holidays[$i]['dow'] = $holiday['dow'];
- $holidays[$i]['date'] =
mktime(0,0,0,$holiday['month'],$day+1,$year);
- $holidays[$i]['obervance_rule'] = 0;
+ $addcnt = count($holidays) + 1;
+ $holidays[$addcnt]['locale'] =
$holiday['locale'];
+ $holidays[$addcnt]['name'] = lang('overlap
holiday');
+ $holidays[$addcnt]['day'] = $day + 1;
+ $holidays[$addcnt]['month'] = $holiday['month'];
+ $holidays[$addcnt]['occurence'] =
$holiday['occurence'];
+ $holidays[$addcnt]['dow'] = $holiday['dow'];
+ $holidays[$addcnt]['date'] =
mktime(0,0,0,$holiday['month'],$day+1,$year);
+ $holidays[$addcnt]['observance_rule'] = 0;
}
}
====================================================
Index: class.uicustom_fields.inc.php
<?php
/**************************************************************************\
* phpGroupWare - Calendar - Custom fields and sorting *
* http://www.phpgroupware.org *
* Written by Ralf Becker <address@hidden> *
* -------------------------------------------- *
* 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: class.uicustom_fields.inc.php,v 1.2 2005/05/15 06:57:37 skwashd
Exp $ */
require_once(PHPGW_INCLUDE_ROOT.'/calendar/inc/class.bocustom_fields.inc.php');
$GLOBALS['phpgw_info']['flags']['included_classes']['bocustom_fields']
= True; // for 0.9.14
class uicustom_fields extends bocustom_fields
{
var $public_functions = array(
'index' => True,
'submited' => True
);
function uicustom_fields()
{
$this->bocustom_fields(); // call constructor of
extended class
$this->tpl = $GLOBALS['phpgw']->template;
if (!is_object($GLOBALS['phpgw']->nextmatchs))
{
$GLOBALS['phpgw']->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
}
$this->html = CreateObject('calendar.html');
}
function index($error='')
{
unset($GLOBALS['phpgw_info']['flags']['noheader']);
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
$GLOBALS['phpgw_info']['flags']['app_header'] =
$GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Custom fields
and sorting');
$GLOBALS['phpgw']->common->phpgw_header();
$this->tpl = $GLOBALS['phpgw']->template;
$this->tpl->set_unknowns('remove');
$this->tpl->set_file(array(
'custom_fields_tpl' => 'custom_fields.tpl'
));
$this->tpl->set_block('custom_fields_tpl','custom_fields','custom_fields');
$this->tpl->set_block('custom_fields_tpl','row','row');
$n = 0;
foreach($this->fields as $field => $data)
{
$data['order'] = ($n += 10);
if (isset($this->stock_fields[$field]))
{
$this->set_row($data,$field);
}
else
{
$this->set_row($data,$field,'delete','Delete');
}
}
$this->tpl->set_var(array(
'hidden_vars' => '',
'lang_error' => $error,
'lang_name' => lang('Name'),
'lang_length' => lang('Length<br />(<= 255)'),
'lang_shown' => lang('Length shown<br
/>(emtpy for full length)'),
'lang_order' => lang('Order'),
'lang_title' => lang('Title-row'),
'lang_disabled'=> lang('Disabled'),
'action_url' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicustom_fields.submited'),
'save_button' =>
$this->html->submit_button('save','Save'),
'cancel_button'=>
$this->html->submit_button('cancel','Cancel'),
));
$this->set_row(array('order' =>
$n+10),'***new***','add','Add');
$this->tpl->pfp('out','custom_fields');
}
function set_row($values,$id='',$name='',$label='')
{
if ($id !== '')
{
$id = '['.htmlspecialchars($id).']';
}
$this->tpl->set_var(array(
'name' => $values['label'] ?
lang($values['label']) :
$this->html->input('name'.$id,$values['name'],'','SIZE="40" MAXLENGTH="40"'),
'length' => $values['label'] ? ' ' :
$this->html->input('length'.$id,$values['length'],'','SIZE="3"'),
'shown' => $values['label'] ? ' ' :
$this->html->input('shown'.$id,$values['shown'],'','SIZE="3"'),
'order' =>
$this->html->input('order'.$id,$values['order'],'','SIZE="3"'),
'title' =>
$this->html->checkbox('title'.$id,$values['title']),
'disabled'=>
$this->html->checkbox('disabled'.$id,$values['disabled']),
'button' => $name ?
$this->html->submit_button($name.$id,$label) : ' '
));
if ($name !== 'add')
{
$this->tpl->set_var('tr_color',$values['title']
? $GLOBALS['phpgw_info']['theme']['th_bg'] :
$GLOBALS['phpgw']->nextmatchs->alternate_row_color());
$this->tpl->parse('rows','row',True);
}
}
function submited()
{
if ($_POST['cancel'])
{
$GLOBALS['phpgw']->redirect_link('/admin/');
}
//echo "<pre>"; print_r($_POST); echo "</pre>";
foreach ($_POST['order'] as $field => $order)
{
if (isset($_POST['delete'][$field]) || $field
== '***new***')
{
continue;
}
while(isset($ordered[$order]))
{
++$order;
}
$ordered[$order] = array(
'field' => $field,
'name' =>
stripslashes($_POST['name'][$field]),
'length' =>
intval($_POST['length'][$field]),
'shown' =>
intval($_POST['shown'][$field]),
'title' =>
!!$_POST['title'][$field],
'disabled' =>
!!$_POST['disabled'][$field]
);
if (isset($this->stock_fields[$field]))
{
$ordered[$order]['name'] =
$this->fields[$field]['name'];
$ordered[$order]['label'] =
$this->fields[$field]['label'];
}
}
if (isset($_POST['add']) ||
strlen($_POST['name']['***new***']))
{
$name =
stripslashes($_POST['name']['***new***']);
if (!strlen($name) ||
array_search($name,$_POST['name']) != '***new***')
{
$error .= lang('New name must not exist
and not be empty!!!');
}
else
{
$order = $_POST['order']['***new***'];
while(isset($_POST['order'][$order]))
{
++$order;
}
$ordered[$order] = array(
'field' => '#'.$name,
'name' => $name,
'length' =>
intval($_POST['length']['***new***']),
'shown' =>
intval($_POST['shown']['***new***']),
'title' =>
!!$_POST['title']['***new***'],
'disabled' =>
!!$_POST['disabled']['***new***']
);
}
}
//echo "<pre>"; print_r($ordered); echo "</pre>\n";
ksort($ordered,SORT_NUMERIC);
$this->fields = array();
foreach($ordered as $order => $data)
{
if ($data['length'] > 255)
{
$data['length'] = 255;
}
if ($data['length'] <= 0)
{
unset($data['length']);
}
if ($data['shown'] >= $data['length'] ||
$data['shown'] <= 0)
{
unset($data['shown']);
}
if (!$data['title'])
{
unset($data['title']);
}
if (!$data['disabled'])
{
unset($data['disabled']);
}
$field = $data['field'];
unset($data['field']);
$this->fields[$field] = $data;
}
if (!$error && isset($_POST['save']))
{
$this->save();
$GLOBALS['phpgw']->redirect_link('/admin/');
}
$this->index($error);
}
}
?>
====================================================
Index: hook_sidebox_menu.inc.php
<?php
/**************************************************************************\
* phpGroupWare - Calendar's Sidebox-Menu for idots-template *
* http://www.phpgroupware.org *
* Written by Pim Snel <address@hidden> *
* -------------------------------------------- *
* 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: hook_sidebox_menu.inc.php,v 1.2 2005/05/15 06:57:37 skwashd Exp $ */
{
/*
This hookfile is for generating an app-specific side menu used in the
idots
template set.
$menu_title speaks for itself
$file is the array with link to app functions
display_sidebox can be called as much as you like
*/
$menu_title = $GLOBALS['phpgw_info']['apps'][$appname]['title'] . ' '.
lang('Menu');
$file = Array(
array('text' => 'New Entry',
'url' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.add')),
array('text' => '_NewLine_'),
array('text' => 'Today',
'url' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.day')),
array('text' => 'This week',
'url' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.week')),
array('text' => 'This month',
'url' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.month')),
array('text' => 'This year',
'url' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.year')),
array('text' => '_NewLine_'), // give a newline
array('text' => 'Group Planner',
'url' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.planner')),
array('text' => 'Daily Matrix View',
'url' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.matrixselect')),
array('text' => 'Import',
'url'
=>$GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uiicalendar.import')),
);
display_sidebox($appname,$menu_title,$file);
if ($GLOBALS['phpgw_info']['user']['apps']['preferences'])
{
$menu_title = lang('Preferences');
$file = Array(
array('text' => 'Calendar preferences',
'url'
=>$GLOBALS['phpgw']->link('/preferences/preferences.php','appname=calendar')),
array('text' => 'Grant Access',
'url'
=>$GLOBALS['phpgw']->link('/index.php','menuaction=preferences.uiaclprefs.index&acl_app=calendar')),
array('text' => 'Edit Categories',
'url'
=>$GLOBALS['phpgw']->link('/index.php','menuaction=preferences.uicategories.index&cats_app=calendar&cats_level=True&global_cats=True')),
);
display_sidebox($appname,$menu_title,$file);
}
if ($GLOBALS['phpgw_info']['user']['apps']['admin'])
{
$menu_title = lang('Administration');
$file = Array(
array('text' => 'Configuration',
'url' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiconfig.index&appname=calendar')),
array('text' => 'Custom Fields',
'url'
=>$GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicustom_fields.index')),
array('text' => 'Holiday Management',
'url'
=>$GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uiholiday.admin')),
array('text' => 'Global Categories',
'url'
=>$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uicategories.index&appname=calendar')),
);
display_sidebox($appname,$menu_title,$file);
}
}
?>
====================================================
Index: class.bocustom_fields.inc.php
<?php
/**************************************************************************\
* phpGroupWare - Calendar - Custom fields and sorting *
* http://www.phpgroupware.org *
* Written by Ralf Becker <address@hidden> *
* -------------------------------------------- *
* 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: class.bocustom_fields.inc.php,v 1.2 2005/05/15 06:57:37 skwashd
Exp $ */
class bocustom_fields
{
var $stock_fields = array(
'title' => array(
'label' => 'Title',
'title' => True
),
'description' => 'Description',
'category' => 'Category',
'location' => 'Location',
'startdate' => 'Start Date/Time',
'enddate' => 'End Date/Time',
'priority' => 'Priority',
'access' => 'Access',
'participants'=> 'Participants',
'owner' => 'Created By',
'updated' => 'Updated',
'alarm' => 'Alarm',
'recure_type' => 'Repetition'
);
function bocustom_fields()
{
$this->config =
CreateObject('phpgwapi.config','calendar');
$this->config->read_repository();
$this->fields = &$this->config->config_data['fields'];
if (!is_array($this->fields)) {
$this->fields = array();
}
foreach ($this->fields as $field => $data) // this
can be removed after a while
{
if (!isset($this->stock_fields[$field]) &&
$field[0] != '#')
{
unset($this->fields[$field]);
$this->fields['#'.$field] = $data;
}
}
foreach($this->stock_fields as $field => $data)
{
if (!is_array($data))
{
$data = array('label' => $data);
}
if (!isset($this->fields[$field]))
{
$this->fields[$field] = array(
'name' => $field,
'title' => $data['title'],
'disabled' => $data['disabled']
);
}
$this->fields[$field]['label'] =
$data['label'];
$this->fields[$field]['length'] =
$data['length'];
$this->fields[$field]['shown'] =
$data['shown'];
}
}
function set($data)
{
if (is_array($data) && strlen($data['name']) > 0)
{
if (!isset($this->stock_fields[$name =
$data['name']]))
{
$name = '#'.$name;
}
$this->fields[$name] = $data;
}
}
function save($fields=False)
{
if ($fields)
{
$this->fields = $fields;
}
//echo "<pre>"; print_r($this->config->config_data);
echo "</pre>\n";
$this->config->save_repository();
}
}
- [Phpgroupware-cvs] calendar/inc hook_deleteaccount.inc.php, 1.7 hook_admin.inc.php, 1.15 hook_add_def_pref.inc.php, 1.4 hook_email.inc.php, 1.8 hook_home.inc.php, 1.42 hook_home_month.inc.php, 1.6 hook_home_day.inc.php, 1.6 class.uiicalendar.inc.php, 1.9 class.uiholiday.inc.php, 1.9 class.socalendar_sql.inc.php, 1.37 class.socalendar__.inc.php, 1.16 class.soholiday.inc.php, 1.6 class.uialarm.inc.php, 1.9 class.uicalendar.inc.php, 1.108 hook_home_planner.inc.php, 1.5 hook_home_week.inc.php, 1.6 hook_manual.inc.php, 1.7 hook_home_year.inc.php, 1.6 hook_preferences.inc.php, 1.26 hook_settings.inc.php, 1.5 class.socalendar_.inc.php, 1.7 class.socalendar.inc.php, 1.29 class.calendar_holiday.inc.php, 1.26 class.boicalendar.inc.php, 1.25 class.calendar_icap.inc.php, 1.18 class.holidaycalc.inc.php, 1.8 class.html.inc.php, 1.5 class.holidaycalc_US.inc.php, 1.10 class.boholiday.inc.php, 1.14 class.bocalendar.inc.php, 1.93 class.boalarm.inc.php, 1.7 class.holidaycalc_JP.inc.php, 1.6 class.uicustom_fields.inc.php, 1.2 hook_sidebo x_menu.inc.php,1.2 class.bocustom_fields.inc.php,1.2,
skwashd <=
- [Phpgroupware-cvs] calendar/inc hook_deleteaccount.inc.php, 1.7 hook_admin.inc.php, 1.15 hook_add_def_pref.inc.php, 1.4 hook_email.inc.php, 1.8 hook_home.inc.php, 1.42 hook_home_month.inc.php, 1.6 hook_home_day.inc.php, 1.6 class.uiicalendar.inc.php, 1.9 class.uiholiday.inc.php, 1.9 class.socalendar_sql.inc.php, 1.37 class.socalendar__.inc.php, 1.16 class.soholiday.inc.php, 1.6 class.uialarm.inc.php, 1.9 class.uicalendar.inc.php, 1.108 hook_home_planner.inc.php, 1.5 hook_home_week.inc.php, 1.6 hook_manual.inc.php, 1.7 hook_home_year.inc.php, 1.6 hook_preferences.inc.php, 1.26 hook_settings.inc.php, 1.5 class.socalendar_.inc.php, 1.7 class.socalendar.inc.php, 1.29 class.calendar_holiday.inc.php, 1.26 class.boicalendar.inc.php, 1.25 class.calendar_icap.inc.php, 1.18 class.holidaycalc.inc.php, 1.8 class.html.inc.php, 1.5 class.holidaycalc_US.inc.php, 1.10 class.boholiday.inc.php, 1.14 class.bocalendar.inc.php, 1.93 class.boalarm.inc.php, 1.7 class.holidaycalc_JP.inc.php, 1.6 class.uicustom_fields.inc.php, 1.2 hook_sidebo x_menu.inc.php,1.2 class.bocustom_fields.inc.php,1.2, skwashd, 2005/05/16
- [Phpgroupware-cvs] calendar/inc hook_deleteaccount.inc.php, 1.7 hook_admin.inc.php, 1.15 hook_add_def_pref.inc.php, 1.4 hook_email.inc.php, 1.8 hook_home.inc.php, 1.42 hook_home_month.inc.php, 1.6 hook_home_day.inc.php, 1.6 class.uiicalendar.inc.php, 1.9 class.uiholiday.inc.php, 1.9 class.socalendar_sql.inc.php, 1.37 class.socalendar__.inc.php, 1.16 class.soholiday.inc.php, 1.6 class.uialarm.inc.php, 1.9 class.uicalendar.inc.php, 1.108 hook_home_planner.inc.php, 1.5 hook_home_week.inc.php, 1.6 hook_manual.inc.php, 1.7 hook_home_year.inc.php, 1.6 hook_preferences.inc.php, 1.26 hook_settings.inc.php, 1.5 class.socalendar_.inc.php, 1.7 class.socalendar.inc.php, 1.29 class.calendar_holiday.inc.php, 1.26 class.boicalendar.inc.php, 1.25 class.calendar_icap.inc.php, 1.18 class.holidaycalc.inc.php, 1.8 class.html.inc.php, 1.5 class.holidaycalc_US.inc.php, 1.10 class.boholiday.inc.php, 1.14 class.bocalendar.inc.php, 1.93 class.boalarm.inc.php, 1.7 class.holidaycalc_JP.inc.php, 1.6 class.uicustom_fields.inc.php, 1.2 hook_sidebo x_menu.inc.php,1.2 class.bocustom_fields.inc.php,1.2, skwashd, 2005/05/17
- [Phpgroupware-cvs] calendar/inc hook_deleteaccount.inc.php, 1.7 hook_admin.inc.php, 1.15 hook_add_def_pref.inc.php, 1.4 hook_email.inc.php, 1.8 hook_home.inc.php, 1.42 hook_home_month.inc.php, 1.6 hook_home_day.inc.php, 1.6 class.uiicalendar.inc.php, 1.9 class.uiholiday.inc.php, 1.9 class.socalendar_sql.inc.php, 1.37 class.socalendar__.inc.php, 1.16 class.soholiday.inc.php, 1.6 class.uialarm.inc.php, 1.9 class.uicalendar.inc.php, 1.108 hook_home_planner.inc.php, 1.5 hook_home_week.inc.php, 1.6 hook_manual.inc.php, 1.7 hook_home_year.inc.php, 1.6 hook_preferences.inc.php, 1.26 hook_settings.inc.php, 1.5 class.socalendar_.inc.php, 1.7 class.socalendar.inc.php, 1.29 class.calendar_holiday.inc.php, 1.26 class.boicalendar.inc.php, 1.25 class.calendar_icap.inc.php, 1.18 class.holidaycalc.inc.php, 1.8 class.html.inc.php, 1.5 class.holidaycalc_US.inc.php, 1.10 class.boholiday.inc.php, 1.14 class.bocalendar.inc.php, 1.93 class.boalarm.inc.php, 1.7 class.holidaycalc_JP.inc.php, 1.6 class.uicustom_fields.inc.php, 1.2 hook_sidebo x_menu.inc.php,1.2 class.bocustom_fields.inc.php,1.2, skwashd, 2005/05/17
- Prev by Date:
[Phpgroupware-cvs] calendar ical.php, 1.2 index.php, 1.49 preferences.php, 1.44
- Next by Date:
[Phpgroupware-cvs] admin/inc class.uicurrentsessions.inc.php,1.11
- Previous by thread:
[Phpgroupware-cvs] calendar ical.php, 1.2 index.php, 1.49 preferences.php, 1.44
- Next by thread:
[Phpgroupware-cvs] calendar/inc hook_deleteaccount.inc.php, 1.7 hook_admin.inc.php, 1.15 hook_add_def_pref.inc.php, 1.4 hook_email.inc.php, 1.8 hook_home.inc.php, 1.42 hook_home_month.inc.php, 1.6 hook_home_day.inc.php, 1.6 class.uiicalendar.inc.php, 1.9 class.uiholiday.inc.php, 1.9 class.socalendar_sql.inc.php, 1.37 class.socalendar__.inc.php, 1.16 class.soholiday.inc.php, 1.6 class.uialarm.inc.php, 1.9 class.uicalendar.inc.php, 1.108 hook_home_planner.inc.php, 1.5 hook_home_week.inc.php, 1.6 hook_manual.inc.php, 1.7 hook_home_year.inc.php, 1.6 hook_preferences.inc.php, 1.26 hook_settings.inc.php, 1.5 class.socalendar_.inc.php, 1.7 class.socalendar.inc.php, 1.29 class.calendar_holiday.inc.php, 1.26 class.boicalendar.inc.php, 1.25 class.calendar_icap.inc.php, 1.18 class.holidaycalc.inc.php, 1.8 class.html.inc.php, 1.5 class.holidaycalc_US.inc.php, 1.10 class.boholiday.inc.php, 1.14 class.bocalendar.inc.php, 1.93 class.boalarm.inc.php, 1.7 class.holidaycalc_JP.inc.php, 1.6 class.uicustom_fields.inc.php, 1.2 hook_sidebo x_menu.inc.php,1.2 class.bocustom_fields.inc.php,1.2
- Index(es):