Commit | Line | Data |
---|---|---|
93c91ee4 | 1 | <?php |
7423f116 | 2 | |
3 | ///////////////////////////////////////////////////////////////////////////// | |
4 | // // | |
5 | // NOTICE OF COPYRIGHT // | |
6 | // // | |
7 | // Moodle - Calendar extension // | |
8 | // // | |
9 | // Copyright (C) 2003-2004 Greek School Network www.sch.gr // | |
10 | // // | |
11 | // Designed by: // | |
bdcb26b7 | 12 | // Avgoustos Tsinakos (tsinakos@teikav.edu.gr) // |
13 | // Jon Papaioannou (pj@moodle.org) // | |
7423f116 | 14 | // // |
15 | // Programming and development: // | |
bdcb26b7 | 16 | // Jon Papaioannou (pj@moodle.org) // |
7423f116 | 17 | // // |
18 | // For bugs, suggestions, etc contact: // | |
bdcb26b7 | 19 | // Jon Papaioannou (pj@moodle.org) // |
7423f116 | 20 | // // |
21 | // The current module was developed at the University of Macedonia // | |
22 | // (www.uom.gr) under the funding of the Greek School Network (www.sch.gr) // | |
23 | // The aim of this project is to provide additional and improved // | |
24 | // functionality to the Asynchronous Distance Education service that the // | |
25 | // Greek School Network deploys. // | |
26 | // // | |
27 | // This program is free software; you can redistribute it and/or modify // | |
28 | // it under the terms of the GNU General Public License as published by // | |
29 | // the Free Software Foundation; either version 2 of the License, or // | |
30 | // (at your option) any later version. // | |
31 | // // | |
32 | // This program is distributed in the hope that it will be useful, // | |
33 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // | |
34 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // | |
35 | // GNU General Public License for more details: // | |
36 | // // | |
37 | // http://www.gnu.org/copyleft/gpl.html // | |
38 | // // | |
39 | ///////////////////////////////////////////////////////////////////////////// | |
40 | ||
9629790b SB |
41 | /** |
42 | * Display the calendar page. | |
43 | * @copyright 2003 Jon Papaioannou | |
44 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | |
45 | * @package core_calendar | |
46 | */ | |
7423f116 | 47 | |
93c91ee4 | 48 | require_once('../config.php'); |
49 | require_once($CFG->dirroot.'/course/lib.php'); | |
50 | require_once($CFG->dirroot.'/calendar/lib.php'); | |
707fbef4 | 51 | |
d0e56d84 | 52 | $categoryid = optional_param('category', null, PARAM_INT); |
797cedc7 | 53 | $courseid = optional_param('course', SITEID, PARAM_INT); |
93c91ee4 | 54 | $view = optional_param('view', 'upcoming', PARAM_ALPHA); |
7287834c LB |
55 | $day = optional_param('cal_d', 0, PARAM_INT); |
56 | $mon = optional_param('cal_m', 0, PARAM_INT); | |
57 | $year = optional_param('cal_y', 0, PARAM_INT); | |
da304137 | 58 | $time = optional_param('time', 0, PARAM_INT); |
982fef46 | 59 | $lookahead = optional_param('lookahead', null, PARAM_INT); |
7423f116 | 60 | |
a6855934 | 61 | $url = new moodle_url('/calendar/view.php'); |
da304137 | 62 | |
7287834c LB |
63 | // If a day, month and year were passed then convert it to a timestamp. If these were passed |
64 | // then we can assume the day, month and year are passed as Gregorian, as no where in core | |
65 | // should we be passing these values rather than the time. This is done for BC. | |
66 | if (!empty($day) && !empty($mon) && !empty($year)) { | |
67 | if (checkdate($mon, $day, $year)) { | |
68 | $time = make_timestamp($year, $mon, $day); | |
69 | } | |
70 | } | |
71 | ||
7bdc3ba6 NP |
72 | if (empty($time)) { |
73 | $time = time(); | |
74 | } | |
75 | ||
fed1cc73 SL |
76 | $iscoursecalendar = $courseid != SITEID; |
77 | ||
78 | if ($iscoursecalendar) { | |
7bdc3ba6 NP |
79 | $url->param('course', $courseid); |
80 | } | |
81 | ||
d0e56d84 AN |
82 | if ($categoryid) { |
83 | $url->param('categoryid', $categoryid); | |
84 | } | |
85 | ||
7bdc3ba6 NP |
86 | if ($view !== 'upcoming') { |
87 | $time = usergetmidnight($time); | |
88 | $url->param('view', $view); | |
93c91ee4 | 89 | } |
da304137 MN |
90 | |
91 | $url->param('time', $time); | |
92 | ||
93c91ee4 | 93 | $PAGE->set_url($url); |
c9c9fb90 | 94 | |
39e36451 AN |
95 | $course = get_course($courseid); |
96 | ||
fed1cc73 | 97 | if ($iscoursecalendar && !empty($courseid)) { |
797cedc7 | 98 | navigation_node::override_active_url(new moodle_url('/course/view.php', array('id' => $course->id))); |
39e36451 | 99 | } else if (!empty($categoryid)) { |
beff3806 | 100 | core_course_category::get($categoryid); // Check that category exists and can be accessed. |
39e36451 AN |
101 | $PAGE->set_category_by_id($categoryid); |
102 | navigation_node::override_active_url(new moodle_url('/course/index.php', array('categoryid' => $categoryid))); | |
ca74470c | 103 | } else { |
39e36451 | 104 | $PAGE->set_context(context_system::instance()); |
93c91ee4 | 105 | } |
da304137 | 106 | |
fb1a615d | 107 | require_login($course, false); |
2d4fb02f | 108 | |
39e36451 | 109 | $calendar = calendar_information::create($time, $courseid, $categoryid); |
37d87d11 | 110 | |
93c91ee4 | 111 | $pagetitle = ''; |
7423f116 | 112 | |
93c91ee4 | 113 | $strcalendar = get_string('calendar', 'calendar'); |
7423f116 | 114 | |
93c91ee4 | 115 | switch($view) { |
116 | case 'day': | |
117 | $PAGE->navbar->add(userdate($time, get_string('strftimedate'))); | |
3fe4a2fa | 118 | $pagetitle = get_string('dayviewtitle', 'calendar', userdate($time, get_string('strftimedaydate'))); |
93c91ee4 | 119 | break; |
120 | case 'month': | |
121 | $PAGE->navbar->add(userdate($time, get_string('strftimemonthyear'))); | |
3fe4a2fa | 122 | $pagetitle = get_string('detailedmonthviewtitle', 'calendar', userdate($time, get_string('strftimemonthyear'))); |
93c91ee4 | 123 | break; |
124 | case 'upcoming': | |
125 | $pagetitle = get_string('upcomingevents', 'calendar'); | |
126 | break; | |
127 | } | |
1e1ff33b | 128 | |
93c91ee4 | 129 | // Print title and header |
36dc3b71 | 130 | $PAGE->set_pagelayout('standard'); |
797cedc7 | 131 | $PAGE->set_title("$course->shortname: $strcalendar: $pagetitle"); |
fed1cc73 SL |
132 | |
133 | $headingstr = ($iscoursecalendar) ? get_string('coursecalendar', 'core_calendar', $COURSE->shortname) : | |
134 | get_string('calendar', 'core_calendar'); | |
135 | $PAGE->set_heading($headingstr); | |
f22f1333 | 136 | |
36dc3b71 SH |
137 | $renderer = $PAGE->get_renderer('core_calendar'); |
138 | $calendar->add_sidecalendar_blocks($renderer, true, $view); | |
7423f116 | 139 | |
36dc3b71 SH |
140 | echo $OUTPUT->header(); |
141 | echo $renderer->start_layout(); | |
142 | echo html_writer::start_tag('div', array('class'=>'heightcontainer')); | |
fed1cc73 | 143 | |
7423f116 | 144 | |
6bc8a2e1 | 145 | |
982fef46 | 146 | list($data, $template) = calendar_get_view($calendar, $view, true, false, $lookahead); |
6bc8a2e1 JUCA |
147 | echo $renderer->render_from_template($template, $data); |
148 | ||
36dc3b71 | 149 | echo html_writer::end_tag('div'); |
644b2e98 SL |
150 | |
151 | list($data, $template) = calendar_get_footer_options($calendar); | |
152 | echo $renderer->render_from_template($template, $data); | |
153 | ||
e503ec17 | 154 | echo $renderer->complete_layout(); |
136f8f09 | 155 | echo $OUTPUT->footer(); |