MDL-11515:
[moodle-linuxchix.git] / calendar / export.php
blobc97dd274c230661fc5db3df4e02b1277dee55b68
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);
13 if (isset($SESSION->cal_course_referer)) {
14 $course = $SESSION->cal_course_referer;
15 } else {
16 $course = optional_param('course', 0, PARAM_INT);
19 require_login();
21 if(!$site = get_site()) {
22 redirect($CFG->wwwroot.'/'.$CFG->admin.'/index.php');
25 // Initialize the session variables
26 calendar_session_vars();
28 $pagetitle = get_string('export', 'calendar');
29 $navlinks = array();
30 $now = usergetdate(time());
32 $navlinks[] = array('name' => get_string('calendar', 'calendar'),
33 'link' =>calendar_get_link_href(CALENDAR_URL.'view.php?view=upcoming&amp;course='.$course.'&amp;',
34 $now['mday'], $now['mon'], $now['year']),
35 'type' => 'misc');
36 $navlinks[] = array('name' => $pagetitle, 'link' => null, 'type' => 'misc');
37 $navigation = build_navigation($navlinks);
39 if(!checkdate($mon, $day, $yr)) {
40 $day = intval($now['mday']);
41 $mon = intval($now['mon']);
42 $yr = intval($now['year']);
44 $time = make_timestamp($yr, $mon, $day);
46 $SESSION->cal_courses_shown = calendar_get_default_courses(true);
47 calendar_set_referring_course(0);
49 if (empty($USER->id) or isguest()) {
50 $defaultcourses = calendar_get_default_courses();
51 calendar_set_filters($courses, $groups, $users, $defaultcourses, $defaultcourses);
53 } else {
54 calendar_set_filters($courses, $groups, $users);
57 $strcalendar = get_string('calendar', 'calendar');
58 $prefsbutton = calendar_preferences_button();
60 // Print title and header
61 print_header("$site->shortname: $strcalendar: $pagetitle", $strcalendar, $navigation,
62 '', '', true, $prefsbutton, user_login_string($site));
64 echo calendar_overlib_html();
66 // Layout the whole page as three big columns.
67 echo '<table id="calendar">';
68 echo '<tr>';
70 // START: Main column
72 echo '<td class="maincalendar">';
74 $username = $USER->username;
75 $usernameencoded = urlencode($USER->username);
76 $authtoken = sha1($USER->username . $USER->password);
78 switch($action) {
79 case 'advanced':
80 break;
81 case '':
82 default:
83 // Let's populate some vars to let "common tasks" be somewhat smart...
84 // If today it's weekend, give the "next week" option
85 $allownextweek = CALENDAR_WEEKEND & (1 << $now['wday']);
86 // If it's the last week of the month, give the "next month" option
87 $allownextmonth = calendar_days_in_month($now['mon'], $now['year']) - $now['mday'] < 7;
88 // If today it's weekend but tomorrow it isn't, do NOT give the "this week" option
89 $allowthisweek = !((CALENDAR_WEEKEND & (1 << $now['wday'])) && !(CALENDAR_WEEKEND & (1 << (($now['wday'] + 1) % 7))));
90 echo '<div class="header">' . get_string('export', 'calendar') . '</div>';
91 include('export_basic.html');
96 echo '</td>';
98 // END: Main column
100 // START: Last column (3-month display)
101 echo '<td class="sidecalendar">';
102 echo '<div class="header">'.get_string('monthlyview', 'calendar').'</div>';
104 list($prevmon, $prevyr) = calendar_sub_month($mon, $yr);
105 list($nextmon, $nextyr) = calendar_add_month($mon, $yr);
106 $getvars = 'cal_d='.$day.'&amp;cal_m='.$mon.'&amp;cal_y='.$yr; // For filtering
108 echo '<div class="minicalendarblock">';
109 echo calendar_top_controls('display', array('id' => $course, 'm' => $prevmon, 'y' => $prevyr));
110 echo calendar_get_mini($courses, $groups, $users, $prevmon, $prevyr);
111 echo '</div><div class="minicalendarblock">';
112 echo calendar_top_controls('display', array('id' => $course, 'm' => $mon, 'y' => $yr));
113 echo calendar_get_mini($courses, $groups, $users, $mon, $yr);
114 echo '</div><div class="minicalendarblock">';
115 echo calendar_top_controls('display', array('id' => $course, 'm' => $nextmon, 'y' => $nextyr));
116 echo calendar_get_mini($courses, $groups, $users, $nextmon, $nextyr);
117 echo '</div>';
119 echo '</td>';
121 echo '</tr></table>';
123 print_footer();