MDL-69559 course: Add course setting and cap to control course downloads

This commit is contained in:
Michael Hawkins
2020-10-26 10:25:37 +08:00
parent c053b93f0c
commit d358b91e2b
9 changed files with 210 additions and 3 deletions
+21
View File
@@ -120,6 +120,27 @@ class course_edit_form extends moodleform {
$mform->setConstant('visible', $courseconfig->visible);
}
}
// Download course content.
if ($CFG->downloadcoursecontentallowed) {
$downloadchoices = [
DOWNLOAD_COURSE_CONTENT_DISABLED => get_string('no'),
DOWNLOAD_COURSE_CONTENT_ENABLED => get_string('yes'),
];
$sitedefaultstring = $downloadchoices[$courseconfig->downloadcontentsitedefault];
$downloadchoices[DOWNLOAD_COURSE_CONTENT_SITE_DEFAULT] = get_string('sitedefaultspecified', '', $sitedefaultstring);
$downloadselectdefault = $courseconfig->downloadcontent ?? DOWNLOAD_COURSE_CONTENT_SITE_DEFAULT;
$mform->addElement('select', 'downloadcontent', get_string('enabledownloadcoursecontent', 'course'), $downloadchoices);
$mform->addHelpButton('downloadcontent', 'downloadcoursecontent', 'course');
$mform->setDefault('downloadcontent', $downloadselectdefault);
if (!has_capability('moodle/course:configuredownloadcontent', $coursecontext)) {
$mform->hardFreeze('downloadcontent');
$mform->setConstant('downloadcontent', $downloadselectdefault);
}
}
$mform->addElement('date_time_selector', 'startdate', get_string('startdate'));
$mform->addHelpButton('startdate', 'startdate');
$date = (new DateTime())->setTimestamp(usergetmidnight(time()));