forked from phacility/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhabricatorCountdownDeleteController.php
54 lines (41 loc) · 1.31 KB
/
PhabricatorCountdownDeleteController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* @group countdown
*/
final class PhabricatorCountdownDeleteController
extends PhabricatorCountdownController {
private $id;
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$countdown = id(new CountdownQuery())
->setViewer($user)
->withIDs(array($this->id))
->executeOne();
if (!$countdown) {
return new Aphront404Response();
}
if (($countdown->getAuthorPHID() !== $user->getPHID())
&& $user->getIsAdmin() === false) {
return new Aphront403Response();
}
if ($request->isFormPost()) {
$countdown->delete();
return id(new AphrontRedirectResponse())
->setURI('/countdown/');
}
$inst = pht('Are you sure you want to delete the countdown %s?',
$countdown->getTitle());
$dialog = new AphrontDialogView();
$dialog->setUser($request->getUser());
$dialog->setTitle(pht('Really delete this countdown?'));
$dialog->appendChild(hsprintf('<p>%s</p>', $inst));
$dialog->addSubmitButton(pht('Delete'));
$dialog->addCancelButton('/countdown/');
$dialog->setSubmitURI($request->getPath());
return id(new AphrontDialogResponse())->setDialog($dialog);
}
}