Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phortune/query/PhortuneCartSearchEngine.php
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { | ||||
$query = id(new PhortuneCartQuery()) | $query = id(new PhortuneCartQuery()) | ||||
->needPurchases(true); | ->needPurchases(true); | ||||
$viewer = $this->requireViewer(); | $viewer = $this->requireViewer(); | ||||
$merchant = $this->getMerchant(); | $merchant = $this->getMerchant(); | ||||
$account = $this->getAccount(); | $account = $this->getAccount(); | ||||
if ($merchant) { | if ($merchant) { | ||||
$can_edit = PhabricatorPolicyFilter::hasCapability( | |||||
$viewer, | |||||
$merchant, | |||||
PhabricatorPolicyCapability::CAN_EDIT); | |||||
if (!$can_edit) { | |||||
throw new Exception( | |||||
pht('You can not query orders for a merchant you do not control.')); | |||||
} | |||||
$query->withMerchantPHIDs(array($merchant->getPHID())); | $query->withMerchantPHIDs(array($merchant->getPHID())); | ||||
} else if ($account) { | } else if ($account) { | ||||
$can_edit = PhabricatorPolicyFilter::hasCapability( | |||||
$viewer, | |||||
$account, | |||||
PhabricatorPolicyCapability::CAN_EDIT); | |||||
if (!$can_edit) { | |||||
throw new Exception( | |||||
pht( | |||||
'You can not query orders 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 All 27 Lines | public function buildSearchForm( | ||||
PhabricatorSavedQuery $saved_query) {} | PhabricatorSavedQuery $saved_query) {} | ||||
protected function getURI($path) { | protected function getURI($path) { | ||||
$merchant = $this->getMerchant(); | $merchant = $this->getMerchant(); | ||||
$account = $this->getAccount(); | $account = $this->getAccount(); | ||||
if ($merchant) { | if ($merchant) { | ||||
return '/phortune/merchant/orders/'.$merchant->getID().'/'.$path; | return '/phortune/merchant/orders/'.$merchant->getID().'/'.$path; | ||||
} else if ($account) { | } else if ($account) { | ||||
return '/phortune/'.$account->getID().'/order/'.$path; | return $account->getOrderListURI($path); | ||||
} else { | } else { | ||||
return '/phortune/order/'.$path; | return '/phortune/order/'.$path; | ||||
} | } | ||||
} | } | ||||
protected function getBuiltinQueryNames() { | protected function getBuiltinQueryNames() { | ||||
$names = array( | $names = array( | ||||
'all' => pht('Order History'), | 'all' => pht('Order History'), | ||||
▲ Show 20 Lines • Show All 100 Lines • Show Last 20 Lines |