Merge commit 'catalyst/MOODLE_19_STABLE' into mdl19-linuxchix
[moodle-linuxchix.git] / calendar / export.php
blobfaaa10530b4e8bbd0b48c82590d7fa11d2ed769a
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 $day = optional_param('cal_d', 0, PARAM_INT);
10 $mon = optional_param('cal_m', 0, PARAM_INT);
11 $yr = optional_param('cal_y', 0, PARAM_INT);
12 if ($courseid = optional_param('course', 0, PARAM_INT)) {
13 $course = get_record('course', 'id', $courseid);
16 require_login();
18 if(!$site = get_site()) {
19 redirect($CFG->wwwroot.'/'.$CFG->admin.'/index.php');
22 // Initialize the session variables
23 calendar_session_vars();
25 $pagetitle = get_string('export', 'calendar');
26 $navlinks = array();
27 $now = usergetdate(time());
29 if ($course->id != SITEID) {
30 $navlinks[] = array('name' => $course->shortname,
31 'link' => "$CFG->wwwroot/course/view.php?id=$course->id",
32 'type' => 'misc');
34 $navlinks[] = array('name' => get_string('calendar', 'calendar'),
35 'link' =>calendar_get_link_href(CALENDAR_URL.'view.php?view=upcoming&amp;course='.$courseid.'&amp;',
36 $now['mday'], $now['mon'], $now['year']),
37 'type' => 'misc');
38 $navlinks[] = array('name' => $pagetitle, 'link' => null, 'type' => 'misc');
40 $navigation = build_navigation($navlinks);
42 if(!checkdate($mon, $day, $yr)) {
43 $day = intval($now['mday']);
44 $mon = intval($now['mon']);
45 $yr = intval($now['year']);
47 $time = make_timestamp($yr, $mon, $day);
49 if (empty($USER->id) or isguest()) {
50 $defaultcourses = calendar_get_default_courses();
51 calendar_set_filters($courses, $groups, $users, $defaultcourses, $defaultcourses);
52 } else {
53 calendar_set_filters($courses, $groups, $users);
56 if (empty($USER->id) or isguest()) {
57 $defaultcourses = calendar_get_default_courses();
58 calendar_set_filters($courses, $groups, $users, $defaultcourses, $defaultcourses);
60 } else {
61 calendar_set_filters($courses, $groups, $users);
64 $strcalendar = get_string('calendar', 'calendar');
65 $prefsbutton = calendar_preferences_button();
67 // Print title and header
68 print_header("$site->shortname: $strcalendar: $pagetitle", $strcalendar, $navigation,
69 '', '', true, $prefsbutton, user_login_string($site));
71 echo calendar_overlib_html();
73 // Layout the whole page as three big columns.
74 echo '<table id="calendar">';
75 echo '<tr>';
77 // START: Main column
79 echo '<td class="maincalendar">';
81 $username = $USER->username;
82 $usernameencoded = urlencode($USER->username);
83 $authtoken = sha1($USER->username . $USER->password);
85 switch($action) {
86 case 'advanced':
87 break;
88 case '':
89 default:
90 // Let's populate some vars to let "common tasks" be somewhat smart...
91 // If today it's weekend, give the "next week" option
92 $allownextweek = CALENDAR_WEEKEND & (1 << $now['wday']);
93 // If it's the last week of the month, give the "next month" option
94 $allownextmonth = calendar_days_in_month($now['mon'], $now['year']) - $now['mday'] < 7;
95 // If today it's weekend but tomorrow it isn't, do NOT give the "this week" option
96 $allowthisweek = !((CALENDAR_WEEKEND & (1 << $now['wday'])) && !(CALENDAR_WEEKEND & (1 << (($now['wday'] + 1) % 7))));
97 echo '<div class="header">' . get_string('export', 'calendar') . '</div>';
98 include('export_basic.html');
103 echo '</td>';
105 // END: Main column
107 // START: Last column (3-month display)
108 echo '<td class="sidecalendar">';
109 echo '<div class="header">'.get_string('monthlyview', 'calendar').'</div>';
111 list($prevmon, $prevyr) = calendar_sub_month($mon, $yr);
112 list($nextmon, $nextyr) = calendar_add_month($mon, $yr);
113 $getvars = 'cal_d='.$day.'&amp;cal_m='.$mon.'&amp;cal_y='.$yr; // For filtering
115 echo '<div class="minicalendarblock">';
116 echo calendar_top_controls('display', array('id' => $courseid, 'm' => $prevmon, 'y' => $prevyr));
117 echo calendar_get_mini($courses, $groups, $users, $prevmon, $prevyr);
118 echo '</div><div class="minicalendarblock">';
119 echo calendar_top_controls('display', array('id' => $courseid, 'm' => $mon, 'y' => $yr));
120 echo calendar_get_mini($courses, $groups, $users, $mon, $yr);
121 echo '</div><div class="minicalendarblock">';
122 echo calendar_top_controls('display', array('id' => $courseid, 'm' => $nextmon, 'y' => $nextyr));
123 echo calendar_get_mini($courses, $groups, $users, $nextmon, $nextyr);
124 echo '</div>';
126 echo '</td>';
128 echo '</tr></table>';
130 print_footer();