mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 23:02:42 +01:00
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
This commit is contained in:
parent
6575cc568d
commit
0f914afda9
13 changed files with 211 additions and 68 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE {$NAMESPACE}_calendar.calendar_event
|
||||||
|
ADD isCancelled BOOL NOT NULL;
|
|
@ -1482,7 +1482,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorCalendarController' => 'applications/calendar/controller/PhabricatorCalendarController.php',
|
'PhabricatorCalendarController' => 'applications/calendar/controller/PhabricatorCalendarController.php',
|
||||||
'PhabricatorCalendarDAO' => 'applications/calendar/storage/PhabricatorCalendarDAO.php',
|
'PhabricatorCalendarDAO' => 'applications/calendar/storage/PhabricatorCalendarDAO.php',
|
||||||
'PhabricatorCalendarEvent' => 'applications/calendar/storage/PhabricatorCalendarEvent.php',
|
'PhabricatorCalendarEvent' => 'applications/calendar/storage/PhabricatorCalendarEvent.php',
|
||||||
'PhabricatorCalendarEventDeleteController' => 'applications/calendar/controller/PhabricatorCalendarEventDeleteController.php',
|
'PhabricatorCalendarEventCancelController' => 'applications/calendar/controller/PhabricatorCalendarEventCancelController.php',
|
||||||
'PhabricatorCalendarEventEditController' => 'applications/calendar/controller/PhabricatorCalendarEventEditController.php',
|
'PhabricatorCalendarEventEditController' => 'applications/calendar/controller/PhabricatorCalendarEventEditController.php',
|
||||||
'PhabricatorCalendarEventEditor' => 'applications/calendar/editor/PhabricatorCalendarEventEditor.php',
|
'PhabricatorCalendarEventEditor' => 'applications/calendar/editor/PhabricatorCalendarEventEditor.php',
|
||||||
'PhabricatorCalendarEventInvalidEpochException' => 'applications/calendar/exception/PhabricatorCalendarEventInvalidEpochException.php',
|
'PhabricatorCalendarEventInvalidEpochException' => 'applications/calendar/exception/PhabricatorCalendarEventInvalidEpochException.php',
|
||||||
|
@ -4808,8 +4808,12 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorMarkupInterface',
|
'PhabricatorMarkupInterface',
|
||||||
'PhabricatorApplicationTransactionInterface',
|
'PhabricatorApplicationTransactionInterface',
|
||||||
'PhabricatorSubscribableInterface',
|
'PhabricatorSubscribableInterface',
|
||||||
|
'PhabricatorTokenReceiverInterface',
|
||||||
|
'PhabricatorDestructibleInterface',
|
||||||
|
'PhabricatorMentionableInterface',
|
||||||
|
'PhabricatorFlaggableInterface',
|
||||||
),
|
),
|
||||||
'PhabricatorCalendarEventDeleteController' => 'PhabricatorCalendarController',
|
'PhabricatorCalendarEventCancelController' => 'PhabricatorCalendarController',
|
||||||
'PhabricatorCalendarEventEditController' => 'PhabricatorCalendarController',
|
'PhabricatorCalendarEventEditController' => 'PhabricatorCalendarController',
|
||||||
'PhabricatorCalendarEventEditor' => 'PhabricatorApplicationTransactionEditor',
|
'PhabricatorCalendarEventEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||||
'PhabricatorCalendarEventInvalidEpochException' => 'Exception',
|
'PhabricatorCalendarEventInvalidEpochException' => 'Exception',
|
||||||
|
|
|
@ -51,8 +51,8 @@ final class PhabricatorCalendarApplication extends PhabricatorApplication {
|
||||||
=> 'PhabricatorCalendarEventEditController',
|
=> 'PhabricatorCalendarEventEditController',
|
||||||
'edit/(?P<id>[1-9]\d*)/'
|
'edit/(?P<id>[1-9]\d*)/'
|
||||||
=> 'PhabricatorCalendarEventEditController',
|
=> 'PhabricatorCalendarEventEditController',
|
||||||
'delete/(?P<id>[1-9]\d*)/'
|
'cancel/(?P<id>[1-9]\d*)/'
|
||||||
=> 'PhabricatorCalendarEventDeleteController',
|
=> 'PhabricatorCalendarEventCancelController',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorCalendarEventCancelController
|
||||||
|
extends PhabricatorCalendarController {
|
||||||
|
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
public function willProcessRequest(array $data) {
|
||||||
|
$this->id = idx($data, 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function processRequest() {
|
||||||
|
$request = $this->getRequest();
|
||||||
|
$user = $request->getUser();
|
||||||
|
|
||||||
|
$status = id(new PhabricatorCalendarEventQuery())
|
||||||
|
->setViewer($user)
|
||||||
|
->withIDs(array($this->id))
|
||||||
|
->requireCapabilities(
|
||||||
|
array(
|
||||||
|
PhabricatorPolicyCapability::CAN_VIEW,
|
||||||
|
PhabricatorPolicyCapability::CAN_EDIT,
|
||||||
|
))
|
||||||
|
->executeOne();
|
||||||
|
|
||||||
|
if (!$status) {
|
||||||
|
return new Aphront404Response();
|
||||||
|
}
|
||||||
|
|
||||||
|
$cancel_uri = '/E'.$status->getID();
|
||||||
|
$validation_exception = null;
|
||||||
|
$is_cancelled = $status->getIsCancelled();
|
||||||
|
|
||||||
|
if ($request->isFormPost()) {
|
||||||
|
$xactions = array();
|
||||||
|
|
||||||
|
$xaction = id(new PhabricatorCalendarEventTransaction())
|
||||||
|
->setTransactionType(
|
||||||
|
PhabricatorCalendarEventTransaction::TYPE_CANCEL)
|
||||||
|
->setNewValue(!$is_cancelled);
|
||||||
|
|
||||||
|
$editor = id(new PhabricatorCalendarEventEditor())
|
||||||
|
->setActor($user)
|
||||||
|
->setContentSourceFromRequest($request)
|
||||||
|
->setContinueOnNoEffect(true)
|
||||||
|
->setContinueOnMissingFields(true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$editor->applyTransactions($status, array($xaction));
|
||||||
|
return id(new AphrontRedirectResponse())->setURI($cancel_uri);
|
||||||
|
} catch (PhabricatorApplicationTransactionValidationException $ex) {
|
||||||
|
$validation_exception = $ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($is_cancelled) {
|
||||||
|
$title = pht('Reinstate Event');
|
||||||
|
$paragraph = pht('Reinstate this event?');
|
||||||
|
$cancel = pht('Don\'t Reinstate Event');
|
||||||
|
$submit = pht('Reinstate Event');
|
||||||
|
} else {
|
||||||
|
$title = pht('Cancel Event');
|
||||||
|
$paragraph = pht('You can always reinstate the event later.');
|
||||||
|
$cancel = pht('Don\'t Cancel Event');
|
||||||
|
$submit = pht('Cancel Event');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->newDialog()
|
||||||
|
->setTitle($title)
|
||||||
|
->setValidationException($validation_exception)
|
||||||
|
->appendParagraph($paragraph)
|
||||||
|
->addCancelButton($cancel_uri, $cancel)
|
||||||
|
->addSubmitButton($submit);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,54 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class PhabricatorCalendarEventDeleteController
|
|
||||||
extends PhabricatorCalendarController {
|
|
||||||
|
|
||||||
private $id;
|
|
||||||
|
|
||||||
public function willProcessRequest(array $data) {
|
|
||||||
$this->id = idx($data, 'id');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function processRequest() {
|
|
||||||
$request = $this->getRequest();
|
|
||||||
$user = $request->getUser();
|
|
||||||
|
|
||||||
$status = id(new PhabricatorCalendarEventQuery())
|
|
||||||
->setViewer($user)
|
|
||||||
->withIDs(array($this->id))
|
|
||||||
->requireCapabilities(
|
|
||||||
array(
|
|
||||||
PhabricatorPolicyCapability::CAN_VIEW,
|
|
||||||
PhabricatorPolicyCapability::CAN_EDIT,
|
|
||||||
))
|
|
||||||
->executeOne();
|
|
||||||
|
|
||||||
if (!$status) {
|
|
||||||
return new Aphront404Response();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($request->isFormPost()) {
|
|
||||||
$status->delete();
|
|
||||||
$uri = new PhutilURI($this->getApplicationURI());
|
|
||||||
$uri->setQueryParams(
|
|
||||||
array(
|
|
||||||
'deleted' => true,
|
|
||||||
));
|
|
||||||
return id(new AphrontRedirectResponse())
|
|
||||||
->setURI($uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
$dialog = new AphrontDialogView();
|
|
||||||
$dialog->setUser($user);
|
|
||||||
$dialog->setTitle(pht('Really delete status?'));
|
|
||||||
$dialog->appendChild(
|
|
||||||
pht('Permanently delete this status? This action can not be undone.'));
|
|
||||||
$dialog->addSubmitButton(pht('Delete'));
|
|
||||||
$dialog->addCancelButton(
|
|
||||||
$this->getApplicationURI('event/'));
|
|
||||||
|
|
||||||
return id(new AphrontDialogResponse())->setDialog($dialog);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -19,7 +19,6 @@ final class PhabricatorCalendarEventEditController
|
||||||
$error_name = true;
|
$error_name = true;
|
||||||
$validation_exception = null;
|
$validation_exception = null;
|
||||||
|
|
||||||
|
|
||||||
$start_time = id(new AphrontFormDateControl())
|
$start_time = id(new AphrontFormDateControl())
|
||||||
->setUser($user)
|
->setUser($user)
|
||||||
->setName('start')
|
->setName('start')
|
||||||
|
|
|
@ -56,16 +56,22 @@ final class PhabricatorCalendarEventViewController
|
||||||
|
|
||||||
private function buildHeaderView(PhabricatorCalendarEvent $event) {
|
private function buildHeaderView(PhabricatorCalendarEvent $event) {
|
||||||
$viewer = $this->getRequest()->getUser();
|
$viewer = $this->getRequest()->getUser();
|
||||||
|
$is_cancelled = $event->getIsCancelled();
|
||||||
|
$icon = $is_cancelled ? ('fa-times') : ('fa-calendar');
|
||||||
|
$color = $is_cancelled ? ('grey') : ('green');
|
||||||
|
$status = $is_cancelled ? ('Cancelled') : ('Active');
|
||||||
|
|
||||||
return id(new PHUIHeaderView())
|
return id(new PHUIHeaderView())
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
->setHeader($event->getName())
|
->setHeader($event->getName())
|
||||||
|
->setStatus($icon, $color, $status)
|
||||||
->setPolicyObject($event);
|
->setPolicyObject($event);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildActionView(PhabricatorCalendarEvent $event) {
|
private function buildActionView(PhabricatorCalendarEvent $event) {
|
||||||
$viewer = $this->getRequest()->getUser();
|
$viewer = $this->getRequest()->getUser();
|
||||||
$id = $event->getID();
|
$id = $event->getID();
|
||||||
|
$is_cancelled = $event->getIsCancelled();
|
||||||
|
|
||||||
$actions = id(new PhabricatorActionListView())
|
$actions = id(new PhabricatorActionListView())
|
||||||
->setObjectURI($this->getApplicationURI('event/'.$id.'/'))
|
->setObjectURI($this->getApplicationURI('event/'.$id.'/'))
|
||||||
|
@ -85,13 +91,23 @@ final class PhabricatorCalendarEventViewController
|
||||||
->setDisabled(!$can_edit)
|
->setDisabled(!$can_edit)
|
||||||
->setWorkflow(!$can_edit));
|
->setWorkflow(!$can_edit));
|
||||||
|
|
||||||
|
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(
|
$actions->addAction(
|
||||||
id(new PhabricatorActionView())
|
id(new PhabricatorActionView())
|
||||||
->setName(pht('Cancel Event'))
|
->setName(pht('Cancel Event'))
|
||||||
->setIcon('fa-times')
|
->setIcon('fa-times')
|
||||||
->setHref($this->getApplicationURI("event/delete/{$id}/"))
|
->setHref($this->getApplicationURI("event/cancel/{$id}/"))
|
||||||
->setDisabled(!$can_edit)
|
->setDisabled(!$can_edit)
|
||||||
->setWorkflow(true));
|
->setWorkflow(true));
|
||||||
|
}
|
||||||
|
|
||||||
return $actions;
|
return $actions;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ final class PhabricatorCalendarEventEditor
|
||||||
$types[] = PhabricatorCalendarEventTransaction::TYPE_END_DATE;
|
$types[] = PhabricatorCalendarEventTransaction::TYPE_END_DATE;
|
||||||
$types[] = PhabricatorCalendarEventTransaction::TYPE_STATUS;
|
$types[] = PhabricatorCalendarEventTransaction::TYPE_STATUS;
|
||||||
$types[] = PhabricatorCalendarEventTransaction::TYPE_DESCRIPTION;
|
$types[] = PhabricatorCalendarEventTransaction::TYPE_DESCRIPTION;
|
||||||
|
$types[] = PhabricatorCalendarEventTransaction::TYPE_CANCEL;
|
||||||
|
|
||||||
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
||||||
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
||||||
|
@ -44,6 +45,8 @@ final class PhabricatorCalendarEventEditor
|
||||||
return (int)$status;
|
return (int)$status;
|
||||||
case PhabricatorCalendarEventTransaction::TYPE_DESCRIPTION:
|
case PhabricatorCalendarEventTransaction::TYPE_DESCRIPTION:
|
||||||
return $object->getDescription();
|
return $object->getDescription();
|
||||||
|
case PhabricatorCalendarEventTransaction::TYPE_CANCEL:
|
||||||
|
return $object->getIsCancelled();
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::getCustomTransactionOldValue($object, $xaction);
|
return parent::getCustomTransactionOldValue($object, $xaction);
|
||||||
|
@ -58,6 +61,7 @@ final class PhabricatorCalendarEventEditor
|
||||||
case PhabricatorCalendarEventTransaction::TYPE_START_DATE:
|
case PhabricatorCalendarEventTransaction::TYPE_START_DATE:
|
||||||
case PhabricatorCalendarEventTransaction::TYPE_END_DATE:
|
case PhabricatorCalendarEventTransaction::TYPE_END_DATE:
|
||||||
case PhabricatorCalendarEventTransaction::TYPE_DESCRIPTION:
|
case PhabricatorCalendarEventTransaction::TYPE_DESCRIPTION:
|
||||||
|
case PhabricatorCalendarEventTransaction::TYPE_CANCEL:
|
||||||
return $xaction->getNewValue();
|
return $xaction->getNewValue();
|
||||||
case PhabricatorCalendarEventTransaction::TYPE_STATUS:
|
case PhabricatorCalendarEventTransaction::TYPE_STATUS:
|
||||||
return (int)$xaction->getNewValue();
|
return (int)$xaction->getNewValue();
|
||||||
|
@ -86,6 +90,9 @@ final class PhabricatorCalendarEventEditor
|
||||||
case PhabricatorCalendarEventTransaction::TYPE_DESCRIPTION:
|
case PhabricatorCalendarEventTransaction::TYPE_DESCRIPTION:
|
||||||
$object->setDescription($xaction->getNewValue());
|
$object->setDescription($xaction->getNewValue());
|
||||||
return;
|
return;
|
||||||
|
case PhabricatorCalendarEventTransaction::TYPE_CANCEL:
|
||||||
|
$object->setIsCancelled((int)$xaction->getNewValue());
|
||||||
|
return;
|
||||||
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_EDGE:
|
case PhabricatorTransactions::TYPE_EDGE:
|
||||||
|
@ -106,6 +113,7 @@ final class PhabricatorCalendarEventEditor
|
||||||
case PhabricatorCalendarEventTransaction::TYPE_END_DATE:
|
case PhabricatorCalendarEventTransaction::TYPE_END_DATE:
|
||||||
case PhabricatorCalendarEventTransaction::TYPE_STATUS:
|
case PhabricatorCalendarEventTransaction::TYPE_STATUS:
|
||||||
case PhabricatorCalendarEventTransaction::TYPE_DESCRIPTION:
|
case PhabricatorCalendarEventTransaction::TYPE_DESCRIPTION:
|
||||||
|
case PhabricatorCalendarEventTransaction::TYPE_CANCEL:
|
||||||
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_EDGE:
|
case PhabricatorTransactions::TYPE_EDGE:
|
||||||
|
|
|
@ -30,11 +30,16 @@ final class PhabricatorCalendarEventPHIDType extends PhabricatorPHIDType {
|
||||||
|
|
||||||
$id = $event->getID();
|
$id = $event->getID();
|
||||||
$name = $event->getName();
|
$name = $event->getName();
|
||||||
|
$is_cancelled = $event->getIsCancelled();
|
||||||
|
|
||||||
$handle
|
$handle
|
||||||
->setName($name)
|
->setName($name)
|
||||||
->setFullName(pht('E%d: %s', $id, $name))
|
->setFullName(pht('E%d: %s', $id, $name))
|
||||||
->setURI('/E'.$id);
|
->setURI('/E'.$id);
|
||||||
|
|
||||||
|
if ($is_cancelled) {
|
||||||
|
$handle->setStatus(PhabricatorObjectHandleStatus::STATUS_CLOSED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ final class PhabricatorCalendarEventQuery
|
||||||
private $rangeEnd;
|
private $rangeEnd;
|
||||||
private $invitedPHIDs;
|
private $invitedPHIDs;
|
||||||
private $creatorPHIDs;
|
private $creatorPHIDs;
|
||||||
|
private $isCancelled;
|
||||||
|
|
||||||
public function withIDs(array $ids) {
|
public function withIDs(array $ids) {
|
||||||
$this->ids = $ids;
|
$this->ids = $ids;
|
||||||
|
@ -36,6 +37,11 @@ final class PhabricatorCalendarEventQuery
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function withIsCancelled($is_cancelled) {
|
||||||
|
$this->isCancelled = $is_cancelled;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
protected function loadPage() {
|
protected function loadPage() {
|
||||||
$table = new PhabricatorCalendarEvent();
|
$table = new PhabricatorCalendarEvent();
|
||||||
$conn_r = $table->establishConnection('r');
|
$conn_r = $table->establishConnection('r');
|
||||||
|
@ -99,6 +105,13 @@ final class PhabricatorCalendarEventQuery
|
||||||
$this->creatorPHIDs);
|
$this->creatorPHIDs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->isCancelled !== null) {
|
||||||
|
$where[] = qsprintf(
|
||||||
|
$conn_r,
|
||||||
|
'isCancelled = %d',
|
||||||
|
(int)$this->isCancelled);
|
||||||
|
}
|
||||||
|
|
||||||
$where[] = $this->buildPagingClause($conn_r);
|
$where[] = $this->buildPagingClause($conn_r);
|
||||||
|
|
||||||
return $this->formatWhereClause($where);
|
return $this->formatWhereClause($where);
|
||||||
|
|
|
@ -34,6 +34,10 @@ final class PhabricatorCalendarEventSearchEngine
|
||||||
'creatorPHIDs',
|
'creatorPHIDs',
|
||||||
$this->readUsersFromRequest($request, 'creators'));
|
$this->readUsersFromRequest($request, 'creators'));
|
||||||
|
|
||||||
|
$saved->setParameter(
|
||||||
|
'isCancelled',
|
||||||
|
$request->getStr('isCancelled'));
|
||||||
|
|
||||||
return $saved;
|
return $saved;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,6 +77,16 @@ final class PhabricatorCalendarEventSearchEngine
|
||||||
$query->withCreatorPHIDs($creator_phids);
|
$query->withCreatorPHIDs($creator_phids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$is_cancelled = $saved->getParameter('isCancelled');
|
||||||
|
switch ($is_cancelled) {
|
||||||
|
case 'active':
|
||||||
|
$query->withIsCancelled(false);
|
||||||
|
break;
|
||||||
|
case 'cancelled':
|
||||||
|
$query->withIsCancelled(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,9 +97,15 @@ final class PhabricatorCalendarEventSearchEngine
|
||||||
$range_start = $saved->getParameter('rangeStart');
|
$range_start = $saved->getParameter('rangeStart');
|
||||||
$range_end = $saved->getParameter('rangeEnd');
|
$range_end = $saved->getParameter('rangeEnd');
|
||||||
$upcoming = $saved->getParameter('upcoming');
|
$upcoming = $saved->getParameter('upcoming');
|
||||||
|
$is_cancelled = $saved->getParameter('isCancelled', 'active');
|
||||||
|
|
||||||
$invited_phids = $saved->getParameter('invitedPHIDs', array());
|
$invited_phids = $saved->getParameter('invitedPHIDs', array());
|
||||||
$creator_phids = $saved->getParameter('creatorPHIDs', array());
|
$creator_phids = $saved->getParameter('creatorPHIDs', array());
|
||||||
|
$resolution_types = array(
|
||||||
|
'active' => pht('Active Events Only'),
|
||||||
|
'cancelled' => pht('Cancelled Events Only'),
|
||||||
|
'both' => pht('Both Cancelled and Active Events'),
|
||||||
|
);
|
||||||
|
|
||||||
$form
|
$form
|
||||||
->appendControl(
|
->appendControl(
|
||||||
|
@ -120,7 +140,13 @@ final class PhabricatorCalendarEventSearchEngine
|
||||||
'upcoming',
|
'upcoming',
|
||||||
1,
|
1,
|
||||||
pht('Show only upcoming events.'),
|
pht('Show only upcoming events.'),
|
||||||
$upcoming));
|
$upcoming))
|
||||||
|
->appendChild(
|
||||||
|
id(new AphrontFormSelectControl())
|
||||||
|
->setLabel(pht('Cancelled Events'))
|
||||||
|
->setName('isCancelled')
|
||||||
|
->setValue($is_cancelled)
|
||||||
|
->setOptions($resolution_types));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getURI($path) {
|
protected function getURI($path) {
|
||||||
|
|
|
@ -6,6 +6,7 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
|
||||||
PhabricatorApplicationTransactionInterface,
|
PhabricatorApplicationTransactionInterface,
|
||||||
PhabricatorSubscribableInterface,
|
PhabricatorSubscribableInterface,
|
||||||
PhabricatorTokenReceiverInterface,
|
PhabricatorTokenReceiverInterface,
|
||||||
|
PhabricatorDestructibleInterface,
|
||||||
PhabricatorMentionableInterface,
|
PhabricatorMentionableInterface,
|
||||||
PhabricatorFlaggableInterface {
|
PhabricatorFlaggableInterface {
|
||||||
|
|
||||||
|
@ -15,6 +16,7 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
|
||||||
protected $dateTo;
|
protected $dateTo;
|
||||||
protected $status;
|
protected $status;
|
||||||
protected $description;
|
protected $description;
|
||||||
|
protected $isCancelled;
|
||||||
|
|
||||||
const STATUS_AWAY = 1;
|
const STATUS_AWAY = 1;
|
||||||
const STATUS_SPORADIC = 2;
|
const STATUS_SPORADIC = 2;
|
||||||
|
@ -26,7 +28,8 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
|
||||||
->executeOne();
|
->executeOne();
|
||||||
|
|
||||||
return id(new PhabricatorCalendarEvent())
|
return id(new PhabricatorCalendarEvent())
|
||||||
->setUserPHID($actor->getPHID());
|
->setUserPHID($actor->getPHID())
|
||||||
|
->setIsCancelled(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static $statusTexts = array(
|
private static $statusTexts = array(
|
||||||
|
@ -64,6 +67,7 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
|
||||||
'dateTo' => 'epoch',
|
'dateTo' => 'epoch',
|
||||||
'status' => 'uint32',
|
'status' => 'uint32',
|
||||||
'description' => 'text',
|
'description' => 'text',
|
||||||
|
'isCancelled' => 'bool',
|
||||||
),
|
),
|
||||||
self::CONFIG_KEY_SCHEMA => array(
|
self::CONFIG_KEY_SCHEMA => array(
|
||||||
'userPHID_dateFrom' => array(
|
'userPHID_dateFrom' => array(
|
||||||
|
@ -244,4 +248,15 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
|
||||||
public function getUsersToNotifyOfTokenGiven() {
|
public function getUsersToNotifyOfTokenGiven() {
|
||||||
return array($this->getUserPHID());
|
return array($this->getUserPHID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -( PhabricatorDestructibleInterface )----------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
public function destroyObjectPermanently(
|
||||||
|
PhabricatorDestructionEngine $engine) {
|
||||||
|
|
||||||
|
$this->openTransaction();
|
||||||
|
$this->delete();
|
||||||
|
$this->saveTransaction();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ final class PhabricatorCalendarEventTransaction
|
||||||
const TYPE_END_DATE = 'calendar.enddate';
|
const TYPE_END_DATE = 'calendar.enddate';
|
||||||
const TYPE_STATUS = 'calendar.status';
|
const TYPE_STATUS = 'calendar.status';
|
||||||
const TYPE_DESCRIPTION = 'calendar.description';
|
const TYPE_DESCRIPTION = 'calendar.description';
|
||||||
|
const TYPE_CANCEL = 'calendar.cancel';
|
||||||
|
|
||||||
const MAILTAG_CONTENT = 'calendar-content';
|
const MAILTAG_CONTENT = 'calendar-content';
|
||||||
const MAILTAG_OTHER = 'calendar-other';
|
const MAILTAG_OTHER = 'calendar-other';
|
||||||
|
@ -33,6 +34,7 @@ final class PhabricatorCalendarEventTransaction
|
||||||
case self::TYPE_END_DATE:
|
case self::TYPE_END_DATE:
|
||||||
case self::TYPE_STATUS:
|
case self::TYPE_STATUS:
|
||||||
case self::TYPE_DESCRIPTION:
|
case self::TYPE_DESCRIPTION:
|
||||||
|
case self::TYPE_CANCEL:
|
||||||
$phids[] = $this->getObjectPHID();
|
$phids[] = $this->getObjectPHID();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -47,6 +49,7 @@ final class PhabricatorCalendarEventTransaction
|
||||||
case self::TYPE_END_DATE:
|
case self::TYPE_END_DATE:
|
||||||
case self::TYPE_STATUS:
|
case self::TYPE_STATUS:
|
||||||
case self::TYPE_DESCRIPTION:
|
case self::TYPE_DESCRIPTION:
|
||||||
|
case self::TYPE_CANCEL:
|
||||||
return ($old === null);
|
return ($old === null);
|
||||||
}
|
}
|
||||||
return parent::shouldHide();
|
return parent::shouldHide();
|
||||||
|
@ -59,6 +62,7 @@ final class PhabricatorCalendarEventTransaction
|
||||||
case self::TYPE_END_DATE:
|
case self::TYPE_END_DATE:
|
||||||
case self::TYPE_STATUS:
|
case self::TYPE_STATUS:
|
||||||
case self::TYPE_DESCRIPTION:
|
case self::TYPE_DESCRIPTION:
|
||||||
|
case self::TYPE_CANCEL:
|
||||||
return 'fa-pencil';
|
return 'fa-pencil';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -115,6 +119,18 @@ final class PhabricatorCalendarEventTransaction
|
||||||
"%s updated the event's description.",
|
"%s updated the event's description.",
|
||||||
$this->renderHandleLink($author_phid));
|
$this->renderHandleLink($author_phid));
|
||||||
break;
|
break;
|
||||||
|
case self::TYPE_CANCEL:
|
||||||
|
if ($new) {
|
||||||
|
return pht(
|
||||||
|
'%s cancelled this event.',
|
||||||
|
$this->renderHandleLink($author_phid));
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
return pht(
|
||||||
|
'%s reinstated this event.',
|
||||||
|
$this->renderHandleLink($author_phid));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::getTitle();
|
return parent::getTitle();
|
||||||
|
@ -186,6 +202,20 @@ final class PhabricatorCalendarEventTransaction
|
||||||
$this->renderHandleLink($author_phid),
|
$this->renderHandleLink($author_phid),
|
||||||
$this->renderHandleLink($object_phid));
|
$this->renderHandleLink($object_phid));
|
||||||
break;
|
break;
|
||||||
|
case self::TYPE_CANCEL:
|
||||||
|
if ($new) {
|
||||||
|
return pht(
|
||||||
|
'%s cancelled %s.',
|
||||||
|
$this->renderHandleLink($author_phid),
|
||||||
|
$this->renderHandleLink($object_phid));
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
return pht(
|
||||||
|
'%s reinstated %s.',
|
||||||
|
$this->renderHandleLink($author_phid),
|
||||||
|
$this->renderHandleLink($object_phid));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::getTitleForFeed();
|
return parent::getTitleForFeed();
|
||||||
|
@ -201,6 +231,7 @@ final class PhabricatorCalendarEventTransaction
|
||||||
case self::TYPE_END_DATE:
|
case self::TYPE_END_DATE:
|
||||||
case self::TYPE_STATUS:
|
case self::TYPE_STATUS:
|
||||||
case self::TYPE_DESCRIPTION:
|
case self::TYPE_DESCRIPTION:
|
||||||
|
case self::TYPE_CANCEL:
|
||||||
return PhabricatorTransactions::COLOR_GREEN;
|
return PhabricatorTransactions::COLOR_GREEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,6 +281,9 @@ final class PhabricatorCalendarEventTransaction
|
||||||
case self::TYPE_DESCRIPTION:
|
case self::TYPE_DESCRIPTION:
|
||||||
$tags[] = self::MAILTAG_CONTENT;
|
$tags[] = self::MAILTAG_CONTENT;
|
||||||
break;
|
break;
|
||||||
|
case self::TYPE_CANCEL:
|
||||||
|
$tags[] = self::MAILTAG_CONTENT;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return $tags;
|
return $tags;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue