From 3485ecf2257bb2f9f4abb69b09227348318eff0a Mon Sep 17 00:00:00 2001 From: Kevin Wiliarty Date: Thu, 8 May 2014 12:37:13 -0400 Subject: [PATCH] MDL-45483 mod_forum: corrects values for maxattachments in forum settings --- mod/forum/db/upgrade.php | 18 ++++++++++++++++++ mod/forum/mod_form.php | 17 ++++++++++++++++- mod/forum/version.php | 2 +- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/mod/forum/db/upgrade.php b/mod/forum/db/upgrade.php index 9fbf31faea5..a9516d957e1 100644 --- a/mod/forum/db/upgrade.php +++ b/mod/forum/db/upgrade.php @@ -136,5 +136,23 @@ function xmldb_forum_upgrade($oldversion) { upgrade_mod_savepoint(true, 2014040400, 'forum'); } + if ($oldversion < 2014051201) { + + // Incorrect values that need to be replaced. + $replacements = array( + 11 => 20, + 12 => 50, + 13 => 100 + ); + + // Run the replacements. + foreach ($replacements as $old => $new) { + $DB->set_field('forum', 'maxattachments', $new, array('maxattachments' => $old)); + } + + // Forum savepoint reached. + upgrade_mod_savepoint(true, 2014051201, 'forum'); + } + return true; } diff --git a/mod/forum/mod_form.php b/mod/forum/mod_form.php index 8c6c4704c7d..f9800334e75 100644 --- a/mod/forum/mod_form.php +++ b/mod/forum/mod_form.php @@ -63,7 +63,22 @@ class mod_forum_mod_form extends moodleform_mod { $mform->addHelpButton('maxbytes', 'maxattachmentsize', 'forum'); $mform->setDefault('maxbytes', $CFG->forum_maxbytes); - $choices = array(0,1,2,3,4,5,6,7,8,9,10,20,50,100); + $choices = array( + 0 => 0, + 1 => 1, + 2 => 2, + 3 => 3, + 4 => 4, + 5 => 5, + 6 => 6, + 7 => 7, + 8 => 8, + 9 => 9, + 10 => 10, + 20 => 20, + 50 => 50, + 100 => 100 + ); $mform->addElement('select', 'maxattachments', get_string('maxattachments', 'forum'), $choices); $mform->addHelpButton('maxattachments', 'maxattachments', 'forum'); $mform->setDefault('maxattachments', $CFG->forum_maxattachments); diff --git a/mod/forum/version.php b/mod/forum/version.php index ed924b37cd0..94ae58a5943 100644 --- a/mod/forum/version.php +++ b/mod/forum/version.php @@ -24,7 +24,7 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2014051200; // The current module version (Date: YYYYMMDDXX) +$plugin->version = 2014051201; // The current module version (Date: YYYYMMDDXX) $plugin->requires = 2014050800; // Requires this Moodle version $plugin->component = 'mod_forum'; // Full name of the plugin (used for diagnostics) $plugin->cron = 60;