diff --git a/calendar/inc/class.bocalendar.inc.php b/calendar/inc/class.bocalendar.inc.php
index 7d5e094771..1ee04144f5 100755
--- a/calendar/inc/class.bocalendar.inc.php
+++ b/calendar/inc/class.bocalendar.inc.php
@@ -461,13 +461,15 @@
print_debug('count event exceptions',count($event['recur_exception']));
$this->so->add_entry($event);
$cd = 16;
+
+ $this->so->cal->event = $temp_event;
+ unset($temp_event);
}
else
{
$cd = 60;
}
- $this->so->cal->event = $temp_event;
- unset($temp_event);
+// }
return $cd;
}
@@ -879,6 +881,45 @@
return mktime($time['hour'],$time['min'],$time['sec'],$time['month'],$time['mday'],$time['year']);
}
+ /*!
+ @function time2array
+ @abstract returns a date-array suitable for the start- or endtime of an event from a timestamp
+ @syntax time2array($time,$alarm=0)
+ @param $time the timestamp for the values of the array
+ @param $alarm (optional) alarm field of the array, defaults to 0
+ @author ralfbecker
+ */
+ function time2array($time,$alarm = 0)
+ {
+ return array(
+ 'year' => intval(date('Y',$time)),
+ 'month' => intval(date('m',$time)),
+ 'mday' => intval(date('d',$time)),
+ 'hour' => intval(date('H',$time)),
+ 'min' => intval(date('i',$time)),
+ 'sec' => intval(date('s',$time)),
+ 'alarm' => intval($alarm)
+ );
+ }
+
+ /*!
+ @function set_recur_date
+ @abstract set the start- and enddates of a recuring event for a recur-date
+ @syntax set_recur_date(&$event,$date)
+ @param $event the event which fields to set (has to be the original event for start-/end-times)
+ @param $date the recuring date in form 'Ymd', eg. 20030226
+ @author ralfbecker
+ */
+ function set_recur_date(&$event,$date)
+ {
+ $org_start = $this->maketime($event['start']);
+ $org_end = $this->maketime($event['end']);
+ $start = mktime($event['start']['hour'],$event['start']['min'],0,substr($date,4,2),substr($date,6,2),substr($date,0,4));
+ $end = $org_end + $start - $org_start;
+ $event['start'] = $this->time2array($start);
+ $event['end'] = $this->time2array($end);
+ }
+
function fix_update_time(&$time_param)
{
if ($this->prefs['common']['timeformat'] == '12')
@@ -2201,79 +2242,28 @@
function remove_doubles_in_cache($firstday,$lastday)
{
$already_moved = Array();
- $has_category = Array(); // remove only multiple occurences of a category per event/day
for($v=$firstday;$v<=$lastday;$v++)
{
if (!$this->cached_events[$v])
{
continue;
}
- while (list($g,$event) = each($this->cached_events[$v]))
+ $cached = $this->cached_events[$v];
+ $this->cached_events[$v] = array();
+ while (list($g,$event) = each($cached))
{
- $start = sprintf('%04d%02d%02d',$event['start']['year'],$event['start']['month'],$event['start']['mday']);
+ $end = date('Ymd',$this->maketime($event['end']));
print_debug('EVENT',_debug_array($event,False));
print_debug('start',$start);
print_debug('v',$v);
- if($start < $firstday)
+ if (!isset($already_moved[$event['id']]) || $event['recur_type'] && $v > $end)
{
- $start = $firstday; // event continues into current month/year
- }
-
-// if ($start != $v && $event['recur_type'] == MCAL_RECUR_NONE) // this is an enddate-entry --> remove it
- if ($start != $v) // this is an enddate-entry --> remove it
- {
- unset($this->cached_events[$v][$g]);
- if($g != count($this->cached_events[$v]))
- {
- if ($has_category[$event['id']]['category'] != True)
- {
- continue; // we need at least one evidence for this category
- }
- for($h=$g + 1;$h<$c_daily;$h++)
- {
- $this->cached_events[$v][$h - 1] = $this->cached_events[$v][$h];
- }
- unset($this->cached_events[$v][$h]);
- $has_category[$event['id']]['category'] = True;
- }
-
-// if ($start < $firstday && $event['recur_type'] == MCAL_RECUR_NONE) // start before period --> move it to the beginning
- if ($start < $firstday) // start before period --> move it to the beginning
- {
- if($already_moved[$event['id']] > 0)
- {
- continue;
- }
- $add_event = True;
- $c_events = count($this->cached_events[$firstday]);
- for($i=0;$i<$c_events;$i++)
- {
- $add_event = ($this->cached_events[$firstday][$i]['id'] == $event['id']?False:$add_event);
- }
- if($add_event)
- {
- $this->cached_events[$firstday][] = $event;
- $already_moved[$event['id']] = 1;
- print_debug('Event moved');
- }
- else
- {
- $already_moved[$event['id']] = 2;
- print_debug('Event removed (not moved)');
- }
- }
- else
- {
- print_debug('Event removed');
- }
- }
- else
- {
- print_debug('Event OK');
+ $this->cached_events[$v][] = $event;
+ $already_moved[$event['id']] = 1;
+ print_debug('Event moved');
}
}
- flush();
}
}
diff --git a/calendar/inc/class.uicalendar.inc.php b/calendar/inc/class.uicalendar.inc.php
index 2164d2f711..6124f27ea8 100755
--- a/calendar/inc/class.uicalendar.inc.php
+++ b/calendar/inc/class.uicalendar.inc.php
@@ -1028,6 +1028,7 @@
'action_text_button' => lang('Delete Single'),
'action_confirm_button' => "onClick=\"return confirm('".lang("Are you sure\\nyou want to\\ndelete this single occurence ?\\n\\nThis will delete\\nthis entry for all users.")."')\"",
'action_extra_field' => ''
+ . ''
);
$p->set_var($var);
$p->parse('phpgw_body','form_button',True);
@@ -1093,11 +1094,12 @@
function edit($params='')
{
- if(!$this->bo->check_perms(PHPGW_ACL_EDIT))
- {
- $this->no_edit();
- }
-
+// No event loaded, so what to check?
+// if(!$this->bo->check_perms(PHPGW_ACL_EDIT))
+// {
+// $this->no_edit();
+// }
+
if($this->debug)
{
echo ''."\n";
@@ -1140,18 +1142,14 @@
if(@isset($GLOBALS['HTTP_POST_VARS']['edit_type']) && $GLOBALS['HTTP_POST_VARS']['edit_type'] == 'single')
{
$event['id'] = 0;
- $event['start']['month'] = $this->bo->month;
- $event['start']['mday'] = $this->bo->day;
- $event['start']['year'] = $this->bo->year;
- $event['end']['month'] = $this->bo->month;
- $event['end']['mday'] = $this->bo->day;
- $event['end']['year'] = $this->bo->year;
+ $this->bo->set_recur_date($event,$GLOBALS['HTTP_POST_VARS']['date']);
$event['recur_type'] = MCAL_RECUR_NONE;
$event['recur_interval'] = 0;
$event['recur_data'] = 0;
$event['recur_enddate']['month'] = 0;
$event['recur_enddate']['mday'] = 0;
$event['recur_enddate']['year'] = 0;
+ $event['recur_execption'] = array();
}
$this->edit_form(
Array(
@@ -1427,12 +1425,13 @@
$delete_type = get_var('delete_type',Array('POST'));
if($deleted_type && $delete_type == 'single')
{
+ $date = $GLOBALS['HTTP_POST_VARS']['date'];
$cd = $this->bo->delete_single(
Array(
'id' => intval($cal_id),
- 'year' => $this->bo->year,
- 'month' => $this->bo->month,
- 'day' => $this->bo->day
+ 'year' => substr($date,0,4),
+ 'month' => substr($date,4,2),
+ 'day' => substr($date,6,2)
)
);
}
@@ -1822,7 +1821,7 @@
/**
* planner_update_row - update a row of the planner view
*
- * parameters are:
+ * parameters are:
* - index (e.g. user id, category id, ...) of the row
* - name/title of the row (e.g. user name, category name)
* - the event to be integrated
@@ -1834,11 +1833,12 @@
$rows = &$this->planner_rows;
$intervals_per_day = $this->bo->prefs['calendar']['planner_intervals_per_day'];
$is_private = !$this->bo->check_perms(PHPGW_ACL_READ,$event);
-
+
$view = $this->planner_html->link('/index.php',
array(
'menuaction' => 'calendar.uicalendar.view',
- 'cal_id' => $event['id']
+ 'cal_id' => $event['id'],
+ 'date' => date('Ymd',$this->bo->maketime($event['start']))
)
);
@@ -1869,13 +1869,14 @@
$akt_cell = &$rows[$ka];
} while ($akt_cell > $start_cell);
+ $id = $event['id'].'-'.date('Ymd',$this->bo->maketime($event['start']));
if ($akt_cell < $start_cell)
{
- $row[$event['id'].'_1'] = ' ';
- $row['.'.$event['id'].'_1'] = 'colspan="'.($start_cell-$akt_cell).'"';
+ $row[$id.'_1'] = ' ';
+ $row['.'.$id.'_1'] = 'colspan="'.($start_cell-$akt_cell).'"';
}
- $opt = &$row['.'.$event['id'].'_2'];
- $cel = &$row[$event['id'].'_2'];
+ $opt = &$row['.'.$id.'_2'];
+ $cel = &$row[$id.'_2'];
// if possible, display information about event within cells representing it
//
@@ -1955,6 +1956,10 @@
{
$cel .= $this->planner_html->image('calendar','mini-calendar-bar.gif','','border="0"');
}
+ if ($event['recur_type'])
+ {
+ $cel .= $this->planner_html->image('calendar','recur.gif','','border="0"');
+ }
$cel .= $this->planner_html->image('calendar',count($event['participants'])>1?'multi_3.gif':'single.gif',$this->planner_participants($event['participants']),'border="0"');
$cel .= '';
@@ -2006,7 +2011,6 @@
if ($event_end <= $this->planner_lastday)
{
$days_between = $GLOBALS['phpgw']->datetime->days_between($this->bo->month,1,$this->bo->year,$event['end']['month'],$event['end']['mday'],$event['end']['year']);
-
$end_cell = $intervals_per_day * $days_between + $interval[$event['end']['hour']];
if ($end_cell == $start_cell && $end_cell < $last_cell)
{
@@ -2017,7 +2021,6 @@
{
$end_cell = $last_cell;
}
-
// get the categories associated with event
//
if ($c = $event['category'])
@@ -2156,8 +2159,12 @@
// process all events on day $v
//
- while (list($nul,$event) = @each($daily))
+ while (list(,$event) = @each($daily))
{
+ if ($event['recur_type']) // calculate start- + end-datetime for recuring events
+ {
+ $this->bo->set_recur_date($event,$v);
+ }
$this->planner_process_event($event);
}
}
@@ -3719,7 +3726,7 @@
if((($ind <> 99) && ($ind <> 0)) && (($starttime <> 0) && ($endtime <> 0)))
{
print_debug('IND before',$ind);
- if($ind <= date('H',$last_endtime-1)) // -1 to allow events to end on a full hour, without blocking the next hour-slot
+ if($ind <= date('H',$last_endtime-1) && $last_ind) // -1 to allow events to end on a full hour, without blocking the next hour-slot
{
$ind = $last_ind;
$interval_start = $last_interval_start;
@@ -4379,7 +4386,7 @@
$var = Array(
'action_url_button' => $this->page('delete','&cal_id='.$event['id']),
'action_text_button' => lang('Delete'),
- 'action_confirm_button' => "onClick=\"return confirm('".lang("Are you sure\\nyou want to \\ndelete this entry?\\n\\nThis will delete\\nthis entry for all users.")."')\"",
+ 'action_confirm_button' => "onClick=\"return confirm('".lang("Are you sure\\nyou want to \\ndelete this entry ?\\n\\nThis will delete\\nthis entry for all users.")."')\"",
'action_extra_field' => ''
);
$p->set_var($var);