Automatic installer.php lang files by installer_builder (20070726)
[moodle-linuxchix.git] / calendar / preferences.php
blob048fb99974360484415c5ee1239d9d72468e2010
1 <?PHP // $Id$
2 // preferences.php - user prefs for calendar
4 require_once('../config.php');
5 require_once($CFG->dirroot.'/calendar/lib.php');
7 if (isset($SESSION->cal_course_referer)) {
8 if (! $course = get_record('course', 'id', $SESSION->cal_course_referer)) {
9 $course = get_site();
13 if ($course->id != SITEID) {
14 require_login($course->id);
16 // Initialize the session variables
17 calendar_session_vars();
19 /// If data submitted, then process and store.
21 if ($form = data_submitted()) {
22 foreach ($form as $preference => $value) {
23 switch ($preference) {
24 case 'timeformat':
25 if ($value != CALENDAR_TF_12 and $value != CALENDAR_TF_24) {
26 $value = '';
28 set_user_preference('calendar_timeformat', $value);
29 break;
30 case 'startwday':
31 $value = intval($value);
32 if ($value < 0 or $value > 6) {
33 $value = abs($value % 7);
35 set_user_preference('calendar_startwday', $value);
36 break;
37 case 'maxevents':
38 if (intval($value) >= 1) {
39 set_user_preference('calendar_maxevents', $value);
41 break;
42 case 'lookahead':
43 if (intval($value) >= 1) {
44 set_user_preference('calendar_lookahead', $value);
46 break;
47 case 'persistflt':
48 set_user_preference('calendar_persistflt', intval($value));
49 break;
52 redirect('view.php', get_string('changessaved'), 1);
53 exit;
56 $site = get_site();
58 $strcalendar = get_string('calendar', 'calendar');
59 $strpreferences = get_string('preferences', 'calendar');
61 if ($course->id != SITEID) {
62 $navigation = "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ->
63 <a href=\"view.php\">$strcalendar</a> -> $strpreferences";
64 } else {
65 $navigation = "<a href=\"view.php\">$strcalendar</a> -> $strpreferences";
69 print_header("$site->shortname: $strcalendar: $strpreferences", $strcalendar, $navigation,
70 '', '', true, '', user_login_string($site));
73 print_heading($strpreferences);
75 print_simple_box_start("center");
77 $prefs->timeformat = get_user_preferences('calendar_timeformat', '');
78 $prefs->startwday = get_user_preferences('calendar_startwday', CALENDAR_STARTING_WEEKDAY);
79 $prefs->maxevents = get_user_preferences('calendar_maxevents', CALENDAR_UPCOMING_MAXEVENTS);
80 $prefs->lookahead = get_user_preferences('calendar_lookahead', CALENDAR_UPCOMING_DAYS);
81 $prefs->persistflt = get_user_preferences('calendar_persistflt', 0);
83 include('./preferences.html');
84 print_simple_box_end();
86 print_footer($course);