MDL-80326 course_format: Visibility changes only when capability is set

* When an editing teacher has not the capability to change visibility
(for example if for a given module the capability is removed), the visibility
drop down menu in the card should not be available.
This commit is contained in:
Laurent David
2024-02-08 09:21:09 +01:00
parent 3fc907e3d8
commit 716da575e7
@@ -78,7 +78,8 @@ class visibility implements named_templatable, renderable {
}
$format = $this->format;
// In rare legacy cases, the section could be stealth (orphaned) but they are not editable.
if (!$format->show_editor()) {
if (!$format->show_editor()
|| !has_capability('moodle/course:activityvisibility', $this->mod->context)) {
return $this->build_static_data($output);
} else {
return $this->build_editor_data($output);