@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 PhortuneExternalUnsubscribeController
4 extends PhortuneExternalController {
5
6 protected function handleExternalRequest(AphrontRequest $request) {
7 $xviewer = $this->getExternalViewer();
8 $email = $this->getAccountEmail();
9 $account = $email->getAccount();
10
11 $email_uri = $email->getExternalURI();
12
13 if ($request->isFormOrHisecPost()) {
14 $xactions = array();
15
16 $xactions[] = $email->getApplicationTransactionTemplate()
17 ->setTransactionType(
18 PhortuneAccountEmailStatusTransaction::TRANSACTIONTYPE)
19 ->setNewValue(PhortuneAccountEmailStatus::STATUS_UNSUBSCRIBED);
20
21 $email->getApplicationTransactionEditor()
22 ->setActor($xviewer)
23 ->setActingAsPHID($email->getPHID())
24 ->setContentSourceFromRequest($request)
25 ->setContinueOnMissingFields(true)
26 ->setContinueOnNoEffect(true)
27 ->setCancelURI($email_uri)
28 ->applyTransactions($email, $xactions);
29
30 return id(new AphrontRedirectResponse())->setURI($email_uri);
31 }
32
33 $email_display = phutil_tag(
34 'strong',
35 array(),
36 $email->getAddress());
37
38 $account_display = phutil_tag(
39 'strong',
40 array(),
41 $account->getName());
42
43 $submit = pht(
44 'Permanently Unsubscribe (%s)',
45 $email->getAddress());
46
47 return $this->newDialog()
48 ->setTitle(pht('Permanently Unsubscribe'))
49 ->appendParagraph(
50 pht(
51 'Permanently unsubscribe this email address (%s) from this '.
52 'payment account (%s)?',
53 $email_display,
54 $account_display))
55 ->appendParagraph(
56 pht(
57 'You will no longer receive email and access links will no longer '.
58 'function.'))
59 ->appendParagraph(
60 pht(
61 'This action is permanent and can not be undone.'))
62 ->addCancelButton($email_uri)
63 ->addSubmitButton($submit);
64
65 }
66
67}