diff --git a/lib/classes/MvvPerm.php b/lib/classes/MvvPerm.php index 918375da771213819308a41b3b79045d85fff6a2..702dfd06827baa6bfd1f37839339edbc36563996 100644 --- a/lib/classes/MvvPerm.php +++ b/lib/classes/MvvPerm.php @@ -534,20 +534,20 @@ class MvvPerm { /** * * - * @param type $user_id + * @param string $user_id * @return */ public static function getRoles($user_id) { - if (!self::$roles[$user_id]) { - $assigned = RolePersistence::getAssignedRoles($user_id); - foreach (RolePersistence::getAssignedRoles($user_id) as $role_id => $role) { - if (substr_compare($role->rolename, 'MVV', 1, 3, true)) { - self::$roles[$user_id][] = $role; + if (!isset(self::$roles[$user_id])) { + self::$roles[$user_id] = array_filter( + RolePersistence::getAssignedRoles($user_id), + function ($role) { + return stripos($role->rolename, 'mvv') === 0; } - } + ); } - return (self::$roles[$user_id] ?: []); + return self::$roles[$user_id]; } /**