From 86a1ba04fd1191b6494d5578aaec968d398eb93a Mon Sep 17 00:00:00 2001 From: skodak Date: Sat, 2 Sep 2006 11:44:04 +0000 Subject: [PATCH] replace all uses of isset($USER->id) with empty() to allow proper operation of $CFG->notloggedinroleid hack --- blocks/blog_menu/block_blog_menu.php | 2 +- blocks/course_list/block_course_list.php | 2 +- blocks/rss_client/block_rss_client.php | 2 +- blog/header.php | 2 +- blog/lib.php | 2 +- blog/tags.php | 2 +- calendar/lib.php | 2 +- course/lib.php | 2 +- index.php | 2 +- lib/moodlelib.php | 2 +- lib/weblib.php | 2 +- mod/assignment/lib.php | 2 +- mod/assignment/type/upload/assignment.class.php | 2 +- mod/choice/index.php | 2 +- mod/choice/view.php | 2 +- mod/glossary/sql.php | 2 +- mod/survey/index.php | 2 +- user/policy.php | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/blocks/blog_menu/block_blog_menu.php b/blocks/blog_menu/block_blog_menu.php index c689fb0185..edc8ba2b2e 100755 --- a/blocks/blog_menu/block_blog_menu.php +++ b/blocks/blog_menu/block_blog_menu.php @@ -33,7 +33,7 @@ class block_blog_menu extends block_base { } global $CFG, $USER, $course; - if (isset($USER->id)) { + if (!empty($USER->id)) { $userBlog->userid = $USER->id; } //what is $userBlog anyway if($this->content !== NULL) { diff --git a/blocks/course_list/block_course_list.php b/blocks/course_list/block_course_list.php index dd9434c84f..fe8bf720b2 100644 --- a/blocks/course_list/block_course_list.php +++ b/blocks/course_list/block_course_list.php @@ -34,7 +34,7 @@ class block_course_list extends block_list { } } - if (empty($CFG->disablemycourses) and isset($USER->id) and !(isadmin() and $adminseesall)) { // Just print My Courses + if (empty($CFG->disablemycourses) and !empty($USER->id) and !(isadmin() and $adminseesall)) { // Just print My Courses if ($courses = get_my_courses($USER->id)) { foreach ($courses as $course) { if ($course->id == SITEID) { diff --git a/blocks/rss_client/block_rss_client.php b/blocks/rss_client/block_rss_client.php index 555eaa6f4f..aa4603474f 100644 --- a/blocks/rss_client/block_rss_client.php +++ b/blocks/rss_client/block_rss_client.php @@ -97,7 +97,7 @@ // then allow the user to add rss feeds global $USER; $userisloggedin = false; - if (isset($USER) && isset($USER->id) && $USER->id && !isguest()) { + if (isset($USER) && !empty($USER->id) && $USER->id && !isguest()) { $userisloggedin = true; } if ( $userisloggedin && ($submitters == SUBMITTERS_ALL_ACCOUNT_HOLDERS || ($submitters == SUBMITTERS_ADMIN_AND_TEACHER && $isteacher)) ) { diff --git a/blog/header.php b/blog/header.php index e5ba7a2b7a..f5304af25f 100755 --- a/blog/header.php +++ b/blog/header.php @@ -41,7 +41,7 @@ $pageclass = 'page_blog'; page_map_class($pagetype, $pageclass); // Now, create our page object. -if (!isset($USER->id)) { +if (empty($USER->id)) { $PAGE = page_create_object($pagetype); } else { $PAGE = page_create_object($pagetype, $USER->id); diff --git a/blog/lib.php b/blog/lib.php index e0f0b0965d..41e9dd9c13 100755 --- a/blog/lib.php +++ b/blog/lib.php @@ -247,7 +247,7 @@ echo '
'; - if (isset($USER->id)) { + if (!empty($USER->id)) { $context = get_context_instance(CONTEXT_SYSTEM, SITEID); $canmanage = has_capability('moodle/blog:manageentries', $context->id); diff --git a/blog/tags.php b/blog/tags.php index 46a99359e4..14f93e4b79 100755 --- a/blog/tags.php +++ b/blog/tags.php @@ -40,7 +40,7 @@ switch ($mode) { /// Everyone can add personal tags as long as they can write blog entries. if (!confirm_sesskey() || !has_capability('moodle/blog:writeentries', $context) || - !isset($USER->id)) { + empty($USER->id)) { error ('you can not add tags'); } diff --git a/calendar/lib.php b/calendar/lib.php index 88f87ea663..ecd8c6aab8 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -1034,7 +1034,7 @@ function calendar_session_vars() { // The empty() instead of !isset() here makes a whole world of difference, // as it will automatically change to the user's id when the user first logs // in. With !isset(), it would never do that. - $SESSION->cal_users_shown = isset($USER->id) ? $USER->id : false; + $SESSION->cal_users_shown = !empty($USER->id) ? $USER->id : false; } else if(is_numeric($SESSION->cal_users_shown) && !empty($USER->id) && $SESSION->cal_users_shown != $USER->id) { // Follow the white rabbit, for example if a teacher logs in as a student diff --git a/course/lib.php b/course/lib.php index e86a35458d..08d3af3847 100644 --- a/course/lib.php +++ b/course/lib.php @@ -1566,7 +1566,7 @@ function print_my_moodle() { global $USER, $CFG; - if (!isset($USER->id)) { + if (empty($USER->id)) { error("It shouldn't be possible to see My Moodle without being logged in."); } diff --git a/index.php b/index.php index 7674bc4d2b..242c947c62 100644 --- a/index.php +++ b/index.php @@ -159,7 +159,7 @@ error('Could not find or create a main news forum for the site'); } - if (isset($USER->id)) { + if (!empty($USER->id)) { $SESSION->fromdiscussion = $CFG->wwwroot; if (forum_is_subscribed($USER->id, $newsforum->id)) { $subtext = get_string('unsubscribe', 'forum'); diff --git a/lib/moodlelib.php b/lib/moodlelib.php index e53b490b7f..acad9ecffe 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -1465,7 +1465,7 @@ function sesskey() { function require_logout() { global $USER, $CFG; - if (isset($USER) and isset($USER->id)) { + if (!empty($USER->id)) { add_to_log(SITEID, "user", "logout", "view.php?id=$USER->id&course=".SITEID, $USER->id, 0, $USER->id); if ($USER->auth == 'cas' && !empty($CFG->cas_enabled)) { diff --git a/lib/weblib.php b/lib/weblib.php index 386a3e481e..c873aba147 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -2574,7 +2574,7 @@ function theme_setup($theme = '', $params=NULL) { function user_login_string($course=NULL, $user=NULL) { global $USER, $CFG, $SITE; - if (empty($user) and isset($USER->id)) { + if (empty($user) and !empty($USER->id)) { $user = $USER; } diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php index 3cdf636ebc..64d8639368 100644 --- a/mod/assignment/lib.php +++ b/mod/assignment/lib.php @@ -291,7 +291,7 @@ class assignment_base { $submitted = ''. get_string('viewsubmissions', 'assignment', $count).''; } else { - if (isset($USER->id)) { + if (!empty($USER->id)) { if ($submission = $this->get_submission($USER->id)) { if ($submission->timemodified) { if ($submission->timemodified <= $this->assignment->timedue || empty($this->assignment->timedue)) { diff --git a/mod/assignment/type/upload/assignment.class.php b/mod/assignment/type/upload/assignment.class.php index 729e038efa..d80391dc66 100644 --- a/mod/assignment/type/upload/assignment.class.php +++ b/mod/assignment/type/upload/assignment.class.php @@ -1036,7 +1036,7 @@ class assignment_upload extends assignment_base { $output .= ''.$icon.''. ''.$file.' ['.$filesize.']
'; } else { - if (isset($USER->id)) { + if (!empty($USER->id)) { if ($submission = $this->get_submission($USER->id)) { //i have changed timemodified=0 for Draft assignments, thats' why we remove this condition //otherwise student's dont' se etheir own submissions diff --git a/mod/choice/index.php b/mod/choice/index.php index 970d016aa2..66681a7f98 100644 --- a/mod/choice/index.php +++ b/mod/choice/index.php @@ -24,7 +24,7 @@ notice("There are no choices", "../../course/view.php?id=$course->id"); } - if ( isset($USER->id) and $allanswers = get_records("choice_answers", "userid", $USER->id)) { + if ( !empty($USER->id) and $allanswers = get_records("choice_answers", "userid", $USER->id)) { foreach ($allanswers as $aa) { $answers[$aa->choiceid] = $aa; } diff --git a/mod/choice/view.php b/mod/choice/view.php index 87a1977bcb..58a2c85930 100644 --- a/mod/choice/view.php +++ b/mod/choice/view.php @@ -69,7 +69,7 @@ } //if user has already made a selection, and they are not allowed to update it, show their selected answer. - if (isset($USER->id) && ($current = get_record('choice_answers', 'choiceid', $choice->id, 'userid', $USER->id))) { + if (!empty($USER->id) && ($current = get_record('choice_answers', 'choiceid', $choice->id, 'userid', $USER->id))) { print_simple_box(get_string("yourselection", "choice", userdate($choice->timeopen)).": ".format_string(choice_get_option_text($choice, $current->optionid)), "center"); } diff --git a/mod/glossary/sql.php b/mod/glossary/sql.php index cfa9dc38fa..915353d246 100644 --- a/mod/glossary/sql.php +++ b/mod/glossary/sql.php @@ -41,7 +41,7 @@ $fullpivot = 1; $userid = ''; - if ( isset($USER->id) ) { + if ( !empty($USER->id) ) { $userid = "OR ge.userid = $USER->id"; } switch ($tab) { diff --git a/mod/survey/index.php b/mod/survey/index.php index f2283049fb..27609b7fa9 100644 --- a/mod/survey/index.php +++ b/mod/survey/index.php @@ -42,7 +42,7 @@ $currentsection = ''; foreach ($surveys as $survey) { - if (isset($USER->id) and survey_already_done($survey->id, $USER->id)) { + if (!empty($USER->id) and survey_already_done($survey->id, $USER->id)) { $ss = $strdone; } else { $ss = $strnotdone; diff --git a/user/policy.php b/user/policy.php index bcc1b9aa91..0519883c66 100644 --- a/user/policy.php +++ b/user/policy.php @@ -7,7 +7,7 @@ define('MESSAGE_WINDOW', true); // This prevents the message window coming up - if (!isset($USER->id)) { + if (empty($USER->id)) { require_login(); } -- 2.39.5