From 7d80ee44554bea0bdf7b37d10d4af898fed3ecb8 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 b189aef2ded..8cc2bee8d96 100644 --- a/mod/forum/db/upgrade.php +++ b/mod/forum/db/upgrade.php @@ -112,5 +112,23 @@ function xmldb_forum_upgrade($oldversion) { // Moodle v2.6.0 release upgrade line. // Put any upgrade step following this. + if ($oldversion < 2013110501) { + + // 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, 2013110501, 'forum'); + } + return true; } diff --git a/mod/forum/mod_form.php b/mod/forum/mod_form.php index 4003cc4537c..87dc0b792d5 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 de7944d8fc1..8f598a2a79c 100644 --- a/mod/forum/version.php +++ b/mod/forum/version.php @@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die(); -$module->version = 2013110500; // The current module version (Date: YYYYMMDDXX) +$module->version = 2013110501; // The current module version (Date: YYYYMMDDXX) $module->requires = 2013110500; // Requires this Moodle version $module->component = 'mod_forum'; // Full name of the plugin (used for diagnostics) $module->cron = 60;