mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 16:48:49 +01:00
* Calendar: when moving a series exceptions where lost (regular recurrences shown again) and exceptions where moved too
This commit is contained in:
parent
e1c0177c50
commit
012e2e4763
@ -737,16 +737,16 @@ class calendar_bo
|
||||
$this->insert_all_recurrences($event,$start,$this->date2usertime($this->config['horizont']),$events);
|
||||
|
||||
$limit = min($this->config['horizont'], $event['end']);
|
||||
$days = $this->so->get_recurrence_exceptions($event, null, $start, $limit); // content of array is in server-time!
|
||||
//error_log('set_recurrences: days=' . array2string($days) );
|
||||
$exceptions = array();
|
||||
foreach((array)$event['recur_exception'] as $exception)
|
||||
{
|
||||
$exceptions[] = egw_time::to($exception, true); // true = date
|
||||
}
|
||||
//error_log(__METHOD__."(".array2string($event).", $start) exceptions=".array2string($exceptions));
|
||||
foreach($events as $event)
|
||||
{
|
||||
$is_exception = in_array(egw_time::to($event['start'], true), $exceptions);
|
||||
$start = $this->date2ts($event['start'],true);
|
||||
if (in_array($start, (array)$days))
|
||||
{
|
||||
// we don't change the stati of recurrence exceptions
|
||||
$event['participants'] = array();
|
||||
}
|
||||
if ($event['whole_day'])
|
||||
{
|
||||
$time = new egw_time($event['end'], egw_time::$user_timezone);
|
||||
@ -758,7 +758,8 @@ class calendar_bo
|
||||
{
|
||||
$end = $this->date2ts($event['end'],true);
|
||||
}
|
||||
$this->so->recurrence($event['id'],$start,$end,$event['participants']);
|
||||
//error_log(__METHOD__."() start=".egw_time::to($start).", is_exception=".array2string($is_exception));
|
||||
$this->so->recurrence($event['id'], $start, $end, $event['participants'], $is_exception);
|
||||
}
|
||||
}
|
||||
|
||||
@ -960,6 +961,8 @@ class calendar_bo
|
||||
// insert at least the event itself, if it's behind the horizont
|
||||
$event['recur_enddate'] = $this->date2ts($end) < $this->date2ts($event['end']) ? $event['end'] : $end;
|
||||
}
|
||||
// unset exceptions, as we need to add them as recurrence too, but marked as exception
|
||||
unset($event['recur_exception']);
|
||||
// loop over all recurrences and insert them, if they are after $start
|
||||
$rrule = calendar_rrule::event2rrule($event, true); // true = we operate in usertime, like the rest of calendar_bo
|
||||
foreach($rrule as $time)
|
||||
@ -1584,9 +1587,13 @@ class calendar_bo
|
||||
}
|
||||
$cat = $id2cat[$cat_id];
|
||||
|
||||
if ($cat['data']['color'] || preg_match('/(#[0-9A-Fa-f]{6})/',$cat['description'],$parts))
|
||||
if (is_array($cat['data']) && !empty($cat['data']['color']))
|
||||
{
|
||||
$color = $cat['data']['color'] ? $cat['data']['color'] : $parts[1];
|
||||
$color = $cat['data']['color'];
|
||||
}
|
||||
elseif(preg_match('/(#[0-9A-Fa-f]{6})/', $cat['description'], $parts))
|
||||
{
|
||||
$color = $parts[1];
|
||||
}
|
||||
$cats[$cat_id] = stripslashes($cat['name']);
|
||||
}
|
||||
|
@ -1112,7 +1112,7 @@ class calendar_boupdate extends calendar_bo
|
||||
// same with the recur exceptions
|
||||
if (isset($event['recur_exception']) && is_array($event['recur_exception']))
|
||||
{
|
||||
foreach($event['recur_exception'] as $n => $date)
|
||||
foreach($event['recur_exception'] as &$date)
|
||||
{
|
||||
if ($event['whole_day'])
|
||||
{
|
||||
@ -1122,9 +1122,10 @@ class calendar_boupdate extends calendar_bo
|
||||
}
|
||||
else
|
||||
{
|
||||
$event['recur_exception'][$n] = $this->date2ts($date,true);
|
||||
$date = $this->date2ts($date,true);
|
||||
}
|
||||
}
|
||||
unset($date);
|
||||
}
|
||||
// same with the alarms
|
||||
if (isset($event['alarm']) && is_array($event['alarm']) && isset($event['start']))
|
||||
|
@ -1696,14 +1696,16 @@ ORDER BY cal_user_type, cal_usre_id
|
||||
* @param int $cal_id
|
||||
* @param int $start
|
||||
* @param int $end
|
||||
* @param boolean $exception=null true or false to set recure_exception flag, null leave it unchanged (new are by default no exception)
|
||||
* @param array $participants uid => status pairs
|
||||
*/
|
||||
function recurrence($cal_id,$start,$end,$participants)
|
||||
function recurrence($cal_id,$start,$end,$participants,$exception=null)
|
||||
{
|
||||
//echo "<p>socal::recurrence($cal_id,$start,$end,".print_r($participants,true).")</p>\n";
|
||||
$this->db->insert($this->dates_table,array(
|
||||
'cal_end' => $end,
|
||||
),array(
|
||||
//error_log(__METHOD__."($cal_id, $start, $end, ".array2string($participants).", ".array2string($exception));
|
||||
$update = array('cal_end' => $end);
|
||||
if (isset($exception)) $update['recur_exception'] = $exception;
|
||||
|
||||
$this->db->insert($this->dates_table, $update, array(
|
||||
'cal_id' => $cal_id,
|
||||
'cal_start' => $start,
|
||||
),__LINE__,__FILE__,'calendar');
|
||||
@ -1712,24 +1714,27 @@ ORDER BY cal_user_type, cal_usre_id
|
||||
{
|
||||
error_log(__METHOD__."($cal_id, $start, $end, ".array2string($participants).") participants is NO array! ".function_backtrace());
|
||||
}
|
||||
foreach($participants as $uid => $status)
|
||||
if ($exception !== true)
|
||||
{
|
||||
if ($status == 'G') continue; // dont save group-invitations
|
||||
foreach($participants as $uid => $status)
|
||||
{
|
||||
if ($status == 'G') continue; // dont save group-invitations
|
||||
|
||||
$type = '';
|
||||
$id = null;
|
||||
self::split_user($uid,$type,$id);
|
||||
self::split_status($status,$quantity,$role);
|
||||
$this->db->insert($this->user_table,array(
|
||||
'cal_status' => $status,
|
||||
'cal_quantity' => $quantity,
|
||||
'cal_role' => $role
|
||||
),array(
|
||||
'cal_id' => $cal_id,
|
||||
'cal_recur_date' => $start,
|
||||
'cal_user_type' => $type,
|
||||
'cal_user_id' => $id,
|
||||
),__LINE__,__FILE__,'calendar');
|
||||
$type = '';
|
||||
$id = null;
|
||||
self::split_user($uid,$type,$id);
|
||||
self::split_status($status,$quantity,$role);
|
||||
$this->db->insert($this->user_table,array(
|
||||
'cal_status' => $status,
|
||||
'cal_quantity' => $quantity,
|
||||
'cal_role' => $role
|
||||
),array(
|
||||
'cal_id' => $cal_id,
|
||||
'cal_recur_date' => $start,
|
||||
'cal_user_type' => $type,
|
||||
'cal_user_id' => $id,
|
||||
),__LINE__,__FILE__,'calendar');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -836,16 +836,6 @@ class calendar_uiforms extends calendar_ui
|
||||
$exception['recurrence'] += $offset;
|
||||
$exception['reference'] = $event['id'];
|
||||
$exception['uid'] = $event['uid'];
|
||||
$exception['start'] += $offset;
|
||||
$exception['end'] += $offset;
|
||||
$exception['whole_day'] = $event['whole_day'];
|
||||
$alarms = array();
|
||||
foreach ($exception['alarm'] as $id => &$alarm)
|
||||
{
|
||||
$alarm['time'] = $exception['start'] - $alarm['offset'];
|
||||
$alarms[] = $alarm;
|
||||
}
|
||||
$event['alarm'] = $alarms;
|
||||
$this->bo->update($exception, true, true, true, true, $msg=null, $content['no_notifications']);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user