Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/base/PhabricatorApplication.php b/src/applications/base/PhabricatorApplication.php
index 938073273b..ebe44f0f89 100644
--- a/src/applications/base/PhabricatorApplication.php
+++ b/src/applications/base/PhabricatorApplication.php
@@ -1,441 +1,450 @@
<?php
/**
* @task info Application Information
* @task ui UI Integration
* @task uri URI Routing
* @task fact Fact Integration
* @task meta Application Management
* @group apps
*/
abstract class PhabricatorApplication
implements PhabricatorPolicyInterface {
const GROUP_CORE = 'core';
const GROUP_COMMUNICATION = 'communication';
const GROUP_ORGANIZATION = 'organization';
const GROUP_UTILITIES = 'util';
const GROUP_ADMIN = 'admin';
const GROUP_DEVELOPER = 'developer';
const GROUP_MISC = 'misc';
const TILE_INVISIBLE = 'invisible';
const TILE_HIDE = 'hide';
const TILE_SHOW = 'show';
const TILE_FULL = 'full';
public static function getApplicationGroups() {
return array(
self::GROUP_CORE => pht('Core Applications'),
self::GROUP_COMMUNICATION => pht('Communication'),
self::GROUP_ORGANIZATION => pht('Organization'),
self::GROUP_UTILITIES => pht('Utilities'),
self::GROUP_ADMIN => pht('Administration'),
self::GROUP_DEVELOPER => pht('Developer Tools'),
self::GROUP_MISC => pht('Miscellaneous Applications'),
);
}
public static function getTileDisplayName($constant) {
$names = array(
self::TILE_INVISIBLE => pht('Invisible'),
self::TILE_HIDE => pht('Hidden'),
self::TILE_SHOW => pht('Show Small Tile'),
self::TILE_FULL => pht('Show Large Tile'),
);
return idx($names, $constant);
}
/* -( Application Information )-------------------------------------------- */
public function getName() {
return substr(get_class($this), strlen('PhabricatorApplication'));
}
public function getShortDescription() {
return $this->getName().' Application';
}
public function isInstalled() {
if (!$this->canUninstall()) {
return true;
}
$beta = PhabricatorEnv::getEnvConfig('phabricator.show-beta-applications');
if (!$beta && $this->isBeta()) {
return false;
}
$uninstalled = PhabricatorEnv::getEnvConfig(
'phabricator.uninstalled-applications');
return empty($uninstalled[get_class($this)]);
}
public static function isClassInstalled($class) {
return self::getByClass($class)->isInstalled();
}
public function isBeta() {
return false;
}
+ /**
+ * Return true if this application should not appear in application lists in
+ * the UI. Primarily intended for unit test applications or other
+ * pseudo-applications.
+ *
+ * @return bool True to remove application from UI lists.
+ */
public function isUnlisted() {
return false;
}
/**
* Returns true if an application is first-party (developed by Phacility)
* and false otherwise.
+ *
+ * @return bool True if this application is developed by Phacility.
*/
final public function isFirstParty() {
$where = id(new ReflectionClass($this))->getFileName();
$root = phutil_get_library_root('phabricator');
if (!Filesystem::isDescendant($where, $root)) {
return false;
}
if (Filesystem::isDescendant($where, $root.'/extensions')) {
return false;
}
return true;
}
public function canUninstall() {
return true;
}
public function getPHID() {
return 'PHID-APPS-'.get_class($this);
}
public function getTypeaheadURI() {
return $this->getBaseURI();
}
public function getBaseURI() {
return null;
}
public function getApplicationURI($path = '') {
return $this->getBaseURI().ltrim($path, '/');
}
public function getIconURI() {
return null;
}
public function getIconName() {
return 'application';
}
public function shouldAppearInLaunchView() {
return true;
}
public function getApplicationOrder() {
return PHP_INT_MAX;
}
public function getApplicationGroup() {
return self::GROUP_MISC;
}
public function getTitleGlyph() {
return null;
}
public function getHelpURI() {
// TODO: When these applications get created, link to their docs:
//
// - Drydock
// - OAuth Server
return null;
}
public function getEventListeners() {
return array();
}
public function getDefaultTileDisplay(PhabricatorUser $user) {
switch ($this->getApplicationGroup()) {
case self::GROUP_CORE:
return self::TILE_FULL;
case self::GROUP_UTILITIES:
case self::GROUP_DEVELOPER:
return self::TILE_HIDE;
case self::GROUP_ADMIN:
if ($user->getIsAdmin()) {
return self::TILE_SHOW;
} else {
return self::TILE_INVISIBLE;
}
break;
default:
return self::TILE_SHOW;
}
}
public function getRemarkupRules() {
return array();
}
/* -( URI Routing )-------------------------------------------------------- */
public function getRoutes() {
return array();
}
/* -( Fact Integration )--------------------------------------------------- */
public function getFactObjectsForAnalysis() {
return array();
}
/* -( UI Integration )----------------------------------------------------- */
/**
* Render status elements (like "3 Waiting Reviews") for application list
* views. These provide a way to alert users to new or pending action items
* in applications.
*
* @param PhabricatorUser Viewing user.
* @return list<PhabricatorApplicationStatusView> Application status elements.
* @task ui
*/
public function loadStatus(PhabricatorUser $user) {
return array();
}
/**
* You can provide an optional piece of flavor text for the application. This
* is currently rendered in application launch views if the application has no
* status elements.
*
* @return string|null Flavor text.
* @task ui
*/
public function getFlavorText() {
return null;
}
/**
* Build items for the main menu.
*
* @param PhabricatorUser The viewing user.
* @param AphrontController The current controller. May be null for special
* pages like 404, exception handlers, etc.
* @return list<PhabricatorMainMenuIconView> List of menu items.
* @task ui
*/
public function buildMainMenuItems(
PhabricatorUser $user,
PhabricatorController $controller = null) {
return array();
}
/**
* On the Phabricator homepage sidebar, this function returns the URL for
* a quick create X link which is displayed in the wide button only.
*
* @return string
* @task ui
*/
public function getQuickCreateURI() {
return null;
}
/* -( Application Management )--------------------------------------------- */
public static function getByClass($class_name) {
$selected = null;
$applications = PhabricatorApplication::getAllApplications();
foreach ($applications as $application) {
if (get_class($application) == $class_name) {
$selected = $application;
break;
}
}
if (!$selected) {
throw new Exception("No application '{$class_name}'!");
}
return $selected;
}
public static function getAllApplications() {
static $applications;
if ($applications === null) {
$apps = id(new PhutilSymbolLoader())
->setAncestorClass(__CLASS__)
->loadObjects();
// Reorder the applications into "application order". Notably, this
// ensures their event handlers register in application order.
$apps = msort($apps, 'getApplicationOrder');
$apps = mgroup($apps, 'getApplicationGroup');
$group_order = array_keys(self::getApplicationGroups());
$apps = array_select_keys($apps, $group_order) + $apps;
$apps = array_mergev($apps);
$applications = $apps;
}
return $applications;
}
public static function getAllInstalledApplications() {
$all_applications = self::getAllApplications();
$apps = array();
foreach ($all_applications as $app) {
if (!$app->isInstalled()) {
continue;
}
$apps[] = $app;
}
return $apps;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */
public function getCapabilities() {
return array_merge(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
),
array_keys($this->getCustomCapabilities()));
}
public function getPolicy($capability) {
$default = $this->getCustomPolicySetting($capability);
if ($default) {
return $default;
}
switch ($capability) {
case PhabricatorPolicyCapability::CAN_VIEW:
if (PhabricatorEnv::getEnvConfig('policy.allow-public')) {
return PhabricatorPolicies::POLICY_PUBLIC;
} else {
return PhabricatorPolicies::POLICY_USER;
}
case PhabricatorPolicyCapability::CAN_EDIT:
return PhabricatorPolicies::POLICY_ADMIN;
default:
$spec = $this->getCustomCapabilitySpecification($capability);
return idx($spec, 'default', PhabricatorPolicies::POLICY_USER);
}
}
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( Policies )----------------------------------------------------------- */
protected function getCustomCapabilities() {
return array();
}
private function getCustomPolicySetting($capability) {
if (!$this->isCapabilityEditable($capability)) {
return null;
}
$config = PhabricatorEnv::getEnvConfig('phabricator.application-settings');
$app = idx($config, $this->getPHID());
if (!$app) {
return null;
}
$policy = idx($app, 'policy');
if (!$policy) {
return null;
}
return idx($policy, $capability);
}
private function getCustomCapabilitySpecification($capability) {
$custom = $this->getCustomCapabilities();
if (empty($custom[$capability])) {
throw new Exception("Unknown capability '{$capability}'!");
}
return $custom[$capability];
}
public function getCapabilityLabel($capability) {
$map = array(
PhabricatorPolicyCapability::CAN_VIEW => pht('Can Use Application'),
PhabricatorPolicyCapability::CAN_EDIT => pht('Can Configure Application'),
);
$map += ipull($this->getCustomCapabilities(), 'label');
return idx($map, $capability);
}
public function isCapabilityEditable($capability) {
switch ($capability) {
case PhabricatorPolicyCapability::CAN_VIEW:
return $this->canUninstall();
case PhabricatorPolicyCapability::CAN_EDIT:
return false;
default:
$spec = $this->getCustomCapabilitySpecification($capability);
return idx($spec, 'edit', true);
}
}
public function getCapabilityCaption($capability) {
switch ($capability) {
case PhabricatorPolicyCapability::CAN_VIEW:
if (!$this->canUninstall()) {
return pht(
'This application is required for Phabricator to operate, so all '.
'users must have access to it.');
} else {
return null;
}
case PhabricatorPolicyCapability::CAN_EDIT:
return null;
default:
$spec = $this->getCustomCapabilitySpecification($capability);
return idx($spec, 'caption');
}
}
}
diff --git a/src/applications/meta/controller/PhabricatorApplicationsListController.php b/src/applications/meta/controller/PhabricatorApplicationsListController.php
index 5a05aee538..0a358fecc1 100644
--- a/src/applications/meta/controller/PhabricatorApplicationsListController.php
+++ b/src/applications/meta/controller/PhabricatorApplicationsListController.php
@@ -1,56 +1,52 @@
<?php
final class PhabricatorApplicationsListController
extends PhabricatorApplicationsController
implements PhabricatorApplicationSearchResultsControllerInterface {
private $queryKey;
public function willProcessRequest(array $data) {
$this->queryKey = idx($data, 'queryKey');
}
public function processRequest() {
$request = $this->getRequest();
$controller = id(new PhabricatorApplicationSearchController($request))
->setQueryKey($this->queryKey)
->setSearchEngine(new PhabricatorAppSearchEngine())
->setNavigation($this->buildSideNavView());
return $this->delegateToController($controller);
}
public function renderResultsList(
array $applications,
PhabricatorSavedQuery $query) {
assert_instances_of($applications, 'PhabricatorApplication');
$list = new PHUIObjectItemListView();
$applications = msort($applications, 'getName');
foreach ($applications as $application) {
- if ($application->isUnlisted()) {
- continue;
- }
-
$item = id(new PHUIObjectItemView())
->setHeader($application->getName())
->setHref('/applications/view/'.get_class($application).'/')
->addAttribute($application->getShortDescription());
if (!$application->isInstalled()) {
$item->addIcon('delete', pht('Uninstalled'));
}
if ($application->isBeta()) {
$item->addIcon('lint-warning', pht('Beta'));
}
$list->addItem($item);
}
return $list;
}
}
diff --git a/src/applications/meta/query/PhabricatorAppSearchEngine.php b/src/applications/meta/query/PhabricatorAppSearchEngine.php
index 9824664948..d3c82e6d79 100644
--- a/src/applications/meta/query/PhabricatorAppSearchEngine.php
+++ b/src/applications/meta/query/PhabricatorAppSearchEngine.php
@@ -1,135 +1,136 @@
<?php
final class PhabricatorAppSearchEngine
extends PhabricatorApplicationSearchEngine {
public function getPageSize(PhabricatorSavedQuery $saved) {
return INF;
}
public function buildSavedQueryFromRequest(AphrontRequest $request) {
$saved = new PhabricatorSavedQuery();
$saved->setParameter('name', $request->getStr('name'));
$saved->setParameter('installed', $this->readBool($request, 'installed'));
$saved->setParameter('beta', $this->readBool($request, 'beta'));
$saved->setParameter('firstParty', $this->readBool($request, 'firstParty'));
return $saved;
}
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
$query = id(new PhabricatorApplicationQuery())
- ->setOrder(PhabricatorApplicationQuery::ORDER_NAME);
+ ->setOrder(PhabricatorApplicationQuery::ORDER_NAME)
+ ->withUnlisted(false);
$name = $saved->getParameter('name');
if (strlen($name)) {
$query->withNameContains($name);
}
$installed = $saved->getParameter('installed');
if ($installed !== null) {
$query->withInstalled($installed);
}
$beta = $saved->getParameter('beta');
if ($beta !== null) {
$query->withBeta($beta);
}
$first_party = $saved->getParameter('firstParty');
if ($first_party !== null) {
$query->withFirstParty($first_party);
}
return $query;
}
public function buildSearchForm(
AphrontFormView $form,
PhabricatorSavedQuery $saved) {
$form
->appendChild(
id(new AphrontFormTextControl())
->setLabel(pht('Name Contains'))
->setName('name')
->setValue($saved->getParameter('name')))
->appendChild(
id(new AphrontFormSelectControl())
->setLabel(pht('Installed'))
->setName('installed')
->setValue($this->getBool($saved, 'installed'))
->setOptions(
array(
'' => pht('Show All Applications'),
'true' => pht('Show Installed Applications'),
'false' => pht('Show Uninstalled Applications'),
)))
->appendChild(
id(new AphrontFormSelectControl())
->setLabel(pht('Beta'))
->setName('beta')
->setValue($this->getBool($saved, 'beta'))
->setOptions(
array(
'' => pht('Show All Applications'),
'true' => pht('Show Beta Applications'),
'false' => pht('Show Released Applications'),
)))
->appendChild(
id(new AphrontFormSelectControl())
->setLabel(pht('Provenance'))
->setName('firstParty')
->setValue($this->getBool($saved, 'firstParty'))
->setOptions(
array(
'' => pht('Show All Applications'),
'true' => pht('Show First-Party Applications'),
'false' => pht('Show Third-Party Applications'),
)));
}
protected function getURI($path) {
return '/applications/'.$path;
}
public function getBuiltinQueryNames() {
$names = array(
'all' => pht('All Applications'),
);
return $names;
}
public function buildSavedQueryFromBuiltin($query_key) {
$query = $this->newSavedQuery();
$query->setQueryKey($query_key);
switch ($query_key) {
case 'all':
return $query;
}
return parent::buildSavedQueryFromBuiltin($query_key);
}
private function readBool(AphrontRequest $request, $key) {
if (!strlen($request->getStr($key))) {
return null;
}
return $request->getBool($key);
}
private function getBool(PhabricatorSavedQuery $query, $key) {
$value = $query->getParameter($key);
if ($value === null) {
return $value;
}
return $value ? 'true' : 'false';
}
}
diff --git a/src/applications/meta/query/PhabricatorApplicationQuery.php b/src/applications/meta/query/PhabricatorApplicationQuery.php
index c15ece6eb6..30106cd1f2 100644
--- a/src/applications/meta/query/PhabricatorApplicationQuery.php
+++ b/src/applications/meta/query/PhabricatorApplicationQuery.php
@@ -1,121 +1,135 @@
<?php
final class PhabricatorApplicationQuery
extends PhabricatorCursorPagedPolicyAwareQuery {
private $installed;
private $beta;
private $firstParty;
private $nameContains;
+ private $unlisted;
private $classes;
private $phids;
const ORDER_APPLICATION = 'order:application';
const ORDER_NAME = 'order:name';
private $order = self::ORDER_APPLICATION;
public function withNameContains($name_contains) {
$this->nameContains = $name_contains;
return $this;
}
public function withInstalled($installed) {
$this->installed = $installed;
return $this;
}
public function withBeta($beta) {
$this->beta = $beta;
return $this;
}
public function withFirstParty($first_party) {
$this->firstParty = $first_party;
return $this;
}
+ public function withUnlisted($unlisted) {
+ $this->unlisted = $unlisted;
+ return $this;
+ }
+
public function withClasses(array $classes) {
$this->classes = $classes;
return $this;
}
public function withPHIDs(array $phids) {
$this->phids = $phids;
return $this;
}
public function setOrder($order) {
$this->order = $order;
return $this;
}
public function loadPage() {
$apps = PhabricatorApplication::getAllApplications();
if ($this->classes) {
$classes = array_fuse($this->classes);
foreach ($apps as $key => $app) {
if (empty($classes[get_class($app)])) {
unset($apps[$key]);
}
}
}
if ($this->phids) {
$phids = array_fuse($this->phids);
foreach ($apps as $key => $app) {
if (empty($phids[$app->getPHID()])) {
unset($apps[$key]);
}
}
}
if (strlen($this->nameContains)) {
foreach ($apps as $key => $app) {
if (stripos($app->getName(), $this->nameContains) === false) {
unset($apps[$key]);
}
}
}
if ($this->installed !== null) {
foreach ($apps as $key => $app) {
if ($app->isInstalled() != $this->installed) {
unset($apps[$key]);
}
}
}
if ($this->beta !== null) {
foreach ($apps as $key => $app) {
if ($app->isBeta() != $this->beta) {
unset($apps[$key]);
}
}
}
if ($this->firstParty !== null) {
foreach ($apps as $key => $app) {
if ($app->isFirstParty() != $this->firstParty) {
unset($apps[$key]);
}
}
}
+ if ($this->unlisted !== null) {
+ foreach ($apps as $key => $app) {
+ if ($app->isUnlisted() != $this->unlisted) {
+ unset($apps[$key]);
+ }
+ }
+ }
+
switch ($this->order) {
case self::ORDER_NAME:
$apps = msort($apps, 'getName');
break;
case self::ORDER_APPLICATION:
$apps = $apps;
break;
default:
throw new Exception(
pht('Unknown order "%s"!', $this->order));
}
return $apps;
}
}
diff --git a/src/applications/settings/panel/PhabricatorSettingsPanelHomePreferences.php b/src/applications/settings/panel/PhabricatorSettingsPanelHomePreferences.php
index 37480acf35..13a46ba0ef 100644
--- a/src/applications/settings/panel/PhabricatorSettingsPanelHomePreferences.php
+++ b/src/applications/settings/panel/PhabricatorSettingsPanelHomePreferences.php
@@ -1,213 +1,213 @@
<?php
final class PhabricatorSettingsPanelHomePreferences
extends PhabricatorSettingsPanel {
public function getPanelKey() {
return 'home';
}
public function getPanelName() {
return pht('Home Page');
}
public function getPanelGroup() {
return pht('Application Settings');
}
public function processRequest(AphrontRequest $request) {
$user = $request->getUser();
$preferences = $user->loadPreferences();
require_celerity_resource('phabricator-settings-css');
- $apps = PhabricatorApplication::getAllInstalledApplications();
+ $apps = id(new PhabricatorApplicationQuery())
+ ->setViewer($user)
+ ->withUnlisted(false)
+ ->execute();
+
$pref_tiles = PhabricatorUserPreferences::PREFERENCE_APP_TILES;
$tiles = $preferences->getPreference($pref_tiles, array());
if ($request->isFormPost()) {
$values = $request->getArr('tile');
foreach ($apps as $app) {
$key = get_class($app);
$value = idx($values, $key);
switch ($value) {
case PhabricatorApplication::TILE_FULL:
case PhabricatorApplication::TILE_SHOW:
case PhabricatorApplication::TILE_HIDE:
$tiles[$key] = $value;
break;
default:
unset($tiles[$key]);
break;
}
}
$preferences->setPreference($pref_tiles, $tiles);
$preferences->save();
return id(new AphrontRedirectResponse())
->setURI($this->getPanelURI('?saved=true'));
}
$form = id(new AphrontFormView())
->setUser($user);
$group_map = PhabricatorApplication::getApplicationGroups();
$output = array();
$applications = PhabricatorApplication::getAllInstalledApplications();
$applications = mgroup($applications, 'getApplicationGroup');
$applications = array_select_keys(
$applications,
array_keys($group_map));
foreach ($applications as $group => $apps) {
$group_name = $group_map[$group];
$rows = array();
foreach ($apps as $app) {
if (!$app->shouldAppearInLaunchView()) {
continue;
}
$default = $app->getDefaultTileDisplay($user);
if ($default == PhabricatorApplication::TILE_INVISIBLE) {
continue;
}
$default_name = PhabricatorApplication::getTileDisplayName($default);
$hide = PhabricatorApplication::TILE_HIDE;
$show = PhabricatorApplication::TILE_SHOW;
$full = PhabricatorApplication::TILE_FULL;
$key = get_class($app);
$default_radio_button_status =
(idx($tiles, $key, 'default') == 'default') ? 'checked' : null;
$hide_radio_button_status =
(idx($tiles, $key, 'default') == $hide) ? 'checked' : null;
$show_radio_button_status =
(idx($tiles, $key, 'default') == $show) ? 'checked' : null;
$full_radio_button_status =
(idx($tiles, $key, 'default') == $full) ? 'checked' : null;
$default_radio_button = phutil_tag(
'input',
array(
'type' => 'radio',
'name' => 'tile['.$key.']',
'value' => 'default',
'checked' => $default_radio_button_status,
));
$hide_radio_button = phutil_tag(
'input',
array(
'type' => 'radio',
'name' => 'tile['.$key.']',
'value' => $hide,
'checked' => $hide_radio_button_status,
));
$show_radio_button = phutil_tag(
'input',
array(
'type' => 'radio',
'name' => 'tile['.$key.']',
'value' => $show,
'checked' => $show_radio_button_status,
));
$full_radio_button = phutil_tag(
'input',
array(
'type' => 'radio',
'name' => 'tile['.$key.']',
'value' => $full,
'checked' => $full_radio_button_status,
));
$app_column = hsprintf(
- "<strong>%s</strong><br /><em> Default: %s</em>"
+ "<strong>%s</strong><br /><em>Default: %s</em>"
, $app->getName(), $default_name);
$rows[] = array(
$app_column,
$default_radio_button,
$hide_radio_button,
$show_radio_button,
$full_radio_button,
);
}
if (empty($rows)) {
continue;
}
$table = new AphrontTableView($rows);
$table
->setClassName('phabricator-settings-homepagetable')
->setHeaders(
array(
pht('Applications'),
pht('Default'),
pht('Hidden'),
pht('Small'),
pht('Large'),
))
->setColumnClasses(
array(
'',
'fixed',
'fixed',
'fixed',
'fixed',
));
$panel = id(new AphrontPanelView())
- ->setHeader($group_name)
- ->addClass('phabricator-settings-panelview')
- ->appendChild($table)
- ->setNoBackground();
-
+ ->setHeader($group_name)
+ ->addClass('phabricator-settings-panelview')
+ ->appendChild($table)
+ ->setNoBackground();
$output[] = $panel;
-
}
$form
->appendChild($output)
->appendChild(
id(new AphrontFormSubmitControl())
->setValue(pht('Save Preferences')));
$error_view = null;
if ($request->getStr('saved') === 'true') {
$error_view = id(new AphrontErrorView())
->setTitle(pht('Preferences Saved'))
->setSeverity(AphrontErrorView::SEVERITY_NOTICE)
->setErrors(array(pht('Your preferences have been saved.')));
}
$form_box = id(new PHUIObjectBoxView())
->setHeaderText(pht('Home Page Preferences'))
->setFormError($error_view)
->setForm($form);
- return array(
- $form_box,
- );
+ return $form_box;
}
}

File Metadata

Mime Type
text/x-diff
Expires
Thu, Nov 6, 9:02 AM (9 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
321752
Default Alt Text
(27 KB)

Event Timeline