]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14679 towards /calendar conversion
authorskodak <skodak>
Sun, 1 Jun 2008 14:25:05 +0000 (14:25 +0000)
committerskodak <skodak>
Sun, 1 Jun 2008 14:25:05 +0000 (14:25 +0000)
calendar/event.php
calendar/event_new.html
calendar/export.php
calendar/lib.php
calendar/preferences.php
calendar/set.php
calendar/view.php

index 3cf31e287e290c7f86100171499d09e981ffc5c4..26751d7b999422864b0dbfd112b9ae172869e35c 100644 (file)
@@ -87,7 +87,7 @@
     }
 
     // If a course has been supplied in the URL, change the filters to show that one
-    if($urlcourse > 0 && record_exists('course', 'id', $urlcourse)) {
+    if($urlcourse > 0 && $DB->record_exists('course', array('id'=>$urlcourse))) {
         require_login($urlcourse, false);
 
         if($urlcourse == SITEID) {
     switch($action) {
         case 'delete':
             $title = get_string('deleteevent', 'calendar');
-            $event = get_record('event', 'id', $eventid);
+            $event = $DB->get_record('event', array('id'=>$eventid));
             if($event === false) {
                 print_error('invalidevent');
             }
 
         case 'edit':
             $title = get_string('editevent', 'calendar');
-            $event = get_record('event', 'id', $eventid);
+            $event = $DB->get_record('event', array('id'=>$eventid));
             $repeats = optional_param('repeats', 0, PARAM_INT);
 
-            if($event === false) {
+            if ($event === false) {
                 print_error('invalidevent');
             }
-            if(!calendar_edit_event_allowed($event)) {
+            if (!calendar_edit_event_allowed($event)) {
                 print_error('nopermissions');
             }
 
-            if($form = data_submitted()) {
+            if($form = data_submitted(false)) {
 
                 $form->name = clean_param(strip_tags($form->name,'<lang><span>'), PARAM_CLEAN);
 
                             $timestartoffset = 'timestart - '.($event->timestart - $form->timestart);
                         }
 
-                        execute_sql('UPDATE '.$CFG->prefix.'event SET '.
-                            'name = '.addslashes($form->name).','.
-                            'description = '.addslashes($form->description).','.
-                            'timestart = '.$timestartoffset.','.
-                            'timeduration = '.$form->timeduration.','.
-                            'timemodified = '.time().' WHERE repeatid = '.$event->repeatid);
+                        $sql = "UPDATE {event}
+                                   SET name = ?,
+                                       description = ?,
+                                       timestart = ?,
+                                       timeduration = ?,
+                                       timemodified = ?
+                                 WHERE repeatid = ?";
+                        $params = array($form->name, $form->description, $timestartoffset, $form->timeduration, time(), $event->repeatid);
+
+                        $DB->execute_sql($sql, $params);
 
                         /// Log the event update.
-                        $form->name = stripslashes($form->name);  //To avoid double-slashes
                         add_to_log($form->courseid, 'calendar', 'edit all', 'event.php?action=edit&amp;id='.$form->id, $form->name);
                     }
 
                     else {
                         // Update this
                         $form->timemodified = time();
-                        update_record('event', $form);
+                        $DB->update_record('event', $form);
 
                         /// Log the event update.
-                        $form->name = stripslashes($form->name);  //To avoid double-slashes
                         add_to_log($form->courseid, 'calendar', 'edit', 'event.php?action=edit&amp;id='.$form->id, $form->name);
                     }
 
 
         case 'new':
             $title = get_string('newevent', 'calendar');
-            $form = data_submitted();
+            $form = data_submitted(false);
             if(!empty($form) && !empty($form->name)) {
 
                 $form->name = clean_text(strip_tags($form->name, '<lang><span>'));
                     $form->timemodified = time();
 
                     /// Get the event id for the log record.
-                    $eventid = insert_record('event', $form, true);
+                    $eventid = $DB->insert_record('event', $form);
                     
                     /// Use the event id as the repeatid to link repeat entries together
                     if ($form->repeat) {
                         $form->repeatid = $form->id = $eventid;
-                        update_record('event', $form);         // update the row, to set its repeatid          
+                        $DB->update_record('event', $form);         // update the row, to set its repeatid             
                     }
 
                     /// Log the event entry.
-                    add_to_log($form->courseid, 'calendar', 'add', 'event.php?action=edit&amp;id='.$eventid, stripslashes($form->name));
+                    add_to_log($form->courseid, 'calendar', 'add', 'event.php?action=edit&amp;id='.$eventid, $form->name);
 
                     if ($form->repeat) {
                         for($i = 1; $i < $form->repeats; $i++) {
                             $form->timestart += $dst_offset_prev - dst_offset_on($form->timestart);
 
                             /// Get the event id for the log record.
-                            $eventid = insert_record('event', $form, true);
+                            $eventid = $DB->insert_record('event', $form);
 
                             /// Log the event entry.
-                            add_to_log($form->courseid, 'calendar', 'add', 'event.php?action=edit&amp;id='.$eventid, stripslashes($form->name));
+                            add_to_log($form->courseid, 'calendar', 'add', 'event.php?action=edit&amp;id='.$eventid, $form->name);
                         }
                     }
                     // OK, now redirect to day view
 
     if (!empty($SESSION->cal_course_referer)) {
         // TODO: This is part of the Great $course Hack in Moodle. Replace it at some point.
-        $course = get_record('course', 'id', $SESSION->cal_course_referer);
+        $course = $DB->get_record('course', array('id'=>$SESSION->cal_course_referer));
     } else {
         $course = $site;
     }
     echo '<table id="calendar">';
     echo '<tr><td class="maincalendar">';
 
-    switch($action) {
+    switch ($action) {
         case 'delete':
             $confirm = optional_param('confirm', 0, PARAM_INT);
             $repeats = optional_param('repeats', 0, PARAM_INT);
-            if($confirm) {
+            if ($confirm) {
                 // Kill it and redirect to day view
-                if(($event = get_record('event', 'id', $eventid)) !== false) {
+                if(($event = $DB->get_record('event', array('id'=>$eventid))) !== false) {
 
-                    if($event->repeatid && $repeats) {
-                        delete_records('event', 'repeatid', $event->repeatid);
+                    if ($event->repeatid && $repeats) {
+                        $DB->delete_records('event', array('repeatid'=>$event->repeatid));
                         add_to_log($event->courseid, 'calendar', 'delete all', '', $event->name);
-                    }
-                    else {
-                        delete_records('event', 'id', $eventid);
+                    } else {
+                        $DB->delete_records('event', array('id'=>$eventid));
                         add_to_log($event->courseid, 'calendar', 'delete', '', $event->name);
                     }
                 }
                 $d = $eventtime['mday'];
                 $y = $eventtime['year'];
 
-                if($event->repeatid) {
-                    $fetch = get_record_sql('SELECT 1, COUNT(id) AS repeatcount FROM '.$CFG->prefix.'event WHERE repeatid = '.$event->repeatid);
-                    $repeatcount = $fetch->repeatcount;
-                }
-                else {
+                if ($event->repeatid) {
+                    $repeatcount = $DB->count_records('event', array('repeatid'=>$event->repeatid));
+                } else {
                     $repeatcount = 0;
                 }
 
 
             if (!empty($form->courseid)) {
                 // TODO: This is part of the Great $course Hack in Moodle. Replace it at some point.
-                $course = get_record('course', 'id', $form->courseid);
+                $course = $DB->get_record('course', array('id'=>$form->courseid));
             } else {
                 $course = $site;
             }
 
-            if($event->repeatid) {
-                $fetch = get_record_sql('SELECT 1, COUNT(id) AS repeatcount FROM '.$CFG->prefix.'event WHERE repeatid = '.$event->repeatid);
+            if ($event->repeatid) {
+                $repeatcount = $DB->count_records('event', array('repeatid'=>$event->repeatid));
                 $repeatcount = $fetch->repeatcount;
-            }
-            else {
+            } else {
                 $repeatcount = 0;
             }
 
                 break;
                 case 'course':
                     $courseid = optional_param('courseid', 0, PARAM_INT);
-                    if(!record_exists('course', 'id', $courseid)) {
+                    if (!$DB->record_exists('course', array('id'=>$courseid))) {
                         calendar_get_allowed_types($allowed);
                         $eventtype = 'select';
                     }
                 if ($courseid == 0) { // workaround by Dan for bug #6130
                     $courseid = SITEID;
                 }
-                if (!$course = get_record('course', 'id', $courseid)) {
+                if (!$course = $DB->get_record('course', array('id'=>$courseid))) {
                     print_error('invalidcourse');
                 }
                 
 
 
 function validate_form(&$form, &$err) {
+    global $DB;
 
     $form->name = trim($form->name);
     $form->description = trim($form->description);
@@ -591,7 +590,7 @@ function validate_form(&$form, &$err) {
     }
     if(!empty($form->courseid)) {
         // Timestamps must be >= course startdate
-        $course = get_record('course', 'id', $form->courseid);
+        $course = $DB->get_record('course', array('id'=>$form->courseid));
         if($course === false) {
             print_error('invalidcourse');
         }
@@ -602,7 +601,7 @@ function validate_form(&$form, &$err) {
 }
 
 function calendar_add_event_allowed($event) {
-    global $USER;
+    global $USER, $DB;
 
     // can not be using guest account
     if (empty($USER->id) or $USER->username == 'guest') {
@@ -623,7 +622,7 @@ function calendar_add_event_allowed($event) {
             // Allow users to add/edit group events if:
             // 1) They have manageentries (= entries for whole course)
             // 2) They have managegroupentries AND are in the group
-            $group = get_record('groups', 'id', $event->groupid);         
+            $group = $DB->get_record('groups', array('id'=>$event->groupid));         
             return $group && (
                 has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_COURSE, $group->courseid)) ||
                 (has_capability('moodle/calendar:managegroupentries', get_context_instance(CONTEXT_COURSE, $group->courseid))
index 15035d5e04bef74da9b795a34a0e2386f699d1ba..2e094f3820f412b5dc849a25d1fbbd26a3a1eb49 100644 (file)
@@ -1,6 +1,6 @@
 <?php
     // The following is a hack to fix bug 1488
-    $course = get_record('course', 'id', ($form->courseid) ? $form->courseid : $site->id);
+    $course = $DB->get_record('course', array('id'=>($form->courseid ? $form->courseid : $site->id)));
 ?>
 <form method="post" action="event.php" id="eventform">
 <table cellpadding="5">
index 41d59c2e38670d56a9f04dad2f6837b3f71c672f..1dccb7bdb83855f8a2da852f73a1cd2ff10070c1 100644 (file)
@@ -10,7 +10,7 @@ $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 ($courseid = optional_param('course', 0, PARAM_INT)) {
-    $course = get_record('course', 'id', $courseid); 
+    $course = $DB->get_record('course', array('id'=>$courseid)); 
 }
 
 require_login();
@@ -32,7 +32,7 @@ if ($course->id != SITEID) {
                         'type' => 'misc');
 }
 $navlinks[] = array('name' => get_string('calendar', 'calendar'),
-                    'link' =>calendar_get_link_href(CALENDAR_URL.'view.php?view=upcoming&amp;course='.$course.'&amp;',
+                    'link' =>calendar_get_link_href(CALENDAR_URL.'view.php?view=upcoming&amp;course='.$courseid.'&amp;',
                                                     $now['mday'], $now['mon'], $now['year']),
                     'type' => 'misc');
 $navlinks[] = array('name' => $pagetitle, 'link' => null, 'type' => 'misc');
@@ -112,13 +112,13 @@ list($nextmon, $nextyr) = calendar_add_month($mon, $yr);
 $getvars = 'cal_d='.$day.'&amp;cal_m='.$mon.'&amp;cal_y='.$yr; // For filtering
 
 echo '<div class="minicalendarblock">';
-echo calendar_top_controls('display', array('id' => $course, 'm' => $prevmon, 'y' => $prevyr));
+echo calendar_top_controls('display', array('id' => $courseid, 'm' => $prevmon, 'y' => $prevyr));
 echo calendar_get_mini($courses, $groups, $users, $prevmon, $prevyr);
 echo '</div><div class="minicalendarblock">';
-echo calendar_top_controls('display', array('id' => $course, 'm' => $mon, 'y' => $yr));
+echo calendar_top_controls('display', array('id' => $courseid, 'm' => $mon, 'y' => $yr));
 echo calendar_get_mini($courses, $groups, $users, $mon, $yr);
 echo '</div><div class="minicalendarblock">';
-echo calendar_top_controls('display', array('id' => $course, 'm' => $nextmon, 'y' => $nextyr));
+echo calendar_top_controls('display', array('id' => $courseid, 'm' => $nextmon, 'y' => $nextyr));
 echo calendar_get_mini($courses, $groups, $users, $nextmon, $nextyr);
 echo '</div>';
 
index b80c51ab9fbe0ee68ae7cac1c2a1b877ce93e18b..30acc32090b4d415b6455b59474da9c471c49ecf 100644 (file)
@@ -46,6 +46,8 @@ define('CALENDAR_DEFAULT_STARTING_WEEKDAY',   1);
 // Default value = 65 = 64 + 1 = 2^6 + 2^0 = Saturday & Sunday
 define('CALENDAR_DEFAULT_WEEKEND',            65);
 
+//TODO: fix this ehm "not nice code at all"
+
 // Fetch the correct values from admin settings/lang pack
 // If no such settings found, use the above defaults
 $firstday = isset($CFG->calendar_startwday) ? $CFG->calendar_startwday : get_string('firstdayofweek');
@@ -356,14 +358,14 @@ function calendar_get_popup($is_today, $event_timestart, $popupcontent='') {
     } else {
         $popupcaption .= get_string('eventsfor', 'calendar', userdate($event_timestart, get_string('strftimedayshort')));
     }
-    $popupcontent = str_replace("'", "\'", htmlspecialchars($popupcontent));
-    $popupcaption = str_replace("'", "\'", htmlspecialchars($popupcaption));
+    $popupcontent = addslashes_js($popupcontent);
+    $popupcaption = addslashes_js($popupcaption);
     $popup = 'onmouseover="return overlib(\''.$popupcontent.'\', CAPTION, \''.$popupcaption.'\');" onmouseout="return nd();"';
     return $popup;
 }
 
 function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxevents, $fromtime=0) {
-    global $CFG, $COURSE;
+    global $CFG, $COURSE, $DB;
 
     $display = new stdClass;
     $display->range = $daysinfuture; // How many days in the future we 'll look
@@ -430,7 +432,7 @@ function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxeve
                 if ($event->modulename == 'assignment'){
                     // TODO: rewrite this hack somehow
                     if (!calendar_edit_event_allowed($event)){ // cannot manage entries, eg. student  
-                        if(!$assignment = get_record('assignment','id',$event->instance)){
+                        if (!$assignment = $DB->get_record('assignment', array('id'=>$event->instance))) {
                             // print_error("invalidid", 'assignment');
                             continue;
                         }
@@ -586,6 +588,8 @@ function calendar_print_event($event) {
  * @return array of selected events or an empty array if there aren't any (or there was an error)
  */
 function calendar_get_events($tstart, $tend, $users, $groups, $courses, $withduration=true, $ignorehidden=true) {
+    global $DB;
+
     $whereclause = '';
     // Quick test
     if(is_bool($users) && is_bool($groups) && is_bool($courses)) {
@@ -679,7 +683,7 @@ function calendar_get_events($tstart, $tend, $users, $groups, $courses, $withdur
         $whereclause .= ' AND visible = 1';
     }
 
-    $events = get_records_select('event', $whereclause, 'timestart');
+    $events = $DB->get_records_select('event', $whereclause, null, 'timestart');
     if ($events === false) {
         $events = array();
     }
@@ -1125,12 +1129,13 @@ function calendar_get_module_cached(&$coursecache, $modulename, $instance) {
 }
 
 function calendar_get_course_cached(&$coursecache, $courseid) {
-    global $COURSE;
+    global $COURSE, $DB;
+
     if (!isset($coursecache[$courseid])) {
         if ($courseid == $COURSE->id) {
             $coursecache[$courseid] = $COURSE;
         } else {
-            $coursecache[$courseid] = get_record('course', 'id', $courseid);
+            $coursecache[$courseid] = $DB->get_record('course', array('id'=>$courseid));
         }
     }
     return $coursecache[$courseid];
@@ -1202,7 +1207,7 @@ function calendar_set_referring_course($courseid) {
 }
 
 function calendar_set_filters(&$courses, &$group, &$user, $courseeventsfrom = NULL, $groupeventsfrom = NULL, $ignorefilters = false) {
-    global $SESSION, $USER, $CFG;
+    global $SESSION, $USER, $CFG, $DB;
 
     // Insidious bug-wannabe: setting $SESSION->cal_courses_shown to $course->id would cause
     // the code to function incorrectly UNLESS we convert it to an integer. One case where
@@ -1219,12 +1224,12 @@ function calendar_set_filters(&$courses, &$group, &$user, $courseeventsfrom = NU
     // we probably should do some clean up and make sure that session is set to use the proper form
     if (is_int($courseeventsfrom)) { // case of an int, e.g. calendar view page
         $c = array();
-        $c[$courseeventsfrom] = get_record('course', 'id', $courseeventsfrom);
+        $c[$courseeventsfrom] = $DB->get_record('course', array('id'=>$courseeventsfrom));
         $courseeventsfrom = $c;
     } else if (is_array($courseeventsfrom)) { // case of an array of ints, e.g. course home page
         foreach ($courseeventsfrom as $i=>$courseid) { // TODO: this seems wrong, the array is often constructed as [courseid] => 1 ???
             if (is_int($courseid)) {
-                $courseeventsfrom[$i] = get_record('course', 'id', $courseid);
+                $courseeventsfrom[$i] = $DB->get_record('course', array('id'=>$courseid));
             } 
         }    
     }
@@ -1316,9 +1321,9 @@ function calendar_set_filters(&$courses, &$group, &$user, $courseeventsfrom = NU
                         if (is_object($courseeventsfrom[$courseid])) { // SHOULD be set MDL-11221
                             $courserecord = $courseeventsfrom[$courseid];
                         } else {
-                            $courserecord = get_record('course', 'id', $courseid);
+                            $courserecord = $DB->get_record('course', array('id'=>$courseid));
                         } 
-                        $courserecord = get_record('course', 'id', $courseid);
+                        $courserecord = $DB->get_record('course', array('id'=>$courseid));
                         if ($courserecord->groupmode != NOGROUPS || !$courserecord->groupmodeforce) {
                             $groupids[] = $courseid;
                         }
@@ -1339,10 +1344,10 @@ function calendar_set_filters(&$courses, &$group, &$user, $courseeventsfrom = NU
 
             if (!empty($groupids)) {
                 $sql = "SELECT *
-                        FROM {$CFG->prefix}groups
+                        FROM {groups}
                         WHERE courseid IN (".implode(',', $groupids).')';
 
-                if ($grouprecords= get_records_sql($sql)) {
+                if ($grouprecords = $DB->get_records_sql($sql, null)) {
                     foreach ($grouprecords as $grouprecord) {
                         $grouparray[] = $grouprecord->id;
                     }
@@ -1364,8 +1369,7 @@ function calendar_set_filters(&$courses, &$group, &$user, $courseeventsfrom = NU
 }
 
 function calendar_edit_event_allowed($event) {
-
-    global $USER;
+    global $USER, $DB;
 
     // Must be logged in
     if (!isloggedin()) {
@@ -1388,7 +1392,7 @@ function calendar_edit_event_allowed($event) {
         // Allow users to add/edit group events if:
         // 1) They have manageentries (= entries for whole course)
         // 2) They have managegroupentries AND are in the group
-        $group = get_record('groups', 'id', $event->groupid);
+        $group = $DB->get_record('groups', array('id'=>$event->groupid));
         return $group && (
             has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_COURSE, $group->courseid)) ||
             (has_capability('moodle/calendar:managegroupentries', get_context_instance(CONTEXT_COURSE, $group->courseid))
@@ -1405,7 +1409,7 @@ function calendar_edit_event_allowed($event) {
 }
 
 function calendar_get_default_courses($ignoreref = false) {
-    global $USER, $CFG, $SESSION;
+    global $USER, $CFG, $SESSION, $DB;
 
     if(!empty($SESSION->cal_course_referer) && !$ignoreref) {
         return array($SESSION->cal_course_referer => 1);
@@ -1418,7 +1422,7 @@ function calendar_get_default_courses($ignoreref = false) {
     $courses = array();
     if (has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_SYSTEM))) {
         if (!empty($CFG->calendar_adminseesall)) {
-            $courses = get_records_sql('SELECT id, 1 FROM '.$CFG->prefix.'course');
+            $courses = $DB->get_records_sql('SELECT id, 1 FROM {course}');
             return $courses;
         }
     }
@@ -1572,7 +1576,7 @@ function calendar_set_filters_status($packed_bitfield) {
 }
 
 function calendar_get_allowed_types(&$allowed) {
-    global $USER, $CFG, $SESSION;
+    global $USER, $CFG, $SESSION, $DB;
     $sitecontext = get_context_instance(CONTEXT_SYSTEM);
     $allowed->user = has_capability('moodle/calendar:manageownentries', $sitecontext);
     $allowed->groups = false; // This may change just below
@@ -1580,7 +1584,7 @@ function calendar_get_allowed_types(&$allowed) {
     $allowed->site = has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_COURSE, SITEID));
 
     if(!empty($SESSION->cal_course_referer) && $SESSION->cal_course_referer != SITEID) {
-        $course = get_record('course', 'id', $SESSION->cal_course_referer);
+        $course = $DB->get_record('course', array('id'=>$SESSION->cal_course_referer));
         $coursecontext = get_context_instance(CONTEXT_COURSE, $SESSION->cal_course_referer);
 
         if(has_capability('moodle/calendar:manageentries', $coursecontext)) {
index 98fd0912bbc3cc63e65cbeaf26e32999e8c7c641..28989e413a6f0ea7861a997da27d27f81a052fea 100644 (file)
@@ -5,7 +5,7 @@
     require_once($CFG->dirroot.'/calendar/lib.php');
 
     if (isset($SESSION->cal_course_referer)) {
-        if (! $course = get_record('course', 'id', $SESSION->cal_course_referer)) {
+        if (! $course = $DB->get_record('course', array('id'=>$SESSION->cal_course_referer))) {
             $course = get_site();
         }
     }
@@ -18,7 +18,7 @@
 
 /// If data submitted, then process and store.
 
-    if ($form = data_submitted()) {
+    if ($form = data_submitted(false)) {
         foreach ($form as $preference => $value) {
             switch ($preference) {
                 case 'timeformat':
index 0893605a1f33688066aef15e70d8f0bbbf9a54ca..6d1844f34fca34e58e456e7b4725e4ccda5cba83 100644 (file)
@@ -76,7 +76,7 @@
                 calendar_set_referring_course(0);
             }
             else {
-                if(get_record('course', 'id', $id) === false) {
+                if($DB->get_record('course', array('id'=>$id)) === false) {
                     // There is no such course
                     $SESSION->cal_courses_shown = array();
                     calendar_set_referring_course(0);
index 9ecc0b2e3bb22b568cce5a4a72b436f2720c1cd5..827e63cea274b830c65e5ec5c8539ce5249fed3a 100644 (file)
@@ -98,7 +98,7 @@
 
     // If a course has been supplied in the URL, change the filters to show that one
     if (!empty($courseid)) {
-        if ($course = get_record('course', 'id', $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);
     // 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 = get_field('course', 'shortname', 'id', $SESSION->cal_course_referer)) !== false) {
+       ($shortname = $DB->get_field('course', 'shortname', array('id'=>$SESSION->cal_course_referer))) !== false) {
         require_login();
         if (empty($course)) {
-            $course = get_record('course', 'id', $SESSION->cal_course_referer); // Useful to have around
+            $course = $DB->get_record('course', array('id'=>$SESSION->cal_course_referer)); // Useful to have around
         }
     }
 
@@ -307,7 +307,7 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users, $course
 
     $getvars = 'from=month&amp;cal_d='.$day.'&amp;cal_m='.$mon.'&amp;cal_y='.$yr; // For filtering
 
-    $display = &New stdClass;
+    $display = new stdClass;
     $display->minwday = get_user_preferences('calendar_startwday', CALENDAR_STARTING_WEEKDAY);
     $display->maxwday = $display->minwday + 6;