Remove all "FileHasObject" edge reads and writes
[phabricator.git] / src / applications / badges / controller / PhabricatorBadgesArchiveController.php
blobf109d9459a2b32092b8dc1791142f7a48de3f9db
1 <?php
3 final class PhabricatorBadgesArchiveController
4 extends PhabricatorBadgesController {
6 public function handleRequest(AphrontRequest $request) {
7 $viewer = $request->getViewer();
8 $id = $request->getURIData('id');
10 $badge = id(new PhabricatorBadgesQuery())
11 ->setViewer($viewer)
12 ->withIDs(array($id))
13 ->requireCapabilities(
14 array(
15 PhabricatorPolicyCapability::CAN_VIEW,
16 PhabricatorPolicyCapability::CAN_EDIT,
18 ->executeOne();
19 if (!$badge) {
20 return new Aphront404Response();
23 $view_uri = $this->getApplicationURI('view/'.$badge->getID().'/');
25 if ($request->isFormPost()) {
26 if ($badge->isArchived()) {
27 $new_status = PhabricatorBadgesBadge::STATUS_ACTIVE;
28 } else {
29 $new_status = PhabricatorBadgesBadge::STATUS_ARCHIVED;
32 $xactions = array();
34 $xactions[] = id(new PhabricatorBadgesTransaction())
35 ->setTransactionType(
36 PhabricatorBadgesBadgeStatusTransaction::TRANSACTIONTYPE)
37 ->setNewValue($new_status);
39 id(new PhabricatorBadgesEditor())
40 ->setActor($viewer)
41 ->setContentSourceFromRequest($request)
42 ->setContinueOnNoEffect(true)
43 ->setContinueOnMissingFields(true)
44 ->applyTransactions($badge, $xactions);
46 return id(new AphrontRedirectResponse())->setURI($view_uri);
49 if ($badge->isArchived()) {
50 $title = pht('Activate Badge');
51 $body = pht('This badge will be re-commissioned into service.');
52 $button = pht('Activate Badge');
53 } else {
54 $title = pht('Archive Badge');
55 $body = pht(
56 'This dedicated badge, once a distinguish icon of this install, '.
57 'shall be immediately retired from service, but will never far from '.
58 'our hearts. Godspeed.');
59 $button = pht('Archive Badge');
62 return $this->newDialog()
63 ->setTitle($title)
64 ->appendChild($body)
65 ->addCancelButton($view_uri)
66 ->addSubmitButton($button);