@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhabricatorBadgesRemoveRecipientsController
4 extends PhabricatorBadgesController {
5
6 public function handleRequest(AphrontRequest $request) {
7 $viewer = $request->getViewer();
8 $id = $request->getURIData('id');
9
10 $badge = id(new PhabricatorBadgesQuery())
11 ->setViewer($viewer)
12 ->withIDs(array($id))
13 ->requireCapabilities(
14 array(
15 PhabricatorPolicyCapability::CAN_VIEW,
16 PhabricatorPolicyCapability::CAN_EDIT,
17 ))
18 ->executeOne();
19 if (!$badge) {
20 return new Aphront404Response();
21 }
22
23 $remove_phid = $request->getStr('phid');
24 $view_uri = $this->getApplicationURI('recipients/'.$badge->getID().'/');
25
26 if ($request->isFormPost()) {
27 $xactions = array();
28 $xactions[] = id(new PhabricatorBadgesTransaction())
29 ->setTransactionType(
30 PhabricatorBadgesBadgeRevokeTransaction::TRANSACTIONTYPE)
31 ->setNewValue(array($remove_phid));
32
33 $editor = id(new PhabricatorBadgesEditor())
34 ->setActor($viewer)
35 ->setContentSourceFromRequest($request)
36 ->setContinueOnNoEffect(true)
37 ->setContinueOnMissingFields(true)
38 ->applyTransactions($badge, $xactions);
39
40 return id(new AphrontRedirectResponse())
41 ->setURI($view_uri);
42 }
43
44 $handle = id(new PhabricatorHandleQuery())
45 ->setViewer($viewer)
46 ->withPHIDs(array($remove_phid))
47 ->executeOne();
48
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'));
59
60 return $dialog;
61 }
62
63}