Path: blob/master/src/applications/calendar/xaction/PhabricatorCalendarEventDateTransaction.php
12256 views
<?php12abstract class PhabricatorCalendarEventDateTransaction3extends PhabricatorCalendarEventTransactionType {45abstract protected function getInvalidDateMessage();67public function isInheritedEdit() {8return false;9}1011public function generateNewValue($object, $value) {12$editor = $this->getEditor();1314if ($value->isDisabled()) {15return null;16}1718return $value->newPhutilDateTime()19->setIsAllDay($editor->getNewIsAllDay())20->newAbsoluteDateTime()21->toDictionary();22}2324public function getTransactionHasEffect($object, $old, $new) {25// If either value is `null` (for example, when setting a recurring event26// end date for the first time) and the other value is not `null`, this27// transaction has an effect.28$has_null = (($old === null) || ($new === null));29if ($has_null) {30return ($old !== $new);31}3233$editor = $this->getEditor();3435$actor = $this->getActor();36$actor_timezone = $actor->getTimezoneIdentifier();3738// When an edit only changes the timezone of an event without materially39// changing the absolute time, discard it. This can happen if two users in40// different timezones edit an event without rescheduling it.4142// Eventually, after T11073, there may be a UI control to adjust timezones.43// If a user explicitly changed the timezone, we should respect that.44// However, there is no way for users to intentionally apply this kind of45// edit today.4647$old_datetime = PhutilCalendarAbsoluteDateTime::newFromDictionary($old)48->setIsAllDay($editor->getNewIsAllDay())49->setViewerTimezone($actor_timezone);5051$new_datetime = PhutilCalendarAbsoluteDateTime::newFromDictionary($new)52->setIsAllDay($editor->getNewIsAllDay())53->setViewerTimezone($actor_timezone);5455$old_epoch = $old_datetime->getEpoch();56$new_epoch = $new_datetime->getEpoch();5758return ($old_epoch !== $new_epoch);59}6061public function validateTransactions($object, array $xactions) {62$errors = array();6364foreach ($xactions as $xaction) {65if ($xaction->getNewValue()->isValid()) {66continue;67}6869$message = $this->getInvalidDateMessage();70$errors[] = $this->newInvalidError($message, $xaction);71}7273return $errors;74}7576}777879