Commit 3c164489 authored by Robert Rollins's avatar Robert Rollins

Issue #2206109: Fixed RRULE import to work with newest Feeds version.

Thanks go to d.o user MegaChriz for this fix!
parent eb767269
...@@ -256,14 +256,22 @@ function date_ical_sanitize_text($text = '') { ...@@ -256,14 +256,22 @@ function date_ical_sanitize_text($text = '') {
* @param string $target * @param string $target
* The machine name of the field into which this RRULE shall be parsed, * The machine name of the field into which this RRULE shall be parsed,
* with ":rrule" appended to the end. * with ":rrule" appended to the end.
* @param string $repeat_rule * @param string|array $repeat_rule
* The repeat rule string, formatted like "$rrule|$rdate|$exrule|$exdate". * The repeat rule string, formatted like "$rrule|$rdate|$exrule|$exdate".
* Newer versions of Feeds send this value as an array containing the string.
*/ */
function date_ical_feeds_set_rrule($source, $entity, $target, $repeat_rule) { function date_ical_feeds_set_rrule($source, $entity, $target, $repeat_rule) {
if (empty($repeat_rule)) { if (empty($repeat_rule)) {
// Don't alter the entity if there's no repeat rule. // Don't alter the entity if there's no repeat rule.
return; return;
} }
if (is_array($repeat_rule)) {
// Newer versions of Feeds return $repeat_rule as an array containing the
// string we returned from ParseVcalendar::parseRepeatProperty().
$repeat_rule = reset($repeat_rule);
}
// $target looks like <field_name>:rrule, but we only need <field_name>. // $target looks like <field_name>:rrule, but we only need <field_name>.
$field_name = current(explode(':', $target, 2)); $field_name = current(explode(':', $target, 2));
// Parse the repeat rule into RRULE, RDATE, EXRULE, and EXDATE strings. // Parse the repeat rule into RRULE, RDATE, EXRULE, and EXDATE strings.
......
...@@ -450,6 +450,7 @@ class ParserVcalendar { ...@@ -450,6 +450,7 @@ class ParserVcalendar {
// Due to a few bugs and limitations with Date Repeat, we need to massage // Due to a few bugs and limitations with Date Repeat, we need to massage
// the RRULE a bit. // the RRULE a bit.
if (count($vcalendar_component->rrule) > 1) { if (count($vcalendar_component->rrule) > 1) {
// TODO: Is Date Repeat still limited to 1 RRULE with Feeds 2.0-beta1?
$msg = 'The event with UID %uid has multiple RRULEs, but the Date Repeat module only supports one. Only the first RRULE in the event will be used. $msg = 'The event with UID %uid has multiple RRULEs, but the Date Repeat module only supports one. Only the first RRULE in the event will be used.
If your events need to have a complex repeat pattern, using RDATEs should help.'; If your events need to have a complex repeat pattern, using RDATEs should help.';
watchdog('date_ical', $msg, array('%uid' => $uid), 'warning'); watchdog('date_ical', $msg, array('%uid' => $uid), 'warning');
...@@ -462,6 +463,7 @@ class ParserVcalendar { ...@@ -462,6 +463,7 @@ class ParserVcalendar {
} }
foreach ($vcalendar_component->rrule as &$rrule_data) { foreach ($vcalendar_component->rrule as &$rrule_data) {
// RRULEs must have an INTERVAL, or Date Repeat will throw errors. // RRULEs must have an INTERVAL, or Date Repeat will throw errors.
// TODO: Is this still true with Feeds 2.0-beta1?
if (!isset($rrule_data['value']['INTERVAL'])) { if (!isset($rrule_data['value']['INTERVAL'])) {
$rrule_data['value']['INTERVAL'] = '1'; $rrule_data['value']['INTERVAL'] = '1';
} }
......
...@@ -38,4 +38,3 @@ SUMMARY:Debugging event. ...@@ -38,4 +38,3 @@ SUMMARY:Debugging event.
END:VEVENT END:VEVENT
END:VCALENDAR END:VCALENDAR
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