MDL-59377 course: when module intro is visible display embedded files

Even when course module is not available the intro text can still be visible on the
course page. In this case the availability restriction is displayed to the student
but link to the activity is not available
This commit is contained in:
Marina Glancy 2017-06-28 09:33:30 +08:00
parent 16a68a2f76
commit 66347456ec

View File

@ -4650,7 +4650,18 @@ function file_pluginfile($relativepath, $forcedownload, $preview = null, $offlin
if (!plugin_supports('mod', $modname, FEATURE_MOD_INTRO, true)) {
send_file_not_found();
}
require_course_login($course, true, $cm);
// Require login to the course first (without login to the module).
require_course_login($course, true);
// Now check if module is available OR it is restricted but the intro is shown on the course page.
$cminfo = cm_info::create($cm);
if (!$cminfo->uservisible) {
if (!$cm->showdescription || !$cminfo->is_visible_on_course_page()) {
// Module intro is not visible on the course page and module is not available, show access error.
require_course_login($course, true, $cminfo);
}
}
// all users may access it
$filename = array_pop($args);