2011-06-13 01:06:17 +02:00
|
|
|
<?php
|
|
|
|
|
2013-05-23 15:47:54 +02:00
|
|
|
/**
|
|
|
|
* @group countdown
|
|
|
|
*/
|
2012-03-10 00:46:25 +01:00
|
|
|
final class PhabricatorCountdownDeleteController
|
2011-06-13 01:06:17 +02:00
|
|
|
extends PhabricatorCountdownController {
|
|
|
|
|
2012-10-04 23:33:50 +02:00
|
|
|
private $id;
|
|
|
|
|
2011-06-13 01:06:17 +02:00
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->id = $data['id'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
2013-07-22 23:42:25 +02:00
|
|
|
$countdown = id(new PhabricatorCountdownQuery())
|
2013-05-23 15:47:54 +02:00
|
|
|
->setViewer($user)
|
|
|
|
->withIDs(array($this->id))
|
2013-07-23 15:16:19 +02:00
|
|
|
->requireCapabilities(
|
|
|
|
array(
|
|
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
|
|
))
|
2013-05-23 15:47:54 +02:00
|
|
|
->executeOne();
|
|
|
|
|
|
|
|
if (!$countdown) {
|
2011-06-13 01:06:17 +02:00
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($request->isFormPost()) {
|
2013-05-23 15:47:54 +02:00
|
|
|
$countdown->delete();
|
2011-06-13 01:06:17 +02:00
|
|
|
return id(new AphrontRedirectResponse())
|
|
|
|
->setURI('/countdown/');
|
|
|
|
}
|
|
|
|
|
2013-02-25 21:48:55 +01:00
|
|
|
$inst = pht('Are you sure you want to delete the countdown %s?',
|
2013-05-23 15:47:54 +02:00
|
|
|
$countdown->getTitle());
|
2013-02-25 21:48:55 +01:00
|
|
|
|
2011-06-13 01:06:17 +02:00
|
|
|
$dialog = new AphrontDialogView();
|
|
|
|
$dialog->setUser($request->getUser());
|
2013-02-25 21:48:55 +01:00
|
|
|
$dialog->setTitle(pht('Really delete this countdown?'));
|
|
|
|
$dialog->appendChild(hsprintf('<p>%s</p>', $inst));
|
|
|
|
$dialog->addSubmitButton(pht('Delete'));
|
2011-06-13 01:06:17 +02:00
|
|
|
$dialog->addCancelButton('/countdown/');
|
|
|
|
$dialog->setSubmitURI($request->getPath());
|
|
|
|
|
|
|
|
return id(new AphrontDialogResponse())->setDialog($dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|