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();
|
Canceling calendar events should deactivate the event
Summary: Closes T7943, Canceling calendar event should deactivate the event instead of destroying data.
Test Plan: Create an event, cancel it, see changed status icon, query for active events, event should not appear, query for deactivated events, event should appear in results.
Reviewers: #blessed_reviewers, epriestley
Reviewed By: #blessed_reviewers, epriestley
Subscribers: Korvin, epriestley
Maniphest Tasks: T7943
Differential Revision: https://secure.phabricator.com/D12604
2015-04-29 17:39:39 +02:00
|
|
|
$is_cancelled = $event->getIsCancelled();
|
|
|
|
$icon = $is_cancelled ? ('fa-times') : ('fa-calendar');
|
|
|
|
$color = $is_cancelled ? ('grey') : ('green');
|
|
|
|
$status = $is_cancelled ? ('Cancelled') : ('Active');
|
2014-02-06 19:10:27 +01:00
|
|
|
|
|
|
|
return id(new PHUIHeaderView())
|
|
|
|
->setUser($viewer)
|
2015-04-28 17:34:26 +02:00
|
|
|
->setHeader($event->getName())
|
Canceling calendar events should deactivate the event
Summary: Closes T7943, Canceling calendar event should deactivate the event instead of destroying data.
Test Plan: Create an event, cancel it, see changed status icon, query for active events, event should not appear, query for deactivated events, event should appear in results.
Reviewers: #blessed_reviewers, epriestley
Reviewed By: #blessed_reviewers, epriestley
Subscribers: Korvin, epriestley
Maniphest Tasks: T7943
Differential Revision: https://secure.phabricator.com/D12604
2015-04-29 17:39:39 +02:00
|
|
|
->setStatus($icon, $color, $status)
|
2014-02-06 19:10:27 +01:00
|
|
|
->setPolicyObject($event);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function buildActionView(PhabricatorCalendarEvent $event) {
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
$id = $event->getID();
|
Canceling calendar events should deactivate the event
Summary: Closes T7943, Canceling calendar event should deactivate the event instead of destroying data.
Test Plan: Create an event, cancel it, see changed status icon, query for active events, event should not appear, query for deactivated events, event should appear in results.
Reviewers: #blessed_reviewers, epriestley
Reviewed By: #blessed_reviewers, epriestley
Subscribers: Korvin, epriestley
Maniphest Tasks: T7943
Differential Revision: https://secure.phabricator.com/D12604
2015-04-29 17:39:39 +02:00
|
|
|
$is_cancelled = $event->getIsCancelled();
|
2014-02-06 19:10:27 +01:00
|
|
|
|
|
|
|
$actions = id(new PhabricatorActionListView())
|
|
|
|
->setObjectURI($this->getApplicationURI('event/'.$id.'/'))
|
2015-04-28 19:40:35 +02:00
|
|
|
->setUser($viewer)
|
|
|
|
->setObject($event);
|
2014-02-06 19:10:27 +01:00
|
|
|
|
|
|
|
$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));
|
|
|
|
|
Canceling calendar events should deactivate the event
Summary: Closes T7943, Canceling calendar event should deactivate the event instead of destroying data.
Test Plan: Create an event, cancel it, see changed status icon, query for active events, event should not appear, query for deactivated events, event should appear in results.
Reviewers: #blessed_reviewers, epriestley
Reviewed By: #blessed_reviewers, epriestley
Subscribers: Korvin, epriestley
Maniphest Tasks: T7943
Differential Revision: https://secure.phabricator.com/D12604
2015-04-29 17:39:39 +02:00
|
|
|
if ($is_cancelled) {
|
|
|
|
$actions->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName(pht('Reinstate Event'))
|
|
|
|
->setIcon('fa-plus')
|
|
|
|
->setHref($this->getApplicationURI("event/cancel/{$id}/"))
|
|
|
|
->setDisabled(!$can_edit)
|
|
|
|
->setWorkflow(true));
|
|
|
|
} else {
|
|
|
|
$actions->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName(pht('Cancel Event'))
|
|
|
|
->setIcon('fa-times')
|
|
|
|
->setHref($this->getApplicationURI("event/cancel/{$id}/"))
|
|
|
|
->setDisabled(!$can_edit)
|
|
|
|
->setWorkflow(true));
|
|
|
|
}
|
2014-02-06 19:10:27 +01:00
|
|
|
|
|
|
|
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));
|
|
|
|
|
2015-04-29 22:51:09 +02:00
|
|
|
$invitees = $event->getInvitees();
|
|
|
|
$invitee_list = new PHUIStatusListView();
|
|
|
|
foreach ($invitees as $invitee) {
|
|
|
|
$item = new PHUIStatusItemView();
|
|
|
|
$invitee_phid = $invitee->getInviteePHID();
|
|
|
|
$target = $viewer->renderHandle($invitee_phid);
|
|
|
|
$item->setTarget($target);
|
|
|
|
$invitee_list->addItem($item);
|
|
|
|
}
|
|
|
|
|
|
|
|
$properties->addProperty(
|
|
|
|
pht('Invitees'),
|
|
|
|
$invitee_list);
|
|
|
|
|
2015-04-28 19:40:35 +02:00
|
|
|
$properties->invokeWillRenderEvent();
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|