2011-06-13 01:06:17 +02:00
|
|
|
<?php
|
|
|
|
|
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-05-04 00:49:29 +02:00
|
|
|
$timer = id(new PhabricatorCountdown())->load($this->id);
|
2011-06-13 01:06:17 +02:00
|
|
|
if (!$timer) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (($timer->getAuthorPHID() !== $user->getPHID())
|
|
|
|
&& $user->getIsAdmin() === false) {
|
2012-01-15 10:07:56 +01:00
|
|
|
return new Aphront403Response();
|
2011-06-13 01:06:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($request->isFormPost()) {
|
|
|
|
$timer->delete();
|
|
|
|
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?',
|
|
|
|
$timer->getTitle());
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|