mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 19:40:55 +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:
parent
f4a3887b6b
commit
48666839fe
3 changed files with 30 additions and 1 deletions
|
@ -403,6 +403,9 @@ abstract class PhabricatorCalendarImportEngine
|
||||||
$until_datetime->setViewerTimezone($timezone);
|
$until_datetime->setViewerTimezone($timezone);
|
||||||
$event->setUntilDateTime($until_datetime);
|
$event->setUntilDateTime($until_datetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$count = $rrule->getCount();
|
||||||
|
$event->setParameter('recurrenceCount', $count);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $event;
|
return $event;
|
||||||
|
|
|
@ -633,6 +633,11 @@ final class PhabricatorCalendarEventQuery
|
||||||
PhabricatorCalendarEvent $event,
|
PhabricatorCalendarEvent $event,
|
||||||
$raw_limit) {
|
$raw_limit) {
|
||||||
|
|
||||||
|
$count = $event->getRecurrenceCount();
|
||||||
|
if ($count && ($count <= $raw_limit)) {
|
||||||
|
return ($count - 1);
|
||||||
|
}
|
||||||
|
|
||||||
return $raw_limit;
|
return $raw_limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -226,10 +226,16 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$limit = $sequence + 1;
|
||||||
|
$count = $this->getRecurrenceCount();
|
||||||
|
if ($count && ($count < $limit)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$instances = $set->getEventsBetween(
|
$instances = $set->getEventsBetween(
|
||||||
null,
|
null,
|
||||||
$this->newUntilDateTime(),
|
$this->newUntilDateTime(),
|
||||||
$sequence + 1);
|
$limit);
|
||||||
|
|
||||||
return idx($instances, $sequence, null);
|
return idx($instances, $sequence, null);
|
||||||
}
|
}
|
||||||
|
@ -907,9 +913,24 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
|
||||||
$rrule->setUntil($until);
|
$rrule->setUntil($until);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$count = $this->getRecurrenceCount();
|
||||||
|
if ($count) {
|
||||||
|
$rrule->setCount($count);
|
||||||
|
}
|
||||||
|
|
||||||
return $rrule;
|
return $rrule;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getRecurrenceCount() {
|
||||||
|
$count = (int)$this->getParameter('recurrenceCount');
|
||||||
|
|
||||||
|
if (!$count) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $count;
|
||||||
|
}
|
||||||
|
|
||||||
public function newRecurrenceSet() {
|
public function newRecurrenceSet() {
|
||||||
if ($this->isChildEvent()) {
|
if ($this->isChildEvent()) {
|
||||||
return $this->getParentEvent()->newRecurrenceSet();
|
return $this->getParentEvent()->newRecurrenceSet();
|
||||||
|
|
Loading…
Reference in a new issue