Differential D16955 Diff 40808 src/applications/calendar/xaction/PhabricatorCalendarEventDateTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/calendar/xaction/PhabricatorCalendarEventDateTransaction.php
Show All 16 Lines | public function generateNewValue($object, $value) { | ||||
} | } | ||||
return $value->newPhutilDateTime() | return $value->newPhutilDateTime() | ||||
->setIsAllDay($editor->getNewIsAllDay()) | ->setIsAllDay($editor->getNewIsAllDay()) | ||||
->newAbsoluteDateTime() | ->newAbsoluteDateTime() | ||||
->toDictionary(); | ->toDictionary(); | ||||
} | } | ||||
public function getTransactionHasEffect($object, $old, $new) { | |||||
$editor = $this->getEditor(); | |||||
$actor = $this->getActor(); | |||||
$actor_timezone = $actor->getTimezoneIdentifier(); | |||||
// When an edit only changes the timezone of an event without materially | |||||
// changing the absolute time, discard it. This can happen if two users in | |||||
// different timezones edit an event without rescheduling it. | |||||
// Eventually, after T11073, there may be a UI control to adjust timezones. | |||||
// If a user explicitly changed the timezone, we should respect that. | |||||
// However, there is no way for users to intentionally apply this kind of | |||||
// edit today. | |||||
$old_datetime = PhutilCalendarAbsoluteDateTime::newFromDictionary($old) | |||||
->setIsAllDay($editor->getNewIsAllDay()) | |||||
->setViewerTimezone($actor_timezone); | |||||
$new_datetime = PhutilCalendarAbsoluteDateTime::newFromDictionary($new) | |||||
->setIsAllDay($editor->getNewIsAllDay()) | |||||
->setViewerTimezone($actor_timezone); | |||||
$old_epoch = $old_datetime->getEpoch(); | |||||
$new_epoch = $new_datetime->getEpoch(); | |||||
return ($old_epoch !== $new_epoch); | |||||
} | |||||
public function validateTransactions($object, array $xactions) { | public function validateTransactions($object, array $xactions) { | ||||
$errors = array(); | $errors = array(); | ||||
foreach ($xactions as $xaction) { | foreach ($xactions as $xaction) { | ||||
if ($xaction->getNewValue()->isValid()) { | if ($xaction->getNewValue()->isValid()) { | ||||
continue; | continue; | ||||
} | } | ||||
$message = $this->getInvalidDateMessage(); | $message = $this->getInvalidDateMessage(); | ||||
$errors[] = $this->newInvalidError($message, $xaction); | $errors[] = $this->newInvalidError($message, $xaction); | ||||
} | } | ||||
return $errors; | return $errors; | ||||
} | } | ||||
} | } |