1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 04:42:40 +01:00

Support RRULE "COUNT" for recurring events

Summary:
Ref T10747. RRULE events can repeat "UNTIL" a certain time, or a certain "COUNT" of times.

In the UI, we only support "UNTIL". Also support "COUNT".

Test Plan: Imported an event which repeats every other day, 5 times. Got 5 instances.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10747

Differential Revision: https://secure.phabricator.com/D16749
This commit is contained in:
epriestley 2016-10-25 10:31:10 -07:00
parent f4a3887b6b
commit 48666839fe
3 changed files with 30 additions and 1 deletions

View file

@ -403,6 +403,9 @@ abstract class PhabricatorCalendarImportEngine
$until_datetime->setViewerTimezone($timezone);
$event->setUntilDateTime($until_datetime);
}
$count = $rrule->getCount();
$event->setParameter('recurrenceCount', $count);
}
return $event;

View file

@ -633,6 +633,11 @@ final class PhabricatorCalendarEventQuery
PhabricatorCalendarEvent $event,
$raw_limit) {
$count = $event->getRecurrenceCount();
if ($count && ($count <= $raw_limit)) {
return ($count - 1);
}
return $raw_limit;
}

View file

@ -226,10 +226,16 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
return null;
}
$limit = $sequence + 1;
$count = $this->getRecurrenceCount();
if ($count && ($count < $limit)) {
return null;
}
$instances = $set->getEventsBetween(
null,
$this->newUntilDateTime(),
$sequence + 1);
$limit);
return idx($instances, $sequence, null);
}
@ -907,9 +913,24 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
$rrule->setUntil($until);
}
$count = $this->getRecurrenceCount();
if ($count) {
$rrule->setCount($count);
}
return $rrule;
}
public function getRecurrenceCount() {
$count = (int)$this->getParameter('recurrenceCount');
if (!$count) {
return null;
}
return $count;
}
public function newRecurrenceSet() {
if ($this->isChildEvent()) {
return $this->getParentEvent()->newRecurrenceSet();