Changeset View
Changeset View
Standalone View
Standalone View
src/applications/settings/panel/PhabricatorSettingsPanel.php
Show All 11 Lines | |||||
* @task config Panel Configuration | * @task config Panel Configuration | ||||
* @task panel Panel Implementation | * @task panel Panel Implementation | ||||
* @task internal Internals | * @task internal Internals | ||||
* | * | ||||
* @group settings | * @group settings | ||||
*/ | */ | ||||
abstract class PhabricatorSettingsPanel { | abstract class PhabricatorSettingsPanel { | ||||
private $user; | |||||
private $viewer; | |||||
public function setUser(PhabricatorUser $user) { | |||||
$this->user = $user; | |||||
return $this; | |||||
} | |||||
public function getUser() { | |||||
return $this->user; | |||||
} | |||||
public function setViewer(PhabricatorUser $viewer) { | |||||
$this->viewer = $viewer; | |||||
return $this; | |||||
} | |||||
public function getViewer() { | |||||
return $this->viewer; | |||||
} | |||||
/* -( Panel Configuration )------------------------------------------------ */ | /* -( Panel Configuration )------------------------------------------------ */ | ||||
/** | /** | ||||
* Return a unique string used in the URI to identify this panel, like | * Return a unique string used in the URI to identify this panel, like | ||||
* "example". | * "example". | ||||
* | * | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | /* -( Panel Configuration )------------------------------------------------ */ | ||||
* @return list<PhabricatorSettingsPanel> Zero or more panels. | * @return list<PhabricatorSettingsPanel> Zero or more panels. | ||||
* @task config | * @task config | ||||
*/ | */ | ||||
public function buildPanels() { | public function buildPanels() { | ||||
return array($this); | return array($this); | ||||
} | } | ||||
/** | |||||
* Return true if this panel is available to administrators while editing | |||||
* system agent accounts. | |||||
* | |||||
* @return bool True to enable edit by administrators. | |||||
* @task config | |||||
*/ | |||||
public function isEditableByAdministrators() { | |||||
return false; | |||||
} | |||||
/* -( Panel Implementation )----------------------------------------------- */ | /* -( Panel Implementation )----------------------------------------------- */ | ||||
/** | /** | ||||
* Process a user request for this settings panel. Implement this method like | * Process a user request for this settings panel. Implement this method like | ||||
* a lightweight controller. If you return an @{class:AphrontResponse}, the | * a lightweight controller. If you return an @{class:AphrontResponse}, the | ||||
* response will be used in whole. If you return anything else, it will be | * response will be used in whole. If you return anything else, it will be | ||||
* treated as a view and composed into a normal settings page. | * treated as a view and composed into a normal settings page. | ||||
Show All 15 Lines | /* -( Panel Implementation )----------------------------------------------- */ | ||||
* | * | ||||
* @param string? Optional path to append. | * @param string? Optional path to append. | ||||
* @return string Relative URI for the panel. | * @return string Relative URI for the panel. | ||||
* @task panel | * @task panel | ||||
*/ | */ | ||||
final public function getPanelURI($path = '') { | final public function getPanelURI($path = '') { | ||||
$key = $this->getPanelKey(); | $key = $this->getPanelKey(); | ||||
$key = phutil_escape_uri($key); | $key = phutil_escape_uri($key); | ||||
return '/settings/panel/'.$key.'/'.ltrim($path, '/'); | |||||
$path = ltrim($path, '/'); | |||||
if ($this->getUser()->getPHID() != $this->getViewer()->getPHID()) { | |||||
$user_id = $this->getUser()->getID(); | |||||
return "/settings/{$user_id}/panel/{$key}/{$path}"; | |||||
} else { | |||||
return "/settings/panel/{$key}/{$path}"; | |||||
} | |||||
} | } | ||||
/* -( Internals )---------------------------------------------------------- */ | /* -( Internals )---------------------------------------------------------- */ | ||||
/** | /** | ||||
* Generates a key to sort the list of panels. | * Generates a key to sort the list of panels. | ||||
Show All 12 Lines |