wwwroot.'/'.$CFG->admin.'/index.php'); } if(isguest()) { redirect($CFG->wwwroot.'/index.php'); } optional_variable($_GET['edit'], ''); optional_variable($_GET['commit'], 0); $knownpreference = false; // Defensive coding: let's be suspicious from the beginning $prefs = calendar_preferences_array(); // Get this now, we 'll be using it all the time if(in_array($_GET['edit'], array_keys($prefs))) { // If we know this preference, you 'll get to see the setting page $knownpreference = true; } if($_GET['commit']) { switch($_GET['edit']) { case 'startwday': $day = intval($_GET[$_GET['edit']]); if($day < 0 || $day > 6) { $day = abs($day % 7); } set_user_preference('calendar_'.$_GET['edit'], $day); break; case 'maxevents': $events = intval($_GET[$_GET['edit']]); if($events >= 1) { set_user_preference('calendar_'.$_GET['edit'], $events); } break; case 'lookahead': $days = intval($_GET[$_GET['edit']]); if($days >= 1) { set_user_preference('calendar_'.$_GET['edit'], $days); } break; } // Use this trick to get back to the preferences list after editing one $knownpreference = false; $_GET['edit'] = ''; } $firstcolumn = false; // for now $side = 175; calendar_session_vars(); $now = usergetdate(time()); $pagetitle = get_string('preferences', 'calendar'); $nav = calendar_get_link_tag(get_string('calendar', 'calendar'), $CFG->wwwroot.'/calendar/view.php?view=upcoming&', $now['mday'], $now['mon'], $now['year']); if($knownpreference) { $nav .= ' -> '.$pagetitle.' -> '.$prefs[$_GET['edit']]; } else { $nav .= ' -> '.$pagetitle; } // Let's see if we are supposed to provide a referring course link // but NOT for the front page if($SESSION->cal_course_referer > 1 && ($shortname = get_field('course', 'shortname', 'id', $SESSION->cal_course_referer)) !== false) { // If we know about the referring course, show a return link $nav = ''.$shortname.' -> '.$nav; } print_header(get_string('calendar', 'calendar').': '.$pagetitle, $site->fullname, $nav, '', '', true, '', '

'.user_login_string($site).'

'); echo calendar_overlib_html(); // Layout the whole page as three big columns. echo ''; // START: The left column echo ''; } // END: The left column // START: Middle column echo '
'; $sections = get_all_sections($site->id); if ($site->newsitems > 0 or $sections[0]->sequence or isediting($site->id) or isadmin()) { echo ""; $firstcolumn=true; if ($sections[0]->sequence or isediting($site->id)) { get_all_mods($site->id, $mods, $modnames, $modnamesplural, $modnamesused); print_section_block(get_string("mainmenu"), $site, $sections[0], $mods, $modnames, $modnamesused, true, $side); } print_courses_sideblock(0, $side); if ($site->newsitems) { if ($news = forum_get_course_forum($site->id, "news")) { print_side_block_start(get_string("latestnews"), $side, "sideblocklatestnews"); echo ""; forum_print_latest_discussions($news->id, $site->newsitems, "minimal", "", false); echo ""; print_side_block_end(); } } print_spacer(1,$side); } if (iscreator()) { if (!$firstcolumn) { echo ""; $firstcolumn=true; } print_admin_links($site->id, $side); } if ($firstcolumn) { echo ''; $text = '
'.get_string('calendarheading', 'calendar', strip_tags($site->shortname)).'
'; $text.= calendar_get_preferences_menu(); $text.= '
'; print_heading_block($text); print_spacer(8,1); $defaultcourses = calendar_get_default_courses(); $courses = array(); calendar_set_filters($courses, $groups, $users, $defaultcourses, $defaultcourses); $day = $now['mday']; $mon = $now['mon']; $yr = $now['year']; if($knownpreference) { print_side_block_start($prefs[$_GET['edit']], '', 'mycalendar'); echo '

'; print_string('explain_'.$_GET['edit'], 'calendar'); echo '

'; echo ''; } switch($_GET['edit']) { case 'startwday': echo ''; break; case 'maxevents': echo ''; break; case 'lookahead': echo ''; break; default: // Print a form displaying all the preferences and their values print_side_block_start(get_string('preferences', 'calendar'), '', 'mycalendar'); echo '
'.get_string('preferences_available', 'calendar').'
'; echo '

'.$prefs[$_GET['edit']].':'; $days = array( get_string('sunday', 'calendar'), get_string('monday', 'calendar'), get_string('tuesday', 'calendar'), get_string('wednesday', 'calendar'), get_string('thursday', 'calendar'), get_string('friday', 'calendar'), get_string('saturday', 'calendar')); choose_from_menu($days, 'startwday', get_user_preferences('calendar_startwday', CALENDAR_STARTING_WEEKDAY), ''); echo '
'; // Get the actual values of all preferences $values = array(); foreach($prefs as $name => $description) { $values[$name] = get_user_preferences('calendar_'.$name); } // Fix 'display-friendly' values now $days = array( get_string('sunday', 'calendar'), get_string('monday', 'calendar'), get_string('tuesday', 'calendar'), get_string('wednesday', 'calendar'), get_string('thursday', 'calendar'), get_string('friday', 'calendar'), get_string('saturday', 'calendar')); $values['startwday'] = $days[$values['startwday']]; // OK, display them foreach($prefs as $name => $description) { echo ''; echo ''; } // Done echo '
'.$description.':'.($values[$name] === NULL?get_string('default', 'calendar'):$values[$name]) .'

'; print_side_block_end(); break; } if($knownpreference) { echo '
'; echo '

'; echo ''; echo '

'; echo ''; print_side_block_end(); } echo ''; // END: Middle column // START: Last column (3-month display) echo ''; print_side_block_start(get_string('monthlyview', 'calendar'), '', 'sideblockmain'); list($prevmon, $prevyr) = calendar_sub_month($mon, $yr); list($nextmon, $nextyr) = calendar_add_month($mon, $yr); echo calendar_filter_controls($_GET['view']); echo '

'; echo calendar_top_controls('display', array('m' => $prevmon, 'y' => $prevyr)); echo calendar_get_mini($courses, $groups, $users, $prevmon, $prevyr); echo '

'; echo calendar_top_controls('display', array('m' => $mon, 'y' => $yr)); echo calendar_get_mini($courses, $groups, $users, $mon, $yr); echo '

'; echo calendar_top_controls('display', array('m' => $nextmon, 'y' => $nextyr)); echo calendar_get_mini($courses, $groups, $users, $nextmon, $nextyr); echo '

'; print_side_block_end(); print_spacer(1, $side); echo ''; // START: Last column (3-month display) echo ''; print_footer(); ?>