From 1e7b646f3785a8b690832b4aca1204d24391b92a Mon Sep 17 00:00:00 2001 From: mjansen Date: Wed, 21 Aug 2024 14:18:14 +0200 Subject: [PATCH] MyStaff: Check feature activation before expensive database operations See: https://mantis.ilias.de/view.php?id=31352 --- .../classes/Provider/StaffMainBarProvider.php | 4 ++++ .../MyStaff/classes/class.ilMyStaffAccess.php | 23 ++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Services/MyStaff/classes/Provider/StaffMainBarProvider.php b/Services/MyStaff/classes/Provider/StaffMainBarProvider.php index b0b8d0f19238..f5453059c2b7 100644 --- a/Services/MyStaff/classes/Provider/StaffMainBarProvider.php +++ b/Services/MyStaff/classes/Provider/StaffMainBarProvider.php @@ -52,6 +52,10 @@ final public function getStaticTopItems(): array */ final public function getStaticSubItems(): array { + if (!ilMyStaffAccess::isMyStaffActive()) { + return []; + } + $this->dic->language()->loadLanguageModule('mst'); $dic = $this->dic; $items = []; diff --git a/Services/MyStaff/classes/class.ilMyStaffAccess.php b/Services/MyStaff/classes/class.ilMyStaffAccess.php index 4600a3df50a1..35007570ab63 100644 --- a/Services/MyStaff/classes/class.ilMyStaffAccess.php +++ b/Services/MyStaff/classes/class.ilMyStaffAccess.php @@ -56,6 +56,10 @@ public static function getInstance(): self if (self::$instance === null) { self::$instance = new self(); + if (!self::isMyStaffActive()) { + return self::$instance; + } + self::$instance->dropTempTable(self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_SPEC_PERMISSIONS . "_" . self::ACCESS_ENROLMENTS_ORG_UNIT_OPERATION . "_" . self::COURSE_CONTEXT); self::$instance->dropTempTable(self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_DEFAULT_PERMISSIONS . "_" . self::ACCESS_ENROLMENTS_ORG_UNIT_OPERATION @@ -75,11 +79,18 @@ public function __construct() { } + public static function isMyStaffActive(): bool + { + global $DIC; + + return (bool) $DIC->settings()->get('enable_my_staff'); + } + public function hasCurrentUserAccessToMyStaff(): bool { global $DIC; - if (!$DIC->settings()->get("enable_my_staff")) { + if (!self::isMyStaffActive()) { return false; } @@ -110,7 +121,7 @@ public function hasCurrentUserAccessToCertificates(): bool { global $DIC; - if (!$DIC->settings()->get("enable_my_staff")) { + if (!self::isMyStaffActive()) { return false; } @@ -156,7 +167,7 @@ public function hasCurrentUserAccessToTalks(): bool { global $DIC; - if (!$DIC->settings()->get("enable_my_staff")) { + if (!self::isMyStaffActive()) { return false; } @@ -197,7 +208,7 @@ public function hasCurrentUserAccessToCompetences(): bool { global $DIC; - if (!$DIC->settings()->get("enable_my_staff")) { + if (!self::isMyStaffActive()) { return false; } @@ -253,7 +264,7 @@ public function hasCurrentUserAccessToCourseMemberships(): bool { global $DIC; - if (!$DIC->settings()->get("enable_my_staff")) { + if (!self::isMyStaffActive()) { return false; } @@ -279,7 +290,7 @@ public function hasCurrentUserAccessToUser(int $usr_id): bool { global $DIC; - if (!$DIC->settings()->get("enable_my_staff")) { + if (!self::isMyStaffActive()) { return false; }