3 abstract class PhabricatorCalendarEventDateTransaction
4 extends PhabricatorCalendarEventTransactionType
{
6 abstract protected function getInvalidDateMessage();
8 public function isInheritedEdit() {
12 public function generateNewValue($object, $value) {
13 $editor = $this->getEditor();
15 if ($value->isDisabled()) {
19 return $value->newPhutilDateTime()
20 ->setIsAllDay($editor->getNewIsAllDay())
21 ->newAbsoluteDateTime()
25 public function getTransactionHasEffect($object, $old, $new) {
26 // If either value is `null` (for example, when setting a recurring event
27 // end date for the first time) and the other value is not `null`, this
28 // transaction has an effect.
29 $has_null = (($old === null) ||
($new === null));
31 return ($old !== $new);
34 $editor = $this->getEditor();
36 $actor = $this->getActor();
37 $actor_timezone = $actor->getTimezoneIdentifier();
39 // When an edit only changes the timezone of an event without materially
40 // changing the absolute time, discard it. This can happen if two users in
41 // different timezones edit an event without rescheduling it.
43 // Eventually, after T11073, there may be a UI control to adjust timezones.
44 // If a user explicitly changed the timezone, we should respect that.
45 // However, there is no way for users to intentionally apply this kind of
48 $old_datetime = PhutilCalendarAbsoluteDateTime
::newFromDictionary($old)
49 ->setIsAllDay($editor->getNewIsAllDay())
50 ->setViewerTimezone($actor_timezone);
52 $new_datetime = PhutilCalendarAbsoluteDateTime
::newFromDictionary($new)
53 ->setIsAllDay($editor->getNewIsAllDay())
54 ->setViewerTimezone($actor_timezone);
56 $old_epoch = $old_datetime->getEpoch();
57 $new_epoch = $new_datetime->getEpoch();
59 return ($old_epoch !== $new_epoch);
62 public function validateTransactions($object, array $xactions) {
65 foreach ($xactions as $xaction) {
66 if ($xaction->getNewValue()->isValid()) {
70 $message = $this->getInvalidDateMessage();
71 $errors[] = $this->newInvalidError($message, $xaction);