3 abstract class PhortuneExternalController
4 extends PhortuneController
{
8 final public function shouldAllowPublic() {
12 abstract protected function handleExternalRequest(AphrontRequest
$request);
14 final protected function hasAccountEmail() {
15 return (bool)$this->email
;
18 final protected function getAccountEmail() {
22 final protected function getExternalViewer() {
23 return PhabricatorUser
::getOmnipotentUser();
26 final public function handleRequest(AphrontRequest
$request) {
27 $address_key = $request->getURIData('addressKey');
28 $access_key = $request->getURIData('accessKey');
30 $viewer = $this->getViewer();
31 $xviewer = $this->getExternalViewer();
33 $email = id(new PhortuneAccountEmailQuery())
35 ->withAddressKeys(array($address_key))
38 return new Aphront404Response();
41 $account = $email->getAccount();
43 $can_see = PhabricatorPolicyFilter
::hasCapability(
46 PhabricatorPolicyCapability
::CAN_EDIT
);
48 $email_display = phutil_tag('strong', array(), $email->getAddress());
49 $user_display = phutil_tag('strong', array(), $viewer->getUsername());
51 $actual_key = $email->getAccessKey();
52 if (!phutil_hashes_are_identical($access_key, $actual_key)) {
53 $dialog = $this->newDialog()
54 ->setTitle(pht('Email Access Link Out of Date'))
57 'You are trying to access this payment account as: %s',
61 'The access link you have followed is out of date and no longer '.
65 $dialog->appendParagraph(
67 'You are currently logged in as a user (%s) who has '.
68 'permission to manage the payment account, so you can '.
69 'continue to the updated link.',
72 $dialog->addCancelButton(
73 $email->getExternalURI(),
74 pht('Continue to Updated Link'));
76 $dialog->appendParagraph(
78 'To access information about this payment account, follow '.
79 'a more recent link or ask a user with access to give you '.
86 switch ($email->getStatus()) {
87 case PhortuneAccountEmailStatus
::STATUS_ACTIVE
:
89 case PhortuneAccountEmailStatus
::STATUS_DISABLED
:
90 return $this->newDialog()
91 ->setTitle(pht('Address Disabled'))
94 'This email address (%s) has been disabled and no longer has '.
95 'access to this payment account.',
97 case PhortuneAccountEmailStatus
::STATUS_UNSUBSCRIBED
:
98 return $this->newDialog()
99 ->setTitle(pht('Permanently Unsubscribed'))
102 'This email address (%s) has been permanently unsubscribed '.
103 'and no longer has access to this payment account.',
107 return new Aphront404Response();
110 $this->email
= $email;
112 return $this->handleExternalRequest($request);
115 final protected function newExternalCrumbs() {
116 $viewer = $this->getViewer();
118 $crumbs = new PHUICrumbsView();
120 if ($this->hasAccountEmail()) {
121 $email = $this->getAccountEmail();
122 $account = $email->getAccount();
125 'Payment Account: %s',
126 $account->getName());
128 $crumb = id(new PHUICrumbView())
129 ->setIcon('fa-diamond')
130 ->setName($crumb_name)
131 ->setHref($email->getExternalURI());
136 $crumb = id(new PHUICrumbView())
137 ->setIcon('fa-diamond')
138 ->setText(pht('External Account View'));
140 $crumbs->addCrumb($crumb);
146 final protected function newExternalView() {
147 $email = $this->getAccountEmail();
148 $xviewer = $this->getExternalViewer();
150 $origin_phid = $email->getAuthorPHID();
152 $handles = $xviewer->loadHandles(array($origin_phid));
157 'You are viewing this payment account as: %s',
158 phutil_tag('strong', array(), $email->getAddress()));
161 'This email address was added to this payment account by: %s',
162 phutil_tag('strong', array(), $handles[$origin_phid]->getFullName()));
165 'Anyone who has a link to this page can view order history for '.
166 'this payment account.');
168 return id(new PHUIInfoView())
169 ->setSeverity(PHUIInfoView
::SEVERITY_WARNING
)
170 ->setErrors($messages);