diff --git a/lang/en_utf8/chat.php b/lang/en_utf8/chat.php index 3c887c97f11e0..704a097dfe2de 100644 --- a/lang/en_utf8/chat.php +++ b/lang/en_utf8/chat.php @@ -3,9 +3,10 @@ $string['autoscroll'] = 'Auto Scroll'; $string['beep'] = 'beep'; -$string['chat:chat'] = 'Talk in a chat'; +$string['chat:chat'] = 'Access a chat room'; $string['chat:deletelog'] = 'Delete chat logs'; $string['chat:readlog'] = 'Read chat logs'; +$string['chat:talk'] = 'Talk in a chat'; $string['chatintro'] = 'Introduction text'; $string['chatname'] = 'Name of this chat room'; $string['chatreport'] = 'Chat sessions'; diff --git a/mod/chat/db/access.php b/mod/chat/db/access.php index e3d25887c02b0..1029cf23b04ad 100644 --- a/mod/chat/db/access.php +++ b/mod/chat/db/access.php @@ -47,6 +47,20 @@ ) ), + 'mod/chat:talk' => array( + + 'riskbitmask' => RISK_SPAM, + + 'captype' => 'write', + 'contextlevel' => CONTEXT_MODULE, + 'legacy' => array( + 'student' => CAP_ALLOW, + 'teacher' => CAP_ALLOW, + 'editingteacher' => CAP_ALLOW, + 'admin' => CAP_ALLOW + ) + ), + 'mod/chat:readlog' => array( 'captype' => 'read', diff --git a/mod/chat/gui_header_js/chatinput.php b/mod/chat/gui_header_js/chatinput.php index 990a7782d9204..9a93fc48fe035 100644 --- a/mod/chat/gui_header_js/chatinput.php +++ b/mod/chat/gui_header_js/chatinput.php @@ -6,10 +6,25 @@ require('../lib.php'); $chat_sid = required_param('chat_sid', PARAM_ALPHANUM); + $chatid = required_param('chat_id', PARAM_INT); if (!$chatuser = get_record('chat_users', 'sid', $chat_sid)) { error('Not logged in!'); } + if (!$chat = get_record('chat', 'id', $chatid)) { + error('Could not find that chat room!'); + } + + if (!$course = get_record('course', 'id', $chat->course)) { + error('Could not find the course this belongs to!'); + } + + if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) { + error('Course Module ID was incorrect'); + } + + $context = get_context_instance(CONTEXT_MODULE, $cm->id); + //Get the user theme $USER = get_record('user', 'id', $chatuser->userid); @@ -48,6 +63,7 @@ function enableForm() { $meta = ob_get_clean(); print_header('', '', '', 'input_chat_message', $meta, false); + if(has_capability('mod/chat:chatlog',$context)){ ?>
+