Permalink
Browse files

MDL-28407 Fixed up calendar preferences form handling

  • Loading branch information...
1 parent 80eb52c commit 1ad4fb6f127698a87e2be9da1997675ce64d11a3 Sam Hemelryk committed Jul 29, 2011
Showing with 7 additions and 4 deletions.
  1. +7 −4 calendar/preferences.php
View
11 calendar/preferences.php
@@ -9,7 +9,7 @@
$courseid = required_param('course', PARAM_INT);
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
-$PAGE->set_url('/calendar/preferences.php', array('id' => $courseid));
+$PAGE->set_url(new moodle_url('/calendar/preferences.php', array('course' => $courseid)));
$PAGE->set_pagelayout('standard');
require_login($course);
@@ -37,10 +37,13 @@
$prefs->lookahead = get_user_preferences('calendar_lookahead', $defaultlookahead);
$prefs->persistflt = get_user_preferences('calendar_persistflt', 0);
-$form = new calendar_preferences_form();
+$form = new calendar_preferences_form($PAGE->url);
$form->set_data($prefs);
-if ($data = $form->get_data() && confirm_sesskey()) {
+if ($form->is_cancelled()) {
+ redirect($viewurl);
+} else if ($form->is_submitted() && $form->is_validated() && confirm_sesskey()) {
+ $data = $form->get_data();
if ($data->timeformat != CALENDAR_TF_12 && $data->timeformat != CALENDAR_TF_24) {
$data->timeformat = '';
}
@@ -68,7 +71,7 @@
$strcalendar = get_string('calendar', 'calendar');
$strpreferences = get_string('calendarpreferences', 'calendar');
-$PAGE->navbar->add($strpreferences, new moodle_url('/calendar/view.php'));
+$PAGE->navbar->add($strpreferences);
$PAGE->set_pagelayout('admin');
$PAGE->set_title("$course->shortname: $strcalendar: $strpreferences");
$PAGE->set_heading($course->fullname);

0 comments on commit 1ad4fb6

Please sign in to comment.