Skip to content

Commit

Permalink
Merge pull request #7978 from mjansenDatabay/hotfix/9/31352-mystaff
Browse files Browse the repository at this point in the history
MyStaff: Check feature activation before expensive database operations
  • Loading branch information
tfamula authored Sep 20, 2024
2 parents 62f6752 + 1e7b646 commit 4c7b7f7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
4 changes: 4 additions & 0 deletions Services/MyStaff/classes/Provider/StaffMainBarProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
23 changes: 17 additions & 6 deletions Services/MyStaff/classes/class.ilMyStaffAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}

Expand Down Expand Up @@ -110,7 +121,7 @@ public function hasCurrentUserAccessToCertificates(): bool
{
global $DIC;

if (!$DIC->settings()->get("enable_my_staff")) {
if (!self::isMyStaffActive()) {
return false;
}

Expand Down Expand Up @@ -156,7 +167,7 @@ public function hasCurrentUserAccessToTalks(): bool
{
global $DIC;

if (!$DIC->settings()->get("enable_my_staff")) {
if (!self::isMyStaffActive()) {
return false;
}

Expand Down Expand Up @@ -197,7 +208,7 @@ public function hasCurrentUserAccessToCompetences(): bool
{
global $DIC;

if (!$DIC->settings()->get("enable_my_staff")) {
if (!self::isMyStaffActive()) {
return false;
}

Expand Down Expand Up @@ -253,7 +264,7 @@ public function hasCurrentUserAccessToCourseMemberships(): bool
{
global $DIC;

if (!$DIC->settings()->get("enable_my_staff")) {
if (!self::isMyStaffActive()) {
return false;
}

Expand All @@ -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;
}

Expand Down

0 comments on commit 4c7b7f7

Please sign in to comment.