From 4314c0bcf55b907406ee6ee3ba19883806c5dd76 Mon Sep 17 00:00:00 2001 From: dongsheng Date: Tue, 16 Dec 2008 04:58:40 +0000 Subject: [PATCH] "MDL-14949, add a new capablity chat:talk to enable readonly chat user, merged from 1.9" --- lang/en_utf8/chat.php | 3 ++- mod/chat/db/access.php | 14 ++++++++++++++ mod/chat/gui_header_js/chatinput.php | 19 +++++++++++++++++++ mod/chat/gui_header_js/index.php | 2 +- mod/chat/version.php | 2 +- 5 files changed, 37 insertions(+), 3 deletions(-) diff --git a/lang/en_utf8/chat.php b/lang/en_utf8/chat.php index a32a3d377b..31931a5f1f 100644 --- a/lang/en_utf8/chat.php +++ b/lang/en_utf8/chat.php @@ -6,11 +6,12 @@ $string['autoscroll'] = 'Auto Scroll'; $string['beep'] = 'beep'; $string['cantlogin'] = 'Could not log in to chat room!!'; $string['cantinsert'] = 'Could not insert a chat message!'; -$string['chat:chat'] = 'Talk in a chat'; +$string['chat:chat'] = 'Access a chat room'; $string['chat:deletelog'] = 'Delete chat logs'; $string['chat:exportsession'] = 'Export chat session'; $string['chat:exportparticipatedsession'] = 'Export participated-in chat session'; $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 f34243f41e..bfe71e4d94 100644 --- a/mod/chat/db/access.php +++ b/mod/chat/db/access.php @@ -47,6 +47,20 @@ $mod_chat_capabilities = array( ) ), + '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 42312caeba..6d1232c516 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 = $DB->get_record('chat_users', array('sid'=>$chat_sid))) { print_error('notlogged', 'chat'); } + 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 = $DB->get_record('user', array('id'=>$chatuser->userid)); @@ -48,6 +63,7 @@ $meta = ob_get_clean(); print_header('', '', '', 'input_chat_message', $meta, false); + if(has_capability('mod/chat:chatlog',$context)){ ?>
@@ -55,6 +71,9 @@
+
diff --git a/mod/chat/gui_header_js/index.php b/mod/chat/gui_header_js/index.php index a468e6c567..aba89dfbaa 100644 --- a/mod/chat/gui_header_js/index.php +++ b/mod/chat/gui_header_js/index.php @@ -50,7 +50,7 @@ print_error('cantlogin', 'chat'); } - $params = "chat_sid=$chat_sid"; + $params = "chat_id=$id&chat_sid={$chat_sid}"; // fallback to the old jsupdate, but allow other update modes $updatemode = 'jsupdate'; diff --git a/mod/chat/version.php b/mod/chat/version.php index 8873b80f91..70e959a59e 100644 --- a/mod/chat/version.php +++ b/mod/chat/version.php @@ -5,7 +5,7 @@ /// This fragment is called by moodle_needs_upgrading() and /admin/index.php ///////////////////////////////////////////////////////////////////////////////// -$module->version = 2008081400; // The (date) version of this module +$module->version = 2008081401; // The (date) version of this module $module->requires = 2007101509; // Requires this Moodle version $module->cron = 300; // How often should cron check this module (seconds)? -- 2.39.5