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 //
|
|
|
|
// //
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Display the calendar page.
|
|
|
|
|
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
|
|
|
|
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);
|
|
|
|
$day = optional_param('cal_d', 0, PARAM_INT);
|
|
|
|
$mon = optional_param('cal_m', 0, PARAM_INT);
|
|
|
|
$yr = optional_param('cal_y', 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');
|
2011-06-29 14:50:38 +08:00
|
|
|
if ($courseid != SITEID) {
|
2009-09-29 02:51:00 +00:00
|
|
|
$url->param('course', $courseid);
|
|
|
|
}
|
|
|
|
if ($view !== 'upcoming') {
|
|
|
|
$url->param('view', $view);
|
|
|
|
}
|
|
|
|
if ($day !== 0) {
|
|
|
|
$url->param('cal_d', $day);
|
|
|
|
}
|
|
|
|
if ($mon !== 0) {
|
|
|
|
$url->param('cal_m', $mon);
|
|
|
|
}
|
|
|
|
if ($yr !== 0) {
|
|
|
|
$url->param('cal_y', $yr);
|
|
|
|
}
|
|
|
|
$PAGE->set_url($url);
|
2009-09-18 05:12:45 +00:00
|
|
|
|
2011-06-29 14:50:38 +08:00
|
|
|
if ($courseid != SITEID && !empty($courseid)) {
|
|
|
|
$course = $DB->get_record('course', array('id' => $courseid));
|
|
|
|
$courses = array($course->id => $course);
|
|
|
|
$issite = false;
|
|
|
|
navigation_node::override_active_url(new moodle_url('/course/view.php', array('id' => $course->id)));
|
2010-08-04 07:37:02 +00:00
|
|
|
} else {
|
2011-06-29 14:50:38 +08:00
|
|
|
$course = get_site();
|
|
|
|
$courses = calendar_get_default_courses();
|
|
|
|
$issite = true;
|
2009-09-29 02:51:00 +00:00
|
|
|
}
|
2011-06-29 14:50:38 +08:00
|
|
|
require_course_login($course);
|
2006-07-17 21:08:01 +00:00
|
|
|
|
2010-06-22 04:03:44 +00:00
|
|
|
$calendar = new calendar_information($day, $mon, $yr);
|
2011-06-29 14:50:38 +08:00
|
|
|
$calendar->prepare_for_view($course, $courses);
|
2007-05-06 04:28:11 +00:00
|
|
|
|
2009-09-29 02:51:00 +00:00
|
|
|
$now = usergetdate(time());
|
|
|
|
$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
|
|
|
|
2011-06-29 14:50:38 +08:00
|
|
|
if (!checkdate($mon, $day, $yr)) {
|
2009-09-29 02:51:00 +00:00
|
|
|
$day = intval($now['mday']);
|
|
|
|
$mon = intval($now['mon']);
|
|
|
|
$yr = intval($now['year']);
|
|
|
|
}
|
|
|
|
$time = make_timestamp($yr, $mon, $day);
|
|
|
|
|
|
|
|
switch($view) {
|
|
|
|
case 'day':
|
|
|
|
$PAGE->navbar->add(userdate($time, get_string('strftimedate')));
|
|
|
|
$pagetitle = get_string('dayview', 'calendar');
|
|
|
|
break;
|
|
|
|
case 'month':
|
|
|
|
$PAGE->navbar->add(userdate($time, get_string('strftimemonthyear')));
|
|
|
|
$pagetitle = get_string('detailedmonthview', 'calendar');
|
|
|
|
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);
|
|
|
|
$PAGE->set_button(calendar_preferences_button($course));
|
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'));
|
2004-03-29 15:28:15 +00:00
|
|
|
|
2009-09-29 02:51:00 +00:00
|
|
|
switch($view) {
|
|
|
|
case 'day':
|
2010-06-22 04:03:44 +00:00
|
|
|
echo $renderer->show_day($calendar);
|
2009-09-29 02:51:00 +00:00
|
|
|
break;
|
|
|
|
case 'month':
|
2012-04-23 14:58:39 +08:00
|
|
|
echo $renderer->show_month_detailed($calendar, $url);
|
2009-09-29 02:51:00 +00:00
|
|
|
break;
|
|
|
|
case 'upcoming':
|
2011-06-29 14:50:38 +08:00
|
|
|
$defaultlookahead = CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD;
|
|
|
|
if (isset($CFG->calendar_lookahead)) {
|
|
|
|
$defaultlookahead = intval($CFG->calendar_lookahead);
|
|
|
|
}
|
|
|
|
$lookahead = get_user_preferences('calendar_lookahead', $defaultlookahead);
|
|
|
|
|
|
|
|
$defaultmaxevents = CALENDAR_DEFAULT_UPCOMING_MAXEVENTS;
|
|
|
|
if (isset($CFG->calendar_maxevents)) {
|
|
|
|
$defaultmaxevents = intval($CFG->calendar_maxevents);
|
|
|
|
}
|
|
|
|
$maxevents = get_user_preferences('calendar_maxevents', $defaultmaxevents);
|
|
|
|
echo $renderer->show_upcoming_events($calendar, $lookahead, $maxevents);
|
2009-09-29 02:51:00 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-01-03 08:12:21 +00:00
|
|
|
|
2009-09-29 02:51:00 +00:00
|
|
|
//Link to calendar export page
|
|
|
|
echo $OUTPUT->container_start('bottom');
|
|
|
|
if (!empty($CFG->enablecalendarexport)) {
|
2010-01-03 15:46:14 +00:00
|
|
|
echo $OUTPUT->single_button(new moodle_url('export.php', array('course'=>$courseid)), get_string('exportcalendar', 'calendar'));
|
2010-03-31 07:41:31 +00:00
|
|
|
if (isloggedin()) {
|
2011-11-07 17:07:00 +08:00
|
|
|
$authtoken = sha1($USER->id . $USER->password . $CFG->calendar_exportsalt);
|
|
|
|
$link = new moodle_url('/calendar/export_execute.php', array('preset_what'=>'all', 'preset_time'=>'recentupcoming', 'userid' => $USER->id, 'authtoken'=>$authtoken));
|
2010-06-22 04:03:44 +00:00
|
|
|
$icon = html_writer::empty_tag('img', array('src'=>$OUTPUT->pix_url('i/ical'), 'height'=>'14', 'width'=>'36', 'alt'=>get_string('ical', 'calendar'), 'title'=>get_string('quickdownloadcalendar', 'calendar')));
|
|
|
|
echo html_writer::tag('a', $icon, array('href'=>$link));
|
2006-11-23 20:21:29 +00:00
|
|
|
}
|
2009-09-29 02:51:00 +00:00
|
|
|
}
|
2011-06-29 14:50:38 +08:00
|
|
|
|
2009-09-29 02:51:00 +00:00
|
|
|
echo $OUTPUT->container_end();
|
2010-06-22 04:03:44 +00:00
|
|
|
echo html_writer::end_tag('div');
|
|
|
|
echo $renderer->complete_layout();
|
2009-09-29 02:51:00 +00:00
|
|
|
echo $OUTPUT->footer();
|