Add fallback for recurrence computation when the kolabcalendaring php module isn't available
This commit is contained in:
parent
1f9f09fe09
commit
53c77796dd
2 changed files with 35 additions and 5 deletions
|
@ -414,7 +414,14 @@ class kolab_calendar
|
||||||
}
|
}
|
||||||
|
|
||||||
// use libkolab to compute recurring events
|
// use libkolab to compute recurring events
|
||||||
$recurrence = new kolab_date_recurrence($object);
|
if (class_exists('kolabcalendaring')) {
|
||||||
|
$recurrence = new kolab_date_recurrence($object);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// fallback to local recurrence implementation
|
||||||
|
require_once($this->cal->home . '/lib/calendar_recurrence.php');
|
||||||
|
$recurrence = new calendar_recurrence($this->cal, $event);
|
||||||
|
}
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$events = array();
|
$events = array();
|
||||||
|
|
|
@ -41,6 +41,10 @@ class calendar_recurrence
|
||||||
*/
|
*/
|
||||||
function __construct($cal, $event)
|
function __construct($cal, $event)
|
||||||
{
|
{
|
||||||
|
// use Horde classes to compute recurring instances
|
||||||
|
// TODO: replace with something that has less than 6'000 lines of code
|
||||||
|
require_once(__DIR__ . '/Horde_Date_Recurrence.php');
|
||||||
|
|
||||||
$this->cal = $cal;
|
$this->cal = $cal;
|
||||||
$this->event = $event;
|
$this->event = $event;
|
||||||
$this->next = new Horde_Date($event['start'], $cal->timezone->getName());
|
$this->next = new Horde_Date($event['start'], $cal->timezone->getName());
|
||||||
|
@ -49,10 +53,6 @@ class calendar_recurrence
|
||||||
if (is_object($event['start']) && is_object($event['end']))
|
if (is_object($event['start']) && is_object($event['end']))
|
||||||
$this->duration = $event['start']->diff($event['end']);
|
$this->duration = $event['start']->diff($event['end']);
|
||||||
|
|
||||||
// use Horde classes to compute recurring instances
|
|
||||||
// TODO: replace with something that has less than 6'000 lines of code
|
|
||||||
require_once($this->cal->home . '/lib/Horde_Date_Recurrence.php');
|
|
||||||
|
|
||||||
$this->engine = new Horde_Date_Recurrence($event['start']);
|
$this->engine = new Horde_Date_Recurrence($event['start']);
|
||||||
$this->engine->fromRRule20(libcalendaring::to_rrule($event['recurrence']));
|
$this->engine->fromRRule20(libcalendaring::to_rrule($event['recurrence']));
|
||||||
|
|
||||||
|
@ -83,4 +83,27 @@ class calendar_recurrence
|
||||||
return $time;
|
return $time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the next recurring instance of this event
|
||||||
|
*
|
||||||
|
* @return mixed Array with event properties or False if recurrence ended
|
||||||
|
*/
|
||||||
|
public function next_instance()
|
||||||
|
{
|
||||||
|
if ($next_start = $this->next_start()) {
|
||||||
|
$next_end = clone $next_start;
|
||||||
|
$next_end->add($this->duration);
|
||||||
|
|
||||||
|
$next = $this->event;
|
||||||
|
$next['recurrence_id'] = $next_start->format('Y-m-d');
|
||||||
|
$next['start'] = $next_start;
|
||||||
|
$next['end'] = $next_end;
|
||||||
|
unset($next['_formatobj']);
|
||||||
|
|
||||||
|
return $next;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue