Merge branch 'wip-MDL-59377-master-3' of git://github.com/marinaglancy/moodle
This commit is contained in:
+12
-1
@@ -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);
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
function xmldb_label_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
// Moodle v3.1.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
@@ -56,5 +56,16 @@ function xmldb_label_upgrade($oldversion) {
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2017062800) {
|
||||
// Update all records in 'course_modules' for labels to have showdescription = 1.
|
||||
if ($modid = $DB->get_field('modules', 'id', ['name' => 'label'])) {
|
||||
$DB->execute("UPDATE {course_modules} SET showdescription = ? WHERE module = ?",
|
||||
[1, $modid]);
|
||||
}
|
||||
|
||||
// Label savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2017062800, 'label');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,10 @@ class mod_label_mod_form extends moodleform_mod {
|
||||
$mform->addElement('header', 'generalhdr', get_string('general'));
|
||||
$this->standard_intro_elements(get_string('labeltext', 'label'));
|
||||
|
||||
// Label does not add "Show description" checkbox meaning that 'intro' is always shown on the course page.
|
||||
$mform->addElement('hidden', 'showdescription', 1);
|
||||
$mform->setType('showdescription', PARAM_INT);
|
||||
|
||||
$this->standard_coursemodule_elements();
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
|
||||
@@ -35,5 +35,10 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class mod_label_generator extends testing_module_generator {
|
||||
// No additional fields in label module.
|
||||
|
||||
public function create_instance($record = null, array $options = null) {
|
||||
$record = (array)$record;
|
||||
$record['showdescription'] = 1;
|
||||
return parent::create_instance($record, $options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2017051500; // The current module version (Date: YYYYMMDDXX)
|
||||
$plugin->version = 2017062800; // The current module version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2017050500; // Requires this Moodle version
|
||||
$plugin->component = 'mod_label'; // Full name of the plugin (used for diagnostics)
|
||||
$plugin->cron = 0;
|
||||
|
||||
Reference in New Issue
Block a user