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())
13 ->requireCapabilities(
15 PhabricatorPolicyCapability
::CAN_VIEW
,
16 PhabricatorPolicyCapability
::CAN_EDIT
,
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
;
29 $new_status = PhabricatorBadgesBadge
::STATUS_ARCHIVED
;
34 $xactions[] = id(new PhabricatorBadgesTransaction())
36 PhabricatorBadgesBadgeStatusTransaction
::TRANSACTIONTYPE
)
37 ->setNewValue($new_status);
39 id(new PhabricatorBadgesEditor())
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');
54 $title = pht('Archive Badge');
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()
65 ->addCancelButton($view_uri)
66 ->addSubmitButton($button);