Skip to content

Commit

Permalink
"MDL-14949, add a new capability chat:talk"
Browse files Browse the repository at this point in the history
  • Loading branch information
dongsheng committed Dec 16, 2008
1 parent d09916f commit 9111f5d
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lang/en_utf8/chat.php
Expand Up @@ -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';
Expand Down
14 changes: 14 additions & 0 deletions mod/chat/db/access.php
Expand Up @@ -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',
Expand Down
19 changes: 19 additions & 0 deletions mod/chat/gui_header_js/chatinput.php
Expand Up @@ -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);
Expand Down Expand Up @@ -48,13 +63,17 @@ function enableForm() {
$meta = ob_get_clean();
print_header('', '', '', 'input_chat_message', $meta, false);

if(has_capability('mod/chat:chatlog',$context)){
?>
<form action="../empty.php" method="post" target="empty" id="inputForm"
onsubmit="return empty_field_and_submit()" style="margin:0">
<input type="text" id="input_chat_message" name="chat_message" size="50" value="" />
<?php helpbutton('chatting', get_string('helpchatting', 'chat'), 'chat', true, false); ?><br />
<input type="checkbox" id="auto" size="50" value="" checked='true' /><label for="auto"><?php echo get_string('autoscroll', 'chat');?></label>
</form>
<?php
}
?>

<form action="insert.php" method="post" target="empty" id="sendForm">
<input type="hidden" name="chat_sid" value="<?php echo $chat_sid ?>" />
Expand Down
2 changes: 1 addition & 1 deletion mod/chat/gui_header_js/index.php
Expand Up @@ -50,7 +50,7 @@
error('Could not log in to chat room!!');
}

$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';
Expand Down
2 changes: 1 addition & 1 deletion mod/chat/version.php
Expand Up @@ -5,7 +5,7 @@
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////

$module->version = 2007101509; // The (date) version of this module
$module->version = 2007101510; // The (date) version of this module
$module->requires = 2007101509; // Requires this Moodle version
$module->cron = 300; // How often should cron check this module (seconds)?
Expand Down

0 comments on commit 9111f5d

Please sign in to comment.