Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventJoinController.php b/src/applications/calendar/controller/PhabricatorCalendarEventJoinController.php
index 00a1a80bda..a77856f16a 100644
--- a/src/applications/calendar/controller/PhabricatorCalendarEventJoinController.php
+++ b/src/applications/calendar/controller/PhabricatorCalendarEventJoinController.php
@@ -1,81 +1,93 @@
<?php
final class PhabricatorCalendarEventJoinController
extends PhabricatorCalendarController {
private $id;
const ACTION_ACCEPT = 'accept';
const ACTION_DECLINE = 'decline';
const ACTION_JOIN = 'join';
public function handleRequest(AphrontRequest $request) {
$this->id = $request->getURIData('id');
$action = $request->getURIData('action');
$request = $this->getRequest();
$viewer = $request->getViewer();
$declined_status = PhabricatorCalendarEventInvitee::STATUS_DECLINED;
$attending_status = PhabricatorCalendarEventInvitee::STATUS_ATTENDING;
$event = id(new PhabricatorCalendarEventQuery())
->setViewer($viewer)
->withIDs(array($this->id))
->executeOne();
if (!$event) {
return new Aphront404Response();
}
$cancel_uri = '/E'.$event->getID();
$validation_exception = null;
$is_attending = $event->getIsUserAttending($viewer->getPHID());
if ($request->isFormPost()) {
$new_status = null;
- if ($is_attending) {
- $new_status = array($viewer->getPHID() => $declined_status);
- } else {
- $new_status = array($viewer->getPHID() => $attending_status);
+ switch ($action) {
+ case self::ACTION_ACCEPT:
+ $new_status = $attending_status;
+ break;
+ case self::ACTION_JOIN:
+ if ($is_attending) {
+ $new_status = $declined_status;
+ } else {
+ $new_status = $attending_status;
+ }
+ break;
+ case self::ACTION_DECLINE:
+ $new_status = $declined_status;
+ break;
}
+ $new_status = array($viewer->getPHID() => $new_status);
+
$xaction = id(new PhabricatorCalendarEventTransaction())
->setTransactionType(
PhabricatorCalendarEventTransaction::TYPE_INVITE)
->setNewValue($new_status);
$editor = id(new PhabricatorCalendarEventEditor())
->setActor($viewer)
->setContentSourceFromRequest($request)
->setContinueOnNoEffect(true)
->setContinueOnMissingFields(true);
try {
$editor->applyTransactions($event, array($xaction));
return id(new AphrontRedirectResponse())->setURI($cancel_uri);
} catch (PhabricatorApplicationTransactionValidationException $ex) {
$validation_exception = $ex;
}
}
if (($action == self::ACTION_JOIN && !$is_attending)
|| $action == self::ACTION_ACCEPT) {
$title = pht('Join Event');
$paragraph = pht('Would you like to join this event?');
$submit = pht('Join');
} else {
$title = pht('Decline Event');
$paragraph = pht('Would you like to decline this event?');
$submit = pht('Decline');
}
return $this->newDialog()
->setTitle($title)
->setValidationException($validation_exception)
->appendParagraph($paragraph)
->addCancelButton($cancel_uri)
->addSubmitButton($submit);
}
}
diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php b/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php
index 60c5f32df7..ac97e9e7e5 100644
--- a/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php
+++ b/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php
@@ -1,232 +1,257 @@
<?php
final class PhabricatorCalendarEventViewController
extends PhabricatorCalendarController {
private $id;
public function shouldAllowPublic() {
return true;
}
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();
}
$title = 'E'.$event->getID();
$page_title = $title.' '.$event->getName();
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($title, '/E'.$event->getID());
$timeline = $this->buildTransactionTimeline(
$event,
new PhabricatorCalendarEventTransactionQuery());
$header = $this->buildHeaderView($event);
$actions = $this->buildActionView($event);
$properties = $this->buildPropertyView($event);
$properties->setActionList($actions);
$box = id(new PHUIObjectBoxView())
->setHeader($header)
->addPropertyList($properties);
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
$add_comment_header = $is_serious
? pht('Add Comment')
: pht('Add To Plate');
$draft = PhabricatorDraft::newFromUserAndKey($viewer, $event->getPHID());
$add_comment_form = id(new PhabricatorApplicationTransactionCommentView())
->setUser($viewer)
->setObjectPHID($event->getPHID())
->setDraft($draft)
->setHeaderText($add_comment_header)
->setAction(
$this->getApplicationURI('/event/comment/'.$event->getID().'/'))
->setSubmitButtonName(pht('Add Comment'));
return $this->buildApplicationPage(
array(
$crumbs,
$box,
$timeline,
$add_comment_form,
),
array(
'title' => $page_title,
));
}
private function buildHeaderView(PhabricatorCalendarEvent $event) {
$viewer = $this->getRequest()->getUser();
$id = $event->getID();
$is_cancelled = $event->getIsCancelled();
$icon = $is_cancelled ? ('fa-times') : ('fa-calendar');
$color = $is_cancelled ? ('grey') : ('green');
$status = $is_cancelled ? ('Cancelled') : ('Active');
$invite_status = $event->getUserInviteStatus($viewer->getPHID());
$status_invited = PhabricatorCalendarEventInvitee::STATUS_INVITED;
$is_invite_pending = ($invite_status == $status_invited);
$header = id(new PHUIHeaderView())
->setUser($viewer)
->setHeader($event->getName())
->setStatus($icon, $color, $status)
->setPolicyObject($event);
if ($is_invite_pending) {
$decline_button = id(new PHUIButtonView())
->setTag('a')
->setIcon(id(new PHUIIconView())
->setIconFont('fa-times grey'))
->setHref($this->getApplicationURI("/event/decline/{$id}/"))
->setWorkflow(true)
->setText(pht('Decline'));
$accept_button = id(new PHUIButtonView())
->setTag('a')
->setIcon(id(new PHUIIconView())
->setIconFont('fa-check green'))
->setHref($this->getApplicationURI("/event/accept/{$id}/"))
->setWorkflow(true)
->setText(pht('Accept'));
$header->addActionLink($decline_button)
->addActionLink($accept_button);
}
return $header;
}
private function buildActionView(PhabricatorCalendarEvent $event) {
$viewer = $this->getRequest()->getUser();
$id = $event->getID();
$is_cancelled = $event->getIsCancelled();
$is_attending = $event->getIsUserAttending($viewer->getPHID());
$actions = id(new PhabricatorActionListView())
->setObjectURI($this->getApplicationURI('event/'.$id.'/'))
->setUser($viewer)
->setObject($event);
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$event,
PhabricatorPolicyCapability::CAN_EDIT);
$actions->addAction(
id(new PhabricatorActionView())
->setName(pht('Edit Event'))
->setIcon('fa-pencil')
->setHref($this->getApplicationURI("event/edit/{$id}/"))
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit));
if ($is_attending) {
$actions->addAction(
id(new PhabricatorActionView())
->setName(pht('Decline Event'))
->setIcon('fa-user-times')
->setHref($this->getApplicationURI("event/join/{$id}/"))
->setWorkflow(true));
} else {
$actions->addAction(
id(new PhabricatorActionView())
->setName(pht('Join Event'))
->setIcon('fa-user-plus')
->setHref($this->getApplicationURI("event/join/{$id}/"))
->setWorkflow(true));
}
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));
}
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));
$properties->addProperty(
pht('Host'),
$viewer->renderHandle($event->getUserPHID()));
$invitees = $event->getInvitees();
foreach ($invitees as $key => $invitee) {
if ($invitee->isUninvited()) {
unset($invitees[$key]);
}
}
if ($invitees) {
$invitee_list = new PHUIStatusListView();
+
+ $icon_invited = PHUIStatusItemView::ICON_OPEN;
+ $icon_attending = PHUIStatusItemView::ICON_ACCEPT;
+ $icon_declined = PHUIStatusItemView::ICON_REJECT;
+
+ $status_invited = PhabricatorCalendarEventInvitee::STATUS_INVITED;
+ $status_attending = PhabricatorCalendarEventInvitee::STATUS_ATTENDING;
+ $status_declined = PhabricatorCalendarEventInvitee::STATUS_DECLINED;
+
+ $icon_map = array(
+ $status_invited => $icon_invited,
+ $status_attending => $icon_attending,
+ $status_declined => $icon_declined,
+ );
+
+ $icon_color_map = array(
+ $status_invited => null,
+ $status_attending => 'green',
+ $status_declined => 'red',
+ );
+
foreach ($invitees as $invitee) {
$item = new PHUIStatusItemView();
$invitee_phid = $invitee->getInviteePHID();
+ $status = $invitee->getStatus();
$target = $viewer->renderHandle($invitee_phid);
- $item->setNote($invitee->getStatus())
+ $icon = $icon_map[$status];
+ $icon_color = $icon_color_map[$status];
+
+ $item->setIcon($icon, $icon_color)
->setTarget($target);
$invitee_list->addItem($item);
}
} else {
$invitee_list = phutil_tag(
'em',
array(),
pht('None'));
}
$properties->addProperty(
pht('Invitees'),
$invitee_list);
$properties->invokeWillRenderEvent();
$properties->addSectionHeader(
pht('Description'),
PHUIPropertyListView::ICON_SUMMARY);
$properties->addTextContent($event->getDescription());
return $properties;
}
}

File Metadata

Mime Type
text/x-diff
Expires
Thu, Jul 24, 1:50 AM (1 d, 11 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
182480
Default Alt Text
(11 KB)

Event Timeline