calendar MDL-19793 Upgrade deprecated calls and added set_url calls
This commit is contained in:
+495
-486
File diff suppressed because it is too large
Load Diff
+69
-3
@@ -1,4 +1,50 @@
|
||||
<?php // $Id$
|
||||
<?php
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Calendar extension //
|
||||
// //
|
||||
// Copyright (C) 2003-2004 Greek School Network www.sch.gr //
|
||||
// //
|
||||
// Designed by: //
|
||||
// Avgoustos Tsinakos ([email protected]) //
|
||||
// Jon Papaioannou ([email protected]) //
|
||||
// //
|
||||
// Programming and development: //
|
||||
// Jon Papaioannou ([email protected]) //
|
||||
// //
|
||||
// For bugs, suggestions, etc contact: //
|
||||
// Jon Papaioannou ([email protected]) //
|
||||
// //
|
||||
// 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 //
|
||||
// //
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* This file is part of the User section Moodle
|
||||
*
|
||||
* @copyright 2003-2004 Jon Papaioannou ([email protected])
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v2 or later
|
||||
* @package calendar
|
||||
*/
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
@@ -15,6 +61,24 @@ if ($courseid = optional_param('course', 0, PARAM_INT)) {
|
||||
$course = NULL;
|
||||
}
|
||||
|
||||
$url = new moodle_url($CFG->wwwroot.'/calendar/export.php');
|
||||
if ($action !== '') {
|
||||
$url->param('action', $action);
|
||||
}
|
||||
if ($cal_d !== 0) {
|
||||
$url->param('cal_d', $cal_d);
|
||||
}
|
||||
if ($cal_m !== 0) {
|
||||
$url->param('cal_m', $cal_m);
|
||||
}
|
||||
if ($cal_y !== 0) {
|
||||
$url->param('cal_y', $cal_y);
|
||||
}
|
||||
if ($course !== 0) {
|
||||
$url->param('course', $course);
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
|
||||
require_login();
|
||||
|
||||
if (empty($CFG->enablecalendarexport)) {
|
||||
@@ -43,14 +107,16 @@ if(!checkdate($mon, $day, $yr)) {
|
||||
}
|
||||
$time = make_timestamp($yr, $mon, $day);
|
||||
|
||||
if (empty($USER->id) or isguest()) {
|
||||
$isguest = has_capability('moodle/legacy:guest', get_context_instance(CONTEXT_SYSTEM), 0, false);
|
||||
|
||||
if (empty($USER->id) or $isguest) {
|
||||
$defaultcourses = calendar_get_default_courses();
|
||||
calendar_set_filters($courses, $groups, $users, $defaultcourses, $defaultcourses);
|
||||
} else {
|
||||
calendar_set_filters($courses, $groups, $users);
|
||||
}
|
||||
|
||||
if (empty($USER->id) or isguest()) {
|
||||
if (empty($USER->id) or $isguest) {
|
||||
$defaultcourses = calendar_get_default_courses();
|
||||
calendar_set_filters($courses, $groups, $users, $defaultcourses, $defaultcourses);
|
||||
|
||||
|
||||
+4
-6
@@ -1,7 +1,5 @@
|
||||
<?php // %Id%
|
||||
<?php
|
||||
|
||||
require('../config.php');
|
||||
|
||||
redirect($CFG->wwwroot.'/calendar/view.php');
|
||||
|
||||
?>
|
||||
require('../config.php');
|
||||
$PAGE->set_url(new moodle_url($CFG->wwwroot.'/calendar/view.php'));
|
||||
redirect($CFG->wwwroot.'/calendar/view.php');
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
<?php // $Id$
|
||||
<?php
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
@@ -845,7 +845,7 @@ function calendar_filter_controls($type, $vars = NULL, $course = NULL, $courses
|
||||
}
|
||||
|
||||
|
||||
if(!empty($USER->id) && !isguest()) {
|
||||
if(!empty($USER->id) && !has_capability('moodle/legacy:guest', get_context_instance(CONTEXT_SYSTEM), 0, false)) {
|
||||
$content .= "</tr>\n<tr>";
|
||||
|
||||
if($groupevents) {
|
||||
@@ -1426,7 +1426,7 @@ function calendar_preferences_button() {
|
||||
global $CFG, $USER;
|
||||
|
||||
// Guests have no preferences
|
||||
if (empty($USER->id) || isguest()) {
|
||||
if (empty($USER->id) || has_capability('moodle/legacy:guest', get_context_instance(CONTEXT_SYSTEM), 0, false)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
+69
-68
@@ -1,87 +1,88 @@
|
||||
<?PHP // $Id$
|
||||
// preferences.php - user prefs for calendar
|
||||
<?php
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->dirroot.'/calendar/lib.php');
|
||||
// preferences.php - user prefs for calendar
|
||||
|
||||
if (isset($SESSION->cal_course_referer)) {
|
||||
if (! $course = $DB->get_record('course', array('id'=>$SESSION->cal_course_referer))) {
|
||||
$course = get_site();
|
||||
}
|
||||
require_once('../config.php');
|
||||
require_once($CFG->dirroot.'/calendar/lib.php');
|
||||
|
||||
if (isset($SESSION->cal_course_referer)) {
|
||||
if (! $course = $DB->get_record('course', array('id'=>$SESSION->cal_course_referer))) {
|
||||
$course = get_site();
|
||||
}
|
||||
}
|
||||
|
||||
if ($course->id != SITEID) {
|
||||
require_login($course->id);
|
||||
}
|
||||
// Initialize the session variables
|
||||
calendar_session_vars();
|
||||
$PAGE->set_url(new moodle_url($CFG->wwwroot.'/calendar/preferences.php'));
|
||||
|
||||
if ($course->id != SITEID) {
|
||||
require_login($course->id);
|
||||
}
|
||||
// Initialize the session variables
|
||||
calendar_session_vars();
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($form = data_submitted()) {
|
||||
foreach ($form as $preference => $value) {
|
||||
switch ($preference) {
|
||||
case 'timeformat':
|
||||
if ($value != CALENDAR_TF_12 and $value != CALENDAR_TF_24) {
|
||||
$value = '';
|
||||
}
|
||||
set_user_preference('calendar_timeformat', $value);
|
||||
break;
|
||||
case 'startwday':
|
||||
$value = intval($value);
|
||||
if ($value < 0 or $value > 6) {
|
||||
$value = abs($value % 7);
|
||||
}
|
||||
set_user_preference('calendar_startwday', $value);
|
||||
break;
|
||||
case 'maxevents':
|
||||
if (intval($value) >= 1) {
|
||||
set_user_preference('calendar_maxevents', $value);
|
||||
}
|
||||
break;
|
||||
case 'lookahead':
|
||||
if (intval($value) >= 1) {
|
||||
set_user_preference('calendar_lookahead', $value);
|
||||
}
|
||||
break;
|
||||
case 'persistflt':
|
||||
set_user_preference('calendar_persistflt', intval($value));
|
||||
break;
|
||||
}
|
||||
if ($form = data_submitted()) {
|
||||
foreach ($form as $preference => $value) {
|
||||
switch ($preference) {
|
||||
case 'timeformat':
|
||||
if ($value != CALENDAR_TF_12 and $value != CALENDAR_TF_24) {
|
||||
$value = '';
|
||||
}
|
||||
set_user_preference('calendar_timeformat', $value);
|
||||
break;
|
||||
case 'startwday':
|
||||
$value = intval($value);
|
||||
if ($value < 0 or $value > 6) {
|
||||
$value = abs($value % 7);
|
||||
}
|
||||
set_user_preference('calendar_startwday', $value);
|
||||
break;
|
||||
case 'maxevents':
|
||||
if (intval($value) >= 1) {
|
||||
set_user_preference('calendar_maxevents', $value);
|
||||
}
|
||||
break;
|
||||
case 'lookahead':
|
||||
if (intval($value) >= 1) {
|
||||
set_user_preference('calendar_lookahead', $value);
|
||||
}
|
||||
break;
|
||||
case 'persistflt':
|
||||
set_user_preference('calendar_persistflt', intval($value));
|
||||
break;
|
||||
}
|
||||
redirect('view.php?course='.$course->id, get_string('changessaved'), 1);
|
||||
exit;
|
||||
}
|
||||
redirect('view.php?course='.$course->id, get_string('changessaved'), 1);
|
||||
exit;
|
||||
}
|
||||
|
||||
$site = get_site();
|
||||
$site = get_site();
|
||||
|
||||
$strcalendar = get_string('calendar', 'calendar');
|
||||
$strpreferences = get_string('preferences', 'calendar');
|
||||
$strcalendar = get_string('calendar', 'calendar');
|
||||
$strpreferences = get_string('preferences', 'calendar');
|
||||
|
||||
if ($course->id != SITEID) {
|
||||
$PAGE->navbar-add($course->shortname, new moodle_url($CFG->wwwroot.'/course/view.php', array('id'=>$course->id)));
|
||||
}
|
||||
$PAGE->navbar->add($strpreferences, new moodle_url($CFG->wwwroot.'/calendar/view.php'));
|
||||
if ($course->id != SITEID) {
|
||||
$PAGE->navbar-add($course->shortname, new moodle_url($CFG->wwwroot.'/course/view.php', array('id'=>$course->id)));
|
||||
}
|
||||
$PAGE->navbar->add($strpreferences, new moodle_url($CFG->wwwroot.'/calendar/view.php'));
|
||||
|
||||
$PAGE->set_title("$site->shortname: $strcalendar: $strpreferences");
|
||||
$PAGE->set_heading($strcalendar);
|
||||
$PAGE->set_headingmenu(user_login_string($site));
|
||||
$PAGE->set_title("$site->shortname: $strcalendar: $strpreferences");
|
||||
$PAGE->set_heading($strcalendar);
|
||||
$PAGE->set_headingmenu(user_login_string($site));
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->header();
|
||||
|
||||
echo $OUTPUT->heading($strpreferences);
|
||||
echo $OUTPUT->heading($strpreferences);
|
||||
|
||||
echo $OUTPUT->box_start('generalbox boxaligncenter');
|
||||
echo $OUTPUT->box_start('generalbox boxaligncenter');
|
||||
|
||||
$prefs->timeformat = get_user_preferences('calendar_timeformat', '');
|
||||
$prefs->startwday = get_user_preferences('calendar_startwday', CALENDAR_STARTING_WEEKDAY);
|
||||
$prefs->maxevents = get_user_preferences('calendar_maxevents', CALENDAR_UPCOMING_MAXEVENTS);
|
||||
$prefs->lookahead = get_user_preferences('calendar_lookahead', CALENDAR_UPCOMING_DAYS);
|
||||
$prefs->persistflt = get_user_preferences('calendar_persistflt', 0);
|
||||
$prefs->timeformat = get_user_preferences('calendar_timeformat', '');
|
||||
$prefs->startwday = get_user_preferences('calendar_startwday', CALENDAR_STARTING_WEEKDAY);
|
||||
$prefs->maxevents = get_user_preferences('calendar_maxevents', CALENDAR_UPCOMING_MAXEVENTS);
|
||||
$prefs->lookahead = get_user_preferences('calendar_lookahead', CALENDAR_UPCOMING_DAYS);
|
||||
$prefs->persistflt = get_user_preferences('calendar_persistflt', 0);
|
||||
|
||||
include('./preferences.html');
|
||||
echo $OUTPUT->box_end();
|
||||
include('./preferences.html');
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
?>
|
||||
echo $OUTPUT->footer();
|
||||
+96
-76
@@ -1,4 +1,4 @@
|
||||
<?php // $Id$
|
||||
<?php
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
@@ -38,89 +38,109 @@
|
||||
// //
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->dirroot.'/calendar/lib.php');
|
||||
require_once('../config.php');
|
||||
require_once($CFG->dirroot.'/calendar/lib.php');
|
||||
|
||||
$from = required_param('from', PARAM_ALPHA);
|
||||
$var = required_param('var', PARAM_ALPHA);
|
||||
$id = optional_param('id', 0, PARAM_INT);
|
||||
$cal_d = optional_param('cal_d', 0, PARAM_INT);
|
||||
$cal_m = optional_param('cal_m', 0, PARAM_INT);
|
||||
$cal_y = optional_param('cal_y', 0, PARAM_INT);
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
$type = optional_param('type', '', PARAM_ALPHA);
|
||||
$from = required_param('from', PARAM_ALPHA);
|
||||
$var = required_param('var', PARAM_ALPHA);
|
||||
$id = optional_param('id', 0, PARAM_INT);
|
||||
$cal_d = optional_param('cal_d', 0, PARAM_INT);
|
||||
$cal_m = optional_param('cal_m', 0, PARAM_INT);
|
||||
$cal_y = optional_param('cal_y', 0, PARAM_INT);
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
$type = optional_param('type', '', PARAM_ALPHA);
|
||||
|
||||
// Initialize the session variables
|
||||
calendar_session_vars();
|
||||
$url = new moodle_url($CFG->wwwroot.'/calendar/set.php', array('from'=>$from,'var'=>$var));
|
||||
if ($id !== 0) {
|
||||
$url->param('id', $id);
|
||||
}
|
||||
if ($cal_d !== 0) {
|
||||
$url->param('cal_d', $cal_d);
|
||||
}
|
||||
if ($cal_m !== 0) {
|
||||
$url->param('cal_m', $cal_m);
|
||||
}
|
||||
if ($cal_y !== 0) {
|
||||
$url->param('cal_y', $cal_y);
|
||||
}
|
||||
if ($action !== 0) {
|
||||
$url->param('action', $action);
|
||||
}
|
||||
if ($type !== 0) {
|
||||
$url->param('type', $type);
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
|
||||
// Ensure course id passed if relevant
|
||||
// Required due to changes in view/lib.php mainly (calendar_session_vars())
|
||||
$courseid = '';
|
||||
if (!empty($id)) {
|
||||
$courseid = '&course='.$id;
|
||||
}
|
||||
// Initialize the session variables
|
||||
calendar_session_vars();
|
||||
|
||||
switch($var) {
|
||||
case 'setuser':
|
||||
// Not implemented yet (or possibly at all)
|
||||
break;
|
||||
case 'setcourse':
|
||||
$id = intval($id);
|
||||
if($id == 0) {
|
||||
// Ensure course id passed if relevant
|
||||
// Required due to changes in view/lib.php mainly (calendar_session_vars())
|
||||
$courseid = '';
|
||||
if (!empty($id)) {
|
||||
$courseid = '&course='.$id;
|
||||
}
|
||||
|
||||
switch($var) {
|
||||
case 'setuser':
|
||||
// Not implemented yet (or possibly at all)
|
||||
break;
|
||||
case 'setcourse':
|
||||
$id = intval($id);
|
||||
if($id == 0) {
|
||||
$SESSION->cal_courses_shown = array();
|
||||
calendar_set_referring_course(0);
|
||||
}
|
||||
else if($id == 1) {
|
||||
$SESSION->cal_courses_shown = calendar_get_default_courses(true);
|
||||
calendar_set_referring_course(0);
|
||||
}
|
||||
else {
|
||||
if($DB->get_record('course', array('id'=>$id)) === false) {
|
||||
// There is no such course
|
||||
$SESSION->cal_courses_shown = array();
|
||||
calendar_set_referring_course(0);
|
||||
}
|
||||
else if($id == 1) {
|
||||
$SESSION->cal_courses_shown = calendar_get_default_courses(true);
|
||||
calendar_set_referring_course(0);
|
||||
}
|
||||
else {
|
||||
if($DB->get_record('course', array('id'=>$id)) === false) {
|
||||
// There is no such course
|
||||
$SESSION->cal_courses_shown = array();
|
||||
calendar_set_referring_course(0);
|
||||
}
|
||||
else {
|
||||
calendar_set_referring_course($id);
|
||||
$SESSION->cal_courses_shown = $id;
|
||||
}
|
||||
calendar_set_referring_course($id);
|
||||
$SESSION->cal_courses_shown = $id;
|
||||
}
|
||||
break;
|
||||
case 'showgroups':
|
||||
$SESSION->cal_show_groups = !$SESSION->cal_show_groups;
|
||||
set_user_preference('calendar_savedflt', calendar_get_filters_status());
|
||||
break;
|
||||
case 'showcourses':
|
||||
$SESSION->cal_show_course = !$SESSION->cal_show_course;
|
||||
set_user_preference('calendar_savedflt', calendar_get_filters_status());
|
||||
break;
|
||||
case 'showglobal':
|
||||
$SESSION->cal_show_global = !$SESSION->cal_show_global;
|
||||
set_user_preference('calendar_savedflt', calendar_get_filters_status());
|
||||
break;
|
||||
case 'showuser':
|
||||
$SESSION->cal_show_user = !$SESSION->cal_show_user;
|
||||
set_user_preference('calendar_savedflt', calendar_get_filters_status());
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'showgroups':
|
||||
$SESSION->cal_show_groups = !$SESSION->cal_show_groups;
|
||||
set_user_preference('calendar_savedflt', calendar_get_filters_status());
|
||||
break;
|
||||
case 'showcourses':
|
||||
$SESSION->cal_show_course = !$SESSION->cal_show_course;
|
||||
set_user_preference('calendar_savedflt', calendar_get_filters_status());
|
||||
break;
|
||||
case 'showglobal':
|
||||
$SESSION->cal_show_global = !$SESSION->cal_show_global;
|
||||
set_user_preference('calendar_savedflt', calendar_get_filters_status());
|
||||
break;
|
||||
case 'showuser':
|
||||
$SESSION->cal_show_user = !$SESSION->cal_show_user;
|
||||
set_user_preference('calendar_savedflt', calendar_get_filters_status());
|
||||
break;
|
||||
}
|
||||
|
||||
switch($from) {
|
||||
case 'event':
|
||||
redirect(CALENDAR_URL.'event.php?action='.$action.'&type='.$type.'&id='.intval($id));
|
||||
break;
|
||||
case 'month':
|
||||
redirect(CALENDAR_URL.'view.php?view=month'.$courseid.'&cal_d='.$cal_d.'&cal_m='.$cal_m.'&cal_y='.$cal_y);
|
||||
break;
|
||||
case 'upcoming':
|
||||
redirect(CALENDAR_URL.'view.php?view=upcoming'.$courseid);
|
||||
break;
|
||||
case 'day':
|
||||
redirect(CALENDAR_URL.'view.php?view=day'.$courseid.'&cal_d='.$cal_d.'&cal_m='.$cal_m.'&cal_y='.$cal_y);
|
||||
break;
|
||||
case 'course':
|
||||
redirect($CFG->wwwroot.'/course/view.php?id='.intval($id));
|
||||
break;
|
||||
default:
|
||||
switch($from) {
|
||||
case 'event':
|
||||
redirect(CALENDAR_URL.'event.php?action='.$action.'&type='.$type.'&id='.intval($id));
|
||||
break;
|
||||
case 'month':
|
||||
redirect(CALENDAR_URL.'view.php?view=month'.$courseid.'&cal_d='.$cal_d.'&cal_m='.$cal_m.'&cal_y='.$cal_y);
|
||||
break;
|
||||
case 'upcoming':
|
||||
redirect(CALENDAR_URL.'view.php?view=upcoming'.$courseid);
|
||||
break;
|
||||
case 'day':
|
||||
redirect(CALENDAR_URL.'view.php?view=day'.$courseid.'&cal_d='.$cal_d.'&cal_m='.$cal_m.'&cal_y='.$cal_y);
|
||||
break;
|
||||
case 'course':
|
||||
redirect($CFG->wwwroot.'/course/view.php?id='.intval($id));
|
||||
break;
|
||||
default:
|
||||
|
||||
}
|
||||
?>
|
||||
}
|
||||
+181
-173
@@ -1,4 +1,4 @@
|
||||
<?php // $Id$
|
||||
<?php
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
@@ -40,202 +40,210 @@
|
||||
|
||||
// Display the calendar page.
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
require_once($CFG->dirroot.'/calendar/lib.php');
|
||||
require_once('../config.php');
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
require_once($CFG->dirroot.'/calendar/lib.php');
|
||||
|
||||
$courseid = optional_param('course', 0, PARAM_INT);
|
||||
$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);
|
||||
$courseid = optional_param('course', 0, PARAM_INT);
|
||||
$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);
|
||||
|
||||
if(!$site = get_site()) {
|
||||
redirect($CFG->wwwroot.'/'.$CFG->admin.'/index.php');
|
||||
}
|
||||
if(!$site = get_site()) {
|
||||
redirect($CFG->wwwroot.'/'.$CFG->admin.'/index.php');
|
||||
}
|
||||
|
||||
$url = new moodle_url($CFG->wwwroot.'/calendar/view.php');
|
||||
if ($courseid !== 0) {
|
||||
$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);
|
||||
$url = new moodle_url($CFG->wwwroot.'/calendar/view.php');
|
||||
if ($courseid !== 0) {
|
||||
$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);
|
||||
|
||||
if ($courseid) {
|
||||
require_login($courseid);
|
||||
} else if ($CFG->forcelogin) {
|
||||
require_login();
|
||||
}
|
||||
if ($courseid) {
|
||||
require_login($courseid);
|
||||
} else if ($CFG->forcelogin) {
|
||||
require_login();
|
||||
}
|
||||
|
||||
// Initialize the session variables
|
||||
calendar_session_vars();
|
||||
// Initialize the session variables
|
||||
calendar_session_vars();
|
||||
|
||||
//add_to_log($course->id, "course", "view", "view.php?id=$course->id", "$course->id");
|
||||
$now = usergetdate(time());
|
||||
$pagetitle = '';
|
||||
//add_to_log($course->id, "course", "view", "view.php?id=$course->id", "$course->id");
|
||||
$now = usergetdate(time());
|
||||
$pagetitle = '';
|
||||
|
||||
$strcalendar = get_string('calendar', 'calendar');
|
||||
|
||||
$link = calendar_get_link_href(CALENDAR_URL.'view.php?view=upcoming&course='.$courseid.'&',
|
||||
$now['mday'], $now['mon'], $now['year']);
|
||||
$PAGE->navbar->add($strcalendar, new moodle_url($link));
|
||||
$strcalendar = get_string('calendar', 'calendar');
|
||||
|
||||
if(!checkdate($mon, $day, $yr)) {
|
||||
$day = intval($now['mday']);
|
||||
$mon = intval($now['mon']);
|
||||
$yr = intval($now['year']);
|
||||
}
|
||||
$time = make_timestamp($yr, $mon, $day);
|
||||
$link = calendar_get_link_href(CALENDAR_URL.'view.php?view=upcoming&course='.$courseid.'&',
|
||||
$now['mday'], $now['mon'], $now['year']);
|
||||
$PAGE->navbar->add($strcalendar, new moodle_url($link));
|
||||
|
||||
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;
|
||||
}
|
||||
if(!checkdate($mon, $day, $yr)) {
|
||||
$day = intval($now['mday']);
|
||||
$mon = intval($now['mon']);
|
||||
$yr = intval($now['year']);
|
||||
}
|
||||
$time = make_timestamp($yr, $mon, $day);
|
||||
|
||||
// If a course has been supplied in the URL, change the filters to show that one
|
||||
if (!empty($courseid)) {
|
||||
if ($course = $DB->get_record('course', array('id'=>$courseid))) {
|
||||
if ($course->id == SITEID) {
|
||||
// If coming from the home page, show all courses
|
||||
$SESSION->cal_courses_shown = calendar_get_default_courses(true);
|
||||
calendar_set_referring_course(0);
|
||||
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;
|
||||
}
|
||||
|
||||
} else {
|
||||
// Otherwise show just this one
|
||||
$SESSION->cal_courses_shown = $course->id;
|
||||
calendar_set_referring_course($SESSION->cal_courses_shown);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$course = null;
|
||||
}
|
||||
// If a course has been supplied in the URL, change the filters to show that one
|
||||
if (!empty($courseid)) {
|
||||
if ($course = $DB->get_record('course', array('id'=>$courseid))) {
|
||||
if ($course->id == SITEID) {
|
||||
// If coming from the home page, show all courses
|
||||
$SESSION->cal_courses_shown = calendar_get_default_courses(true);
|
||||
calendar_set_referring_course(0);
|
||||
|
||||
if (empty($USER->id) or isguest()) {
|
||||
$defaultcourses = calendar_get_default_courses();
|
||||
calendar_set_filters($courses, $groups, $users, $defaultcourses, $defaultcourses);
|
||||
|
||||
} else {
|
||||
calendar_set_filters($courses, $groups, $users);
|
||||
}
|
||||
|
||||
// Let's see if we are supposed to provide a referring course link
|
||||
// but NOT for the "main page" course
|
||||
if ($SESSION->cal_course_referer != SITEID &&
|
||||
($shortname = $DB->get_field('course', 'shortname', array('id'=>$SESSION->cal_course_referer))) !== false) {
|
||||
require_login();
|
||||
if (empty($course)) {
|
||||
$course = $DB->get_record('course', array('id'=>$SESSION->cal_course_referer)); // Useful to have around
|
||||
} else {
|
||||
// Otherwise show just this one
|
||||
$SESSION->cal_courses_shown = $course->id;
|
||||
calendar_set_referring_course($SESSION->cal_courses_shown);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$course = null;
|
||||
}
|
||||
|
||||
$strcalendar = get_string('calendar', 'calendar');
|
||||
$prefsbutton = calendar_preferences_button();
|
||||
if (empty($USER->id) or has_capability('moodle/legacy:guest', get_context_instance(CONTEXT_SYSTEM), 0, false)) {
|
||||
$defaultcourses = calendar_get_default_courses();
|
||||
calendar_set_filters($courses, $groups, $users, $defaultcourses, $defaultcourses);
|
||||
|
||||
// Print title and header
|
||||
$PAGE->set_title("$site->shortname: $strcalendar: $pagetitle");
|
||||
$PAGE->set_heading($strcalendar);
|
||||
$PAGE->set_headingmenu(user_login_string($site));
|
||||
$PAGE->set_button($prefsbutton);
|
||||
} else {
|
||||
calendar_set_filters($courses, $groups, $users);
|
||||
}
|
||||
|
||||
$PAGE->requires->yui_lib('animation');
|
||||
$PAGE->requires->js('calendar/calendar.js');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
// Layout the whole page as three big columns.
|
||||
echo '<table id="calendar" style="height:100%;">';
|
||||
echo '<tr>';
|
||||
|
||||
// START: Main column
|
||||
|
||||
echo '<td class="maincalendar">';
|
||||
echo '<div class="heightcontainer">';
|
||||
|
||||
switch($view) {
|
||||
case 'day':
|
||||
calendar_show_day($day, $mon, $yr, $courses, $groups, $users, $courseid);
|
||||
break;
|
||||
case 'month':
|
||||
calendar_show_month_detailed($mon, $yr, $courses, $groups, $users, $courseid);
|
||||
break;
|
||||
case 'upcoming':
|
||||
calendar_show_upcoming_events($courses, $groups, $users, get_user_preferences('calendar_lookahead', CALENDAR_UPCOMING_DAYS), get_user_preferences('calendar_maxevents', CALENDAR_UPCOMING_MAXEVENTS), $courseid);
|
||||
break;
|
||||
// Let's see if we are supposed to provide a referring course link
|
||||
// but NOT for the "main page" course
|
||||
if ($SESSION->cal_course_referer != SITEID &&
|
||||
($shortname = $DB->get_field('course', 'shortname', array('id'=>$SESSION->cal_course_referer))) !== false) {
|
||||
require_login();
|
||||
if (empty($course)) {
|
||||
$course = $DB->get_record('course', array('id'=>$SESSION->cal_course_referer)); // Useful to have around
|
||||
}
|
||||
}
|
||||
|
||||
//Link to calendar export page
|
||||
echo $OUTPUT->container_start('bottom');
|
||||
if (!empty($CFG->enablecalendarexport)) {
|
||||
echo $OUTPUT->button(html_form::make_button('export.php', array('course'=>$courseid), get_string('exportcalendar', 'calendar')));
|
||||
$strcalendar = get_string('calendar', 'calendar');
|
||||
$prefsbutton = calendar_preferences_button();
|
||||
|
||||
if (!empty($USER->id)) {
|
||||
$authtoken = sha1($USER->username . $USER->password . $CFG->calendar_exportsalt);
|
||||
$usernameencoded = urlencode($USER->username);
|
||||
// Print title and header
|
||||
$PAGE->set_title("$site->shortname: $strcalendar: $pagetitle");
|
||||
$PAGE->set_heading($strcalendar);
|
||||
$PAGE->set_headingmenu(user_login_string($site));
|
||||
$PAGE->set_button($prefsbutton);
|
||||
|
||||
echo "<a href=\"export_execute.php?preset_what=all&preset_time=recentupcoming&username=$usernameencoded&authtoken=$authtoken\">"
|
||||
.'<img src="'.$OUTPUT->old_icon_url('i/ical') . '" height="14" width="36" '
|
||||
.'alt="'.get_string('ical', 'calendar').'" '
|
||||
.'title="'.get_string('quickdownloadcalendar', 'calendar').'" />'
|
||||
.'</a>';
|
||||
}
|
||||
$PAGE->requires->yui_lib('animation');
|
||||
$PAGE->requires->js('calendar/calendar.js');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
// Layout the whole page as three big columns.
|
||||
echo '<table id="calendar" style="height:100%;">';
|
||||
echo '<tr>';
|
||||
|
||||
// START: Main column
|
||||
|
||||
echo '<td class="maincalendar">';
|
||||
echo '<div class="heightcontainer">';
|
||||
|
||||
switch($view) {
|
||||
case 'day':
|
||||
calendar_show_day($day, $mon, $yr, $courses, $groups, $users, $courseid);
|
||||
break;
|
||||
case 'month':
|
||||
calendar_show_month_detailed($mon, $yr, $courses, $groups, $users, $courseid);
|
||||
break;
|
||||
case 'upcoming':
|
||||
calendar_show_upcoming_events($courses, $groups, $users, get_user_preferences('calendar_lookahead', CALENDAR_UPCOMING_DAYS), get_user_preferences('calendar_maxevents', CALENDAR_UPCOMING_MAXEVENTS), $courseid);
|
||||
break;
|
||||
}
|
||||
|
||||
//Link to calendar export page
|
||||
echo $OUTPUT->container_start('bottom');
|
||||
if (!empty($CFG->enablecalendarexport)) {
|
||||
echo $OUTPUT->button(html_form::make_button('export.php', array('course'=>$courseid), get_string('exportcalendar', 'calendar')));
|
||||
|
||||
if (!empty($USER->id)) {
|
||||
$authtoken = sha1($USER->username . $USER->password . $CFG->calendar_exportsalt);
|
||||
$usernameencoded = urlencode($USER->username);
|
||||
|
||||
echo "<a href=\"export_execute.php?preset_what=all&preset_time=recentupcoming&username=$usernameencoded&authtoken=$authtoken\">"
|
||||
.'<img src="'.$OUTPUT->old_icon_url('i/ical') . '" height="14" width="36" '
|
||||
.'alt="'.get_string('ical', 'calendar').'" '
|
||||
.'title="'.get_string('quickdownloadcalendar', 'calendar').'" />'
|
||||
.'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
echo $OUTPUT->container_end();
|
||||
echo '</div>';
|
||||
echo '</td>';
|
||||
echo $OUTPUT->container_end();
|
||||
echo '</div>';
|
||||
echo '</td>';
|
||||
|
||||
// END: Main column
|
||||
// END: Main column
|
||||
|
||||
// START: Last column (3-month display)
|
||||
echo '<td class="sidecalendar">';
|
||||
list($prevmon, $prevyr) = calendar_sub_month($mon, $yr);
|
||||
list($nextmon, $nextyr) = calendar_add_month($mon, $yr);
|
||||
$getvars = 'id='.$courseid.'&cal_d='.$day.'&cal_m='.$mon.'&cal_y='.$yr; // For filtering
|
||||
// START: Last column (3-month display)
|
||||
echo '<td class="sidecalendar">';
|
||||
list($prevmon, $prevyr) = calendar_sub_month($mon, $yr);
|
||||
list($nextmon, $nextyr) = calendar_add_month($mon, $yr);
|
||||
$getvars = 'id='.$courseid.'&cal_d='.$day.'&cal_m='.$mon.'&cal_y='.$yr; // For filtering
|
||||
|
||||
$content='<div class="filters">';
|
||||
$content.=calendar_filter_controls($view, $getvars, NULL, $courses);
|
||||
$content.='</div>';
|
||||
|
||||
print_side_block(get_string('eventskey', 'calendar'),$content);
|
||||
|
||||
$content='<div class="minicalendarblock minicalendartop">';
|
||||
$content.=calendar_top_controls('display', array('id' => $courseid, 'm' => $prevmon, 'y' => $prevyr));
|
||||
$content.=calendar_get_mini($courses, $groups, $users, $prevmon, $prevyr);
|
||||
$content.='</div><div class="minicalendarblock">';
|
||||
$content.=calendar_top_controls('display', array('id' => $courseid, 'm' => $mon, 'y' => $yr));
|
||||
$content.=calendar_get_mini($courses, $groups, $users, $mon, $yr);
|
||||
$content.='</div><div class="minicalendarblock">';
|
||||
$content.=calendar_top_controls('display', array('id' => $courseid, 'm' => $nextmon, 'y' => $nextyr));
|
||||
$content.=calendar_get_mini($courses, $groups, $users, $nextmon, $nextyr);
|
||||
$content.='</div>';
|
||||
|
||||
print_side_block(get_string('monthlyview', 'calendar'),$content);
|
||||
$content='<div class="filters">';
|
||||
$content.=calendar_filter_controls($view, $getvars, NULL, $courses);
|
||||
$content.='</div>';
|
||||
|
||||
echo '</td>';
|
||||
$bc = new block_contents();
|
||||
$bc->content = $content;
|
||||
$bc->footer = '';
|
||||
$bc->title = strip_tags(get_string('eventskey', 'calendar'));
|
||||
echo $OUTPUT->block($bc, BLOCK_POS_LEFT);
|
||||
|
||||
echo '</tr></table>';
|
||||
$content='<div class="minicalendarblock minicalendartop">';
|
||||
$content.=calendar_top_controls('display', array('id' => $courseid, 'm' => $prevmon, 'y' => $prevyr));
|
||||
$content.=calendar_get_mini($courses, $groups, $users, $prevmon, $prevyr);
|
||||
$content.='</div><div class="minicalendarblock">';
|
||||
$content.=calendar_top_controls('display', array('id' => $courseid, 'm' => $mon, 'y' => $yr));
|
||||
$content.=calendar_get_mini($courses, $groups, $users, $mon, $yr);
|
||||
$content.='</div><div class="minicalendarblock">';
|
||||
$content.=calendar_top_controls('display', array('id' => $courseid, 'm' => $nextmon, 'y' => $nextyr));
|
||||
$content.=calendar_get_mini($courses, $groups, $users, $nextmon, $nextyr);
|
||||
$content.='</div>';
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
$bc = new block_contents();
|
||||
$bc->content = $content;
|
||||
$bc->footer = '';
|
||||
$bc->title = strip_tags(get_string('monthlyview', 'calendar'));
|
||||
echo $OUTPUT->block($bc, BLOCK_POS_LEFT);
|
||||
|
||||
echo '</td>';
|
||||
|
||||
echo '</tr></table>';
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
|
||||
|
||||
@@ -255,7 +263,7 @@ function calendar_show_day($d, $m, $y, $courses, $groups, $users, $courseid) {
|
||||
$events = calendar_get_upcoming($courses, $groups, $users, 1, 100, $starttime);
|
||||
|
||||
$text = '';
|
||||
if (!isguest() && !empty($USER->id) && calendar_user_can_add_event()) {
|
||||
if (!has_capability('moodle/legacy:guest', get_context_instance(CONTEXT_SYSTEM), 0, false) && !empty($USER->id) && calendar_user_can_add_event()) {
|
||||
$text.= '<div class="buttons">';
|
||||
$text.= '<form action="'.CALENDAR_URL.'event.php" method="get">';
|
||||
$text.= '<div>';
|
||||
@@ -396,7 +404,7 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users, $course
|
||||
calendar_events_by_day($events, $m, $y, $eventsbyday, $durationbyday, $typesbyday, $courses);
|
||||
|
||||
$text = '';
|
||||
if(!isguest() && !empty($USER->id) && calendar_user_can_add_event()) {
|
||||
if(!has_capability('moodle/legacy:guest', get_context_instance(CONTEXT_SYSTEM), 0, false) && !empty($USER->id) && calendar_user_can_add_event()) {
|
||||
$text.= '<div class="buttons"><form action="'.CALENDAR_URL.'event.php" method="get">';
|
||||
$text.= '<div>';
|
||||
$text.= '<input type="hidden" name="action" value="new" />';
|
||||
@@ -556,7 +564,7 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users, $course
|
||||
|
||||
echo "</tr>\n";
|
||||
|
||||
if(!empty($USER->id) && !isguest()) {
|
||||
if(!empty($USER->id) && !has_capability('moodle/legacy:guest', get_context_instance(CONTEXT_SYSTEM), 0, false)) {
|
||||
echo '<tr>';
|
||||
// Group events
|
||||
if($SESSION->cal_show_groups) {
|
||||
@@ -589,7 +597,7 @@ function calendar_show_upcoming_events($courses, $groups, $users, $futuredays, $
|
||||
|
||||
$text = '';
|
||||
|
||||
if(!isguest() && !empty($USER->id) && calendar_user_can_add_event()) {
|
||||
if(!has_capability('moodle/legacy:guest', get_context_instance(CONTEXT_SYSTEM), 0, false) && !empty($USER->id) && calendar_user_can_add_event()) {
|
||||
$text.= '<div class="buttons">';
|
||||
$text.= '<form action="'.CALENDAR_URL.'event.php" method="get">';
|
||||
$text.= '<div>';
|
||||
@@ -623,7 +631,7 @@ function calendar_show_upcoming_events($courses, $groups, $users, $futuredays, $
|
||||
function calendar_course_filter_selector($getvars = '') {
|
||||
global $USER, $SESSION, $OUTPUT;
|
||||
|
||||
if (empty($USER->id) or isguest()) {
|
||||
if (empty($USER->id) or has_capability('moodle/legacy:guest', get_context_instance(CONTEXT_SYSTEM), 0, false)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user