@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at recaptime-dev/main 91 lines 2.2 kB view raw
1<?php 2 3final class PhabricatorSavedQuery extends PhabricatorSearchDAO 4 implements PhabricatorPolicyInterface { 5 6 protected $parameters = array(); 7 protected $queryKey; 8 protected $engineClassName; 9 10 private $parameterMap = self::ATTACHABLE; 11 12 protected function getConfiguration() { 13 return array( 14 self::CONFIG_SERIALIZATION => array( 15 'parameters' => self::SERIALIZATION_JSON, 16 ), 17 self::CONFIG_COLUMN_SCHEMA => array( 18 'engineClassName' => 'text255', 19 'queryKey' => 'text12', 20 ), 21 self::CONFIG_KEY_SCHEMA => array( 22 'key_queryKey' => array( 23 'columns' => array('queryKey'), 24 'unique' => true, 25 ), 26 ), 27 ) + parent::getConfiguration(); 28 } 29 30 public function setParameter($key, $value) { 31 $this->parameters[$key] = $value; 32 return $this; 33 } 34 35 public function getParameter($key, $default = null) { 36 return idx($this->parameters, $key, $default); 37 } 38 39 public function save() { 40 if ($this->getEngineClassName() === null) { 41 throw new Exception(pht('Engine class is null.')); 42 } 43 44 // Instantiate the engine to make sure it's valid. 45 $this->newEngine(); 46 47 $serial = $this->getEngineClassName().serialize($this->parameters); 48 $this->queryKey = PhabricatorHash::digestForIndex($serial); 49 50 return parent::save(); 51 } 52 53 public function newEngine() { 54 return newv($this->getEngineClassName(), array()); 55 } 56 57 public function attachParameterMap(array $map) { 58 $this->parameterMap = $map; 59 return $this; 60 } 61 62 public function getEvaluatedParameter($key) { 63 return $this->assertAttachedKey($this->parameterMap, $key); 64 } 65 66 public function newCopy() { 67 return id(new self()) 68 ->setParameters($this->getParameters()) 69 ->setQueryKey(null) 70 ->setEngineClassName($this->getEngineClassName()); 71 } 72 73 74/* -( PhabricatorPolicyInterface )----------------------------------------- */ 75 76 77 public function getCapabilities() { 78 return array( 79 PhabricatorPolicyCapability::CAN_VIEW, 80 ); 81 } 82 83 public function getPolicy($capability) { 84 return PhabricatorPolicies::POLICY_PUBLIC; 85 } 86 87 public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { 88 return false; 89 } 90 91}