diff --git a/mod/chat/view.php b/mod/chat/view.php
index b8e8d51fab7..96fea955325 100644
--- a/mod/chat/view.php
+++ b/mod/chat/view.php
@@ -45,6 +45,29 @@
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ // show some info for guests
+ if (isguestuser()) {
+ $navigation = build_navigation('', $cm);
+ print_header_simple(format_string($chat->name), '', $navigation,
+ '', '', true, '', navmenu($course, $cm));
+ $wwwroot = $CFG->wwwroot.'/login/index.php';
+ if (!empty($CFG->loginhttps)) {
+ $wwwroot = str_replace('http:','https:', $wwwroot);
+ }
+
+ notice_yesno(get_string('noguests', 'chat').'
'.get_string('liketologin'),
+ $wwwroot, $CFG->wwwroot.'/course/view.php?id='.$course->id);
+
+ print_footer($course);
+ exit;
+
+ } else {
+ $navigation = build_navigation('', $cm);
+ print_header_simple(format_string($chat->name), '', $navigation,
+ '', '', true, '', navmenu($course, $cm));
+ require_capability('mod/chat:chat', $context);
+ }
+
add_to_log($course->id, 'chat', 'view', "view.php?id=$cm->id", $chat->id, $cm->id);
// Initialize $PAGE, compute blocks
@@ -111,50 +134,31 @@
print_heading(format_string($chat->name));
/// Print the main part of the page
-
- if (has_capability('mod/chat:chat',$context)) {
- print_box_start('generalbox', 'enterlink');
- // users with screenreader set, will only see 1 link, to the manual refresh page
- // for better accessibility
- if (!empty($USER->screenreader)) {
- $chattarget = "/mod/chat/gui_basic/index.php?id=$chat->id$groupparam";
- } else {
- $chattarget = "/mod/chat/gui_$CFG->chat_method/index.php?id=$chat->id$groupparam";
- }
-
- echo '
'; - link_to_popup_window ($chattarget, - "chat$course->id$chat->id$groupparam", "$strenterchat", 500, 700, get_string('modulename', 'chat')); - echo '
'; - - // if user is using screen reader, then there is no need to display this link again - if ($CFG->chat_method == 'header_js' && empty($USER->screenreader)) { - // show frame/js-less alternative - echo '('; - link_to_popup_window ("/mod/chat/gui_basic/index.php?id=$chat->id$groupparam", - "chat$course->id$chat->id$groupparam", get_string('noframesjs', 'message'), 500, 700, get_string('modulename', 'chat')); - echo ')
'; - } - - print_box_end(); - - } else if (isguestuser()) { - $wwwroot = $CFG->wwwroot.'/login/index.php'; - if (!empty($CFG->loginhttps)) { - $wwwroot = str_replace('http:','https:', $wwwroot); - } - - notice_yesno(get_string('noguests', 'chat').''; + link_to_popup_window ($chattarget, + "chat$course->id$chat->id$groupparam", "$strenterchat", 500, 700, get_string('modulename', 'chat')); + echo '
'; + + // if user is using screen reader, then there is no need to display this link again + if ($CFG->chat_method == 'header_js' && empty($USER->screenreader)) { + // show frame/js-less alternative + echo '('; + link_to_popup_window ("/mod/chat/gui_basic/index.php?id=$chat->id$groupparam", + "chat$course->id$chat->id$groupparam", get_string('noframesjs', 'message'), 500, 700, get_string('modulename', 'chat')); + echo ')
'; + } + + print_box_end(); + if ($chat->chattime and $chat->schedule) { // A chat is scheduled echo "$strnextsession: ".userdate($chat->chattime).' ('.usertimezone($USER->timezone).')
';