1
0
mirror of https://github.com/moodle/moodle.git synced 2025-05-11 10:45:38 +02:00

Merge branch 'MDL-65138-master' of git://github.com/lameze/moodle

This commit is contained in:
Adrian Greeve 2019-04-02 10:37:34 +08:00
commit a5b79e4b85
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'),
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->badges = !empty($CFG->enablebadges);
$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->roles = has_capability('moodle/role:switchroles', $context);
} else {

@ -45,8 +45,9 @@ $hubcourseid = required_param('hubcourseid', PARAM_INT);
//some permissions and parameters checking
$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);
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');
}

@ -39,7 +39,10 @@ $PAGE->set_pagelayout('incourse');
$PAGE->set_title(get_string('publish', 'core_hub') . ': ' . $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 (!\core\hub\registration::is_registered()) {

@ -46,7 +46,10 @@ $PAGE->set_pagelayout('incourse');
$PAGE->set_title(get_string('course') . ': ' . $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.
require_sesskey();

@ -3193,7 +3193,7 @@ class core_course_courselib_testcase extends advanced_testcase {
$this->assertFalse($adminoptions->outcomes);
$this->assertTrue($adminoptions->badges);
$this->assertTrue($adminoptions->import);
$this->assertTrue($adminoptions->publish);
$this->assertFalse($adminoptions->publish);
$this->assertTrue($adminoptions->reset);
$this->assertTrue($adminoptions->roles);
}

@ -75,6 +75,8 @@ $string['edulevelsecondary'] = 'Secondary';
$string['eduleveltertiary'] = 'Tertiary';
$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['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['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. ';