1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-01 11:12:42 +01:00
phorge-phorge/src/applications/maniphest/controller/ManiphestSavedQueryDeleteController.php

47 lines
1.1 KiB
PHP
Raw Normal View History

<?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?')
->appendChild(hsprintf(
'<p>Really delete the query "%s"? It will be lost forever!</p>',
$name))
->addCancelButton('/maniphest/custom/')
->addSubmitButton('Delete');
return id(new AphrontDialogResponse())->setDialog($dialog);
}
}