mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-28 17:52:43 +01:00
587530d973
Summary: Ref T2625. Currently, after saving a query the user is redirected to "/search/", which isn't especially useful. Instead, redirect them back into the application they came from and to the query results page. Also, query hashes may contain ".", which does not match `\w`. Use `[^/]` instead. Test Plan: Saved some custom queries. Reviewers: btrahan, blc Reviewed By: btrahan CC: aran Maniphest Tasks: T2625 Differential Revision: https://secure.phabricator.com/D6055
65 lines
1.5 KiB
PHP
65 lines
1.5 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group search
|
|
*/
|
|
final class PhabricatorSavedQuery extends PhabricatorSearchDAO
|
|
implements PhabricatorPolicyInterface {
|
|
|
|
protected $parameters = array();
|
|
protected $queryKey = "";
|
|
protected $engineClassName = "PhabricatorPasteSearchEngine";
|
|
|
|
public function getConfiguration() {
|
|
return array(
|
|
self::CONFIG_SERIALIZATION => array(
|
|
'parameters' => self::SERIALIZATION_JSON), )
|
|
+ parent::getConfiguration();
|
|
}
|
|
|
|
public function setParameter($key, $value) {
|
|
$this->parameters[$key] = $value;
|
|
return $this;
|
|
}
|
|
|
|
public function getParameter($key, $default = null) {
|
|
return idx($this->parameters, $key, $default);
|
|
}
|
|
|
|
public function save() {
|
|
if ($this->getEngineClassName() === null) {
|
|
throw new Exception(pht("Engine class is null."));
|
|
}
|
|
|
|
// Instantiate the engine to make sure it's valid.
|
|
$this->newEngine();
|
|
|
|
$serial = $this->getEngineClassName().serialize($this->parameters);
|
|
$this->queryKey = PhabricatorHash::digestForIndex($serial);
|
|
|
|
return parent::save();
|
|
}
|
|
|
|
public function newEngine() {
|
|
return newv($this->getEngineClassName(), array());
|
|
}
|
|
|
|
|
|
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
|
|
|
|
|
public function getCapabilities() {
|
|
return array(
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
);
|
|
}
|
|
|
|
public function getPolicy($capability) {
|
|
return PhabricatorPolicies::POLICY_PUBLIC;
|
|
}
|
|
|
|
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
|
|
return false;
|
|
}
|
|
|
|
}
|