mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-11 09:22:40 +01:00
d860008b6a
Summary: Ref T10747. When viewing an imported event: - Make it more clear that it is imported and where it is from. - Add some explicit "this is imported" help. Test Plan: Viewed imported and normal events. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10747 Differential Revision: https://secure.phabricator.com/D16727
83 lines
2.3 KiB
PHP
83 lines
2.3 KiB
PHP
<?php
|
|
|
|
final class PhabricatorCalendarEventJoinController
|
|
extends PhabricatorCalendarController {
|
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
$viewer = $this->getViewer();
|
|
$id = $request->getURIData('id');
|
|
|
|
$event = id(new PhabricatorCalendarEventQuery())
|
|
->setViewer($viewer)
|
|
->withIDs(array($id))
|
|
->executeOne();
|
|
if (!$event) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
$response = $this->newImportedEventResponse($event);
|
|
if ($response) {
|
|
return $response;
|
|
}
|
|
|
|
$cancel_uri = $event->getURI();
|
|
|
|
$action = $request->getURIData('action');
|
|
switch ($action) {
|
|
case 'accept':
|
|
$is_join = true;
|
|
break;
|
|
case 'decline':
|
|
$is_join = false;
|
|
break;
|
|
default:
|
|
$is_join = !$event->getIsUserAttending($viewer->getPHID());
|
|
break;
|
|
}
|
|
|
|
$validation_exception = null;
|
|
if ($request->isFormPost()) {
|
|
if ($is_join) {
|
|
$xaction_type =
|
|
PhabricatorCalendarEventAcceptTransaction::TRANSACTIONTYPE;
|
|
} else {
|
|
$xaction_type =
|
|
PhabricatorCalendarEventDeclineTransaction::TRANSACTIONTYPE;
|
|
}
|
|
|
|
$xaction = id(new PhabricatorCalendarEventTransaction())
|
|
->setTransactionType($xaction_type)
|
|
->setNewValue(true);
|
|
|
|
$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 ($is_join) {
|
|
$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);
|
|
}
|
|
}
|