add page heading
[moodle.git] / calendar / preferences.php
CommitLineData
93c91ee4 1<?php
7423f116 2
93c91ee4 3// preferences.php - user prefs for calendar
7423f116 4
93c91ee4 5require_once('../config.php');
6require_once($CFG->dirroot.'/calendar/lib.php');
7423f116 7
93c91ee4 8if (isset($SESSION->cal_course_referer)) {
9 if (! $course = $DB->get_record('course', array('id'=>$SESSION->cal_course_referer))) {
10 $course = get_site();
7423f116 11 }
93c91ee4 12}
13
a6855934 14$PAGE->set_url('/calendar/preferences.php');
93c91ee4 15
16if ($course->id != SITEID) {
17 require_login($course->id);
18}
19// Initialize the session variables
20calendar_session_vars();
73c24ef8 21
1e1ff33b 22/// If data submitted, then process and store.
23
19c795b8 24if ($form = data_submitted() and confirm_sesskey()) {
93c91ee4 25 foreach ($form as $preference => $value) {
26 switch ($preference) {
27 case 'timeformat':
28 if ($value != CALENDAR_TF_12 and $value != CALENDAR_TF_24) {
29 $value = '';
30 }
31 set_user_preference('calendar_timeformat', $value);
32 break;
33 case 'startwday':
34 $value = intval($value);
35 if ($value < 0 or $value > 6) {
36 $value = abs($value % 7);
37 }
38 set_user_preference('calendar_startwday', $value);
39 break;
40 case 'maxevents':
41 if (intval($value) >= 1) {
42 set_user_preference('calendar_maxevents', $value);
43 }
44 break;
45 case 'lookahead':
46 if (intval($value) >= 1) {
47 set_user_preference('calendar_lookahead', $value);
48 }
49 break;
50 case 'persistflt':
51 set_user_preference('calendar_persistflt', intval($value));
52 break;
7423f116 53 }
7423f116 54 }
93c91ee4 55 redirect('view.php?course='.$course->id, get_string('changessaved'), 1);
56 exit;
57}
7423f116 58
93c91ee4 59$site = get_site();
7423f116 60
93c91ee4 61$strcalendar = get_string('calendar', 'calendar');
62$strpreferences = get_string('preferences', 'calendar');
7423f116 63
93c91ee4 64if ($course->id != SITEID) {
a6855934 65 $PAGE->navbar-add($course->shortname, new moodle_url('/course/view.php', array('id'=>$course->id)));
93c91ee4 66}
a6855934 67$PAGE->navbar->add($strpreferences, new moodle_url('/calendar/view.php'));
7423f116 68
93c91ee4 69$PAGE->set_title("$site->shortname: $strcalendar: $strpreferences");
bd08a24a 70$PAGE->set_heading($COURSE->fullname);
7423f116 71
93c91ee4 72echo $OUTPUT->header();
7423f116 73
93c91ee4 74echo $OUTPUT->heading($strpreferences);
7423f116 75
93c91ee4 76echo $OUTPUT->box_start('generalbox boxaligncenter');
7423f116 77
93c91ee4 78$prefs->timeformat = get_user_preferences('calendar_timeformat', '');
76d9df3f 79$prefs->startwday = get_user_preferences('calendar_startwday', calendar_get_starting_weekday());
93c91ee4 80$prefs->maxevents = get_user_preferences('calendar_maxevents', CALENDAR_UPCOMING_MAXEVENTS);
81$prefs->lookahead = get_user_preferences('calendar_lookahead', CALENDAR_UPCOMING_DAYS);
82$prefs->persistflt = get_user_preferences('calendar_persistflt', 0);
7423f116 83
93c91ee4 84include('./preferences.html');
85echo $OUTPUT->box_end();
7423f116 86
93c91ee4 87echo $OUTPUT->footer();