Page MenuHomePhabricator

D8545.id20280.diff
No OneTemporary

D8545.id20280.diff

diff --git a/src/applications/base/PhabricatorApplication.php b/src/applications/base/PhabricatorApplication.php
--- a/src/applications/base/PhabricatorApplication.php
+++ b/src/applications/base/PhabricatorApplication.php
@@ -74,10 +74,6 @@
return empty($uninstalled[get_class($this)]);
}
- public static function isClassInstalled($class) {
- return self::getByClass($class)->isInstalled();
- }
-
public function isBeta() {
return false;
}
@@ -288,6 +284,7 @@
/* -( Application Management )--------------------------------------------- */
+
public static function getByClass($class_name) {
$selected = null;
$applications = PhabricatorApplication::getAllApplications();
@@ -345,6 +342,48 @@
}
+ /**
+ * Determine if an application is installed, by application class name.
+ *
+ * To check if an application is installed //and// available to a particular
+ * viewer, user @{method:isClassInstalledForViewer}.
+ *
+ * @param string Application class name.
+ * @return bool True if the class is installed.
+ * @task meta
+ */
+ public static function isClassInstalled($class) {
+ return self::getByClass($class)->isInstalled();
+ }
+
+
+ /**
+ * Determine if an application is installed and available to a viewer, by
+ * application class name.
+ *
+ * To check if an application is installed at all, use
+ * @{method:isClassInstalled}.
+ *
+ * @param string Application class name.
+ * @param PhabricatorUser Viewing user.
+ * @return bool True if the class is installed for the viewer.
+ * @task meta
+ */
+ public static function isClassInstalledForViewer(
+ $class,
+ PhabricatorUser $viewer) {
+
+ if (!self::isClassInstalled($class)) {
+ return false;
+ }
+
+ return PhabricatorPolicyFilter::hasCapability(
+ $viewer,
+ self::getByClass($class),
+ PhabricatorPolicyCapability::CAN_VIEW);
+ }
+
+
/* -( PhabricatorPolicyInterface )----------------------------------------- */
diff --git a/src/applications/home/controller/PhabricatorHomeMainController.php b/src/applications/home/controller/PhabricatorHomeMainController.php
--- a/src/applications/home/controller/PhabricatorHomeMainController.php
+++ b/src/applications/home/controller/PhabricatorHomeMainController.php
@@ -33,9 +33,21 @@
private function buildMainResponse($nav, array $projects) {
assert_instances_of($projects, 'PhabricatorProject');
+ $viewer = $this->getRequest()->getUser();
- $maniphest = 'PhabricatorApplicationManiphest';
- if (PhabricatorApplication::isClassInstalled($maniphest)) {
+ $has_maniphest = PhabricatorApplication::isClassInstalledForViewer(
+ 'PhabricatorApplicationManiphest',
+ $viewer);
+
+ $has_audit = PhabricatorApplication::isClassInstalledForViewer(
+ 'PhabricatorApplicationAudit',
+ $viewer);
+
+ $has_differential = PhabricatorApplication::isClassInstalledForViewer(
+ 'PhabricatorApplicationDifferential',
+ $viewer);
+
+ if ($has_maniphest) {
$unbreak_panel = $this->buildUnbreakNowPanel();
$triage_panel = $this->buildNeedsTriagePanel($projects);
$tasks_panel = $this->buildTasksPanel();
@@ -45,8 +57,7 @@
$tasks_panel = null;
}
- $audit = 'PhabricatorApplicationAudit';
- if (PhabricatorApplication::isClassInstalled($audit)) {
+ if ($has_audit) {
$audit_panel = $this->buildAuditPanel();
$commit_panel = $this->buildCommitPanel();
} else {
@@ -61,7 +72,12 @@
}
$jump_panel = $this->buildJumpPanel();
- $revision_panel = $this->buildRevisionPanel();
+
+ if ($has_differential) {
+ $revision_panel = $this->buildRevisionPanel();
+ } else {
+ $revision_panel = null;
+ }
$content = array(
$jump_panel,

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 10, 5:48 AM (2 d, 21 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6710817
Default Alt Text
D8545.id20280.diff (3 KB)

Event Timeline