MDl-47104 Calendar: Make 'calendar_lookahead' more flexible

This commit is contained in:
Stephen Bourget 2015-01-27 14:53:48 -05:00 committed by Eloy Lafuente (stronk7)
parent 5cb440f936
commit 5bc12ca265
4 changed files with 44 additions and 6 deletions

View File

@ -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;

View File

@ -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';

View File

@ -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;
}

View File

@ -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.