MDL-8857
[moodle-linuxchix.git] / calendar / export.php
blobaf7029804a7fb3aaf4135e463d31c647ea132d81
1 <?php // $Id$
3 require_once('../config.php');
4 require_once($CFG->dirroot.'/course/lib.php');
5 require_once($CFG->dirroot.'/calendar/lib.php');
6 //require_once($CFG->libdir.'/bennu/bennu.inc.php');
8 $action = optional_param('action', '', PARAM_ALPHA);
9 $course = optional_param('course', 0);
10 $day = optional_param('cal_d', 0, PARAM_INT);
11 $mon = optional_param('cal_m', 0, PARAM_INT);
12 $yr = optional_param('cal_y', 0, PARAM_INT);
14 require_login();
16 if(!$site = get_site()) {
17 redirect($CFG->wwwroot.'/'.$CFG->admin.'/index.php');
20 $pagetitle = get_string('export', 'calendar');
21 $now = usergetdate(time());
22 $nav = calendar_get_link_tag(get_string('calendar', 'calendar'), CALENDAR_URL.'view.php?view=upcoming&amp;', $now['mday'], $now['mon'], $now['year']).' -> '.$pagetitle;
24 if(!checkdate($mon, $day, $yr)) {
25 $day = intval($now['mday']);
26 $mon = intval($now['mon']);
27 $yr = intval($now['year']);
29 $time = make_timestamp($yr, $mon, $day);
31 $SESSION->cal_courses_shown = calendar_get_default_courses(true);
32 calendar_set_referring_course(0);
34 if (empty($USER->id) or isguest()) {
35 $defaultcourses = calendar_get_default_courses();
36 calendar_set_filters($courses, $groups, $users, $defaultcourses, $defaultcourses);
38 } else {
39 calendar_set_filters($courses, $groups, $users);
42 $strcalendar = get_string('calendar', 'calendar');
43 $prefsbutton = calendar_preferences_button();
45 // Print title and header
46 print_header("$site->shortname: $strcalendar: $pagetitle", $strcalendar, $nav,
47 '', '', true, $prefsbutton, user_login_string($site));
49 echo calendar_overlib_html();
51 // Layout the whole page as three big columns.
52 echo '<table id="calendar">';
53 echo '<tr>';
55 // START: Main column
57 echo '<td class="maincalendar">';
59 $username = $USER->username;
60 $usernameencoded = urlencode($USER->username);
61 $authtoken = sha1($USER->username . $USER->password);
63 switch($action) {
64 case 'advanced':
65 break;
66 case '':
67 default:
68 // Let's populate some vars to let "common tasks" be somewhat smart...
69 // If today it's weekend, give the "next week" option
70 $allownextweek = CALENDAR_WEEKEND & (1 << $now['wday']);
71 // If it's the last week of the month, give the "next month" option
72 $allownextmonth = calendar_days_in_month($now['mon'], $now['year']) - $now['mday'] < 7;
73 // If today it's weekend but tomorrow it isn't, do NOT give the "this week" option
74 $allowthisweek = !((CALENDAR_WEEKEND & (1 << $now['wday'])) && !(CALENDAR_WEEKEND & (1 << (($now['wday'] + 1) % 7))));
75 echo '<div class="header">' . get_string('export', 'calendar') . '</div>';
76 include('export_basic.html');
81 echo '</td>';
83 // END: Main column
85 // START: Last column (3-month display)
86 echo '<td class="sidecalendar">';
87 echo '<div class="header">'.get_string('monthlyview', 'calendar').'</div>';
89 list($prevmon, $prevyr) = calendar_sub_month($mon, $yr);
90 list($nextmon, $nextyr) = calendar_add_month($mon, $yr);
91 $getvars = 'cal_d='.$day.'&amp;cal_m='.$mon.'&amp;cal_y='.$yr; // For filtering
93 echo '<div class="filters">';
94 echo calendar_filter_controls('export', $getvars);
95 echo '</div>';
97 echo '<div class="minicalendarblock">';
98 echo calendar_top_controls('display', array('m' => $prevmon, 'y' => $prevyr));
99 echo calendar_get_mini($courses, $groups, $users, $prevmon, $prevyr);
100 echo '</div><div class="minicalendarblock">';
101 echo calendar_top_controls('display', array('m' => $mon, 'y' => $yr));
102 echo calendar_get_mini($courses, $groups, $users, $mon, $yr);
103 echo '</div><div class="minicalendarblock">';
104 echo calendar_top_controls('display', array('m' => $nextmon, 'y' => $nextyr));
105 echo calendar_get_mini($courses, $groups, $users, $nextmon, $nextyr);
106 echo '</div>';
108 echo '</td>';
110 echo '</tr></table>';
112 print_footer();