import alarms to if supported

This commit is contained in:
Lars Kneschke 2006-01-10 13:53:23 +00:00
parent e833291b13
commit 91fb43964b

View File

@ -312,8 +312,10 @@
if(is_a($component, 'Horde_iCalendar_vevent')) if(is_a($component, 'Horde_iCalendar_vevent'))
{ {
$supportedFields = $this->supportedFields; $supportedFields = $this->supportedFields;
$event = array('participants' => array()); #$event = array('participants' => array());
$vcardData = array('recur_type' => 0); $event = array();
$alarms = array();
$vcardData = array('recur_type' => 0);
// lets see what we can get from the vcard // lets see what we can get from the vcard
foreach($component->_attributes as $attributes) foreach($component->_attributes as $attributes)
@ -323,6 +325,16 @@
switch($attributes['name']) switch($attributes['name'])
{ {
case 'AALARM':
case 'DALARM':
if (preg_match('/.*Z$/',$attributes['value'],$matches))
{
$alarmTime = $vcal->_parseDateTime($attributes['value']);
$alarms[$alarmTime] = array(
'time' => $alarmTime
);
}
break;
case 'CLASS': case 'CLASS':
$vcardData['public'] = (int)(strtolower($attributes['value']) == 'public'); $vcardData['public'] = (int)(strtolower($attributes['value']) == 'public');
break; break;
@ -493,6 +505,9 @@
{ {
switch($fieldName) switch($fieldName)
{ {
case 'alarms':
// not handled here
break;
case 'recur_type': case 'recur_type':
$event['recur_type'] = $vcardData['recur_type']; $event['recur_type'] = $vcardData['recur_type'];
if ($event['recur_type'] != MCAL_RECUR_NONE) if ($event['recur_type'] != MCAL_RECUR_NONE)
@ -529,9 +544,33 @@
#{ #{
# error_log("KEY: $key VALUE: $value"); # error_log("KEY: $key VALUE: $value");
#} #}
//echo "event=";_debug_array($event); #echo "event=";_debug_array($event);exit;
if (!($Ok = $this->update($event, TRUE))) break; // stop with the first error if (!($Ok = $this->update($event, TRUE))) {
break; // stop with the first error
}
else
{
$eventID =& $Ok;
// handle the alarms
if(count($alarms) > 0 || (isset($this->supportedFields['alarms']) && count($alarms) == 0))
{
// delete the old alarms
$updatedEvent = $this->read($eventID);
foreach($updatedEvent['alarm'] as $alarmID => $alarmData)
{
$this->delete_alarm($alarmID);
}
}
foreach($alarms as $alarm)
{
$alarm['offset'] = $event['start'] - $alarm['time'];
$alarm['owner'] = $GLOBALS['egw_info']['user']['account_id'];
$this->save_alarm($eventID, $alarm);
}
}
} }
} }
return $Ok; return $Ok;
@ -570,6 +609,16 @@
} }
break; break;
case 'sonyericsson':
switch(strtolower($_productName))
{
case 'd750i':
default:
$this->supportedFields = $defaultFields + array('alarms' => 'alarms');
break;
}
break;
case 'synthesis ag': case 'synthesis ag':
switch(strtolower($_productName)) switch(strtolower($_productName))
{ {