3 final class PhabricatorCalendarEventForkTransaction
4 extends PhabricatorCalendarEventTransactionType
{
6 const TRANSACTIONTYPE
= 'calendar.fork';
8 public function generateOldValue($object) {
12 public function shouldHide() {
13 // This transaction is purely an internal implementation detail which
14 // supports editing groups of events like "All Future Events".
18 public function applyInternalEffects($object, $value) {
19 $parent = $object->getParentEvent();
21 $object->setInstanceOfEventPHID(null);
22 $object->attachParentEvent(null);
24 $rrule = $parent->newRecurrenceRule();
25 $object->setRecurrenceRule($rrule);
27 $until = $parent->newUntilDateTime();
29 $object->setUntilDateTime($until);
32 $old_sequence_index = $object->getSequenceIndex();
33 $object->setSequenceIndex(0);
35 // Stop the parent event from recurring after the start date of this event.
36 // Since the "until" time is inclusive, rewind it by one second. We could
37 // figure out the previous instance's time instead or use a COUNT, but this
38 // seems simpler as long as it doesn't cause any issues.
39 $until_cutoff = $object->newStartDateTime()
40 ->newRelativeDateTime('-PT1S')
41 ->newAbsoluteDateTime();
43 $parent->setUntilDateTime($until_cutoff);
46 // NOTE: If we implement "COUNT" on editable events, we need to adjust
47 // the "COUNT" here and divide it up between the parent and the fork.
49 // Make all following children of the old parent children of this node
51 $conn = $object->establishConnection('w');
55 instanceOfEventPHID = %s,
56 sequenceIndex = (sequenceIndex - %d)
57 WHERE instanceOfEventPHID = %s
58 AND utcInstanceEpoch > %d',
59 $object->getTableName(),
63 $object->getUTCInstanceEpoch());