Finalize recurring events: use patched Horde_Date_Recurrence class for recurrence computing; fix some misbehavior of the Kolab backend
This commit is contained in:
parent
c2daec1711
commit
8eb9cc25da
3 changed files with 32 additions and 33 deletions
|
@ -323,7 +323,7 @@ class kolab_calendar
|
|||
private function _get_recurring_events($event, $start, $end, $event_id = null)
|
||||
{
|
||||
// use Horde classes to compute recurring instances
|
||||
require_once 'Horde/Date/Recurrence.php';
|
||||
require_once($this->cal->home . '/lib/Horde_Date_Recurrence.php');
|
||||
|
||||
$recurrence = new Horde_Date_Recurrence($event['start']);
|
||||
$recurrence->fromRRule20(calendar::to_rrule($event['recurrence']));
|
||||
|
@ -415,7 +415,7 @@ class kolab_calendar
|
|||
else if ($recurrence['type'] == 'yearday')
|
||||
$rrule['BYYEARDAY'] = $recurrence['daynumber'];
|
||||
}
|
||||
if ($rec['month']) {
|
||||
if ($recurrence['month']) {
|
||||
$monthmap = array_flip($this->month_map);
|
||||
$rrule['BYMONTH'] = strtolower($monthmap[$recurrence['month']]);
|
||||
}
|
||||
|
@ -585,7 +585,7 @@ class kolab_calendar
|
|||
$object['_attachments'] = array();
|
||||
if (!empty($event['attachments'])) {
|
||||
foreach ($event['attachments'] as $idx => $attachment) {
|
||||
// Roundcube ID has nothing to Horde ID, remove it
|
||||
// Roundcube ID has nothing to do with Horde ID, remove it
|
||||
unset($attachment['id']);
|
||||
$object['_attachments'][$attachment['name']] = $attachment;
|
||||
unset($event['attachments'][$idx]);
|
||||
|
|
|
@ -369,7 +369,7 @@ class kolab_driver extends calendar_driver
|
|||
}
|
||||
}
|
||||
|
||||
$event['attachments'] = array_merge($old['attachments'], $attachments);
|
||||
$event['attachments'] = array_merge((array)$old['attachments'], $attachments);
|
||||
|
||||
// modify a recurring event, check submitted savemode to do the right things
|
||||
if ($old['recurrence'] || $old['recurrence_id']) {
|
||||
|
@ -420,7 +420,7 @@ class kolab_driver extends calendar_driver
|
|||
// remove fixed weekday, will be re-set to the new weekday in kolab_calendar::insert_event()
|
||||
if (strlen($event['recurrence']['BYDAY']) == 2)
|
||||
unset($event['recurrence']['BYDAY']);
|
||||
if ($event['recurrence']['BYMONTH'])
|
||||
if ($master['recurrence']['BYMONTH'] == gmdate('n', $master['start']))
|
||||
unset($event['recurrence']['BYMONTH']);
|
||||
|
||||
$success = $storage->insert_event($event);
|
||||
|
@ -448,7 +448,7 @@ class kolab_driver extends calendar_driver
|
|||
// remove fixed weekday, will be re-set to the new weekday in kolab_calendar::update_event()
|
||||
if (strlen($event['recurrence']['BYDAY']) == 2)
|
||||
unset($event['recurrence']['BYDAY']);
|
||||
if ($event['recurrence']['BYMONTH'])
|
||||
if ($old['recurrence']['BYMONTH'] == gmdate('n', $old['start']))
|
||||
unset($event['recurrence']['BYMONTH']);
|
||||
}
|
||||
|
||||
|
|
|
@ -5313,7 +5313,7 @@ class Horde_Date_Recurrence {
|
|||
*/
|
||||
function setRecurByMonth($months)
|
||||
{
|
||||
$this->recurMonths = $months;
|
||||
$this->recurMonths = (array)$months;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5332,7 +5332,7 @@ class Horde_Date_Recurrence {
|
|||
*/
|
||||
function setRecurNthWeekday($nthDay)
|
||||
{
|
||||
$this->recurNthDay = $nthDay;
|
||||
$this->recurNthDay = (int)$nthDay;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5842,7 +5842,7 @@ class Horde_Date_Recurrence {
|
|||
$weekday = $estart->dayOfWeek();
|
||||
}
|
||||
|
||||
// set month from recurrence rule (FEXME: support more than one month)
|
||||
// set month from recurrence rule (FIXME: support more than one month)
|
||||
if ($this->recurMonths) {
|
||||
$estart->month = $this->recurMonths[0];
|
||||
}
|
||||
|
@ -6430,6 +6430,21 @@ class Horde_Date_Recurrence {
|
|||
return false;
|
||||
}
|
||||
|
||||
$month2number = array(
|
||||
'january' => 1,
|
||||
'february' => 2,
|
||||
'march' => 3,
|
||||
'april' => 4,
|
||||
'may' => 5,
|
||||
'june' => 6,
|
||||
'july' => 7,
|
||||
'august' => 8,
|
||||
'september' => 9,
|
||||
'october' => 10,
|
||||
'november' => 11,
|
||||
'december' => 12,
|
||||
);
|
||||
|
||||
$this->setRecurInterval((int) $hash['interval']);
|
||||
|
||||
$parse_day = false;
|
||||
|
@ -6464,11 +6479,9 @@ class Horde_Date_Recurrence {
|
|||
|
||||
case 'weekday':
|
||||
$this->setRecurType(HORDE_DATE_RECUR_MONTHLY_WEEKDAY);
|
||||
$nth_weekday = (int) $hash['daynumber'];
|
||||
$hash['daynumber'] = 1;
|
||||
$this->setRecurNthWeekday($hash['daynumber']);
|
||||
$parse_day = true;
|
||||
$update_daynumber = true;
|
||||
$update_weekday = true;
|
||||
$set_daymask = true;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -6506,12 +6519,13 @@ class Horde_Date_Recurrence {
|
|||
}
|
||||
|
||||
$this->setRecurType(HORDE_DATE_RECUR_YEARLY_WEEKDAY);
|
||||
$nth_weekday = (int) $hash['daynumber'];
|
||||
$hash['daynumber'] = 1;
|
||||
$this->setRecurNthWeekday($hash['daynumber']);
|
||||
$parse_day = true;
|
||||
$update_month = true;
|
||||
$update_daynumber = true;
|
||||
$update_weekday = true;
|
||||
$set_daymask = true;
|
||||
|
||||
if ($hash['month'] && isset($month2number[$hash['month']])) {
|
||||
$this->setRecurByMonth($month2number[$hash['month']]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -6580,21 +6594,6 @@ class Horde_Date_Recurrence {
|
|||
|
||||
if ($update_month || $update_daynumber || $update_weekday) {
|
||||
if ($update_month) {
|
||||
$month2number = array(
|
||||
'january' => 1,
|
||||
'february' => 2,
|
||||
'march' => 3,
|
||||
'april' => 4,
|
||||
'may' => 5,
|
||||
'june' => 6,
|
||||
'july' => 7,
|
||||
'august' => 8,
|
||||
'september' => 9,
|
||||
'october' => 10,
|
||||
'november' => 11,
|
||||
'december' => 12,
|
||||
);
|
||||
|
||||
if (isset($month2number[$hash['month']])) {
|
||||
$this->start->month = $month2number[$hash['month']];
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue