- // save event depending on the given event type
- switch ($event_info['type'])
- {
- case 'SINGLE':
- Horde::logMessage('importVCAL event SINGLE',__FILE__, __LINE__, PEAR_LOG_DEBUG);
-
- // update the event
- if ($event_info['acl_edit'])
- {
- $event_to_store = $event; // prevent $event from being changed by the update method
- $updated_id = $this->update($event_to_store, true);
- unset($event_to_store);
- }
- break;
-
- case 'SERIES-MASTER':
- Horde::logMessage('importVCAL event SERIES-MASTER',__FILE__, __LINE__, PEAR_LOG_DEBUG);
-
- // remove all known "status only" exceptions and update the event
- if ($event_info['acl_edit'])
- {
- $days = $this->so->get_recurrence_exceptions($event);
- if (is_array($days))
- {
- $recur_exceptions = array();
- foreach ($event['recur_exception'] as $recur_exception)
- {
- if (!in_array($recur_exception, $days))
- {
- $recur_exceptions[] = $recur_exception;
- }
- }
- $event['recur_exception'] = $recur_exceptions;
- }
-
- $event_to_store = $event; // prevent $event from being changed by the update method
- $updated_id = $this->update($event_to_store, true);
- unset($event_to_store);
- }
- break;
-
- case 'SERIES-EXCEPTION':
- case 'SERIES-EXCEPTION-PROPAGATE':
- Horde::logMessage('importVCAL event SERIES-EXCEPTION',__FILE__, __LINE__, PEAR_LOG_DEBUG);
-
- // update event
- if ($event_info['acl_edit'])
- {
- if (isset($event_info['stored_event']['id']))
- {
- // We update an existing exception
- $event['id'] = $event_info['stored_event']['id'];
- $event['category'] = $event_info['stored_event']['category'];
- }
- else
- {
- // We create a new exception
- unset($event['id']);
- $event_info['master_event']['recur_exception'] = array_unique(array_merge($event_info['master_event']['recur_exception'], array($event['recurrence'])));
- $event_to_store = $event_info['master_event']; // prevent the master_event from being changed by the update method
- $this->update($event_to_store, true);
- unset($event_to_store);
- $event['reference'] = $event_info['master_event']['id'];
- $event['category'] = $event_info['master_event']['category'];
- }
-
- $event_to_store = $event; // prevent $event from being changed by update method
- $updated_id = $this->update($event_to_store, true, true, false, false);
- unset($event_to_store);
- }
- break;
-
- case 'SERIES-EXCEPTION-STATUS':
- Horde::logMessage('importVCAL event SERIES-EXCEPTION-STATUS',__FILE__, __LINE__, PEAR_LOG_DEBUG);
-
- if ($event_info['acl_edit'])
- {
- // truncate the status only exception from the series master
- $recur_exceptions = array();
- foreach ($event_info['master_event']['recur_exception'] as $recur_exception)
- {
- if ($recur_exception != $event['recurrence'])
- {
- $recur_exceptions[] = $recur_exception;
- }
- }
- $event_info['master_event']['recur_exception'] = $recur_exceptions;
-
- // save the series master with the adjusted exceptions
- $event_to_store = $event_info['master_event']; // prevent the master_event from being changed by the update method
- $updated_id = $this->update($event_to_store, true, true, false, false);
- unset($event_to_store);
- }
-
- break;
- }
-
- // read stored event into info array for fresh stored (new) events
- if (!is_array($event_info['stored_event']) && $updated_id > 0)
- {
- $event_info['stored_event'] = $this->read($updated_id);
- }
-
- // update status depending on the given event type
- switch ($event_info['type'])
- {
- case 'SINGLE':
- case 'SERIES-MASTER':
- case 'SERIES-EXCEPTION':
- case 'SERIES-EXCEPTION-PROPAGATE':
- if (is_array($event_info['stored_event'])) // status update requires a stored event
- {
- if ($event_info['acl_edit'])
- {
- // update all participants if we have the right to do that
- $this->update_status($event, $event_info['stored_event']);
- }
- elseif (isset($event['participants'][$this->user]) || isset($event_info['stored_event']['participants'][$this->user]))
- {
- // update the users status only
- $this->set_status($event_info['stored_event']['id'], $this->user,
- ($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), 0, true);
- }
- }
- break;
-
- case 'SERIES-EXCEPTION-STATUS':
- if (is_array($event_info['master_event'])) // status update requires a stored master event
- {
- if ($event_info['acl_edit'])
- {
- // update all participants if we have the right to do that
- $this->update_status($event, $event_info['master_event'], $event['recurrence']);
- }
- elseif (isset($event['participants'][$this->user]) || isset($event_info['master_event']['participants'][$this->user]))
- {
- // update the users status only
- $this->set_status($event_info['master_event']['id'], $this->user,
- ($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), $event['recurrence'], true);
- }
- }
- break;
- }
-
// update alarms depending on the given event type
- if (isset($this->supportedFields['alarm'])
- && is_array($event_info['stored_event']) // alarm update requires a stored event
- )
+ if (count($event['alarm']) > 0 || isset($this->supportedFields['alarm']))
{
switch ($event_info['type'])
{
@@ -1055,23 +909,9 @@
case 'SERIES-MASTER':
case 'SERIES-EXCEPTION':
case 'SERIES-EXCEPTION-PROPAGATE':
- // delete old alarms
- if (count($event_info['stored_event']['alarm']) > 0)
- {
- foreach ($event_info['stored_event']['alarm'] as $alarm_id => $alarm_data)
- {
- // only touch own alarms
- if ($alarm_data['all'] == false && $alarm_data['owner'] == $this->user)
- {
- $this->delete_alarm($alarm_id);
- }
- }
- }
-
- // save given alarms
if (count($event['alarm']) > 0)
{
- foreach ($event['alarm'] as $alarm)
+ foreach ($event['alarm'] as $newid => &$alarm)
{
if (!isset($alarm['offset']) && isset($alarm['time']))
{
@@ -1083,7 +923,21 @@
}
$alarm['owner'] = $this->user;
$alarm['all'] = false;
- $this->save_alarm($event_info['stored_event']['id'], $alarm);
+
+ if (is_array($event_info['stored_event'])
+ && count($event_info['stored_event']['alarm']) > 0)
+ {
+ foreach ($event_info['stored_event']['alarm'] as $alarm_id => $alarm_data)
+ {
+ if ($alarm['time'] == $alarm_data['time'] &&
+ ($alarm_data['all'] || $alarm_data['owner'] == $this->user))
+ {
+ unset($event['alarm'][$newid]);
+ unset($event_info['stored_event']['alarm'][$alarm_id]);
+ continue;
+ }
+ }
+ }
}
}
break;
@@ -1092,6 +946,162 @@
// nothing to do here
break;
}
+ if (is_array($event_info['stored_event'])
+ && count($event_info['stored_event']['alarm']) > 0)
+ {
+ foreach ($event_info['stored_event']['alarm'] as $alarm_id => $alarm_data)
+ {
+ // only touch own alarms
+ if ($alarm_data['all'] == false && $alarm_data['owner'] == $this->user)
+ {
+ $this->delete_alarm($alarm_id);
+ }
+ }
+ }
+ }
+
+ // save event depending on the given event type
+ switch ($event_info['type'])
+ {
+ case 'SINGLE':
+ Horde::logMessage('importVCAL event SINGLE',__FILE__, __LINE__, PEAR_LOG_DEBUG);
+
+ // update the event
+ if ($event_info['acl_edit'])
+ {
+ $event_to_store = $event; // prevent $event from being changed by the update method
+ $updated_id = $this->update($event_to_store, true);
+ unset($event_to_store);
+ }
+ break;
+
+ case 'SERIES-MASTER':
+ Horde::logMessage('importVCAL event SERIES-MASTER',__FILE__, __LINE__, PEAR_LOG_DEBUG);
+
+ // remove all known "status only" exceptions and update the event
+ if ($event_info['acl_edit'])
+ {
+ $days = $this->so->get_recurrence_exceptions($event);
+ if (is_array($days))
+ {
+ $recur_exceptions = array();
+ foreach ($event['recur_exception'] as $recur_exception)
+ {
+ if (!in_array($recur_exception, $days))
+ {
+ $recur_exceptions[] = $recur_exception;
+ }
+ }
+ $event['recur_exception'] = $recur_exceptions;
+ }
+
+ $event_to_store = $event; // prevent $event from being changed by the update method
+ $updated_id = $this->update($event_to_store, true);
+ unset($event_to_store);
+ }
+ break;
+
+ case 'SERIES-EXCEPTION':
+ case 'SERIES-EXCEPTION-PROPAGATE':
+ Horde::logMessage('importVCAL event SERIES-EXCEPTION',__FILE__, __LINE__, PEAR_LOG_DEBUG);
+
+ // update event
+ if ($event_info['acl_edit'])
+ {
+ if (isset($event_info['stored_event']['id']))
+ {
+ // We update an existing exception
+ $event['id'] = $event_info['stored_event']['id'];
+ $event['category'] = $event_info['stored_event']['category'];
+ }
+ else
+ {
+ // We create a new exception
+ unset($event['id']);
+ $event_info['master_event']['recur_exception'] = array_unique(array_merge($event_info['master_event']['recur_exception'], array($event['recurrence'])));
+ $event_to_store = $event_info['master_event']; // prevent the master_event from being changed by the update method
+ $this->update($event_to_store, true);
+ unset($event_to_store);
+ $event['reference'] = $event_info['master_event']['id'];
+ $event['category'] = $event_info['master_event']['category'];
+ }
+
+ $event_to_store = $event; // prevent $event from being changed by update method
+ $updated_id = $this->update($event_to_store, true, true, false, false);
+ unset($event_to_store);
+ }
+ break;
+
+ case 'SERIES-EXCEPTION-STATUS':
+ Horde::logMessage('importVCAL event SERIES-EXCEPTION-STATUS',__FILE__, __LINE__, PEAR_LOG_DEBUG);
+
+ if ($event_info['acl_edit'])
+ {
+ // truncate the status only exception from the series master
+ $recur_exceptions = array();
+ foreach ($event_info['master_event']['recur_exception'] as $recur_exception)
+ {
+ if ($recur_exception != $event['recurrence'])
+ {
+ $recur_exceptions[] = $recur_exception;
+ }
+ }
+ $event_info['master_event']['recur_exception'] = $recur_exceptions;
+
+ // save the series master with the adjusted exceptions
+ $event_to_store = $event_info['master_event']; // prevent the master_event from being changed by the update method
+ $updated_id = $this->update($event_to_store, true, true, false, false);
+ unset($event_to_store);
+ }
+
+ break;
+ }
+
+ // read stored event into info array for fresh stored (new) events
+ if (!is_array($event_info['stored_event']) && $updated_id > 0)
+ {
+ $event_info['stored_event'] = $this->read($updated_id);
+ }
+
+ // update status depending on the given event type
+ switch ($event_info['type'])
+ {
+ case 'SINGLE':
+ case 'SERIES-MASTER':
+ case 'SERIES-EXCEPTION':
+ case 'SERIES-EXCEPTION-PROPAGATE':
+ if (is_array($event_info['stored_event'])) // status update requires a stored event
+ {
+ if ($event_info['acl_edit'])
+ {
+ // update all participants if we have the right to do that
+ $this->update_status($event, $event_info['stored_event']);
+ }
+ elseif (isset($event['participants'][$this->user]) || isset($event_info['stored_event']['participants'][$this->user]))
+ {
+ // update the users status only
+ $this->set_status($event_info['stored_event']['id'], $this->user,
+ ($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), 0, true);
+ }
+ }
+ break;
+
+ case 'SERIES-EXCEPTION-STATUS':
+ if (is_array($event_info['master_event'])) // status update requires a stored master event
+ {
+ if ($event_info['acl_edit'])
+ {
+ // update all participants if we have the right to do that
+ $this->update_status($event, $event_info['master_event'], $event['recurrence']);
+ }
+ elseif (isset($event['participants'][$this->user]) || isset($event_info['master_event']['participants'][$this->user]))
+ {
+ // update the users status only
+ $this->set_status($event_info['master_event']['id'], $this->user,
+ ($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), $event['recurrence'], true);
+ }
+ }
+ break;
}
// choose which id to return to the client
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference _______________________________________________
eGroupWare-cvs mailing list
eGroupWare-cvs@... https://lists.sourceforge.net/lists/listinfo/egroupware-cvs