Commit 43202cf7 authored by Robert Rollins's avatar Robert Rollins

Issue #2466565: Added a workaround to make VFREEBUSY componenets importable.

Because the iCal spec states that VFREEBUSY components can't have the
SUMMARY property, Date iCal will now fall back to the COMMENT property
for the node title. Unfortuantely, this is the best we can do, becaise
iCalcreator completely leaves out the SUMMARY property on VFREEBUSY
componeents, so there's no way to recover it.
parent 83719ab6
......@@ -153,7 +153,14 @@ class DateiCalFeedsParser extends FeedsParser {
$sources = array();
$sources['SUMMARY'] = array(
'name' => t('Summary/Title'),
'description' => t('The SUMMARY property. A short summary (usually the title) of the event.'),
'description' => t('The SUMMARY property. A short summary (usually the title) of the event.
A title is required for every node, so you need to include this source and have it mapped to the node title, except under unusual circumstances.'
),
'date_ical_parse_handler' => 'parseTextProperty',
);
$sources['COMMENT'] = array(
'name' => t('Comment'),
'description' => t('The COMMENT property. A text comment is allowed on most components.'),
'date_ical_parse_handler' => 'parseTextProperty',
);
$sources['DESCRIPTION'] = array(
......
......@@ -225,12 +225,30 @@ class ParserVcalendar {
}
if ($text === FALSE) {
if ($property_key == 'SUMMARY') {
if ($property_key != 'SUMMARY') {
return NULL;
}
else {
$uid = $vcalendar_component->getProperty('UID');
throw new DateIcalParseException(t('The component with UID %uid is invalid because it has no SUMMARY (nodes require a title).', array('%uid' => $uid)));
if ($vcalendar_component->objName == 'vfreebusy') {
// FREEBUSY elements can't have SUMMARY, but they can have COMMENT.
// So if the feed has been configured to ask for SUMMARY, use COMMENT
// instead. If COMMENT is also missing, we can't import.
$text = $vcalendar_component->getProperty('COMMENT');
if ($text === FALSE) {
throw new DateIcalParseException(t('The VFREEBUSY component with UID %uid is invalid because it has no COMMENT.
Nodes require a title, and since VFREEBUSY components can\'t have SUMMARY, Date iCal pulls that title from the COMMENT.',
array('%uid' => $uid))
);
}
}
else {
// Non-VFREEBUSY components must have a SUMMARY.
throw new DateIcalParseException(t('The component with UID %uid is invalid because it has no SUMMARY (nodes require a title).',
array('%uid' => $uid))
);
}
}
// If the component doesn't have this property, return NULL.
return NULL;
}
// Convert literal \n and \N into newline characters.
$text = str_replace(array('\n', '\N'), "\n", $text);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment