From 5bc12ca26557a92d32cbd2635c9f3cff0cfa1e46 Mon Sep 17 00:00:00 2001 From: Stephen Bourget Date: Tue, 27 Jan 2015 14:53:48 -0500 Subject: [PATCH] MDl-47104 Calendar: Make 'calendar_lookahead' more flexible --- admin/settings/appearance.php | 23 ++++++++++++++++++----- lang/en/moodle.php | 4 ++++ lib/db/upgrade.php | 21 +++++++++++++++++++++ version.php | 2 +- 4 files changed, 44 insertions(+), 6 deletions(-) diff --git a/admin/settings/appearance.php b/admin/settings/appearance.php index 062df28711c..70c564f4057 100644 --- a/admin/settings/appearance.php +++ b/admin/settings/appearance.php @@ -75,11 +75,24 @@ mybadges,badges|/badges/mybadges.php|award', 6 => new lang_string('saturday', 'calendar') ))); $temp->add(new admin_setting_special_calendar_weekend()); - $options = array(); - for ($i=1; $i<=99; $i++) { - $options[$i] = $i; - } - $temp->add(new admin_setting_configselect('calendar_lookahead',new lang_string('configlookahead','admin'),new lang_string('helpupcominglookahead', 'admin'),21,$options)); + $options = array(365 => new lang_string('numyear', '', 1), + 270 => new lang_string('nummonths', '', 9), + 180 => new lang_string('nummonths', '', 6), + 150 => new lang_string('nummonths', '', 5), + 120 => new lang_string('nummonths', '', 4), + 90 => new lang_string('nummonths', '', 3), + 60 => new lang_string('nummonths', '', 2), + 30 => new lang_string('nummonth', '', 1), + 21 => new lang_string('numweeks', '', 3), + 14 => new lang_string('numweeks', '', 2), + 7 => new lang_string('numweek', '', 1), + 6 => new lang_string('numdays', '', 6), + 5 => new lang_string('numdays', '', 5), + 4 => new lang_string('numdays', '', 4), + 3 => new lang_string('numdays', '', 3), + 2 => new lang_string('numdays', '', 2), + 1 => new lang_string('numday', '', 1)); + $temp->add(new admin_setting_configselect('calendar_lookahead', new lang_string('configlookahead', 'admin'), new lang_string('helpupcominglookahead', 'admin'), 21, $options)); $options = array(); for ($i=1; $i<=20; $i++) { $options[$i] = $i; diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 529a654e970..1bb70c93199 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -1348,15 +1348,19 @@ $string['now'] = 'now'; $string['numattempts'] = '{$a} failed login attempt(s)'; $string['numberofcourses'] = 'Number of courses'; $string['numberweeks'] = 'Number of sections'; +$string['numday'] = '{$a} day'; $string['numdays'] = '{$a} days'; $string['numhours'] = '{$a} hours'; $string['numletters'] = '{$a} letters'; $string['numminutes'] = '{$a} minutes'; +$string['nummonth'] = '{$a} month'; $string['nummonths'] = '{$a} months'; $string['numseconds'] = '{$a} seconds'; $string['numviews'] = '{$a} views'; +$string['numweek'] = '{$a} week'; $string['numweeks'] = '{$a} weeks'; $string['numwords'] = '{$a} words'; +$string['numyear'] = '{$a} year'; $string['numyears'] = '{$a} years'; $string['ok'] = 'OK'; $string['oldpassword'] = 'Current password'; diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 1f1c8f1d13d..0019f96ca2c 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -4140,5 +4140,26 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2015012600.00); } + if ($oldversion < 2015012600.01) { + + // Convert calendar_lookahead to nearest new value. + $value = $DB->get_field('config', 'value', array('name' => 'calendar_lookahead')); + if ($value > 90) { + set_config('calendar_lookahead', '120'); + } else if ($value > 60 and $value < 90) { + set_config('calendar_lookahead', '90'); + } else if ($value > 30 and $value < 60) { + set_config('calendar_lookahead', '60'); + } else if ($value > 21 and $value < 30) { + set_config('calendar_lookahead', '30'); + } else if ($value > 14 and $value < 21) { + set_config('calendar_lookahead', '21'); + } else if ($value > 7 and $value < 14) { + set_config('calendar_lookahead', '14'); + } + + // Main savepoint reached. + upgrade_main_savepoint(true, 2015012600.01); + } return true; } diff --git a/version.php b/version.php index eced7165e55..8a44e4664fe 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2015012600.00; // YYYYMMDD = weekly release date of this DEV branch. +$version = 2015012600.01; // YYYYMMDD = weekly release date of this DEV branch. // RR = release increments - 00 in DEV branches. // .XX = incremental changes.