Fix recurrence form serialization; better method names
This commit is contained in:
parent
70818e4998
commit
cd40e54641
5 changed files with 37 additions and 12 deletions
|
@ -604,7 +604,7 @@ function rcube_calendar_ui(settings)
|
||||||
priority: priority.val(),
|
priority: priority.val(),
|
||||||
sensitivity: sensitivity.val(),
|
sensitivity: sensitivity.val(),
|
||||||
status: eventstatus.val(),
|
status: eventstatus.val(),
|
||||||
recurrence: me.serialize_recurrence(),
|
recurrence: me.serialize_recurrence(endtime.val()),
|
||||||
valarms: me.serialize_alarms('#edit-alarms'),
|
valarms: me.serialize_alarms('#edit-alarms'),
|
||||||
attendees: event_attendees,
|
attendees: event_attendees,
|
||||||
deleted_attachments: rcmail.env.deleted_attachments,
|
deleted_attachments: rcmail.env.deleted_attachments,
|
||||||
|
|
|
@ -48,6 +48,16 @@ class calendar_recurrence extends libcalendaring_recurrence
|
||||||
$this->init($event['recurrence'], $event['start']);
|
$this->init($event['recurrence'], $event['start']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias of libcalendaring_recurrence::next()
|
||||||
|
*
|
||||||
|
* @return mixed DateTime object or False if recurrence ended
|
||||||
|
*/
|
||||||
|
public function next_start()
|
||||||
|
{
|
||||||
|
return $this->next();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the next recurring instance of this event
|
* Get the next recurring instance of this event
|
||||||
*
|
*
|
||||||
|
@ -55,7 +65,7 @@ class calendar_recurrence extends libcalendaring_recurrence
|
||||||
*/
|
*/
|
||||||
public function next_instance()
|
public function next_instance()
|
||||||
{
|
{
|
||||||
if ($next_start = $this->next_start()) {
|
if ($next_start = $this->next()) {
|
||||||
$next = $this->event;
|
$next = $this->event;
|
||||||
$next['recurrence_id'] = $next_start->format('Y-m-d');
|
$next['recurrence_id'] = $next_start->format('Y-m-d');
|
||||||
$next['start'] = $next_start;
|
$next['start'] = $next_start;
|
||||||
|
|
|
@ -52,17 +52,15 @@ class libcalendaring_recurrence
|
||||||
* @param array The recurrence properties
|
* @param array The recurrence properties
|
||||||
* @param object DateTime The recurrence start date
|
* @param object DateTime The recurrence start date
|
||||||
*/
|
*/
|
||||||
public function init($recurrence, $start)
|
public function init($recurrence, $start = null)
|
||||||
{
|
{
|
||||||
$this->start = $start;
|
|
||||||
$this->recurrence = $recurrence;
|
$this->recurrence = $recurrence;
|
||||||
$this->dateonly = $start->_dateonly;
|
|
||||||
$this->next = new Horde_Date($start, $this->lib->timezone->getName());
|
|
||||||
$this->hour = $this->next->hour;
|
|
||||||
|
|
||||||
$this->engine = new Horde_Date_Recurrence($start);
|
$this->engine = new Horde_Date_Recurrence($start);
|
||||||
$this->engine->fromRRule20(libcalendaring::to_rrule($recurrence));
|
$this->engine->fromRRule20(libcalendaring::to_rrule($recurrence));
|
||||||
|
|
||||||
|
$this->set_start($start);
|
||||||
|
|
||||||
if (is_array($recurrence['EXDATE'])) {
|
if (is_array($recurrence['EXDATE'])) {
|
||||||
foreach ($recurrence['EXDATE'] as $exdate) {
|
foreach ($recurrence['EXDATE'] as $exdate) {
|
||||||
if (is_a($exdate, 'DateTime')) {
|
if (is_a($exdate, 'DateTime')) {
|
||||||
|
@ -79,12 +77,26 @@ class libcalendaring_recurrence
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for (new) recurrence start date
|
||||||
|
*
|
||||||
|
* @param object DateTime The recurrence start date
|
||||||
|
*/
|
||||||
|
public function set_start($start)
|
||||||
|
{
|
||||||
|
$this->start = $start;
|
||||||
|
$this->dateonly = $start->_dateonly;
|
||||||
|
$this->next = new Horde_Date($start, $this->lib->timezone->getName());
|
||||||
|
$this->hour = $this->next->hour;
|
||||||
|
$this->engine->setRecurStart($this->next);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get date/time of the next occurence of this event
|
* Get date/time of the next occurence of this event
|
||||||
*
|
*
|
||||||
* @return mixed DateTime object or False if recurrence ended
|
* @return mixed DateTime object or False if recurrence ended
|
||||||
*/
|
*/
|
||||||
public function next_start()
|
public function next()
|
||||||
{
|
{
|
||||||
$time = false;
|
$time = false;
|
||||||
$after = clone $this->next;
|
$after = clone $this->next;
|
||||||
|
@ -131,7 +143,7 @@ class libcalendaring_recurrence
|
||||||
if ($this->recurrence['COUNT']) {
|
if ($this->recurrence['COUNT']) {
|
||||||
$last = $this->start;
|
$last = $this->start;
|
||||||
$this->next = new Horde_Date($this->start, $this->lib->timezone->getName());
|
$this->next = new Horde_Date($this->start, $this->lib->timezone->getName());
|
||||||
while (($next = $this->next_start()) && $c < 1000) {
|
while (($next = $this->next()) && $c < 1000) {
|
||||||
$last = $next;
|
$last = $next;
|
||||||
$c++;
|
$c++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -615,7 +615,7 @@ function rcube_libcalendaring(settings)
|
||||||
/**
|
/**
|
||||||
* Gather recurrence settings from form
|
* Gather recurrence settings from form
|
||||||
*/
|
*/
|
||||||
this.serialize_recurrence = function()
|
this.serialize_recurrence = function(timestr)
|
||||||
{
|
{
|
||||||
var recurrence = '',
|
var recurrence = '',
|
||||||
freq = $('#edit-recurrence-frequency').val();
|
freq = $('#edit-recurrence-frequency').val();
|
||||||
|
@ -630,7 +630,7 @@ function rcube_libcalendaring(settings)
|
||||||
if (until == 'count')
|
if (until == 'count')
|
||||||
recurrence.COUNT = $('#edit-recurrence-repeat-times').val();
|
recurrence.COUNT = $('#edit-recurrence-repeat-times').val();
|
||||||
else if (until == 'until')
|
else if (until == 'until')
|
||||||
recurrence.UNTIL = me.date2ISO8601(me.parse_datetime(endtime.val(), $('#edit-recurrence-enddate').val()));
|
recurrence.UNTIL = me.date2ISO8601(me.parse_datetime(timestr || '00:00', $('#edit-recurrence-enddate').val()));
|
||||||
|
|
||||||
if (freq == 'WEEKLY') {
|
if (freq == 'WEEKLY') {
|
||||||
var byday = [];
|
var byday = [];
|
||||||
|
|
|
@ -397,7 +397,10 @@ class libcalendaring extends rcube_plugin
|
||||||
{
|
{
|
||||||
return array_map(function($alarm){
|
return array_map(function($alarm){
|
||||||
if ($alarm['trigger'][0] == '@') {
|
if ($alarm['trigger'][0] == '@') {
|
||||||
try { $alarm['trigger'] = new DateTime($alarm['trigger']); }
|
try {
|
||||||
|
$alarm['trigger'] = new DateTime($alarm['trigger']);
|
||||||
|
$alarm['trigger']->setTimezone(new DateTimeZone('UTC'));
|
||||||
|
}
|
||||||
catch (Exception $e) { /* handle this ? */ }
|
catch (Exception $e) { /* handle this ? */ }
|
||||||
}
|
}
|
||||||
else if ($trigger = libcalendaring::parse_alaram_value($alarm['trigger'])) {
|
else if ($trigger = libcalendaring::parse_alaram_value($alarm['trigger'])) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue