diff -urp chatblock/chatblock.install chatblock-new/chatblock.install --- chatblock.install 2008-05-23 16:48:19.000000000 -0600 +++ chatblock.install 2008-05-23 16:40:10.000000000 -0600 @@ -10,7 +10,7 @@ function chatblock_install() { case 'mysql': case 'mysqli': db_query("CREATE TABLE {chatblock} ( - message varchar(255), + message varchar(1000), username varchar(60), timestamp bigint(14), messageid int(10) NOT NULL auto_increment, diff -urp chatblock/chatblock.js chatblock-new/chatblock.js --- chatblock.js 2008-05-23 16:48:22.000000000 -0600 +++ chatblock.js 2008-05-23 16:33:15.000000000 -0600 @@ -90,15 +90,17 @@ function chatblockSend(el) { var timestamp = document.getElementById("chatblocklastmessage").innerHTML; // build the message to send to the database, make sure to use a random token to prevent IE from caching the response - var message = "×tamp=" + timestamp + "&chatboxtoken=" + Math.random() + "&message=" + document.getElementById("edit-chatblocktext").value; + var message = "×tamp=" + timestamp + "&chatboxtoken=" + Math.random() + "&message=" + document.getElementById("edit-chatblocktext").value + "&username=" +document.getElementById("edit-chatblockusername").value; // empty out the value of the textfield the user sent his message from document.getElementById("edit-chatblocktext").value = ""; // send the message $.ajax({ type: "POST", url: chatBlockUpdateURL, data: message, success: function(text) { chatblockResponse(text); }, error: function (XMLHttpRequest, textStatus, errorThrown) { console.error(XMLHttpRequest.status); } }); - - // don't submit the form regularly + + document.getElementById("edit-chatblockusername").disabled = true; + +// don't submit the form regularly return false; } diff -urp chatblock/chatblock.module chatblock-new/chatblock.module --- chatblock.module 2007-11-20 05:16:03.000000000 -0700 +++ chatblock.module 2008-05-23 16:33:00.000000000 -0600 @@ -188,7 +188,11 @@ function chatblock_settings_form() { function chatblock_database($op, $message = "", $name = "", $timestamp = NULL, $limit = 100) { // get the user information global $user; - $username = $user->name; + if(!empty($name)){ + $username = $name; + }else{ + $username = $user->name; + } // which database operation are we doing? switch ($op) { @@ -413,11 +417,25 @@ function chatblock_find_url($string){ * This is the basic chatblock form to display. */ function chatblockchatform(){ + global $user; + $form = array(); + if (!$user->uid) { + $form['chatblockusername'] = array( + '#type' => 'textfield', + '#title' => 'Username', + '#size' => 50 + ); + } + + $form['chatblocktext'] = array( - '#type' => 'textfield', - '#size' => 20 + '#type' => 'textarea', + '#title' => 'Message', + '#maxlength' => 600, + '#size' => 1000 + ); $form['chatblocksubmit'] = array( @@ -439,6 +457,10 @@ function chatblock_chat_update_callback( if (isset($_POST['message'])) { $message = strip_tags($_POST['message']); } + + if (isset($_POST['username'])) { + $username = $_POST['username']; + } $show = TRUE; if (strlen($message) == 0) { @@ -446,8 +468,15 @@ function chatblock_chat_update_callback( } if ($show) { - chatblock_database('update', $message); - chatblock_messages(); + if(isset($username)){ + chatblock_database('update', $message, $username); + chatblock_messages(); + }else{ + chatblock_database('update', $message); + chatblock_messages(); + } +// chatblock_database('update', $message); +// chatblock_messages(); } } @@ -597,4 +626,4 @@ $(document).ready(function () { function chatblock_microtime_float() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); -} \ No newline at end of file +}