new Horde_Icalendar throws Horde_Icalendar_Exception on call to getAttribute() for not existing attributes, getAttributeDefault($name, $default) returns $default instead

This commit is contained in:
Ralf Becker 2015-06-24 12:30:56 +00:00
parent 62959f95f9
commit cd48c7c22b
2 changed files with 30 additions and 23 deletions

View File

@ -2223,7 +2223,7 @@ class calendar_ical extends calendar_boupdate
}
if (!is_a($component, 'Horde_Icalendar_Vevent') ||
!($event = $this->vevent2egw($component, $container ? $container->getAttribute('VERSION') : '2.0',
!($event = $this->vevent2egw($component, $container ? $container->getAttributeDefault('VERSION', '2.0') : '2.0',
$this->supportedFields, $principalURL, $container)))
{
return false;
@ -2283,8 +2283,8 @@ class calendar_ical extends calendar_boupdate
}
/*
$mozillaACK = $component->getAttribute('X-MOZ-LASTACK');
if ($this->productName == 'lightning' && !is_a($mozillaACK, 'PEAR_Error'))
$mozillaACK = $component->getAttributeDefault('X-MOZ-LASTACK', null);
if ($this->productName == 'lightning' && !isset($mozillaACK))
{
if ($this->log)
{
@ -2861,9 +2861,11 @@ class calendar_ical extends calendar_boupdate
$vcardData['participants'][$uid] =
calendar_so::combine_status($status, $quantity, $role);
if (!$this->calendarOwner && is_numeric($uid) &&
$role == 'CHAIR' &&
is_a($component->getAttribute('ORGANIZER'), 'PEAR_Error'))
try {
if (!$this->calendarOwner && is_numeric($uid) && $role == 'CHAIR')
$component->getAttribute('ORGANIZER');
}
catch(Horde_Icalendar_Exception $e)
{
// we can store the ORGANIZER as event owner
$event['owner'] = $uid;
@ -2910,9 +2912,8 @@ class calendar_ical extends calendar_boupdate
}
// check if the entry is a birthday
// this field is only set from NOKIA clients
$agendaEntryType = $component->getAttribute('X-EPOCAGENDAENTRYTYPE');
if (!is_a($agendaEntryType, 'PEAR_Error'))
{
try {
$agendaEntryType = $component->getAttribute('X-EPOCAGENDAENTRYTYPE');
if (strtolower($agendaEntryType) == 'anniversary')
{
$event['special'] = '1';
@ -2925,6 +2926,7 @@ class calendar_ical extends calendar_boupdate
$event['special'] = '2';
}
}
catch (Horde_Icalendar_Exception $e) {}
$event['priority'] = 2; // default
$event['alarm'] = $alarms;
@ -3005,13 +3007,15 @@ class calendar_ical extends calendar_boupdate
}
// Apple iCal on OS X uses X-CALENDARSERVER-ACCESS: CONFIDENTIAL on VCALANDAR (not VEVENT!)
if ($this->productManufacturer == 'GroupDAV' && $container &&
($x_calendarserver_access = $container->getAttribute('X-CALENDARSERVER-ACCESS')) &&
!is_a($x_calendarserver_access, 'PEAR_Error'))
{
$event['public'] = (int)(strtoupper($x_calendarserver_access) == 'PUBLIC');
try {
if ($this->productManufacturer == 'GroupDAV' && $container &&
($x_calendarserver_access = $container->getAttribute('X-CALENDARSERVER-ACCESS')))
{
$event['public'] = (int)(strtoupper($x_calendarserver_access) == 'PUBLIC');
}
//error_log(__METHOD__."() X-CALENDARSERVER-ACCESS=".array2string($x_calendarserver_access).' --> public='.array2string($event['public']));
}
//error_log(__METHOD__."() X-CALENDARSERVER-ACCESS=".array2string($x_calendarserver_access).' --> public='.array2string($event['public']));
catch (Horde_Icalendar_Exception $e) {}
// if no end is given in iCal we use the default lenght from user prefs
// whole day events get one day in calendar_boupdate::save()
@ -3023,8 +3027,7 @@ class calendar_ical extends calendar_boupdate
if ($this->calendarOwner) $event['owner'] = $this->calendarOwner;
// parsing ATTACH attributes for managed attachments
$attr = $component->getAttribute('X-EGROUPWARE-ATTACH-INCLUDED');
$event['attach-delete-by-put'] = !is_a($attr, PEAR_Error) && $attr === 'TRUE';
$event['attach-delete-by-put'] = $component->getAttributeDefault('X-EGROUPWARE-ATTACH-INCLUDED', null) === 'TRUE';
$event['attach'] = $component->getAllAttributes('ATTACH');
if ($this->log)

View File

@ -685,15 +685,19 @@ class infolog_ical extends infolog_bo
// iOS reminder app only sets COMPLETED, but never STATUS nor PERCENT-COMPLETED
// if we have no STATUS, set STATUS by existence of COMPLETED and/or PERCENT-COMPLETE and X-INFOLOG-STATUS
// if we have no PERCENT-COMPLETE set it from STATUS: 0=NEEDS-ACTION, 10=IN-PROCESS, 100=COMPLETED
if (!($status = $component->getAttribute('STATUS')) || !is_scalar($status))
try {
$status = $component->getAttribute('STATUS');
}
catch (Horde_Icalendar_Exception $e)
{
$completed = $component->getAttribute('COMPLETED');
$x_infolog_status = $component->getAttribute('X-INFOLOG-STATUS');
unset($e);
$completed = $component->getAttributeDefault('COMPLETED', null);
$x_infolog_status = $component->getAttributeDefault('X-INFOLOG-STATUS', null);
// check if we have a X-INFOLOG-STATUS and it's completed state is different from given COMPLETED attr
if (is_scalar($x_infolog_status) &&
($this->_status2vtodo[$x_infolog_status] === 'COMPLETED') != is_scalar($completed))
{
$percent_completed = $component->getAttribute('PERCENT-COMPLETE');
$percent_completed = $component->getAttributeDefault('PERCENT-COMPLETE', null);
$status = $completed && is_scalar($completed) ? 'COMPLETED' :
($percent_completed && is_scalar($percent_completed) && $percent_completed > 0 ? 'IN-PROCESS' : 'NEEDS-ACTION');
$component->setAttribute('STATUS', $status);
@ -756,7 +760,7 @@ class infolog_ical extends infolog_bo
case 'DURATION':
if (!isset($taskData['info_startdate']))
{
$taskData['info_startdate'] = $component->getAttribute('DTSTART');
$taskData['info_startdate'] = $component->getAttributeDefault('DTSTART', null);
}
$attribute['value'] += $taskData['info_startdate'];
$taskData['##DURATION'] = $attribute['value'];
@ -800,7 +804,7 @@ class infolog_ical extends infolog_bo
case 'STATUS':
// check if we (still) have X-INFOLOG-STATUS set AND it would give an unchanged status (no change by the user)
$taskData['info_status'] = $this->vtodo2status($attribute['value'],
($attr=$component->getAttribute('X-INFOLOG-STATUS')) && is_scalar($attr) ? $attr : null);
$component->getAttributeDefault('X-INFOLOG-STATUS', null));
break;
case 'SUMMARY':