@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 PhabricatorSubscriptionsTransactionController
4 extends PhabricatorController {
5
6 public function handleRequest(AphrontRequest $request) {
7 $viewer = $request->getViewer();
8 $phid = $request->getURIData('phid');
9 $type = $request->getURIData('type');
10
11 $xaction = id(new PhabricatorObjectQuery())
12 ->withPHIDs(array($phid))
13 ->setViewer($viewer)
14 ->executeOne();
15 if (!$xaction) {
16 return new Aphront404Response();
17 }
18
19 $old = $xaction->getOldValue();
20 $new = $xaction->getNewValue();
21 switch ($type) {
22 case 'add':
23 $subscriber_phids = array_diff($new, $old);
24 break;
25 case 'rem':
26 $subscriber_phids = array_diff($old, $new);
27 break;
28 default:
29 return id(new Aphront404Response());
30 }
31
32 $object_phid = $xaction->getObjectPHID();
33 $author_phid = $xaction->getAuthorPHID();
34 $handle_phids = $subscriber_phids;
35 $handle_phids[] = $object_phid;
36 $handle_phids[] = $author_phid;
37
38 $handles = id(new PhabricatorHandleQuery())
39 ->setViewer($viewer)
40 ->withPHIDs($handle_phids)
41 ->execute();
42 $author_handle = $handles[$author_phid];
43 if (!in_array($author_phid, $subscriber_phids)) {
44 unset($handles[$author_phid]);
45 }
46
47 switch ($type) {
48 case 'add':
49 $title = pht(
50 'All %d subscribers added by %s',
51 count($subscriber_phids),
52 $author_handle->renderLink());
53 break;
54 case 'rem':
55 $title = pht(
56 'All %d subscribers removed by %s',
57 count($subscriber_phids),
58 $author_handle->renderLink());
59 break;
60 }
61
62 $dialog = id(new SubscriptionListDialogBuilder())
63 ->setViewer($viewer)
64 ->setTitle($title)
65 ->setObjectPHID($object_phid)
66 ->setHandles($handles)
67 ->buildDialog();
68
69 return id(new AphrontDialogResponse())->setDialog($dialog);
70 }
71
72}