diff --git a/calendar/event.php b/calendar/event.php index fd2e1f24b5b..43304352e60 100644 --- a/calendar/event.php +++ b/calendar/event.php @@ -50,10 +50,13 @@ redirect(CALENDAR_URL.'view.php?view=upcoming'); } - $action = required_param('action', PARAM_ALPHA); - $eventid = optional_param('id', 0, PARAM_INT); + $action = required_param('action', PARAM_ALPHA); + $eventid = optional_param('id', 0, PARAM_INT); $eventtype = optional_param('type', 'select', PARAM_ALPHA); $urlcourse = optional_param('course', 0, PARAM_INT); + $cal_y = optional_param('cal_y'); + $cal_m = optional_param('cal_m'); + $cal_d = optional_param('cal_d'); if(!$site = get_site()) { redirect($CFG->wwwroot.'/'.$CFG->admin.'/index.php'); @@ -361,20 +364,17 @@ break; case 'new': - optional_variable($_GET['cal_y']); - optional_variable($_GET['cal_m']); - optional_variable($_GET['cal_d']); - optional_variable($form->timestart, -1); + set_default($form->timestart, -1); - if($_GET['cal_y'] && $_GET['cal_m'] && $_GET['cal_d'] && checkdate($_GET['cal_m'], $_GET['cal_d'], $_GET['cal_y'])) { - $form->timestart = make_timestamp($_GET['cal_y'], $_GET['cal_m'], $_GET['cal_d'], 0, 0, 0); + if($cal_y && $cal_m && $cal_d && checkdate($cal_m, $cal_d, $cal_y)) { + $form->timestart = make_timestamp($cal_y, $cal_m, $cal_d, 0, 0, 0); } - else if($_GET['cal_y'] && $_GET['cal_m'] && checkdate($_GET['cal_m'], 1, $_GET['cal_y'])) { - if($_GET['cal_y'] == $now['year'] && $_GET['cal_m'] == $now['mon']) { - $form->timestart = make_timestamp($_GET['cal_y'], $_GET['cal_m'], $now['mday'], 0, 0, 0); + else if($cal_y && $cal_m && checkdate($cal_m, 1, $cal_y)) { + if($cal_y == $now['year'] && $cal_m == $now['mon']) { + $form->timestart = make_timestamp($cal_y, $cal_m, $now['mday'], 0, 0, 0); } else { - $form->timestart = make_timestamp($_GET['cal_y'], $_GET['cal_m'], 1, 0, 0, 0); + $form->timestart = make_timestamp($cal_y, $cal_m, 1, 0, 0, 0); } } if($form->timestart < 0) { diff --git a/calendar/lib.php b/calendar/lib.php index 1610b449606..cc170f831eb 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -628,6 +628,8 @@ function calendar_filter_controls($type, $vars = NULL, $course = NULL) { $groupevents = true; $getvars = ''; + + $id = optional_param( 'id',0,PARAM_INT ); switch($type) { case 'event': @@ -637,8 +639,8 @@ function calendar_filter_controls($type, $vars = NULL, $course = NULL) { $getvars = '&from='.$type; break; case 'course': - if (isset($_GET['id'])) { - $getvars = '&from=course&id='.$_GET['id']; + if (isset_param('id')) { + $getvars = '&from=course&id='.$id; } else { $getvars = '&from=course'; } diff --git a/calendar/set.php b/calendar/set.php index 86e3c4d3d9f..2c3f018ee66 100644 --- a/calendar/set.php +++ b/calendar/set.php @@ -41,20 +41,20 @@ require_once('../config.php'); require_once($CFG->dirroot.'/calendar/lib.php'); - require_variable($_GET['from']); - require_variable($_GET['var']); - optional_variable($_GET['value']); - optional_variable($_GET['id']); - optional_variable($_GET['cal_d']); - optional_variable($_GET['cal_m']); - optional_variable($_GET['cal_y']); + $from = required_param('from'); + $var = required_param('var'); + $value = optional_param('value'); + $id = optional_param('id'); + $cal_d = optional_param('cal_d'); + $cal_m = optional_param('cal_m'); + $cal_y = optional_param('cal_y'); - switch($_GET['var']) { + switch($var) { case 'setuser': // Not implemented yet (or possibly at all) break; case 'setcourse': - $id = intval($_GET['id']); + $id = intval($id); if($id == 0) { $SESSION->cal_courses_shown = array(); calendar_set_referring_course(0); @@ -94,21 +94,21 @@ break; } - switch($_GET['from']) { + switch($from) { case 'event': - redirect(CALENDAR_URL.'event.php?action='.$_GET['action'].'&type='.$_GET['type'].'&id='.intval($_GET['id'])); + redirect(CALENDAR_URL.'event.php?action='.$action.'&type='.$type.'&id='.intval($id)); break; case 'month': - redirect(CALENDAR_URL.'view.php?view=month&cal_d='.$_GET['cal_d'].'&cal_m='.$_GET['cal_m'].'&cal_y='.$_GET['cal_y']); + redirect(CALENDAR_URL.'view.php?view=month&cal_d='.$cal_d.'&cal_m='.$cal_m.'&cal_y='.$cal_y); break; case 'upcoming': redirect(CALENDAR_URL.'view.php?view=upcoming'); break; case 'day': - redirect(CALENDAR_URL.'view.php?view=day&cal_d='.$_GET['cal_d'].'&cal_m='.$_GET['cal_m'].'&cal_y='.$_GET['cal_y']); + redirect(CALENDAR_URL.'view.php?view=day&cal_d='.$cal_d.'&cal_m='.$cal_m.'&cal_y='.$cal_y); break; case 'course': - redirect($CFG->wwwroot.'/course/view.php?id='.intval($_GET['id'])); + redirect($CFG->wwwroot.'/course/view.php?id='.intval($id)); break; default: diff --git a/calendar/view.php b/calendar/view.php index 8281b07adf5..a80b7564b40 100644 --- a/calendar/view.php +++ b/calendar/view.php @@ -44,7 +44,11 @@ require_once($CFG->dirroot.'/course/lib.php'); require_once($CFG->dirroot.'/calendar/lib.php'); - optional_variable($_GET['course'], 0); + $course = optional_param('course', 0); + $view = optional_param('view', 'upcoming'); + $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'); @@ -56,10 +60,6 @@ $nav = calendar_get_link_tag(get_string('calendar', 'calendar'), CALENDAR_URL.'view.php?view=upcoming&', $now['mday'], $now['mon'], $now['year']); - $view = optional_param('view', 'upcoming'); - $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(!checkdate($mon, $day, $yr)) { $day = intval($now['mday']); @@ -83,8 +83,8 @@ } // If a course has been supplied in the URL, change the filters to show that one - if (!empty($_GET['course'])) { - if ($course = get_record('course', 'id', $_GET['course'])) { + if (!empty($course)) { + if ($course = get_record('course', 'id', $course)) { if ($course->id == 1) { // If coming from the home page, show all courses $SESSION->cal_courses_shown = calendar_get_default_courses(true);