Differential D10673 Diff 25632 src/applications/phortune/controller/PhortuneAccountViewController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phortune/controller/PhortuneAccountViewController.php
Show All 11 Lines | public function processRequest() { | ||||
$request = $this->getRequest(); | $request = $this->getRequest(); | ||||
$user = $request->getUser(); | $user = $request->getUser(); | ||||
// TODO: Currently, you must be able to edit an account to view the detail | // TODO: Currently, you must be able to edit an account to view the detail | ||||
// page, because the account must be broadly visible so merchants can | // page, because the account must be broadly visible so merchants can | ||||
// process orders but merchants should not be able to see all the details | // 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, | // of an account. Ideally this page should be visible to merchants, too, | ||||
// just with less information. | // just with less information. | ||||
$can_edit = true; | |||||
$account = id(new PhortuneAccountQuery()) | $account = id(new PhortuneAccountQuery()) | ||||
->setViewer($user) | ->setViewer($user) | ||||
->withIDs(array($this->accountID)) | ->withIDs(array($this->accountID)) | ||||
->requireCapabilities( | ->requireCapabilities( | ||||
array( | array( | ||||
PhabricatorPolicyCapability::CAN_VIEW, | PhabricatorPolicyCapability::CAN_VIEW, | ||||
PhabricatorPolicyCapability::CAN_EDIT, | PhabricatorPolicyCapability::CAN_EDIT, | ||||
)) | )) | ||||
->executeOne(); | ->executeOne(); | ||||
if (!$account) { | if (!$account) { | ||||
return new Aphront404Response(); | return new Aphront404Response(); | ||||
} | } | ||||
$title = $account->getName(); | $title = $account->getName(); | ||||
$crumbs = $this->buildApplicationCrumbs(); | $crumbs = $this->buildApplicationCrumbs(); | ||||
$crumbs->addTextCrumb(pht('Account'), $request->getRequestURI()); | $crumbs->addTextCrumb( | ||||
$account->getName(), | |||||
$request->getRequestURI()); | |||||
$header = id(new PHUIHeaderView()) | $header = id(new PHUIHeaderView()) | ||||
->setHeader($title); | ->setHeader($title); | ||||
$edit_uri = $this->getApplicationURI('account/edit/'.$account->getID().'/'); | |||||
$actions = id(new PhabricatorActionListView()) | $actions = id(new PhabricatorActionListView()) | ||||
->setUser($user) | ->setUser($user) | ||||
->setObjectURI($request->getRequestURI()) | ->setObjectURI($request->getRequestURI()) | ||||
->addAction( | ->addAction( | ||||
id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
->setName(pht('Edit Account')) | ->setName(pht('Edit Account')) | ||||
->setIcon('fa-pencil') | ->setIcon('fa-pencil') | ||||
->setHref('#') | ->setHref($edit_uri) | ||||
->setDisabled(true)) | ->setDisabled(!$can_edit) | ||||
->setWorkflow(!$can_edit)) | |||||
->addAction( | ->addAction( | ||||
id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
->setName(pht('Edit Members')) | ->setName(pht('Edit Members')) | ||||
->setIcon('fa-users') | ->setIcon('fa-users') | ||||
->setHref('#') | ->setHref('#') | ||||
->setDisabled(true)); | ->setDisabled(true)); | ||||
$crumbs->setActionList($actions); | $crumbs->setActionList($actions); | ||||
▲ Show 20 Lines • Show All 226 Lines • ▼ Show 20 Lines | $xaction_view = id(new PhabricatorApplicationTransactionView()) | ||||
->setUser($user) | ->setUser($user) | ||||
->setObjectPHID($account->getPHID()) | ->setObjectPHID($account->getPHID()) | ||||
->setTransactions($xactions) | ->setTransactions($xactions) | ||||
->setMarkupEngine($engine); | ->setMarkupEngine($engine); | ||||
return $xaction_view; | return $xaction_view; | ||||
} | } | ||||
protected function buildApplicationCrumbs() { | |||||
$crumbs = parent::buildApplicationCrumbs(); | |||||
$crumbs->addAction( | |||||
id(new PHUIListItemView()) | |||||
->setIcon('fa-exchange') | |||||
->setHref($this->getApplicationURI('account/')) | |||||
->setName(pht('Switch Accounts'))); | |||||
return $crumbs; | |||||
} | |||||
} | } |