isguest() compatible with roles

This commit is contained in:
skodak
2006-08-26 18:42:56 +00:00
parent 907cf31821
commit 18d8a6a741
+12 -1
View File
@@ -2262,7 +2262,18 @@ function isstudent($courseid, $userid=0) {
* @return bool
*/
function isguest($userid=0) {
global $USER;
global $USER, $CFG;
if (!empty($CFG->rolesactive)) {
$context = get_context_instance(CONTEXT_SYSTEM, SITEID);
if (!$userid) {
return has_capability('moodle/legacy:guest', $context);
} else {
return has_capability('moodle/legacy:guest', $context, $userid);
}
}
if (!$userid) {
if (empty($USER->username)) {