From 79997a1445a72e97c036992e14a3a60a80c59600 Mon Sep 17 00:00:00 2001 From: Stuart Lamour Date: Wed, 8 Jan 2025 16:41:09 +0000 Subject: [PATCH] cr - reduce get_user_roles --- block_alerts.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/block_alerts.php b/block_alerts.php index 24093e7..95c21e4 100644 --- a/block_alerts.php +++ b/block_alerts.php @@ -84,11 +84,8 @@ public function get_content(): stdClass { public static function is_teacher(): bool { global $DB, $USER; - // System level roles. - $context = context_system::instance(); - $roles = get_user_roles($context, $USER->id); // Check for manager or coursecreator role. - foreach ($roles as $role) { + foreach (get_user_roles(context_system::instance()) as $role) { if ($role->shortname === 'manager' || $role->shortname === 'coursecreator') { return true; }