Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 66590bd8a7
Fetching contributors…

Cannot retrieve contributors at this time

file 86 lines (69 sloc) 3.021 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
<?PHP // $Id$
       // preferences.php - user prefs for calendar

    require_once('../config.php');
    require_once($CFG->dirroot.'/calendar/lib.php');

    if (isset($SESSION->cal_course_referer)) {
        if (! $course = get_record('course', 'id', $SESSION->cal_course_referer)) {
            $course = get_site();
        }
    }

    if ($course->category) {
        require_login($course->id);
    }

/// If data submitted, then process and store.

    if ($form = data_submitted()) {
        foreach ($form as $preference => $value) {
            switch ($preference) {
                case 'timeformat':
                    if ($value != CALENDAR_TF_12 and $value != CALENDAR_TF_24) {
                        $value = '';
                    }
                    set_user_preference('calendar_timeformat', $value);
                break;
                case 'startwday':
                    $value = intval($value);
                    if ($value < 0 or $value > 6) {
                        $value = abs($value % 7);
                    }
                    set_user_preference('calendar_startwday', $value);
                break;
                case 'maxevents':
                    if (intval($value) >= 1) {
                        set_user_preference('calendar_maxevents', $value);
                    }
                break;
                case 'lookahead':
                    if (intval($value) >= 1) {
                        set_user_preference('calendar_lookahead', $value);
                    }
                break;
                case 'persistflt':
                    set_user_preference('calendar_persistflt', intval($value));
                break;
            }
        }
        redirect('view.php', get_string('changessaved'), 1);
        exit;
    }

    $site = get_site();

    $strcalendar = get_string('calendar', 'calendar');
    $strpreferences = get_string('preferences', 'calendar');

    if ($course->category) {
        $navigation = "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ->
                       <a href=\"view.php\">$strcalendar</a> -> $strpreferences";
    } else {
        $navigation = "<a href=\"view.php\">$strcalendar</a> -> $strpreferences";
    }


    print_header("$site->shortname: $strcalendar: $strpreferences", $strcalendar, $navigation,
                 '', '', true, '', user_login_string($site));


    print_heading($strpreferences);

    print_simple_box_start("center");

    $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->persistflt = get_user_preferences('calendar_persistflt', 0);

    include('./preferences.html');
    print_simple_box_end();

    print_footer($course);

?>
Something went wrong with that request. Please try again.