@@ -102,22 +102,20 @@ public function is_available($not, \core_availability\info $info, $grabthelot, $
102102 if (isset ($ course ->lang ) && $ course ->lang === $ this ->languageid ) {
103103 $ allow = true ;
104104 } else {
105- if ( $ userid === $ USER -> id ) {
105+ $ language = match ( true ) {
106106 // Checking the language of the currently logged in user, so do not
107107 // default to the account language, because the session language
108108 // or the language of the current course may be different.
109- $ language = current_language ();
110- } else {
111- if (is_null ($ userid )) {
112- // Fall back to site language or English.
113- $ language = $ CFG ->lang ;
114- } else {
115- // Checking access for someone else than the logged in user, so
116- // use the preferred language of that user account.
117- // This language is never empty as there is a not-null constraint.
118- $ language = \core_user::get_user ($ userid )->lang ;
119- }
120- }
109+ $ userid === $ USER ->id => current_language (),
110+
111+ // When the userid is null then fall back to site language.
112+ is_null ($ userid ) => $ CFG ->lang ,
113+
114+ // Checking access for someone else than the logged in user, so
115+ // use the preferred language of that user account.
116+ // This language is never empty as there is a not-null constraint.
117+ default => \core_user::get_user ($ userid )->lang ,
118+ };
121119
122120 if ($ language === $ this ->languageid ) {
123121 $ allow = true ;
0 commit comments