Commit 86a1ba04 authored by skodak's avatar skodak
Browse files

replace all uses of isset($USER->id) with empty() to allow proper operation of...

replace all uses of isset($USER->id) with empty() to allow proper operation of $CFG->notloggedinroleid hack
parent 741fee9b
......@@ -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) {
......
......@@ -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) {
......
......@@ -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)) ) {
......
......@@ -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);
......
......@@ -247,7 +247,7 @@
echo '<div class="commands">';
if (isset($USER->id)) {
if (!empty($USER->id)) {
$context = get_context_instance(CONTEXT_SYSTEM, SITEID);
$canmanage = has_capability('moodle/blog:manageentries', $context->id);
......
......@@ -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');
}
......
......@@ -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
......
......@@ -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.");
}
......
......@@ -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');
......
......@@ -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)) {
......
......@@ -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;
}
......
......@@ -291,7 +291,7 @@ class assignment_base {
$submitted = '<a href="submissions.php?id='.$this->cm->id.'">'.
get_string('viewsubmissions', 'assignment', $count).'</a>';
} 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)) {
......
......@@ -1036,7 +1036,7 @@ class assignment_upload extends assignment_base {
$output .= '<img align="middle" src="'.$CFG->pixpath.'/f/'.$icon.'" height="16" width="16" alt="'.$icon.'" />'.
'<a href="'.$ffurl.'" >'.$file.'</a> ['.$filesize.'] <br />';
} 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
......
......@@ -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;
}
......
......@@ -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");
}
......
......@@ -41,7 +41,7 @@
$fullpivot = 1;
$userid = '';
if ( isset($USER->id) ) {
if ( !empty($USER->id) ) {
$userid = "OR ge.userid = $USER->id";
}
switch ($tab) {
......
......@@ -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;
......
......@@ -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();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment