3 final class PhabricatorNamedQuery
extends PhabricatorSearchDAO
4 implements PhabricatorPolicyInterface
{
9 protected $engineClassName;
11 protected $isBuiltin = 0;
12 protected $isDisabled = 0;
13 protected $sequence = 0;
15 const SCOPE_GLOBAL
= 'scope.global';
17 protected function getConfiguration() {
19 self
::CONFIG_COLUMN_SCHEMA
=> array(
20 'engineClassName' => 'text128',
21 'queryName' => 'text255',
22 'queryKey' => 'text12',
23 'isBuiltin' => 'bool',
24 'isDisabled' => 'bool',
25 'sequence' => 'uint32',
27 self
::CONFIG_KEY_SCHEMA
=> array(
28 'key_userquery' => array(
29 'columns' => array('userPHID', 'engineClassName', 'queryKey'),
33 ) + parent
::getConfiguration();
36 public function isGlobal() {
37 if ($this->getIsBuiltin()) {
41 if ($this->getUserPHID() === self
::SCOPE_GLOBAL
) {
48 public function getNamedQuerySortVector() {
49 if (!$this->isGlobal()) {
55 return id(new PhutilSortVector())
57 ->addInt($this->sequence
)
58 ->addInt($this->getID());
61 /* -( PhabricatorPolicyInterface )----------------------------------------- */
64 public function getCapabilities() {
66 PhabricatorPolicyCapability
::CAN_VIEW
,
67 PhabricatorPolicyCapability
::CAN_EDIT
,
71 public function getPolicy($capability) {
72 return PhabricatorPolicies
::POLICY_NOONE
;
75 public function hasAutomaticCapability($capability, PhabricatorUser
$viewer) {
76 if ($viewer->getPHID() == $this->getUserPHID()) {
80 if ($this->isGlobal()) {
81 switch ($capability) {
82 case PhabricatorPolicyCapability
::CAN_VIEW
:
84 case PhabricatorPolicyCapability
::CAN_EDIT
:
85 return $viewer->getIsAdmin();
92 public function describeAutomaticCapability($capability) {
94 'The queries you have saved are private. Only you can view or edit '.