Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / phortune / controller / external / PhortuneExternalUnsubscribeController.php
blobc7c29129d3fcbcc5cc666ca52881dc8bddfe1591
1 <?php
3 final class PhortuneExternalUnsubscribeController
4 extends PhortuneExternalController {
6 protected function handleExternalRequest(AphrontRequest $request) {
7 $xviewer = $this->getExternalViewer();
8 $email = $this->getAccountEmail();
9 $account = $email->getAccount();
11 $email_uri = $email->getExternalURI();
13 if ($request->isFormOrHisecPost()) {
14 $xactions = array();
16 $xactions[] = $email->getApplicationTransactionTemplate()
17 ->setTransactionType(
18 PhortuneAccountEmailStatusTransaction::TRANSACTIONTYPE)
19 ->setNewValue(PhortuneAccountEmailStatus::STATUS_UNSUBSCRIBED);
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);
30 return id(new AphrontRedirectResponse())->setURI($email_uri);
33 $email_display = phutil_tag(
34 'strong',
35 array(),
36 $email->getAddress());
38 $account_display = phutil_tag(
39 'strong',
40 array(),
41 $account->getName());
43 $submit = pht(
44 'Permanently Unsubscribe (%s)',
45 $email->getAddress());
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);