Differential D12840 Diff 30898 src/applications/calendar/storage/PhabricatorCalendarEventTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/calendar/storage/PhabricatorCalendarEventTransaction.php
<?php | <?php | ||||
final class PhabricatorCalendarEventTransaction | final class PhabricatorCalendarEventTransaction | ||||
extends PhabricatorApplicationTransaction { | extends PhabricatorApplicationTransaction { | ||||
const TYPE_NAME = 'calendar.name'; | const TYPE_NAME = 'calendar.name'; | ||||
const TYPE_START_DATE = 'calendar.startdate'; | const TYPE_START_DATE = 'calendar.startdate'; | ||||
const TYPE_END_DATE = 'calendar.enddate'; | const TYPE_END_DATE = 'calendar.enddate'; | ||||
const TYPE_STATUS = 'calendar.status'; | |||||
const TYPE_DESCRIPTION = 'calendar.description'; | const TYPE_DESCRIPTION = 'calendar.description'; | ||||
const TYPE_CANCEL = 'calendar.cancel'; | const TYPE_CANCEL = 'calendar.cancel'; | ||||
const TYPE_ALL_DAY = 'calendar.allday'; | const TYPE_ALL_DAY = 'calendar.allday'; | ||||
const TYPE_INVITE = 'calendar.invite'; | const TYPE_INVITE = 'calendar.invite'; | ||||
const MAILTAG_RESCHEDULE = 'calendar-reschedule'; | const MAILTAG_RESCHEDULE = 'calendar-reschedule'; | ||||
const MAILTAG_CONTENT = 'calendar-content'; | const MAILTAG_CONTENT = 'calendar-content'; | ||||
const MAILTAG_OTHER = 'calendar-other'; | const MAILTAG_OTHER = 'calendar-other'; | ||||
Show All 12 Lines | final class PhabricatorCalendarEventTransaction | ||||
public function getRequiredHandlePHIDs() { | public function getRequiredHandlePHIDs() { | ||||
$phids = parent::getRequiredHandlePHIDs(); | $phids = parent::getRequiredHandlePHIDs(); | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case self::TYPE_NAME: | case self::TYPE_NAME: | ||||
case self::TYPE_START_DATE: | case self::TYPE_START_DATE: | ||||
case self::TYPE_END_DATE: | case self::TYPE_END_DATE: | ||||
case self::TYPE_STATUS: | |||||
case self::TYPE_DESCRIPTION: | case self::TYPE_DESCRIPTION: | ||||
case self::TYPE_CANCEL: | case self::TYPE_CANCEL: | ||||
case self::TYPE_ALL_DAY: | case self::TYPE_ALL_DAY: | ||||
$phids[] = $this->getObjectPHID(); | $phids[] = $this->getObjectPHID(); | ||||
break; | break; | ||||
case self::TYPE_INVITE: | case self::TYPE_INVITE: | ||||
$new = $this->getNewValue(); | $new = $this->getNewValue(); | ||||
foreach ($new as $phid => $status) { | foreach ($new as $phid => $status) { | ||||
$phids[] = $phid; | $phids[] = $phid; | ||||
} | } | ||||
break; | break; | ||||
} | } | ||||
return $phids; | return $phids; | ||||
} | } | ||||
public function shouldHide() { | public function shouldHide() { | ||||
$old = $this->getOldValue(); | $old = $this->getOldValue(); | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case self::TYPE_START_DATE: | case self::TYPE_START_DATE: | ||||
case self::TYPE_END_DATE: | case self::TYPE_END_DATE: | ||||
case self::TYPE_STATUS: | |||||
case self::TYPE_DESCRIPTION: | case self::TYPE_DESCRIPTION: | ||||
case self::TYPE_CANCEL: | case self::TYPE_CANCEL: | ||||
case self::TYPE_ALL_DAY: | case self::TYPE_ALL_DAY: | ||||
case self::TYPE_INVITE: | case self::TYPE_INVITE: | ||||
return ($old === null); | return ($old === null); | ||||
} | } | ||||
return parent::shouldHide(); | return parent::shouldHide(); | ||||
} | } | ||||
public function getIcon() { | public function getIcon() { | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case self::TYPE_NAME: | case self::TYPE_NAME: | ||||
case self::TYPE_START_DATE: | case self::TYPE_START_DATE: | ||||
case self::TYPE_END_DATE: | case self::TYPE_END_DATE: | ||||
case self::TYPE_STATUS: | |||||
case self::TYPE_DESCRIPTION: | case self::TYPE_DESCRIPTION: | ||||
case self::TYPE_ALL_DAY: | case self::TYPE_ALL_DAY: | ||||
case self::TYPE_CANCEL: | case self::TYPE_CANCEL: | ||||
return 'fa-pencil'; | return 'fa-pencil'; | ||||
break; | break; | ||||
case self::TYPE_INVITE: | case self::TYPE_INVITE: | ||||
return 'fa-user-plus'; | return 'fa-user-plus'; | ||||
break; | break; | ||||
Show All 31 Lines | switch ($type) { | ||||
break; | break; | ||||
case self::TYPE_END_DATE: | case self::TYPE_END_DATE: | ||||
if ($old) { | if ($old) { | ||||
return pht( | return pht( | ||||
'%s edited the end date of this event.', | '%s edited the end date of this event.', | ||||
$this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
} | } | ||||
break; | break; | ||||
case self::TYPE_STATUS: | |||||
$old_name = PhabricatorCalendarEvent::getNameForStatus($old); | |||||
$new_name = PhabricatorCalendarEvent::getNameForStatus($new); | |||||
return pht( | |||||
'%s updated the event status from %s to %s.', | |||||
$this->renderHandleLink($author_phid), | |||||
$old_name, | |||||
$new_name); | |||||
case self::TYPE_DESCRIPTION: | case self::TYPE_DESCRIPTION: | ||||
return pht( | return pht( | ||||
"%s updated the event's description.", | "%s updated the event's description.", | ||||
$this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
case self::TYPE_ALL_DAY: | case self::TYPE_ALL_DAY: | ||||
if ($new) { | if ($new) { | ||||
return pht( | return pht( | ||||
'%s made this an all day event.', | '%s made this an all day event.', | ||||
▲ Show 20 Lines • Show All 143 Lines • ▼ Show 20 Lines | switch ($type) { | ||||
return pht( | return pht( | ||||
'%s edited the end date of %s from %s to %s.', | '%s edited the end date of %s from %s to %s.', | ||||
$this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
$this->renderHandleLink($object_phid), | $this->renderHandleLink($object_phid), | ||||
$old, | $old, | ||||
$new); | $new); | ||||
} | } | ||||
break; | break; | ||||
case self::TYPE_STATUS: | |||||
$old_name = PhabricatorCalendarEvent::getNameForStatus($old); | |||||
$new_name = PhabricatorCalendarEvent::getNameForStatus($new); | |||||
return pht( | |||||
'%s updated the status of %s from %s to %s.', | |||||
$this->renderHandleLink($author_phid), | |||||
$this->renderHandleLink($object_phid), | |||||
$old_name, | |||||
$new_name); | |||||
case self::TYPE_DESCRIPTION: | case self::TYPE_DESCRIPTION: | ||||
return pht( | return pht( | ||||
'%s updated the description of %s.', | '%s updated the description of %s.', | ||||
$this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
$this->renderHandleLink($object_phid)); | $this->renderHandleLink($object_phid)); | ||||
case self::TYPE_ALL_DAY: | case self::TYPE_ALL_DAY: | ||||
if ($new) { | if ($new) { | ||||
return pht( | return pht( | ||||
▲ Show 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | final class PhabricatorCalendarEventTransaction | ||||
public function getColor() { | public function getColor() { | ||||
$old = $this->getOldValue(); | $old = $this->getOldValue(); | ||||
$new = $this->getNewValue(); | $new = $this->getNewValue(); | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case self::TYPE_NAME: | case self::TYPE_NAME: | ||||
case self::TYPE_START_DATE: | case self::TYPE_START_DATE: | ||||
case self::TYPE_END_DATE: | case self::TYPE_END_DATE: | ||||
case self::TYPE_STATUS: | |||||
case self::TYPE_DESCRIPTION: | case self::TYPE_DESCRIPTION: | ||||
case self::TYPE_CANCEL: | case self::TYPE_CANCEL: | ||||
case self::TYPE_INVITE: | case self::TYPE_INVITE: | ||||
return PhabricatorTransactions::COLOR_GREEN; | return PhabricatorTransactions::COLOR_GREEN; | ||||
} | } | ||||
return parent::getColor(); | return parent::getColor(); | ||||
} | } | ||||
Show All 22 Lines | public function renderChangeDetails(PhabricatorUser $viewer) { | ||||
return parent::renderChangeDetails($viewer); | return parent::renderChangeDetails($viewer); | ||||
} | } | ||||
public function getMailTags() { | public function getMailTags() { | ||||
$tags = array(); | $tags = array(); | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case self::TYPE_NAME: | case self::TYPE_NAME: | ||||
case self::TYPE_STATUS: | |||||
case self::TYPE_DESCRIPTION: | case self::TYPE_DESCRIPTION: | ||||
case self::TYPE_INVITE: | case self::TYPE_INVITE: | ||||
$tags[] = self::MAILTAG_CONTENT; | $tags[] = self::MAILTAG_CONTENT; | ||||
break; | break; | ||||
case self::TYPE_START_DATE: | case self::TYPE_START_DATE: | ||||
case self::TYPE_END_DATE: | case self::TYPE_END_DATE: | ||||
case self::TYPE_CANCEL: | case self::TYPE_CANCEL: | ||||
$tags[] = self::MAILTAG_RESCHEDULE; | $tags[] = self::MAILTAG_RESCHEDULE; | ||||
break; | break; | ||||
} | } | ||||
return $tags; | return $tags; | ||||
} | } | ||||
} | } |