Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / badges / controller / PhabricatorBadgesRemoveRecipientsController.php
blob4901bf955d28ec66af10da27b853841e3cbeb11e
1 <?php
3 final class PhabricatorBadgesRemoveRecipientsController
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 $remove_phid = $request->getStr('phid');
24 $view_uri = $this->getApplicationURI('recipients/'.$badge->getID().'/');
26 if ($request->isFormPost()) {
27 $xactions = array();
28 $xactions[] = id(new PhabricatorBadgesTransaction())
29 ->setTransactionType(
30 PhabricatorBadgesBadgeRevokeTransaction::TRANSACTIONTYPE)
31 ->setNewValue(array($remove_phid));
33 $editor = id(new PhabricatorBadgesEditor())
34 ->setActor($viewer)
35 ->setContentSourceFromRequest($request)
36 ->setContinueOnNoEffect(true)
37 ->setContinueOnMissingFields(true)
38 ->applyTransactions($badge, $xactions);
40 return id(new AphrontRedirectResponse())
41 ->setURI($view_uri);
44 $handle = id(new PhabricatorHandleQuery())
45 ->setViewer($viewer)
46 ->withPHIDs(array($remove_phid))
47 ->executeOne();
49 $dialog = id(new AphrontDialogView())
50 ->setUser($viewer)
51 ->setTitle(pht('Really Revoke Badge?'))
52 ->appendParagraph(
53 pht(
54 'Really revoke the badge "%s" from %s?',
55 phutil_tag('strong', array(), $badge->getName()),
56 phutil_tag('strong', array(), $handle->getName())))
57 ->addCancelButton($view_uri)
58 ->addSubmitButton(pht('Revoke Badge'));
60 return $dialog;