Changeset View
Changeset View
Standalone View
Standalone View
src/applications/people/typeahead/PhabricatorViewerDatasource.php
Show All 9 Lines | final class PhabricatorViewerDatasource | ||||
public function getPlaceholderText() { | public function getPlaceholderText() { | ||||
return pht('Type viewer()...'); | return pht('Type viewer()...'); | ||||
} | } | ||||
public function getDatasourceApplicationClass() { | public function getDatasourceApplicationClass() { | ||||
return 'PhabricatorPeopleApplication'; | return 'PhabricatorPeopleApplication'; | ||||
} | } | ||||
public function getDatasourceFunctions() { | |||||
return array( | |||||
'viewer' => array( | |||||
'name' => pht('Current Viewer'), | |||||
'summary' => pht('Use the current viewing user.'), | |||||
'description' => pht( | |||||
'This function allows you to change the behavior of a query '. | |||||
'based on who is running it. When you use this function, you will '. | |||||
'be the current viewer, so it works like you typed your own '. | |||||
'username.'. | |||||
"\n\n". | |||||
'However, if you save a query using this function and send it '. | |||||
'to someone else, it will work like //their// username was the '. | |||||
'one that was typed. This can be useful for building dashboard '. | |||||
'panels that always show relevant information to the user who '. | |||||
'is looking at them.'), | |||||
), | |||||
); | |||||
} | |||||
public function loadResults() { | public function loadResults() { | ||||
if ($this->getViewer()->getPHID()) { | if ($this->getViewer()->getPHID()) { | ||||
$results = array($this->renderViewerFunctionToken()); | $results = array($this->renderViewerFunctionToken()); | ||||
} else { | } else { | ||||
$results = array(); | $results = array(); | ||||
} | } | ||||
return $this->filterResultsAgainstTokens($results); | return $this->filterResultsAgainstTokens($results); | ||||
} | } | ||||
protected function canEvaluateFunction($function) { | protected function canEvaluateFunction($function) { | ||||
if (!$this->getViewer()->getPHID()) { | if (!$this->getViewer()->getPHID()) { | ||||
return false; | return false; | ||||
} | } | ||||
return ($function == 'viewer'); | return parent::canEvaluateFunction($function); | ||||
} | } | ||||
protected function evaluateFunction($function, array $argv_list) { | protected function evaluateFunction($function, array $argv_list) { | ||||
$results = array(); | $results = array(); | ||||
foreach ($argv_list as $argv) { | foreach ($argv_list as $argv) { | ||||
$results[] = $this->getViewer()->getPHID(); | $results[] = $this->getViewer()->getPHID(); | ||||
} | } | ||||
return $results; | return $results; | ||||
Show All 20 Lines |