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);
|
2013-09-16 17:30:59 +08:00
|
|
|
$time = optional_param('time', 0, 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
|
|
|
|
2016-04-11 08:46:02 +12:00
|
|
|
if (empty($time)) {
|
|
|
|
$time = time();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($courseid != SITEID) {
|
|
|
|
$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);
|
|
|
|
|
2011-06-29 14:50:38 +08:00
|
|
|
if ($courseid != SITEID && !empty($courseid)) {
|
|
|
|
navigation_node::override_active_url(new moodle_url('/course/view.php', array('id' => $course->id)));
|
2017-10-27 10:27:03 +08:00
|
|
|
} else if (!empty($categoryid)) {
|
|
|
|
$PAGE->set_category_by_id($categoryid);
|
|
|
|
navigation_node::override_active_url(new moodle_url('/course/index.php', array('categoryid' => $categoryid)));
|
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
|
|
|
|
2017-06-22 15:16:53 +08:00
|
|
|
require_login($course, false);
|
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
|
|
|
|
2009-09-29 02:51:00 +00:00
|
|
|
// Print title and header
|
2010-06-22 04:03:44 +00:00
|
|
|
$PAGE->set_pagelayout('standard');
|
2011-06-29 14:50:38 +08:00
|
|
|
$PAGE->set_title("$course->shortname: $strcalendar: $pagetitle");
|
|
|
|
$PAGE->set_heading($COURSE->fullname);
|
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();
|
|
|
|
echo html_writer::start_tag('div', array('class'=>'heightcontainer'));
|
2015-02-02 12:06:31 +13:00
|
|
|
echo $OUTPUT->heading(get_string('calendar', 'calendar'));
|
2004-03-29 15:28:15 +00:00
|
|
|
|
2017-07-19 09:34:34 +08:00
|
|
|
if ($view == 'day' || $view == 'upcoming') {
|
|
|
|
switch($view) {
|
|
|
|
case 'day':
|
2017-09-18 10:53:26 +08:00
|
|
|
list($data, $template) = calendar_get_view($calendar, $view);
|
|
|
|
echo $renderer->render_from_template($template, $data);
|
2017-07-19 09:34:34 +08:00
|
|
|
break;
|
|
|
|
case 'upcoming':
|
2017-09-29 12:59:24 +08:00
|
|
|
list($data, $template) = calendar_get_view($calendar, $view);
|
|
|
|
echo $renderer->render_from_template($template, $data);
|
2017-07-19 09:34:34 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else if ($view == 'month') {
|
|
|
|
list($data, $template) = calendar_get_view($calendar, $view);
|
|
|
|
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);
|
|
|
|
|
2015-02-02 12:06:31 +13:00
|
|
|
echo $OUTPUT->footer();
|