From 629e12fd8166d2e15a69adfe4b44d81b456b4627 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Wed, 25 Aug 2010 08:43:42 +0000 Subject: [PATCH] MDL-23927 do not use = 'guest' because we have CFG->siteguest AND it matches any other username with accents and different case in MySQL --- auth/shibboleth/index.php | 2 +- blocks/online_users/block_online_users.php | 4 ++-- course/recent_form.php | 4 +--- course/report/log/lib.php | 8 ++------ 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/auth/shibboleth/index.php b/auth/shibboleth/index.php index ff8a385090f..f798d402931 100644 --- a/auth/shibboleth/index.php +++ b/auth/shibboleth/index.php @@ -6,7 +6,7 @@ $PAGE->set_url('/auth/shibboleth/index.php'); - if (isloggedin() && $USER->username != 'guest') { // Nothing to do + if (isloggedin() && !isguestuser()) { // Nothing to do if (isset($SESSION->wantsurl) and (strpos($SESSION->wantsurl, $CFG->wwwroot) === 0)) { $urltogo = $SESSION->wantsurl; /// Because it's an address in this site unset($SESSION->wantsurl); diff --git a/blocks/online_users/block_online_users.php b/blocks/online_users/block_online_users.php index decdb0ede04..70ddd2b6d0d 100644 --- a/blocks/online_users/block_online_users.php +++ b/blocks/online_users/block_online_users.php @@ -144,7 +144,7 @@ class block_online_users extends block_base { $this->content->text .= '
  • '; $timeago = format_time(time() - $user->lastaccess); //bruno to calculate correctly on frontpage - if ($user->username == 'guest') { + if (isguestuser($user)) { $this->content->text .= '
    '.$OUTPUT->user_picture($user, array('size'=>16)); $this->content->text .= get_string('guestuser').'
    '; @@ -152,7 +152,7 @@ class block_online_users extends block_base { $this->content->text .= '
    '.$OUTPUT->user_picture($user, array('size'=>16)); $this->content->text .= ''.$user->fullname.'
    '; } - if ($canshowicon and ($USER->id != $user->id) and $user->username != 'guest') { // Only when logged in and messaging active etc + if ($canshowicon and ($USER->id != $user->id) and !isguestuser($user)) { // Only when logged in and messaging active etc $anchortagcontents = ''. get_string('messageselectadd') .''; $anchortag = ''.$anchortagcontents .''; diff --git a/course/recent_form.php b/course/recent_form.php index b8f121c00db..a9f78ef41c3 100644 --- a/course/recent_form.php +++ b/course/recent_form.php @@ -51,9 +51,7 @@ class recent_form extends moodleform { if ($viewparticipants) { $options = array(); $options[0] = get_string('allparticipants'); - if ($guest = get_complete_user_data('username', 'guest')) { - $options[$guest->id] = fullname($guest); - } + $options[$CFG->siteguest] = get_string('guestuser'); if (groups_get_course_groupmode($COURSE) == SEPARATEGROUPS) { $groups = groups_get_user_groups($COURSE->id); diff --git a/course/report/log/lib.php b/course/report/log/lib.php index 3a7b6bc7a0f..420fcf530cc 100644 --- a/course/report/log/lib.php +++ b/course/report/log/lib.php @@ -104,9 +104,7 @@ function print_mnet_log_selector_form($hostid, $course, $selecteduser=0, $select $users[$courseuser->id] = fullname($courseuser, has_capability('moodle/site:viewfullnames', $context)); } } - if ($guest = get_complete_user_data('username', 'guest')) { - $users[$guest->id] = fullname($guest); - } + $users[$CFG->siteguest] = get_string('guestuser'); } // Get all the hosts that have log records @@ -368,9 +366,7 @@ function print_log_selector_form($course, $selecteduser=0, $selecteddate='today' $users[$courseuser->id] = fullname($courseuser, has_capability('moodle/site:viewfullnames', $context)); } } - if ($guest = get_complete_user_data('username', 'guest')) { - $users[$guest->id] = fullname($guest); - } + $users[$CFG->siteguest] = get_string('guestuser'); } if (has_capability('coursereport/log:view', $sitecontext) && $showcourses) {