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
This commit is contained in:
stronk7 2004-10-06 16:52:24 +00:00
parent ed1da52b1b
commit 1066e0dc62
5 changed files with 15 additions and 15 deletions

View File

@ -593,7 +593,7 @@ function calendar_filter_controls($type, $vars = NULL, $course = NULL) {
$content .= '<td style="width: 8px;"></td><td><a href="'.CALENDAR_URL.'set.php?var=showcourses'.$getvars.'" title="'.get_string('tt_showcourse', 'calendar').'">'.get_string('courseevents', 'calendar').'</a></td>'."\n";
}
if(!empty($USER) && !isguest()) {
if(!empty($USER->id) && !isguest()) {
$content .= "</tr>\n<tr>";
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();
}

View File

@ -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 = '<div style="float: left;">'.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 "</tr>\n";
if(!empty($USER) && !isguest()) {
if(!empty($USER->id) && !isguest()) {
echo '<tr>';
// 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 '';
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -1,4 +1,4 @@
<?PHP // $Id$
<?php // $Id$
require_once("../config.php");
require_once("$CFG->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!");
}