Skip to content

Commit

Permalink
replace all uses of isset($USER->id) with empty() to allow proper ope…
Browse files Browse the repository at this point in the history
…ration of $CFG->notloggedinroleid hack
  • Loading branch information
skodak committed Sep 2, 2006
1 parent 741fee9 commit 86a1ba0
Show file tree
Hide file tree
Showing 18 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion blocks/blog_menu/block_blog_menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function get_content() {
}

global $CFG, $USER, $course;
if (isset($USER->id)) {
if (!empty($USER->id)) {
$userBlog->userid = $USER->id;
} //what is $userBlog anyway
if($this->content !== NULL) {
Expand Down
2 changes: 1 addition & 1 deletion blocks/course_list/block_course_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function get_content() {
}
}

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) {
Expand Down
2 changes: 1 addition & 1 deletion blocks/rss_client/block_rss_client.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function get_content() {
// 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)) ) {
Expand Down
2 changes: 1 addition & 1 deletion blog/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
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);
Expand Down
2 changes: 1 addition & 1 deletion blog/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ function blog_print_entry($blogEntry, $viewtype='full', $filtertype='', $filters

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);

Expand Down
2 changes: 1 addition & 1 deletion blog/tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
/// 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');
}

Expand Down
2 changes: 1 addition & 1 deletion calendar/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion course/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}

Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion lib/moodlelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/weblib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion mod/assignment/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ function submittedlink() {
$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)) {
Expand Down
2 changes: 1 addition & 1 deletion mod/assignment/type/upload/assignment.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ function print_user_files($userid=0, $return=false) {
$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
Expand Down
2 changes: 1 addition & 1 deletion mod/choice/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion mod/choice/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down
2 changes: 1 addition & 1 deletion mod/glossary/sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
$fullpivot = 1;

$userid = '';
if ( isset($USER->id) ) {
if ( !empty($USER->id) ) {
$userid = "OR ge.userid = $USER->id";
}
switch ($tab) {
Expand Down
2 changes: 1 addition & 1 deletion mod/survey/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion user/policy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit 86a1ba0

Please sign in to comment.