Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phortune/query/PhortuneChargeSearchEngine.php
Show All 34 Lines | final class PhortuneChargeSearchEngine | ||||
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { | public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { | ||||
$query = id(new PhortuneChargeQuery()); | $query = id(new PhortuneChargeQuery()); | ||||
$viewer = $this->requireViewer(); | $viewer = $this->requireViewer(); | ||||
$account = $this->getAccount(); | $account = $this->getAccount(); | ||||
if ($account) { | if ($account) { | ||||
$can_edit = PhabricatorPolicyFilter::hasCapability( | |||||
$viewer, | |||||
$account, | |||||
PhabricatorPolicyCapability::CAN_EDIT); | |||||
if (!$can_edit) { | |||||
throw new Exception( | |||||
pht( | |||||
'You can not query charges for an account you are not '. | |||||
'a member of.')); | |||||
} | |||||
$query->withAccountPHIDs(array($account->getPHID())); | $query->withAccountPHIDs(array($account->getPHID())); | ||||
} else { | } else { | ||||
$accounts = id(new PhortuneAccountQuery()) | $accounts = id(new PhortuneAccountQuery()) | ||||
->withMemberPHIDs(array($viewer->getPHID())) | ->withMemberPHIDs(array($viewer->getPHID())) | ||||
->execute(); | ->execute(); | ||||
if ($accounts) { | if ($accounts) { | ||||
$query->withAccountPHIDs(mpull($accounts, 'getPHID')); | $query->withAccountPHIDs(mpull($accounts, 'getPHID')); | ||||
} else { | } else { | ||||
▲ Show 20 Lines • Show All 75 Lines • Show Last 20 Lines |