Permalink
Browse files

Merge branch 'wip-MDL-59377-32-3' of git://github.com/marinaglancy/mo…

…odle into MOODLE_32_STABLE
  • Loading branch information...
dmonllao committed Jul 17, 2017
2 parents 5ed5e26 + f7b3577 commit a419a8c997f26ea0629008375e88dda7fc96a002
Showing with 35 additions and 4 deletions.
  1. +12 −1 lib/filelib.php
  2. +12 −1 mod/label/db/upgrade.php
  3. +4 −0 mod/label/mod_form.php
  4. +6 −1 mod/label/tests/generator/lib.php
  5. +1 −1 mod/label/version.php
@@ -4609,7 +4609,18 @@ function file_pluginfile($relativepath, $forcedownload, $preview = null) {
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->availableinfo) {
// 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 v2.8.0 release upgrade line.
// Put any upgrade step following this.
@@ -62,5 +62,16 @@ function xmldb_label_upgrade($oldversion) {
// Automatically generated Moodle v3.2.0 release upgrade line.
// Put any upgrade step following this.
if ($oldversion < 2016120501) {
// 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, 2016120501, 'label');
}
return true;
}
@@ -36,6 +36,10 @@ function definition() {
$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 @@
* @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 = 2016120500; // The current module version (Date: YYYYMMDDXX)
$plugin->version = 2016120501; // The current module version (Date: YYYYMMDDXX)
$plugin->requires = 2016112900; // Requires this Moodle version
$plugin->component = 'mod_label'; // Full name of the plugin (used for diagnostics)
$plugin->cron = 0;

0 comments on commit a419a8c

Please sign in to comment.