From 86f092d25efe8d57d2731e12fed6d3407de764fe Mon Sep 17 00:00:00 2001 From: defacer Date: Wed, 15 Dec 2004 07:14:41 +0000 Subject: [PATCH] New "Calendar" section in Admin -> Configuration. Includes preliminary support for DST! Includes "admin sees all events or only own?" setting (bug 1972) WARNING: Modified moodlelib.php to explicitly specify NOT-DST when calling mktime() and gmmktime(). This is essential since we don't want PHP to second-guess us for the DST matters, but... it may affect existing code? --- admin/calendar.html | 49 ++++++++ admin/calendar.php | 69 +++++++++++ admin/configure.php | 2 + admin/dst.html | 62 ++++++++++ admin/dst.php | 243 ++++++++++++++++++++++++++++++++++++++ admin/dst_edit.html | 66 +++++++++++ admin/index.php | 2 + calendar/lib.php | 129 +++++++++++++++++++- calendar/preferences.html | 32 +++++ calendar/preferences.php | 15 ++- lang/en/admin.php | 22 +++- lang/en/calendar.php | 22 ++++ lib/db/mysql.php | 24 ++++ lib/moodlelib.php | 4 +- theme/standard/styles.php | 14 ++- version.php | 2 +- 16 files changed, 742 insertions(+), 15 deletions(-) create mode 100644 admin/calendar.html create mode 100644 admin/calendar.php create mode 100644 admin/dst.html create mode 100644 admin/dst.php create mode 100644 admin/dst_edit.html diff --git a/admin/calendar.html b/admin/calendar.html new file mode 100644 index 0000000000..d1b83d651d --- /dev/null +++ b/admin/calendar.html @@ -0,0 +1,49 @@ + +
+

+ +
+ + + + + + + + + + + + + + + + + + +
adminseesall: + +
dstforusers: + +
+ + calendar_dstforusers)) echo 'checked="checked"';?> /> + +
+
+ calendar_dstforusers)) echo 'checked="checked"';?> /> + calendar_dstforusers) ? 0 : $CFG->calendar_dstforusers), get_string('choose').'...', 'form.dstradio2.checked=\'checked\''); ?> + +
+ +
managedstpresets: + +
+ + +
+ +
diff --git a/admin/calendar.php b/admin/calendar.php new file mode 100644 index 0000000000..69353561fa --- /dev/null +++ b/admin/calendar.php @@ -0,0 +1,69 @@ +shortname: $strcalendarsettings", "$site->fullname", + "$stradministration -> ". + "$strconfiguration -> $strcalendarsettings"); + + print_heading($strcalendarsettings); + + +/// If data submitted, process and store + + if(confirm_sesskey() && $form = data_submitted()) { + if(isset($form->mode_dst)) { + // Move to DST presets configuration + redirect('dst.php?sesskey='.$USER->sesskey); + die(); + } + // Normal configuration, just save the variables + if(isset($form->adminseesallcourses)) { + set_config('calendar_adminseesall', intval($form->adminseesallcourses) != 0); + unset($SESSION->cal_courses_shown); + } + if(isset($form->dstforusers)) { + if($form->dstforusers == 'force') { + $preset = optional_param('dstpreset', 0, PARAM_INT); + } + else { + $preset = 0; + } + set_config('calendar_dstforusers', $preset); + } + } + + $presets = get_records('dst_preset'); + if(!empty($presets)) { + foreach($presets as $id => $preset) { + $presets[$id] = $preset->name; + } + } + +/// Main display starts here + + print_simple_box_start('center', '100%', $THEME->cellheading); + include('./calendar.html'); + print_simple_box_end(); + + print_footer(); + +?> diff --git a/admin/configure.php b/admin/configure.php index 9c9011ee59..2f4f74ce6d 100644 --- a/admin/configure.php +++ b/admin/configure.php @@ -43,6 +43,8 @@ $table->data[]= array("sesskey\">". get_string('editorsettings') ."", get_string('adminhelpeditorsettings')); + $table->data[]= array("sesskey\">". get_string('calendarsettings', 'admin') ."", + get_string('helpcalendarsettings', 'admin')); print_table($table); diff --git a/admin/dst.html b/admin/dst.html new file mode 100644 index 0000000000..db1d9dd435 --- /dev/null +++ b/admin/dst.html @@ -0,0 +1,62 @@ +
+

+ +
+ + + + + + + +
+
+ '; + foreach($presets as $id => $preset) { + echo ''; + } + echo ''; + } + else { + echo get_string('emptydstlist', 'admin'); + } + ?> +
+
+ +
+ + /> + /> +
+
+
+ +
+ diff --git a/admin/dst.php b/admin/dst.php new file mode 100644 index 0000000000..8e1b9de2ca --- /dev/null +++ b/admin/dst.php @@ -0,0 +1,243 @@ +shortname: $strcalendardstpresets", "$site->fullname", + "$stradministration -> ". + "$strconfiguration -> ". + "sesskey\">$strcalendarsettings -> $strcalendardstpresets"); + + $mode = ''; + $form = false; + + // $action may instruct us to do something first, then go on to display the preset list + $action = optional_param('action', ''); + + switch($action) { + case 'delete': + $presetid = optional_param('preset', 0, PARAM_INT); + $preset = get_record('dst_preset', 'id', $presetid); + if($preset !== false) { + // First delete the preset + delete_records('dst_preset', 'id', $presetid); + // And then disable DST for all users who had selected that preset + execute_sql('UPDATE '.$CFG->prefix.'user_preferences SET value = 0 WHERE name = \'calendar_dstpreset\' AND value = '.$presetid, false); + } + break; + } + + + // $mode, on the other hand, may make us do something INSTEAD of displaying the preset list + if($form = data_submitted()) { + if(isset($form->result_cancel)) { + $mode = ''; + } + else if(isset($form->mode_return)) { + redirect('calendar.php?sesskey='.$USER->sesskey); + die(); + } + else if(isset($form->mode_delete)) { + $mode = 'delete'; + } + else if(isset($form->mode_editform)) { + // Present add/edit form + $mode = 'edit'; + } + else if(isset($form->mode_edit)) { + // Fetch data for existing preset and display edit form + $presetid = optional_param('preset', 0, PARAM_INT); + $preset = get_record('dst_preset', 'id', $presetid); + if($preset !== false) { + // This variable used inside dst_edit.html + $weekdays = array( + -1 => get_string('day', 'calendar'), + 0 => get_string('sunday', 'calendar'), + 1 => get_string('monday', 'calendar'), + 2 => get_string('tuesday', 'calendar'), + 3 => get_string('wednesday', 'calendar'), + 4 => get_string('thursday', 'calendar'), + 5 => get_string('friday', 'calendar'), + 6 => get_string('saturday', 'calendar') + ); + + $preset->apply_offset_sign = ($preset->apply_offset >= 0 ? 1 : -1); + $preset->apply_offset = abs($preset->apply_offset); + list($preset->activate_hour, $preset->activate_minute) = explode(':', $preset->activate_time); + list($preset->deactivate_hour, $preset->deactivate_minute) = explode(':', $preset->deactivate_time); + $mode = 'continueedit'; + } + else { + $mode = ''; + } + } + else if(isset($form->mode_add)) { + // Move to adding a new dst + $preset = new stdClass; + $preset->id = 0; + $mode = 'add'; + } + // Normal configuration, just save the variables + else if(isset($form->adminseesallcourses)) { + set_config('calendar_adminseesall', intval($form->adminseesallcourses) != 0); + unset($SESSION->cal_courses_shown); + } + } + + switch($mode) { + case 'delete': + $presetid = optional_param('preset', 0, PARAM_INT); + $preset = get_record('dst_preset', 'id', $presetid); + if($preset !== false) { + print_heading(get_string('confirmation', 'admin')); + if(!empty($CFG->calendar_dstforusers) && $preset->id == $CFG->calendar_dstforusers) { + notice_yesno(get_string('confirmdeletedstdefault', 'admin', $preset->name), 'dst.php?action=delete&preset='.$presetid.'&sesskey='.$USER->sesskey, 'dst.php?sesskey='.$USER->sesskey); + } + else { + notice_yesno(get_string('confirmdeletedst', 'admin', $preset->name), 'dst.php?action=delete&preset='.$presetid.'&sesskey='.$USER->sesskey, 'dst.php?sesskey='.$USER->sesskey); + } + } + else { + $mode = ''; + } + break; + case 'edit': + // These variables are used inside dst_edit.html + $preset = new stdClass; + $preset->id = optional_param('preset', 0, PARAM_INT); + case 'add': + $preset->name = optional_param('name', get_string('dstdefaultpresetname', 'calendar')); + $preset->apply_offset = abs(optional_param('apply_offset', 60, PARAM_INT)); + $preset->apply_offset_sign = min(max(optional_param('apply_offset_sign', 1, PARAM_INT), -1), 1); + $preset->activate_index = min(max(optional_param('activate_index', 1, PARAM_INT), -1), 1); + $preset->activate_day = min(max(optional_param('activate_day', 0, PARAM_INT), -1), 6); + $preset->activate_month = min(max(optional_param('activate_month', 1, PARAM_INT), 1), 12); + $preset->activate_hour = min(max(optional_param('activate_hour', 3, PARAM_INT), 0), 23); + $preset->activate_minute = min(max(optional_param('activate_minute', 0, PARAM_INT), 0), 59); + $preset->deactivate_index = min(max(optional_param('deactivate_index', 1, PARAM_INT), -1), 1); + $preset->deactivate_day = min(max(optional_param('deactivate_day', 0, PARAM_INT), -1), 6); + $preset->deactivate_month = min(max(optional_param('deactivate_month', 2, PARAM_INT), 1), 12); + $preset->deactivate_hour = min(max(optional_param('deactivate_hour', 3, PARAM_INT), 0), 23); + $preset->deactivate_minute = min(max(optional_param('deactivate_minute', 0, PARAM_INT), 0), 59); + + $preset->apply_offset *= $preset->apply_offset_sign; + case 'continueedit': + if(!empty($form->result_ok)) { + // Complete the transaction + + // Validation here + $errors = array(); + if(empty($name)) { + $errors[] = get_string('errordstpresetnameempty', 'admin'); + } + else { + $other = get_record('dst_preset', 'name', $preset->name); + if($preset->id != $other->id) { + $errors[] = get_string('errordstpresetnameexists', 'admin'); + } + } + if($preset->activate_month >= $preset->deactivate_month) { + $errors[] = get_string('errordstpresetactivateearlier', 'admin'); + } + + // Are we error-free? + if(empty($errors)) { + // Calculate the last/next/current_offset variables + // WARNING: TODO: BUG: To calculate the timestamps, we are taking into account + // the admin's own DST setting. That means that if the admin changes his own DST + // setting and with this change his effective DST status changes, the timestamps + // will NOT be calculated correctly. Thus, the whole DST setting will be wrong + // for ALL USERS! + $preset = calendar_dst_update_preset($preset); + print_object("record is:"); + print_object($preset); + print_object('The last change time (DST) was: '.strftime('%A, %d %B %Y %H:%M', $preset->last_change)); + print_object('The last change time (user) was: '.userdate($preset->last_change)); + print_object('The next change time (DST) is : '.strftime('%A, %d %B %Y %H:%M', $preset->next_change)); + print_object('The next change time (user) is : '.userdate($preset->next_change)); + + // Write it! + if($preset->id) { + print_object("UPDATED!"); + update_record('dst_preset', $preset); + } + else { + print_object("INSERT!"); + insert_record('dst_preset', $preset); + } + echo '
'.get_string('therewereerrors', 'admin').':
'; + echo ''; + print_simple_box_end(); + } + } + + // Show the edit screen + $weekdays = array( + -1 => get_string('day', 'calendar'), + 0 => get_string('sunday', 'calendar'), + 1 => get_string('monday', 'calendar'), + 2 => get_string('tuesday', 'calendar'), + 3 => get_string('wednesday', 'calendar'), + 4 => get_string('thursday', 'calendar'), + 5 => get_string('friday', 'calendar'), + 6 => get_string('saturday', 'calendar') + ); + print_heading(get_string('editingdstpreset', 'admin')); + print_simple_box_start('center', '70%', $THEME->cellheading); + include('./dst_edit.html'); + print_simple_box_end(); + + break; + } + + + // Default behavior here + if(empty($mode)) { + $presets = get_records('dst_preset', '', '', 'name'); + + if(!empty($presets)) { + $presetdescriptions = array(); + foreach($presets as $id => $preset) { + $presetdescriptions[$id] = calendar_human_readable_dst($preset); + } + } + print_heading($strcalendardstpresets); + print_simple_box_start('center', '70%', $THEME->cellheading); + include('./dst.html'); + print_simple_box_end(); + } + + print_footer(); + +?> diff --git a/admin/dst_edit.html b/admin/dst_edit.html new file mode 100644 index 0000000000..1ec12d5153 --- /dev/null +++ b/admin/dst_edit.html @@ -0,0 +1,66 @@ +
+

+ + + +

+ +
+ + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + get_string('first', 'calendar'), '-1' => get_string('last', 'calendar')), 'activate_index', $preset->activate_index, ''); ?> + activate_day, ''); ?> + activate_month); ?> + activate_hour, $preset->activate_minute), 30); ?> + activate_hour; ?> +
+ + + + get_string('timeforward', 'calendar'), '-1' => get_string('timerewind', 'calendar')), 'apply_offset_sign', $preset->apply_offset_sign, ''); ?> + + + +
+ + + + get_string('first', 'calendar'), '-1' => get_string('last', 'calendar')), 'deactivate_index', $preset->deactivate_index, ''); ?> + deactivate_day, ''); ?> + deactivate_month); ?> + deactivate_hour, $preset->deactivate_minute), 30); ?> +
+ +
+ + +
+ +
+ +
diff --git a/admin/index.php b/admin/index.php index 25d618c785..46a9f67fb8 100644 --- a/admin/index.php +++ b/admin/index.php @@ -305,6 +305,8 @@ } $configdata .= " 
sesskey\">". get_string("editorsettings") ." - ". get_string("adminhelpeditorsettings")."
"; + $configdata .= " sesskey\">". get_string('calendarsettings', 'admin') ." - ". + get_string('helpcalendarsettings', 'admin')."
"; $table->data[] = array("".get_string("configuration")."", $configdata); diff --git a/calendar/lib.php b/calendar/lib.php index 3813f67517..c74a5e7015 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -1059,8 +1059,10 @@ function calendar_get_default_courses($ignoreref = false) { $courses = array(); if(!empty($USER->id) && isadmin($USER->id)) { - $courses = get_records_sql('SELECT id, 1 FROM '.$CFG->prefix.'course'); - return $courses; + if(!empty($CFG->calendar_adminseesall)) { + $courses = get_records_sql('SELECT id, 1 FROM '.$CFG->prefix.'course'); + return $courses; + } } if(isset($USER->student) && is_array($USER->student)) { $courses = $USER->student; @@ -1073,9 +1075,10 @@ function calendar_get_default_courses($ignoreref = false) { function calendar_preferences_array() { return array( - 'startwday' => get_string('pref_startwday', 'calendar'), - 'maxevents' => get_string('pref_maxevents', 'calendar'), - 'lookahead' => get_string('pref_lookahead', 'calendar'), + 'dstpreset' => get_string('pref_dstpreset', 'calendar'), + 'startwday' => get_string('pref_startwday', 'calendar'), + 'maxevents' => get_string('pref_maxevents', 'calendar'), + 'lookahead' => get_string('pref_lookahead', 'calendar'), 'timeformat' => get_string('pref_timeformat', 'calendar'), ); } @@ -1155,4 +1158,120 @@ function calendar_format_event_time($event, $now, $morehref, $usecommonwords = t return $eventtime; } +function calendar_human_readable_dst($preset) { + $weekdays = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'); + + $options = new stdClass; + $options->activate_index = ($preset->activate_index == -1) ? get_string('last', 'calendar') : get_string('nth', 'calendar', $preset->activate_index); + $options->activate_weekday = ($preset->activate_day < 0) ? get_string('day', 'calendar') : get_string($weekdays[$preset->activate_day], 'calendar'); + $options->activate_month = date('F', mktime(0, 0, 0, $preset->activate_month, 1, 2000)); + $options->offset = abs($preset->apply_offset); + $options->direction = $preset->apply_offset > 0 ? get_string('timeforward', 'calendar') : get_string('timerewind', 'calendar'); + $options->deactivate_index = ($preset->deactivate_index == -1) ? get_string('last', 'calendar') : get_string('nth', 'calendar', $preset->deactivate_index); + $options->deactivate_weekday = ($preset->deactivate_day < 0) ? get_string('day', 'calendar') : get_string($weekdays[$preset->deactivate_day], 'calendar'); + $options->deactivate_month = date('F', mktime(0, 0, 0, $preset->deactivate_month, 1, 2000)); + + return get_string('dsthumanreadable', 'calendar', $options); + //print_string('dstonthe', 'calendar') + //return 'ID '.$preset->id.': DST is activated on the X of X.'; +} + +// "Find the ($index as int, 1st, 2nd, etc, -1 = last) ($weekday as int, sunday = 0) in ($month) of ($year)" +function calendar_find_day_in_month($index, $weekday, $month, $year) { + if($weekday == -1) { + // Any day of the week will do + if($index == -1) { + // Last day of that month + $targetday = calendar_days_in_month($month, $year); + } + else { + // Not last day; a straight index value + $targetday = $index; + } + } + else { + // We need to calculate when exactly that weekday is + // Fist of all, what day of the week is the first of that month? + + // Convert to timestamp and back to readable representation using the server's timezone; + // this should be correct regardless of what the user's timezone is. + $firstmonthweekday = strftime('%w', mktime(0, 0, 0, $month, 1, $year)); +//PJ print_object('The first of '.$month.'/'.$year.' is '.$firstmonthweekday); + $daysinmonth = calendar_days_in_month($month, $year); + + // This is the first such-named weekday of the month + $targetday = 1 + $weekday - $firstmonthweekday; + if($targetday <= 0) { + $targetday += 7; + } +//PJ print_object('The FIRST SPECIFIC '.$weekday.' of '.$month.'/'.$year.' is on '.$targetday); + + if($index == -1) { + // To find the LAST such weekday, just keep adding 7 days at a time + while($targetday + 7 <= $daysinmonth) { + $targetday += 7; + } +//PJ print_object('The LAST SPECIFIC '.$weekday.' of '.$month.'/'.$year.' is on '.$targetday); + } + else { + // For a specific week, add as many weeks as required + $targetday += $index > 1 ? ($index - 1) * 7 : 0; + } + } + + return $targetday; +} + +function calendar_dst_update_preset($dstpreset) { + $now = time(); + + // What's the date according to our user right now? + $date = usergetdate($now); + + $monthdayactivate = calendar_find_day_in_month($dstpreset->activate_index, $dstpreset->activate_day, $dstpreset->activate_month, $date['year']); + $monthdaydeactivate = calendar_find_day_in_month($dstpreset->deactivate_index, $dstpreset->deactivate_day, $dstpreset->deactivate_month, $date['year']); + + $timeactivate = make_timestamp($date['year'], $dstpreset->activate_month, $monthdayactivate, $dstpreset->activate_hour, $dstpreset->activate_minute); + $timedeactivate = make_timestamp($date['year'], $dstpreset->deactivate_month, $monthdaydeactivate, $dstpreset->deactivate_hour, $dstpreset->deactivate_minute); + + // Great... let's see where exactly we are now. + if($now < $timeactivate) { + print_object("<<"); + // DST has not been turned on this year + $dstpreset->next_change = $timeactivate; + // For the last change, we need to fetch the previous year's DST deactivation timestamp + $monthdaydeactivate = calendar_find_day_in_month($dstpreset->deactivate_index, $dstpreset->deactivate_day, $dstpreset->deactivate_month, $date['year'] - 1); + $timedeactivate = make_timestamp($date['year'] - 1, $dstpreset->deactivate_month, $monthdaydeactivate, $dstpreset->deactivate_hour, $dstpreset->deactivate_minute); + $dstpreset->last_change = $timedeactivate; + } + else if($now < $timedeactivate) { + print_object("<>"); + // DST is on for this year right now + $dstpreset->last_change = $timeactivate; + $dstpreset->next_change = $timedeactivate; + } + else { + print_object(">>"); + // DST has already been turned off; we are nearing the end of the year + $dstpreset->last_change = $timedeactivate; + // For the next change, we need to fetch next year's DST activation timestamp + $monthdayactivate = calendar_find_day_in_month($dstpreset->activate_index, $dstpreset->activate_day, $dstpreset->activate_month, $date['year'] + 1); + $timeactivate = make_timestamp($date['year'] + 1, $dstpreset->activate_month, $monthdayactivate, $dstpreset->activate_hour, $dstpreset->activate_minute); + $dstpreset->next_change = $timeactivate; + } + + return $dstpreset; +} + +function calendar_print_month_selector($name, $selected) { + + $months = array(); + + for ($i=1; $i<=12; $i++) { + $months[$i] = userdate(gmmktime(12, 0, 0, $i, 1, 2000), '%B'); + } + + choose_from_menu($months, $name, $selected, ''); +} + ?> diff --git a/calendar/preferences.html b/calendar/preferences.html index 1dfc6c0389..f0bb8e4fc6 100644 --- a/calendar/preferences.html +++ b/calendar/preferences.html @@ -1,6 +1,38 @@
+ + + + + +
: + calendar_dstforusers)) { + $presets = get_records('dst_preset'); + $presetarray = array('0' => get_string('notusingdst', 'calendar')); + if(!empty($presets)) { + foreach($presets as $preset) { + $presetarray[$preset->id] = $preset->name; + } + } + choose_from_menu ($presetarray, 'dstpreset', $prefs->dstpreset, ''); + } + else { + $preset = get_record('dst_preset', 'id', $CFG->calendar_dstforusers); + echo ''.$preset->name.''; + } + ?> + + calendar_dstforusers)) { + print_string('explain_dstpreset', 'calendar'); + } + else { + print_string('explain_dstpresetforced', 'calendar'); + } + ?> +
: diff --git a/calendar/preferences.php b/calendar/preferences.php index dc082ce54e..a44a1e9eba 100644 --- a/calendar/preferences.php +++ b/calendar/preferences.php @@ -20,6 +20,12 @@ print_header(); foreach ($form as $preference => $value) { switch ($preference) { + case 'dstpreset': + $value = intval($value); + if($value == 0 || get_record('dst_preset', 'id', $value)) { + set_user_preference('calendar_dstpreset', $value); + } + break; case 'timeformat': if ($value != CALENDAR_TF_12 and $value != CALENDAR_TF_24) { $value = ''; @@ -70,12 +76,13 @@ print_simple_box_start("center", "", "$THEME->cellheading"); + $prefs->dstpreset = get_user_preferences('calendar_dstpreset', 0); $prefs->timeformat = get_user_preferences('calendar_timeformat', ''); - $prefs->startwday = get_user_preferences('calendar_startwday', CALENDAR_STARTING_WEEKDAY); - $prefs->maxevents = get_user_preferences('calendar_maxevents', CALENDAR_UPCOMING_MAXEVENTS); - $prefs->lookahead = get_user_preferences('calendar_lookahead', CALENDAR_UPCOMING_DAYS); + $prefs->startwday = get_user_preferences('calendar_startwday', CALENDAR_STARTING_WEEKDAY); + $prefs->maxevents = get_user_preferences('calendar_maxevents', CALENDAR_UPCOMING_MAXEVENTS); + $prefs->lookahead = get_user_preferences('calendar_lookahead', CALENDAR_UPCOMING_DAYS); - include("preferences.html"); + include('./preferences.html'); print_simple_box_end(); print_footer($course); diff --git a/lang/en/admin.php b/lang/en/admin.php index e53937efbf..6f672f5a76 100755 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -1,12 +1,32 @@ $a will immediately disable DST for all users of that preset. This could possibly change their perception of time without warning. Are you sure you want to continue?'; +$string['confirmdeletedstdefault'] = 'The preset named $a is being used for all users of this site! Deleting it will change their perception of time without warning. Are you sure you want to continue?'; +$string['dstisapreference'] = 'Each user can choose which preset to use'; +$string['dstisforcedto'] = 'Force all users to use'; +$string['dstpresets'] = 'DST Presets'; +$string['emptydstlist'] = 'There are currently no DST presets defined. You can add one by clicking on the Add button.'; +$string['editingdstpreset'] = 'Editing a DST preset'; +$string['errordstpresetactivateearlier'] = 'The month of activation must be earlier than the month of deactivation'; +$string['errordstpresetnameempty'] = 'The preset name cannot be empty'; +$string['errordstpresetnameexists'] = 'Another preset with that name already exists'; $string['filteruploadedfiles'] = 'Filter uploaded files'; +$string['helpadminseesall'] = 'Do admins see all calendar events or just those that apply to themselves?'; +$string['helpcalendarsettings'] = 'Configure various calendar and date/time-related aspects of Moodle'; +$string['helpdstforusers'] = 'Can each user choose his own DST settings?'; +$string['helpmanagedstpresets'] = 'Click this button to add, edit and delete the DST presets available for this site.'; +$string['managedstpresets'] = 'Manage DST Presets'; +$string['nodstpresetsexist'] = 'DST support is disabled for all users because there are no DST presets defined. You can define some presets using the button below.'; +$string['therewereerrors'] = 'There were errors in your data'; $string['upgradelogs'] = 'For full functionality, your old logs need to be upgraded. More information'; $string['upgradelogsinfo'] = 'Some changes have recently been made in the way logs are stored. To be able to view all of your old logs on a per-activity basis, your old logs need to be upgraded. Depending on your site this can take a long time (eg several hours) and can be quite taxing on the database for large sites. Once you start this process you should let it finish (by keeping the browser window open). Don\'t worry - your site will work fine for other people while the logs are being upgraded.

Do you want to upgrade your logs now?'; diff --git a/lang/en/calendar.php b/lang/en/calendar.php index cc4f3a2562..1d3076a0ea 100644 --- a/lang/en/calendar.php +++ b/lang/en/calendar.php @@ -95,4 +95,26 @@ $string['thursday'] = 'Thursday'; $string['friday'] = 'Friday'; $string['saturday'] = 'Saturday'; +$string['pref_dstpreset'] = 'Daylight Savings Time'; +$string['notusingdst'] = 'Not using DST'; +$string['dstpresetname'] = 'Preset name'; +$string['dstpresetactivated'] = 'Activation'; +$string['dstpresetdeactivated'] = 'Dectivation'; +$string['dstpresetadjusttime'] = 'Time adjustment'; + +$string['explain_dstpresetforced'] = 'The site administrator does not allow users to modify this option.'; +$string['explain_dstpreset'] = 'You can select which area to use DST settings for, if any, from the drop-down menu.'; +$string['dstdefaultpresetname'] = 'New DST Preset'; +$string['nth'] = '{$a}st'; +$string['dsthumanreadable'] = 'On the $a->activate_index $a->activate_weekday of each $a->activate_month, move the time $a->offset minutes $a->direction. This change lasts until the $a->deactivate_index $a->deactivate_weekday of $a->deactivate_month.'; +$string['dstadjusttime'] = 'Move time'; +$string['dstof'] = 'of'; +$string['dstat'] = 'at'; +$string['dstonthe'] = 'On the'; +$string['dstby'] = 'by'; +$string['day'] = 'day'; +$string['timeforward'] = 'forward'; +$string['timerewind'] = 'backwards'; +$string['first'] = 'first'; +$string['last'] = 'last'; ?> diff --git a/lib/db/mysql.php b/lib/db/mysql.php index 7b9cd84814..39571da3b4 100644 --- a/lib/db/mysql.php +++ b/lib/db/mysql.php @@ -1012,6 +1012,30 @@ function main_upgrade($oldversion=0) { if ($oldversion < 2004121400) { table_column('groups', '', 'password', 'varchar', '50', '', '', 'not null', 'description'); } + + if ($oldversion < 2004121500) { + modify_database('',"CREATE TABLE prefix_dst_preset ( + id int(10) NOT NULL auto_increment, + name char(48) default '' NOT NULL, + + apply_offset tinyint(3) default '0' NOT NULL, + + activate_index tinyint(1) default '1' NOT NULL, + activate_day tinyint(1) default '1' NOT NULL, + activate_month tinyint(2) default '1' NOT NULL, + activate_time char(5) default '03:00' NOT NULL, + + deactivate_index tinyint(1) default '1' NOT NULL, + deactivate_day tinyint(1) default '1' NOT NULL, + deactivate_month tinyint(2) default '2' NOT NULL, + deactivate_time char(5) default '03:00' NOT NULL, + + last_change int(10) default '0' NOT NULL, + next_change int(10) default '0' NOT NULL, + current_offset tinyint(3) default '0' NOT NULL, + + PRIMARY KEY (id))"); + } return $result; diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 21378475c6..57d609b6a7 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -496,9 +496,9 @@ function make_timestamp($year, $month=1, $day=1, $hour=0, $minute=0, $second=0, $timezone = get_user_timezone($timezone); if (abs($timezone) > 13) { - return mktime((int)$hour,(int)$minute,(int)$second,(int)$month,(int)$day,(int)$year); + return mktime((int)$hour,(int)$minute,(int)$second,(int)$month,(int)$day,(int)$year, 0); } else { - $time = gmmktime((int)$hour,(int)$minute,(int)$second,(int)$month,(int)$day,(int)$year); + $time = gmmktime((int)$hour,(int)$minute,(int)$second,(int)$month,(int)$day,(int)$year, 0); return usertime($time, $timezone); // This is GMT } } diff --git a/theme/standard/styles.php b/theme/standard/styles.php index 26d1384ee4..2552baeb37 100644 --- a/theme/standard/styles.php +++ b/theme/standard/styles.php @@ -694,8 +694,18 @@ A IMG { border: none; } -TABLE.formtable TD { - padding: 9px; +table.formtable td, table.formtable th { + padding: 8px; +} + +table.formtable tbody tr { + vertical-align: top; +} + +table.formtable tbody th { + text-align: right; + font-weight: bold; + background: none; } .eventfull { diff --git a/version.php b/version.php index 5db01046e7..2bffd8dcf9 100644 --- a/version.php +++ b/version.php @@ -6,7 +6,7 @@ // This is compared against the values stored in the database to determine // whether upgrades should be performed (see lib/db/*.php) - $version = 2004121400; // YYYYMMDD = date of first major branch release 1.4 + $version = 2004121500; // YYYYMMDD = date of first major branch release 1.4 // XY = increments within a single day $release = '1.5 UNSTABLE DEVELOPMENT'; // Human-friendly version name -- 2.39.5