mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-65138 course: add a setting for course publishing
This commit is contained in:
parent
3271c39c74
commit
73fabadadd
7 changed files with 18 additions and 6 deletions
|
@ -48,4 +48,7 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||||
|
|
||||||
$optionalsubsystems->add(new admin_setting_configcheckbox('allowstealth', new lang_string('allowstealthmodules'),
|
$optionalsubsystems->add(new admin_setting_configcheckbox('allowstealth', new lang_string('allowstealthmodules'),
|
||||||
new lang_string('allowstealthmodules_help'), 0, 1, 0));
|
new lang_string('allowstealthmodules_help'), 0, 1, 0));
|
||||||
|
|
||||||
|
$optionalsubsystems->add(new admin_setting_configcheckbox('enablecoursepublishing',
|
||||||
|
new lang_string('enablecoursepublishing', 'hub'), new lang_string('enablecoursepublishing_help', 'hub'), 0));
|
||||||
}
|
}
|
||||||
|
|
|
@ -3994,7 +3994,7 @@ function course_get_user_administration_options($course, $context) {
|
||||||
$options->outcomes = !empty($CFG->enableoutcomes) && has_capability('moodle/course:update', $context);
|
$options->outcomes = !empty($CFG->enableoutcomes) && has_capability('moodle/course:update', $context);
|
||||||
$options->badges = !empty($CFG->enablebadges);
|
$options->badges = !empty($CFG->enablebadges);
|
||||||
$options->import = has_capability('moodle/restore:restoretargetimport', $context);
|
$options->import = has_capability('moodle/restore:restoretargetimport', $context);
|
||||||
$options->publish = has_capability('moodle/course:publish', $context);
|
$options->publish = !empty($CFG->enablecoursepublishing) && has_capability('moodle/course:publish', $context);
|
||||||
$options->reset = has_capability('moodle/course:reset', $context);
|
$options->reset = has_capability('moodle/course:reset', $context);
|
||||||
$options->roles = has_capability('moodle/role:switchroles', $context);
|
$options->roles = has_capability('moodle/role:switchroles', $context);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -45,8 +45,9 @@ $hubcourseid = required_param('hubcourseid', PARAM_INT);
|
||||||
//some permissions and parameters checking
|
//some permissions and parameters checking
|
||||||
$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);
|
$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);
|
||||||
require_login($course);
|
require_login($course);
|
||||||
if (!has_capability('moodle/course:publish', context_course::instance($id))
|
|
||||||
or !confirm_sesskey()) {
|
$context = context_course::instance($courseid);
|
||||||
|
if (empty($CFG->enablecoursepublishing) || !has_capability('moodle/course:publish', $context) || !confirm_sesskey()) {
|
||||||
throw new moodle_exception('nopermission');
|
throw new moodle_exception('nopermission');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,10 @@ $PAGE->set_pagelayout('incourse');
|
||||||
$PAGE->set_title(get_string('publish', 'core_hub') . ': ' . $COURSE->fullname);
|
$PAGE->set_title(get_string('publish', 'core_hub') . ': ' . $COURSE->fullname);
|
||||||
$PAGE->set_heading($COURSE->fullname);
|
$PAGE->set_heading($COURSE->fullname);
|
||||||
|
|
||||||
require_capability('moodle/course:publish', context_course::instance($courseid));
|
$context = context_course::instance($courseid);
|
||||||
|
if (empty($CFG->enablecoursepublishing) || !has_capability('moodle/course:publish', $context)) {
|
||||||
|
throw new moodle_exception('nopermission');
|
||||||
|
}
|
||||||
|
|
||||||
// If the site is not registered display an error page.
|
// If the site is not registered display an error page.
|
||||||
if (!\core\hub\registration::is_registered()) {
|
if (!\core\hub\registration::is_registered()) {
|
||||||
|
|
|
@ -46,7 +46,10 @@ $PAGE->set_pagelayout('incourse');
|
||||||
$PAGE->set_title(get_string('course') . ': ' . $course->fullname);
|
$PAGE->set_title(get_string('course') . ': ' . $course->fullname);
|
||||||
$PAGE->set_heading($course->fullname);
|
$PAGE->set_heading($course->fullname);
|
||||||
|
|
||||||
require_capability('moodle/course:publish', context_course::instance($id));
|
$context = context_course::instance($courseid);
|
||||||
|
if (empty($CFG->enablecoursepublishing) || !has_capability('moodle/course:publish', $context)) {
|
||||||
|
throw new moodle_exception('nopermission');
|
||||||
|
}
|
||||||
|
|
||||||
// Retrieve hub name and hub url.
|
// Retrieve hub name and hub url.
|
||||||
require_sesskey();
|
require_sesskey();
|
||||||
|
|
|
@ -3193,7 +3193,7 @@ class core_course_courselib_testcase extends advanced_testcase {
|
||||||
$this->assertFalse($adminoptions->outcomes);
|
$this->assertFalse($adminoptions->outcomes);
|
||||||
$this->assertTrue($adminoptions->badges);
|
$this->assertTrue($adminoptions->badges);
|
||||||
$this->assertTrue($adminoptions->import);
|
$this->assertTrue($adminoptions->import);
|
||||||
$this->assertTrue($adminoptions->publish);
|
$this->assertFalse($adminoptions->publish);
|
||||||
$this->assertTrue($adminoptions->reset);
|
$this->assertTrue($adminoptions->reset);
|
||||||
$this->assertTrue($adminoptions->roles);
|
$this->assertTrue($adminoptions->roles);
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,8 @@ $string['edulevelsecondary'] = 'Secondary';
|
||||||
$string['eduleveltertiary'] = 'Tertiary';
|
$string['eduleveltertiary'] = 'Tertiary';
|
||||||
$string['emailalert'] = 'Email notifications';
|
$string['emailalert'] = 'Email notifications';
|
||||||
$string['emailalert_help'] = 'If this is enabled the hub administrator will send you emails about security issues and other important news.';
|
$string['emailalert_help'] = 'If this is enabled the hub administrator will send you emails about security issues and other important news.';
|
||||||
|
$string['enablecoursepublishing'] = "Course sharing on Moodle.net";
|
||||||
|
$string['enablecoursepublishing_help'] = "Moodle.net is our community site for sharing courses and content with other Moodle users worldwide. A course may be shared for others to enrol in (requires email-based self-registration on the site and self enrolment in the course) or as a backup file for others to download.";
|
||||||
$string['enrollable'] = 'Enrollable';
|
$string['enrollable'] = 'Enrollable';
|
||||||
$string['errorbadimageheightwidth'] = 'The image should have a maximum size of {$a->width} X {$a->height}';
|
$string['errorbadimageheightwidth'] = 'The image should have a maximum size of {$a->width} X {$a->height}';
|
||||||
$string['errorcourseinfo'] = 'An error occurred when retrieving course metadata from {$a}. Please try again to retrieve the course metadata by reloading this page later. Otherwise you can decide to continue the registration process with the following default metadata. ';
|
$string['errorcourseinfo'] = 'An error occurred when retrieving course metadata from {$a}. Please try again to retrieve the course metadata by reloading this page later. Otherwise you can decide to continue the registration process with the following default metadata. ';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue