2014-02-06 19:10:27 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorCalendarEventViewController
|
2014-02-18 01:08:50 +01:00
|
|
|
extends PhabricatorCalendarController {
|
2014-02-06 19:10:27 +01:00
|
|
|
|
|
|
|
private $id;
|
|
|
|
|
2014-05-14 19:00:46 +02:00
|
|
|
public function shouldAllowPublic() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-02-06 19:10:27 +01:00
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->id = $data['id'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$viewer = $request->getUser();
|
|
|
|
|
|
|
|
$event = id(new PhabricatorCalendarEventQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->withIDs(array($this->id))
|
|
|
|
->executeOne();
|
|
|
|
if (!$event) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
2015-04-27 23:27:00 +02:00
|
|
|
$title = 'E'.$event->getID();
|
2015-04-28 17:34:26 +02:00
|
|
|
$page_title = $title.' '.$event->getName();
|
2014-02-06 19:10:27 +01:00
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
2015-04-27 23:27:00 +02:00
|
|
|
$crumbs->addTextCrumb($title, '/E'.$event->getID());
|
2014-02-06 19:10:27 +01:00
|
|
|
|
2015-04-28 15:26:48 +02:00
|
|
|
$timeline = $this->buildTransactionTimeline(
|
|
|
|
$event,
|
|
|
|
new PhabricatorCalendarEventTransactionQuery());
|
|
|
|
|
2014-02-06 19:10:27 +01:00
|
|
|
$header = $this->buildHeaderView($event);
|
|
|
|
$actions = $this->buildActionView($event);
|
|
|
|
$properties = $this->buildPropertyView($event);
|
|
|
|
|
|
|
|
$properties->setActionList($actions);
|
|
|
|
$box = id(new PHUIObjectBoxView())
|
|
|
|
->setHeader($header)
|
|
|
|
->addPropertyList($properties);
|
|
|
|
|
|
|
|
return $this->buildApplicationPage(
|
|
|
|
array(
|
|
|
|
$crumbs,
|
|
|
|
$box,
|
2015-04-28 15:26:48 +02:00
|
|
|
$timeline,
|
2014-02-06 19:10:27 +01:00
|
|
|
),
|
|
|
|
array(
|
2015-04-28 17:34:26 +02:00
|
|
|
'title' => $page_title,
|
2014-02-06 19:10:27 +01:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
private function buildHeaderView(PhabricatorCalendarEvent $event) {
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
return id(new PHUIHeaderView())
|
|
|
|
->setUser($viewer)
|
2015-04-28 17:34:26 +02:00
|
|
|
->setHeader($event->getName())
|
2014-02-06 19:10:27 +01:00
|
|
|
->setPolicyObject($event);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function buildActionView(PhabricatorCalendarEvent $event) {
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
$id = $event->getID();
|
|
|
|
|
|
|
|
$actions = id(new PhabricatorActionListView())
|
|
|
|
->setObjectURI($this->getApplicationURI('event/'.$id.'/'))
|
|
|
|
->setUser($viewer);
|
|
|
|
|
|
|
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
|
|
|
$viewer,
|
|
|
|
$event,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT);
|
|
|
|
|
|
|
|
$actions->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName(pht('Edit Event'))
|
2014-05-12 19:08:32 +02:00
|
|
|
->setIcon('fa-pencil')
|
2014-02-06 19:10:27 +01:00
|
|
|
->setHref($this->getApplicationURI("event/edit/{$id}/"))
|
|
|
|
->setDisabled(!$can_edit)
|
|
|
|
->setWorkflow(!$can_edit));
|
|
|
|
|
|
|
|
$actions->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName(pht('Cancel Event'))
|
2014-05-12 19:08:32 +02:00
|
|
|
->setIcon('fa-times')
|
2014-02-06 19:10:27 +01:00
|
|
|
->setHref($this->getApplicationURI("event/delete/{$id}/"))
|
|
|
|
->setDisabled(!$can_edit)
|
|
|
|
->setWorkflow(true));
|
|
|
|
|
|
|
|
return $actions;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function buildPropertyView(PhabricatorCalendarEvent $event) {
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
$properties = id(new PHUIPropertyListView())
|
|
|
|
->setUser($viewer)
|
|
|
|
->setObject($event);
|
|
|
|
|
|
|
|
$properties->addProperty(
|
|
|
|
pht('Starts'),
|
|
|
|
phabricator_datetime($event->getDateFrom(), $viewer));
|
|
|
|
|
|
|
|
$properties->addProperty(
|
|
|
|
pht('Ends'),
|
|
|
|
phabricator_datetime($event->getDateTo(), $viewer));
|
|
|
|
|
2014-02-18 01:08:25 +01:00
|
|
|
$properties->addSectionHeader(
|
|
|
|
pht('Description'),
|
|
|
|
PHUIPropertyListView::ICON_SUMMARY);
|
|
|
|
$properties->addTextContent($event->getDescription());
|
|
|
|
|
2014-02-06 19:10:27 +01:00
|
|
|
return $properties;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|