Path: blob/master/src/applications/calendar/xaction/PhabricatorCalendarEventForkTransaction.php
12256 views
<?php12final class PhabricatorCalendarEventForkTransaction3extends PhabricatorCalendarEventTransactionType {45const TRANSACTIONTYPE = 'calendar.fork';67public function generateOldValue($object) {8return false;9}1011public function shouldHide() {12// This transaction is purely an internal implementation detail which13// supports editing groups of events like "All Future Events".14return true;15}1617public function applyInternalEffects($object, $value) {18$parent = $object->getParentEvent();1920$object->setInstanceOfEventPHID(null);21$object->attachParentEvent(null);2223$rrule = $parent->newRecurrenceRule();24$object->setRecurrenceRule($rrule);2526$until = $parent->newUntilDateTime();27if ($until) {28$object->setUntilDateTime($until);29}3031$old_sequence_index = $object->getSequenceIndex();32$object->setSequenceIndex(0);3334// Stop the parent event from recurring after the start date of this event.35// Since the "until" time is inclusive, rewind it by one second. We could36// figure out the previous instance's time instead or use a COUNT, but this37// seems simpler as long as it doesn't cause any issues.38$until_cutoff = $object->newStartDateTime()39->newRelativeDateTime('-PT1S')40->newAbsoluteDateTime();4142$parent->setUntilDateTime($until_cutoff);43$parent->save();4445// NOTE: If we implement "COUNT" on editable events, we need to adjust46// the "COUNT" here and divide it up between the parent and the fork.4748// Make all following children of the old parent children of this node49// instead.50$conn = $object->establishConnection('w');51queryfx(52$conn,53'UPDATE %T SET54instanceOfEventPHID = %s,55sequenceIndex = (sequenceIndex - %d)56WHERE instanceOfEventPHID = %s57AND utcInstanceEpoch > %d',58$object->getTableName(),59$object->getPHID(),60$old_sequence_index,61$parent->getPHID(),62$object->getUTCInstanceEpoch());63}6465}666768