示例#1
0
navigation_node::override_active_url($viewurl);
$defaultlookahead = CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD;
if (isset($CFG->calendar_lookahead)) {
    $defaultlookahead = intval($CFG->calendar_lookahead);
}
$defaultmaxevents = CALENDAR_DEFAULT_UPCOMING_MAXEVENTS;
if (isset($CFG->calendar_maxevents)) {
    $defaultmaxevents = intval($CFG->calendar_maxevents);
}
$prefs = new stdClass();
$prefs->timeformat = get_user_preferences('calendar_timeformat', '');
$prefs->startwday = calendar_get_starting_weekday();
$prefs->maxevents = get_user_preferences('calendar_maxevents', $defaultmaxevents);
$prefs->lookahead = get_user_preferences('calendar_lookahead', $defaultlookahead);
$prefs->persistflt = get_user_preferences('calendar_persistflt', 0);
$form = new calendar_preferences_form($PAGE->url);
$form->set_data($prefs);
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 = '';
        }
        set_user_preference('calendar_timeformat', $data->timeformat);
        $data->startwday = intval($data->startwday);
        if ($data->startwday < 0 || $data->startwday > 6) {
            $data->startwday = abs($data->startwday % 7);
        }
        set_user_preference('calendar_startwday', $data->startwday);
navigation_node::override_active_url($viewurl);
$defaultlookahead = CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD;
if (isset($CFG->calendar_lookahead)) {
    $defaultlookahead = intval($CFG->calendar_lookahead);
}
$defaultmaxevents = CALENDAR_DEFAULT_UPCOMING_MAXEVENTS;
if (isset($CFG->calendar_maxevents)) {
    $defaultmaxevents = intval($CFG->calendar_maxevents);
}
$prefs = new stdClass();
$prefs->timeformat = get_user_preferences('calendar_timeformat', '');
$prefs->startwday = get_user_preferences('calendar_startwday', calendar_get_starting_weekday());
$prefs->maxevents = get_user_preferences('calendar_maxevents', $defaultmaxevents);
$prefs->lookahead = get_user_preferences('calendar_lookahead', $defaultlookahead);
$prefs->persistflt = get_user_preferences('calendar_persistflt', 0);
$form = new calendar_preferences_form();
$form->set_data($prefs);
if ($data = $form->get_data() && confirm_sesskey()) {
    if ($data->timeformat != CALENDAR_TF_12 && $data->timeformat != CALENDAR_TF_24) {
        $data->timeformat = '';
    }
    set_user_preference('calendar_timeformat', $data->timeformat);
    $data->startwday = intval($data->startwday);
    if ($data->startwday < 0 || $data->startwday > 6) {
        $data->startwday = abs($data->startwday % 7);
    }
    set_user_preference('calendar_startwday', $data->startwday);
    if (intval($data->maxevents) >= 1) {
        set_user_preference('calendar_maxevents', $data->maxevents);
    }
    if (intval($data->lookahead) >= 1) {