2012-04-10 18:46:04 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group maniphest
|
|
|
|
*/
|
|
|
|
final class ManiphestSavedQueryDeleteController extends ManiphestController {
|
|
|
|
|
|
|
|
private $id;
|
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->id = $data['id'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
|
|
|
$id = $this->id;
|
|
|
|
$query = id(new ManiphestSavedQuery())->load($id);
|
|
|
|
if (!$query) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
if ($query->getUserPHID() != $user->getPHID()) {
|
|
|
|
return new Aphront400Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($request->isDialogFormPost()) {
|
|
|
|
$query->delete();
|
|
|
|
return id(new AphrontRedirectResponse())->setURI('/maniphest/custom/');
|
|
|
|
}
|
|
|
|
|
|
|
|
$name = $query->getName();
|
|
|
|
|
|
|
|
$dialog = id(new AphrontDialogView())
|
|
|
|
->setUser($user)
|
|
|
|
->setTitle('Really delete this query?')
|
2013-02-08 21:07:44 +01:00
|
|
|
->appendChild(hsprintf(
|
|
|
|
'<p>Really delete the query "%s"? It will be lost forever!</p>',
|
|
|
|
$name))
|
2012-04-10 18:46:04 +02:00
|
|
|
->addCancelButton('/maniphest/custom/')
|
|
|
|
->addSubmitButton('Delete');
|
|
|
|
|
|
|
|
return id(new AphrontDialogResponse())->setDialog($dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|