Changeset View
Changeset View
Standalone View
Standalone View
src/applications/calendar/storage/PhabricatorCalendarEvent.php
<?php | <?php | ||||
final class PhabricatorCalendarEvent | final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO | ||||
extends PhabricatorCalendarDAO | implements PhabricatorPolicyInterface, | ||||
implements PhabricatorPolicyInterface { | PhabricatorMarkupInterface { | ||||
protected $userPHID; | protected $userPHID; | ||||
protected $dateFrom; | protected $dateFrom; | ||||
protected $dateTo; | protected $dateTo; | ||||
protected $status; | protected $status; | ||||
protected $description; | protected $description; | ||||
const STATUS_AWAY = 1; | const STATUS_AWAY = 1; | ||||
Show All 37 Lines | protected function getConfiguration() { | ||||
) + parent::getConfiguration(); | ) + parent::getConfiguration(); | ||||
} | } | ||||
public function generatePHID() { | public function generatePHID() { | ||||
return PhabricatorPHID::generateNewPHID( | return PhabricatorPHID::generateNewPHID( | ||||
PhabricatorCalendarEventPHIDType::TYPECONST); | PhabricatorCalendarEventPHIDType::TYPECONST); | ||||
} | } | ||||
public function getMonogram() { | |||||
return 'E'.$this->getID(); | |||||
} | |||||
public function getTerseSummary(PhabricatorUser $viewer) { | public function getTerseSummary(PhabricatorUser $viewer) { | ||||
$until = phabricator_date($this->dateTo, $viewer); | $until = phabricator_date($this->dateTo, $viewer); | ||||
if ($this->status == PhabricatorCalendarEvent::STATUS_SPORADIC) { | if ($this->status == PhabricatorCalendarEvent::STATUS_SPORADIC) { | ||||
return pht('Sporadic until %s', $until); | return pht('Sporadic until %s', $until); | ||||
} else { | } else { | ||||
return pht('Away until %s', $until); | return pht('Away until %s', $until); | ||||
} | } | ||||
} | } | ||||
Show All 23 Lines | public function save() { | ||||
if ($this->getDateTo() <= $this->getDateFrom()) { | if ($this->getDateTo() <= $this->getDateFrom()) { | ||||
throw new PhabricatorCalendarEventInvalidEpochException(); | throw new PhabricatorCalendarEventInvalidEpochException(); | ||||
} | } | ||||
return parent::save(); | return parent::save(); | ||||
} | } | ||||
/* -( Markup Interface )--------------------------------------------------- */ | |||||
/** | |||||
* @task markup | |||||
*/ | |||||
public function getMarkupFieldKey($field) { | |||||
$hash = PhabricatorHash::digest($this->getMarkupText($field)); | |||||
$id = $this->getID(); | |||||
return "calendar:T{$id}:{$field}:{$hash}"; | |||||
} | |||||
/** | |||||
* @task markup | |||||
*/ | |||||
public function getMarkupText($field) { | |||||
return $this->getDescription(); | |||||
} | |||||
/** | |||||
* @task markup | |||||
*/ | |||||
public function newMarkupEngine($field) { | |||||
return PhabricatorMarkupEngine::newCalendarMarkupEngine(); | |||||
} | |||||
/** | |||||
* @task markup | |||||
*/ | |||||
public function didMarkupText( | |||||
$field, | |||||
$output, | |||||
PhutilMarkupEngine $engine) { | |||||
return $output; | |||||
} | |||||
/** | |||||
* @task markup | |||||
*/ | |||||
public function shouldUseMarkupCache($field) { | |||||
return (bool)$this->getID(); | |||||
} | |||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */ | /* -( PhabricatorPolicyInterface )----------------------------------------- */ | ||||
public function getCapabilities() { | public function getCapabilities() { | ||||
return array( | return array( | ||||
PhabricatorPolicyCapability::CAN_VIEW, | PhabricatorPolicyCapability::CAN_VIEW, | ||||
PhabricatorPolicyCapability::CAN_EDIT, | PhabricatorPolicyCapability::CAN_EDIT, | ||||
Show All 21 Lines |