MDL-22871 fixed detection of local guest account, it must have the local mnet id

This commit is contained in:
Petr Skoda
2010-07-25 17:52:53 +00:00
parent 9bea72dcb9
commit a2f5e222b7
+9 -9
View File
@@ -2617,7 +2617,7 @@ function isloggedin() {
* @return bool true if user is the real guest user, false if not logged in or other user
*/
function isguestuser($user=NULL) {
global $USER;
global $USER, $CFG;
if ($user === NULL) {
$user = $USER;
} else if (is_numeric($user)) {
@@ -2628,7 +2628,7 @@ function isguestuser($user=NULL) {
return false; // not logged in, can not be guest
}
return ($user->username == 'guest');
return ($user->username == 'guest' and $user->mnethostid == $CFG->mnet_localhost_id);
}
/**
@@ -3273,7 +3273,7 @@ function complete_user_login($user) {
$USER = $user; // this is required because we need to access preferences here!
if (!empty($CFG->regenloginsession)) {
// please note this setting may break some auth plugins
// please note this setting may break some auth plugins
session_regenerate_id();
}
@@ -5792,7 +5792,7 @@ function get_list_of_countries_language() {
if ($lang == 'en_utf8') {
return;
}
}
$parentlang = get_string('parentlanguage');
if (substr($parentlang, 0, 1) != '[') {
@@ -5805,7 +5805,7 @@ function get_list_of_countries_language() {
if ($parentlang == 'en_utf8') {
return;
}
}
}
if (is_readable($CFG->dataroot.'/lang/en_utf8/countries.php')) {
@@ -5845,7 +5845,7 @@ function get_list_of_countries() {
if (is_readable($CFG->dataroot.'/lang/' . $lang . '_local/countries.php')) {
include($CFG->dataroot.'/lang/' . $lang . '_local/countries.php');
}
if (empty($string)) {
print_error('countriesphpempty', '', '', $lang);
}
@@ -6910,7 +6910,7 @@ function shorten_text($text, $ideal=30, $exact = false) {
// This array stores information about open and close tags and their position
// in the truncated string. Each item in the array is an object with fields
// ->open (true if open), ->tag (tag name in lower case), and ->pos
// ->open (true if open), ->tag (tag name in lower case), and ->pos
// (byte position in truncated text)
$tagdetails = array();
@@ -6923,12 +6923,12 @@ function shorten_text($text, $ideal=30, $exact = false) {
// if tag is a closing tag (f.e. </b>)
} else if (preg_match('/^<\s*\/([^\s]+?)\s*>$/s', $line_matchings[1], $tag_matchings)) {
// record closing tag
$tagdetails[] = (object)array('open'=>false,
$tagdetails[] = (object)array('open'=>false,
'tag'=>strtolower($tag_matchings[1]), 'pos'=>strlen($truncate));
// if tag is an opening tag (f.e. <b>)
} else if (preg_match('/^<\s*([^\s>!]+).*?>$/s', $line_matchings[1], $tag_matchings)) {
// record opening tag
$tagdetails[] = (object)array('open'=>true,
$tagdetails[] = (object)array('open'=>true,
'tag'=>strtolower($tag_matchings[1]), 'pos'=>strlen($truncate));
}
// add html-tag to $truncate'd text