From 16ea495c7a7aebd9e551ff23513c388a9bb27303 Mon Sep 17 00:00:00 2001 From: flashwave Date: Thu, 31 Aug 2023 00:37:09 +0000 Subject: [PATCH] Added permission for displaying load timings in the footer. --- public/index.php | 2 +- src/Perm.php | 3 +++ templates/_layout/footer.twig | 2 +- templates/home/landing.twig | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/public/index.php b/public/index.php index 456548a..d232d92 100644 --- a/public/index.php +++ b/public/index.php @@ -180,7 +180,7 @@ $inManageMode = str_starts_with($_SERVER['REQUEST_URI'], '/manage'); Template::set('header_menu', $msz->getHeaderMenu($userInfo ?? null)); Template::set('user_menu', $msz->getUserMenu($userInfo ?? null, $inManageMode)); -Template::set('display_debug_info', MSZ_DEBUG || (!empty($userInfo) && $userInfo->isSuperUser())); +Template::set('display_timings_info', MSZ_DEBUG || $msz->getAuthInfo()->getPerms('global')->check(Perm::G_TIMINGS_VIEW)); if($inManageMode) { $hasManageAccess = false; diff --git a/src/Perm.php b/src/Perm.php index f9eda95..1e6058f 100644 --- a/src/Perm.php +++ b/src/Perm.php @@ -21,6 +21,7 @@ final class Perm { //public const G_IS_TESTER = 0b00000_00000000_00000000_00000000_00000000_00000000_00010000; // deprecated: tester status went unused public const G_BLACKLIST_MANAGE = 0b00000_00000000_00000000_00000000_00000000_00000000_00100000; // unused: blacklist is currently removed to reduce overhead and it seemed like it was broken //public const G_TWITTER_MANAGE = 0b00000_00000000_00000000_00000000_00000000_00000000_01000000; // deprecated: twitter integration has been removed + public const G_TIMINGS_VIEW = 0b00000_00000000_00000000_00000000_00000000_00000000_10000000; public const G_CL_CHANGES_MANAGE = 0b00000_00000000_00000000_00000000_00000000_00000001_00000000; public const G_CL_TAGS_MANAGE = 0b00000_00000000_00000000_00000000_00000000_00000010_00000000; @@ -102,6 +103,7 @@ final class Perm { self::G_EMOTES_MANAGE, self::G_CONFIG_MANAGE, self::G_BLACKLIST_MANAGE, + self::G_TIMINGS_VIEW, ], ], @@ -222,6 +224,7 @@ final class Perm { //self::G_IS_TESTER => 'Can test experimental features.', self::G_BLACKLIST_MANAGE => 'Can manage registration IP address blacklist.', //self::G_TWITTER_MANAGE => 'Can manage Twitter integration settings.', + self::G_TIMINGS_VIEW => 'Can view page load timings.', self::G_CL_CHANGES_MANAGE => 'Can manage changelog entries.', self::G_CL_TAGS_MANAGE => 'Can manage changelog tags.', diff --git a/templates/_layout/footer.twig b/templates/_layout/footer.twig index aa2a57e..b0444b6 100644 --- a/templates/_layout/footer.twig +++ b/templates/_layout/footer.twig @@ -13,7 +13,7 @@ {{ git_tag }} {% endif %} # {{ git_commit_hash() }} - {% if display_debug_info %} + {% if display_timings_info %} / Index {{ ndx_version() }} / {{ sql_query_count()|number_format }} queries / {{ (startup_time() - startup_time(constant('MSZ_TPL_RENDER')))|number_format(5) }} load diff --git a/templates/home/landing.twig b/templates/home/landing.twig index 1df47e1..9baf9d8 100644 --- a/templates/home/landing.twig +++ b/templates/home/landing.twig @@ -87,7 +87,7 @@ {% endif %} # {{ git_commit_hash() }} -{% if display_debug_info %} +{% if display_timings_info %}