Skip to content

Commit

Permalink
cr - reduce get_user_roles
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartlamour committed Jan 8, 2025
1 parent bae2830 commit 79997a1
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions block_alerts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 79997a1

Please sign in to comment.