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();
|
|
|
|
|
|
|
|
$timer = id(new PhabricatorTimer())->load($this->id);
|
|
|
|
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/');
|
|
|
|
}
|
|
|
|
|
|
|
|
$dialog = new AphrontDialogView();
|
|
|
|
$dialog->setUser($request->getUser());
|
|
|
|
$dialog->setTitle('Really delete this countdown?');
|
2013-02-08 21:07:44 +01:00
|
|
|
$dialog->appendChild(hsprintf(
|
|
|
|
'<p>Are you sure you want to delete the countdown "%s"?</p>',
|
|
|
|
$timer->getTitle()));
|
2011-06-13 01:06:17 +02:00
|
|
|
$dialog->addSubmitButton('Delete');
|
|
|
|
$dialog->addCancelButton('/countdown/');
|
|
|
|
$dialog->setSubmitURI($request->getPath());
|
|
|
|
|
|
|
|
return id(new AphrontDialogResponse())->setDialog($dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|