forked from phacility/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhabricatorCalendarDeleteStatusController.php
51 lines (41 loc) · 1.31 KB
/
PhabricatorCalendarDeleteStatusController.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
<?php
final class PhabricatorCalendarDeleteStatusController
extends PhabricatorCalendarController {
private $id;
public function willProcessRequest(array $data) {
$this->id = idx($data, 'id');
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$status = id(new PhabricatorUserStatus())
->loadOneWhere('id = %d', $this->id);
if (!$status) {
return new Aphront404Response();
}
if ($status->getUserPHID() != $user->getPHID()) {
return new Aphront403Response();
}
if ($request->isFormPost()) {
$status->delete();
$uri = new PhutilURI($this->getApplicationURI());
$uri->setQueryParams(
array(
'deleted' => true,
));
return id(new AphrontRedirectResponse())
->setURI($uri);
}
$dialog = new AphrontDialogView();
$dialog->setUser($user);
$dialog->setTitle(pht('Really delete status?'));
$dialog->appendChild(phutil_tag(
'p',
array(),
pht('Permanently delete this status? This action can not be undone.')));
$dialog->addSubmitButton(pht('Delete'));
$dialog->addCancelButton(
$this->getApplicationURI('status/edit/'.$status->getID().'/'));
return id(new AphrontDialogResponse())->setDialog($dialog);
}
}