Differential D17694 Diff 42554 src/applications/phortune/controller/account/PhortuneAccountManagerController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phortune/controller/account/PhortuneAccountManagerController.php
| <?php | <?php | ||||
| final class PhortuneAccountManagerController | final class PhortuneAccountManagerController | ||||
| extends PhortuneAccountProfileController { | extends PhortuneAccountProfileController { | ||||
| public function handleRequest(AphrontRequest $request) { | public function handleRequest(AphrontRequest $request) { | ||||
| $viewer = $this->getViewer(); | $response = $this->loadAccount(); | ||||
| if ($response) { | |||||
| // TODO: Currently, you must be able to edit an account to view the detail | return $response; | ||||
| // page, because the account must be broadly visible so merchants can | |||||
| // process orders but merchants should not be able to see all the details | |||||
| // of an account. Ideally this page should be visible to merchants, too, | |||||
| // just with less information. | |||||
| $can_edit = true; | |||||
| $account = id(new PhortuneAccountQuery()) | |||||
| ->setViewer($viewer) | |||||
| ->withIDs(array($request->getURIData('id'))) | |||||
| ->requireCapabilities( | |||||
| array( | |||||
| PhabricatorPolicyCapability::CAN_VIEW, | |||||
| PhabricatorPolicyCapability::CAN_EDIT, | |||||
| )) | |||||
| ->executeOne(); | |||||
| if (!$account) { | |||||
| return new Aphront404Response(); | |||||
| } | } | ||||
| $this->setAccount($account); | $account = $this->getAccount(); | ||||
| $title = $account->getName(); | $title = $account->getName(); | ||||
| $crumbs = $this->buildApplicationCrumbs(); | $crumbs = $this->buildApplicationCrumbs(); | ||||
| $crumbs->addTextCrumb(pht('Managers')); | $crumbs->addTextCrumb(pht('Managers')); | ||||
| $header = $this->buildHeaderView(); | $header = $this->buildHeaderView(); | ||||
| $members = $this->buildMembersSection($account); | $members = $this->buildMembersSection($account); | ||||
| Show All 23 Lines | private function buildMembersSection(PhortuneAccount $account) { | ||||
| $id = $account->getID(); | $id = $account->getID(); | ||||
| $add = id(new PHUIButtonView()) | $add = id(new PHUIButtonView()) | ||||
| ->setTag('a') | ->setTag('a') | ||||
| ->setText(pht('New Manager')) | ->setText(pht('New Manager')) | ||||
| ->setIcon('fa-plus') | ->setIcon('fa-plus') | ||||
| ->setWorkflow(true) | ->setWorkflow(true) | ||||
| ->setDisabled(!$can_edit) | |||||
| ->setHref("/phortune/account/manager/add/{$id}/"); | ->setHref("/phortune/account/manager/add/{$id}/"); | ||||
| $header = id(new PHUIHeaderView()) | $header = id(new PHUIHeaderView()) | ||||
| ->setHeader(pht('Account Managers')) | ->setHeader(pht('Account Managers')) | ||||
| ->addActionLink($add); | ->addActionLink($add); | ||||
| $list = id(new PHUIObjectItemListView()) | $list = id(new PHUIObjectItemListView()) | ||||
| ->setUser($viewer); | ->setUser($viewer); | ||||
| Show All 25 Lines | |||||