From 1066e0dc62e299b164a55c91444ea84be8715c8c Mon Sep 17 00:00:00 2001 From: stronk7 Date: Wed, 6 Oct 2004 16:52:24 +0000 Subject: [PATCH] Changed some conditions against the $USER variable to work fine under PHP5. Bug 2053 (http://moodle.org/bugs/bug.php?op=show&bugid=2053) Merged from MOODLE_14_STABLE --- calendar/lib.php | 10 +++++----- calendar/view.php | 12 ++++++------ course/lib.php | 2 +- mod/forum/lib.php | 2 +- user/edit.php | 4 ++-- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/calendar/lib.php b/calendar/lib.php index e4588dc1cb..e569689d9a 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -593,7 +593,7 @@ function calendar_filter_controls($type, $vars = NULL, $course = NULL) { $content .= ''.get_string('courseevents', 'calendar').''."\n"; } - if(!empty($USER) && !isguest()) { + if(!empty($USER->id) && !isguest()) { $content .= "\n"; if($groupevents) { @@ -864,13 +864,13 @@ function calendar_get_course_cached(&$coursecache, $courseid) { function calendar_session_vars() { global $SESSION, $USER; - if(isset($USER) && isset($USER->realuser) && !isset($SESSION->cal_loggedinas)) { + if(!empty($USER->id) && isset($USER->realuser) && !isset($SESSION->cal_loggedinas)) { // We just logged in as someone else, update the filtering unset($SESSION->cal_users_shown); unset($SESSION->cal_courses_shown); $SESSION->cal_loggedinas = true; } - else if(isset($USER) && !isset($USER->realuser) && isset($SESSION->cal_loggedinas)) { + else if(!empty($USER->id) && !isset($USER->realuser) && isset($SESSION->cal_loggedinas)) { // We just logged back to our real self, update again unset($SESSION->cal_users_shown); unset($SESSION->cal_courses_shown); @@ -1010,7 +1010,7 @@ function calendar_set_filters(&$courses, &$group, &$user, $courseeventsfrom = NU function calendar_edit_event_allowed($event) { global $USER; - if(empty($USER) || isguest($USER->id)) { + if(empty($USER->id) || isguest($USER->id)) { return false; } @@ -1045,7 +1045,7 @@ function calendar_get_default_courses($ignoreref = false) { return array($SESSION->cal_course_referer => 1); } - if(empty($USER)) { + if(empty($USER->id)) { return array(); } diff --git a/calendar/view.php b/calendar/view.php index 8ade21a9fd..6e7c236419 100644 --- a/calendar/view.php +++ b/calendar/view.php @@ -105,7 +105,7 @@ } } - if (empty($USER) or isguest()) { + if (empty($USER->id) or isguest()) { $defaultcourses = calendar_get_default_courses(); calendar_set_filters($courses, $groups, $users, $defaultcourses, $defaultcourses); @@ -198,7 +198,7 @@ function calendar_show_day($d, $m, $y, $courses, $groups, $users) { $events = calendar_get_upcoming($courses, $groups, $users, 1, 100, $starttime); // New event button - if (empty($USER) || isguest()) { + if (empty($USER->id) || isguest()) { $text = get_string('dayview', 'calendar').': '.calendar_course_filter_selector($getvars); } else { $text = '
'.get_string('dayview', 'calendar').': '. @@ -319,7 +319,7 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users) { calendar_events_by_day($events, $m, $y, $eventsbyday, $durationbyday, $typesbyday); // New event button - if(empty($USER) || isguest()) { + if(empty($USER->id) || isguest()) { $text = get_string('detailedmonthview', 'calendar').': '.calendar_course_filter_selector($getvars); } else { @@ -482,7 +482,7 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users) { echo "\n"; - if(!empty($USER) && !isguest()) { + if(!empty($USER->id) && !isguest()) { echo ''; // Group events if($SESSION->cal_show_groups) { @@ -515,7 +515,7 @@ function calendar_show_upcoming_events($courses, $groups, $users, $futuredays, $ $events = calendar_get_upcoming($courses, $groups, $users, $futuredays, $maxevents); // New event button - if(empty($USER) || isguest()) { + if(empty($USER->id) || isguest()) { $text = get_string('upcomingevents', 'calendar').': '.calendar_course_filter_selector('from=upcoming'); } else { @@ -601,7 +601,7 @@ function calendar_print_event($event) { function calendar_course_filter_selector($getvars = '') { global $USER, $SESSION; - if (empty($USER) or isguest()) { + if (empty($USER->id) or isguest()) { return ''; } diff --git a/course/lib.php b/course/lib.php index d25bfb167a..4ae1afa47a 100644 --- a/course/lib.php +++ b/course/lib.php @@ -811,7 +811,7 @@ function get_all_sections($courseid) { function course_set_display($courseid, $display=0) { global $USER; - if (empty($USER)) { + if (empty($USER->id)) { return false; } diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 17f304d3a1..97727d5dbf 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -202,7 +202,7 @@ function forum_cron () { $strforums = get_string('forums', 'forum'); } - if (!empty($USER)) { // Remember real USER account if necessary + if (!empty($USER->id)) { // Remember real USER account if necessary $realuser = $USER; } diff --git a/user/edit.php b/user/edit.php index 640aa6d08b..4cd9388d9e 100644 --- a/user/edit.php +++ b/user/edit.php @@ -1,4 +1,4 @@ -libdir/gdlib.php"); @@ -30,7 +30,7 @@ // so that users can set up their accounts $newaccount = true; - if (empty($USER)) { + if (empty($USER->id)) { error("Sessions don't seem to be working on this server!"); } -- 2.39.5