Changeset View
Changeset View
Standalone View
Standalone View
src/applications/calendar/editor/PhabricatorCalendarEventEditor.php
<?php | <?php | ||||
final class PhabricatorCalendarEventEditor | final class PhabricatorCalendarEventEditor | ||||
extends PhabricatorApplicationTransactionEditor { | extends PhabricatorApplicationTransactionEditor { | ||||
public function getEditorApplicationClass() { | public function getEditorApplicationClass() { | ||||
return 'PhabricatorCalendarApplication'; | return 'PhabricatorCalendarApplication'; | ||||
} | } | ||||
public function getEditorObjectsDescription() { | public function getEditorObjectsDescription() { | ||||
return pht('Calendar'); | return pht('Calendar'); | ||||
} | } | ||||
protected function shouldApplyInitialEffects( | |||||
PhabricatorLiskDAO $object, | |||||
array $xactions) { | |||||
return true; | |||||
} | |||||
protected function applyInitialEffects( | |||||
PhabricatorLiskDAO $object, | |||||
array $xactions) { | |||||
$actor = $this->requireActor(); | |||||
$object->removeViewerTimezone($actor); | |||||
if ($object->getIsStub()) { | |||||
$this->materializeStub($object); | |||||
} | |||||
} | |||||
private function materializeStub(PhabricatorCalendarEvent $event) { | |||||
if (!$event->getIsStub()) { | |||||
throw new Exception( | |||||
pht('Can not materialize an event stub: this event is not a stub.')); | |||||
} | |||||
$actor = $this->getActor(); | |||||
$event->copyFromParent($actor); | |||||
$event->setIsStub(0); | |||||
$invitees = $event->getParentEvent()->getInvitees(); | |||||
foreach ($invitees as $invitee) { | |||||
$invitee = id(new PhabricatorCalendarEventInvitee()) | |||||
->setEventPHID($event->getPHID()) | |||||
->setInviteePHID($invitee->getInviteePHID()) | |||||
->setInviterPHID($invitee->getInviterPHID()) | |||||
->setStatus($invitee->getStatus()) | |||||
->save(); | |||||
} | |||||
$event->save(); | |||||
} | |||||
public function getTransactionTypes() { | public function getTransactionTypes() { | ||||
$types = parent::getTransactionTypes(); | $types = parent::getTransactionTypes(); | ||||
$types[] = PhabricatorCalendarEventTransaction::TYPE_NAME; | $types[] = PhabricatorCalendarEventTransaction::TYPE_NAME; | ||||
$types[] = PhabricatorCalendarEventTransaction::TYPE_START_DATE; | $types[] = PhabricatorCalendarEventTransaction::TYPE_START_DATE; | ||||
$types[] = PhabricatorCalendarEventTransaction::TYPE_END_DATE; | $types[] = PhabricatorCalendarEventTransaction::TYPE_END_DATE; | ||||
$types[] = PhabricatorCalendarEventTransaction::TYPE_DESCRIPTION; | $types[] = PhabricatorCalendarEventTransaction::TYPE_DESCRIPTION; | ||||
$types[] = PhabricatorCalendarEventTransaction::TYPE_CANCEL; | $types[] = PhabricatorCalendarEventTransaction::TYPE_CANCEL; | ||||
▲ Show 20 Lines • Show All 169 Lines • ▼ Show 20 Lines | switch ($xaction->getTransactionType()) { | ||||
} | } | ||||
$object->attachInvitees($invitees); | $object->attachInvitees($invitees); | ||||
return; | return; | ||||
} | } | ||||
return parent::applyCustomExternalTransaction($object, $xaction); | return parent::applyCustomExternalTransaction($object, $xaction); | ||||
} | } | ||||
protected function didApplyInternalEffects( | |||||
PhabricatorLiskDAO $object, | |||||
array $xactions) { | |||||
$object->removeViewerTimezone($this->requireActor()); | |||||
return $xactions; | |||||
} | |||||
protected function applyFinalEffects( | protected function applyFinalEffects( | ||||
PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
array $xactions) { | array $xactions) { | ||||
// Clear the availability caches for users whose availability is affected | // Clear the availability caches for users whose availability is affected | ||||
// by this edit. | // by this edit. | ||||
$invalidate_all = false; | $invalidate_all = false; | ||||
▲ Show 20 Lines • Show All 238 Lines • Show Last 20 Lines |