2009-09-29 02:51:00 +00:00
|
|
|
<?php
|
2004-03-29 15:28:15 +00:00
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// //
|
|
|
|
// NOTICE OF COPYRIGHT //
|
|
|
|
// //
|
|
|
|
// Moodle - Calendar extension //
|
|
|
|
// //
|
|
|
|
// Copyright (C) 2003-2004 Greek School Network www.sch.gr //
|
|
|
|
// //
|
|
|
|
// Designed by: //
|
2007-02-27 13:49:43 +00:00
|
|
|
// Avgoustos Tsinakos (tsinakos@teikav.edu.gr) //
|
|
|
|
// Jon Papaioannou (pj@moodle.org) //
|
2004-03-29 15:28:15 +00:00
|
|
|
// //
|
|
|
|
// Programming and development: //
|
2007-02-27 13:49:43 +00:00
|
|
|
// Jon Papaioannou (pj@moodle.org) //
|
2004-03-29 15:28:15 +00:00
|
|
|
// //
|
|
|
|
// For bugs, suggestions, etc contact: //
|
2007-02-27 13:49:43 +00:00
|
|
|
// Jon Papaioannou (pj@moodle.org) //
|
2004-03-29 15:28:15 +00:00
|
|
|
// //
|
|
|
|
// The current module was developed at the University of Macedonia //
|
|
|
|
// (www.uom.gr) under the funding of the Greek School Network (www.sch.gr) //
|
|
|
|
// The aim of this project is to provide additional and improved //
|
|
|
|
// functionality to the Asynchronous Distance Education service that the //
|
|
|
|
// Greek School Network deploys. //
|
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or //
|
|
|
|
// (at your option) any later version. //
|
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License for more details: //
|
|
|
|
// //
|
|
|
|
// http://www.gnu.org/copyleft/gpl.html //
|
|
|
|
// //
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-09-06 21:29:34 -04:00
|
|
|
/**
|
|
|
|
* Display the calendar page.
|
|
|
|
* @copyright 2003 Jon Papaioannou
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
* @package core_calendar
|
|
|
|
*/
|
2004-03-29 15:28:15 +00:00
|
|
|
|
2009-09-29 02:51:00 +00:00
|
|
|
require_once('../config.php');
|
|
|
|
require_once($CFG->dirroot.'/course/lib.php');
|
|
|
|
require_once($CFG->dirroot.'/calendar/lib.php');
|
2004-05-25 06:36:09 +00:00
|
|
|
|
2017-09-19 11:17:04 +08:00
|
|
|
$categoryid = optional_param('category', null, PARAM_INT);
|
2011-06-29 14:50:38 +08:00
|
|
|
$courseid = optional_param('course', SITEID, PARAM_INT);
|
2009-09-29 02:51:00 +00:00
|
|
|
$view = optional_param('view', 'upcoming', PARAM_ALPHA);
|
2020-01-25 00:56:33 +01:00
|
|
|
$day = optional_param('cal_d', 0, PARAM_INT);
|
|
|
|
$mon = optional_param('cal_m', 0, PARAM_INT);
|
|
|
|
$year = optional_param('cal_y', 0, PARAM_INT);
|
2013-09-16 17:30:59 +08:00
|
|
|
$time = optional_param('time', 0, PARAM_INT);
|
2019-04-05 16:40:50 +02:00
|
|
|
$lookahead = optional_param('lookahead', null, PARAM_INT);
|
2004-03-29 15:28:15 +00:00
|
|
|
|
2010-01-16 15:39:56 +00:00
|
|
|
$url = new moodle_url('/calendar/view.php');
|
2013-09-16 17:30:59 +08:00
|
|
|
|
2020-01-25 00:56:33 +01:00
|
|
|
// If a day, month and year were passed then convert it to a timestamp. If these were passed
|
|
|
|
// then we can assume the day, month and year are passed as Gregorian, as no where in core
|
|
|
|
// should we be passing these values rather than the time. This is done for BC.
|
|
|
|
if (!empty($day) && !empty($mon) && !empty($year)) {
|
|
|
|
if (checkdate($mon, $day, $year)) {
|
|
|
|
$time = make_timestamp($year, $mon, $day);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-11 08:46:02 +12:00
|
|
|
if (empty($time)) {
|
|
|
|
$time = time();
|
|
|
|
}
|
|
|
|
|
2019-06-06 14:08:43 +08:00
|
|
|
$iscoursecalendar = $courseid != SITEID;
|
|
|
|
|
|
|
|
if ($iscoursecalendar) {
|
2016-04-11 08:46:02 +12:00
|
|
|
$url->param('course', $courseid);
|
|
|
|
}
|
|
|
|
|
2017-09-19 11:17:04 +08:00
|
|
|
if ($categoryid) {
|
|
|
|
$url->param('categoryid', $categoryid);
|
|
|
|
}
|
|
|
|
|
2016-04-11 08:46:02 +12:00
|
|
|
if ($view !== 'upcoming') {
|
|
|
|
$time = usergetmidnight($time);
|
|
|
|
$url->param('view', $view);
|
2009-09-29 02:51:00 +00:00
|
|
|
}
|
2013-09-16 17:30:59 +08:00
|
|
|
|
|
|
|
$url->param('time', $time);
|
|
|
|
|
2009-09-29 02:51:00 +00:00
|
|
|
$PAGE->set_url($url);
|
2009-09-18 05:12:45 +00:00
|
|
|
|
2017-10-27 10:27:03 +08:00
|
|
|
$course = get_course($courseid);
|
|
|
|
|
2019-06-06 14:08:43 +08:00
|
|
|
if ($iscoursecalendar && !empty($courseid)) {
|
2011-06-29 14:50:38 +08:00
|
|
|
navigation_node::override_active_url(new moodle_url('/course/view.php', array('id' => $course->id)));
|
2022-04-08 15:11:31 +08:00
|
|
|
$PAGE->set_secondary_navigation(false);
|
2017-10-27 10:27:03 +08:00
|
|
|
} else if (!empty($categoryid)) {
|
2018-06-21 13:34:59 +08:00
|
|
|
core_course_category::get($categoryid); // Check that category exists and can be accessed.
|
2017-10-27 10:27:03 +08:00
|
|
|
$PAGE->set_category_by_id($categoryid);
|
|
|
|
navigation_node::override_active_url(new moodle_url('/course/index.php', array('categoryid' => $categoryid)));
|
2021-07-21 19:50:51 +10:00
|
|
|
$PAGE->navbar->add(
|
|
|
|
get_string('calendar', 'calendar'),
|
|
|
|
new moodle_url('/calendar/view.php', ['view' => 'month', 'category' => $categoryid])
|
|
|
|
);
|
2022-04-08 15:11:31 +08:00
|
|
|
$PAGE->set_secondary_navigation(false);
|
2010-08-04 07:37:02 +00:00
|
|
|
} else {
|
2017-10-27 10:27:03 +08:00
|
|
|
$PAGE->set_context(context_system::instance());
|
2009-09-29 02:51:00 +00:00
|
|
|
}
|
2013-09-16 17:30:59 +08:00
|
|
|
|
2023-09-05 10:44:03 +12:00
|
|
|
// Auto log in guests on frontpage.
|
|
|
|
$autologinguest = !$iscoursecalendar;
|
|
|
|
require_login($course, $autologinguest);
|
2006-07-17 21:08:01 +00:00
|
|
|
|
2017-10-27 10:27:03 +08:00
|
|
|
$calendar = calendar_information::create($time, $courseid, $categoryid);
|
2007-05-06 04:28:11 +00:00
|
|
|
|
2009-09-29 02:51:00 +00:00
|
|
|
$pagetitle = '';
|
2004-03-29 15:28:15 +00:00
|
|
|
|
2009-09-29 02:51:00 +00:00
|
|
|
$strcalendar = get_string('calendar', 'calendar');
|
2004-03-29 15:28:15 +00:00
|
|
|
|
2009-09-29 02:51:00 +00:00
|
|
|
switch($view) {
|
|
|
|
case 'day':
|
|
|
|
$PAGE->navbar->add(userdate($time, get_string('strftimedate')));
|
2012-09-11 14:13:27 +08:00
|
|
|
$pagetitle = get_string('dayviewtitle', 'calendar', userdate($time, get_string('strftimedaydate')));
|
2009-09-29 02:51:00 +00:00
|
|
|
break;
|
|
|
|
case 'month':
|
|
|
|
$PAGE->navbar->add(userdate($time, get_string('strftimemonthyear')));
|
2012-09-11 14:13:27 +08:00
|
|
|
$pagetitle = get_string('detailedmonthviewtitle', 'calendar', userdate($time, get_string('strftimemonthyear')));
|
2009-09-29 02:51:00 +00:00
|
|
|
break;
|
|
|
|
case 'upcoming':
|
|
|
|
$pagetitle = get_string('upcomingevents', 'calendar');
|
|
|
|
break;
|
|
|
|
}
|
2004-05-01 17:32:37 +00:00
|
|
|
|
2024-01-26 21:46:56 +07:00
|
|
|
$PAGE->set_show_course_index(false);
|
2010-06-22 04:03:44 +00:00
|
|
|
$PAGE->set_pagelayout('standard');
|
2024-01-26 21:46:56 +07:00
|
|
|
|
|
|
|
// Print title and header.
|
2011-06-29 14:50:38 +08:00
|
|
|
$PAGE->set_title("$course->shortname: $strcalendar: $pagetitle");
|
2019-06-06 14:08:43 +08:00
|
|
|
|
2021-11-08 16:53:39 +05:30
|
|
|
$headingstr = get_string('calendar', 'core_calendar');
|
2024-01-26 21:46:56 +07:00
|
|
|
// If the user is on the course page,
|
|
|
|
// then make the course name linkable to ease the user's navigation to the course page.
|
|
|
|
if ($iscoursecalendar) {
|
|
|
|
$url = new \moodle_url('/course/view.php', ['id' => $courseid]);
|
|
|
|
$linkcourse = html_writer::link($url, $course->shortname);
|
|
|
|
$headingstr = "{$headingstr}: {$linkcourse}";
|
|
|
|
}
|
|
|
|
$PAGE->set_heading($headingstr, false);
|
2009-09-04 04:26:50 +00:00
|
|
|
|
2010-06-22 04:03:44 +00:00
|
|
|
$renderer = $PAGE->get_renderer('core_calendar');
|
|
|
|
$calendar->add_sidecalendar_blocks($renderer, true, $view);
|
2004-03-29 15:28:15 +00:00
|
|
|
|
2010-06-22 04:03:44 +00:00
|
|
|
echo $OUTPUT->header();
|
|
|
|
echo $renderer->start_layout();
|
2021-11-01 22:33:24 +11:00
|
|
|
echo html_writer::start_tag('div', ['class' => 'heightcontainer', 'data-calendar-type' => 'main-block']);
|
2019-06-06 14:08:43 +08:00
|
|
|
|
2004-03-29 15:28:15 +00:00
|
|
|
|
2017-11-08 18:36:03 -02:00
|
|
|
|
2019-04-05 16:40:50 +02:00
|
|
|
list($data, $template) = calendar_get_view($calendar, $view, true, false, $lookahead);
|
2017-11-08 18:36:03 -02:00
|
|
|
echo $renderer->render_from_template($template, $data);
|
|
|
|
|
2010-06-22 04:03:44 +00:00
|
|
|
echo html_writer::end_tag('div');
|
2017-07-19 09:04:19 +08:00
|
|
|
|
|
|
|
list($data, $template) = calendar_get_footer_options($calendar);
|
|
|
|
echo $renderer->render_from_template($template, $data);
|
|
|
|
|
2018-03-16 08:47:24 +00:00
|
|
|
echo $renderer->complete_layout();
|
2015-02-02 12:06:31 +13:00
|
|
|
echo $OUTPUT->footer();
|