Skip to content

Commit

Permalink
radical chat clean up, see forum for details
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Feb 3, 2005
1 parent 60ecca3 commit 516121b
Show file tree
Hide file tree
Showing 32 changed files with 668 additions and 1,556 deletions.
6 changes: 3 additions & 3 deletions mod/chat/chatd.php
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ function promote_final($sessionid, $groupid, $customdata) {
$this->dismiss_half($sessionid, false);
$this->write_data($this->conn_sets[$sessionid][CHAT_CONNECTION_CHANNEL], $CHAT_HTMLHEAD_JS);
$this->trace('Connection accepted: '.$this->conn_sets[$sessionid][CHAT_CONNECTION_CHANNEL].', SID: '.$sessionid.' UID: '.$chatuser->userid.' GID: '.intval($groupid), E_USER_WARNING);

/*
// Finally, broadcast the "entered the chat" message
$msg = &New stdClass;
Expand All @@ -544,7 +544,7 @@ function promote_final($sessionid, $groupid, $customdata) {
insert_record('chat_messages', $msg);
$this->message_broadcast($msg, $this->sets_info[$sessionid]['user']);

*/
return true;
}

Expand Down Expand Up @@ -973,7 +973,7 @@ function cli_switch($switch, $param = NULL) {
if($changed > 0) {
// Let's see what it has to say

$data = socket_read($handle, 512);
$data = socket_read($handle, 2048); // should be more to prevent empty pages and repeated messages!!
if(empty($data)) {
continue;
}
Expand Down
5 changes: 5 additions & 0 deletions mod/chat/db/mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ function chat_upgrade($oldversion) {
modify_database('','ALTER TABLE prefix_chat_users ADD INDEX `groupid` (`groupid`);');
}

if ($oldversion < 2005020300) {
table_column('chat_users', '', 'course');
table_column('chat_users', '', 'lang', 'varchar', '10', '', '');
}

return true;
}

Expand Down
2 changes: 2 additions & 0 deletions mod/chat/db/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ CREATE TABLE `prefix_chat_users` (
`lastping` int(10) unsigned NOT NULL default '0',
`lastmessageping` int(10) unsigned NOT NULL default '0',
`sid` varchar(32) NOT NULL default '',
`course` int(10) NOT NULL default '0',
`lang` varchar(10) NOT NULL default '',
PRIMARY KEY (`id`),
KEY `userid` (`userid`),
KEY `lastping` (`lastping`),
Expand Down
4 changes: 3 additions & 1 deletion mod/chat/db/oci8po.sql
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ CREATE TABLE prefix_chat_users (
firstping number(10) default '0' not null,
lastping number(10) default '0' not null,
lastmessageping number(10) default '0' not null,
sid varchar2(32) default '' not null
sid varchar2(32) default '' not null,
course number(10) default '0' not null,
lang varchar2(10) default '' not null
);

create index userid on prefix_chat_users(userid);
Expand Down
6 changes: 5 additions & 1 deletion mod/chat/db/postgres7.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@ function chat_upgrade($oldversion) {
modify_database('','CREATE INDEX prefix_chat_users_lastping_idx ON prefix_chat_users (lastping);');
}

if ($oldversion < 2005020300) {
table_column('chat_users', '', 'course');
table_column('chat_users', '', 'lang', 'varchar', '10', '', '');
}

return true;
}


?>

2 changes: 2 additions & 0 deletions mod/chat/db/postgres7.sql
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ CREATE TABLE prefix_chat_users (
lastping integer NOT NULL default '0',
lastmessageping integer NOT NULL default '0',
sid varchar(32) NOT NULL default '',
course integer NOT NULL default '0',
lang varchar(10) NOT NULL default '',
PRIMARY KEY (id)
);

Expand Down
38 changes: 0 additions & 38 deletions mod/chat/drawboard.php

This file was deleted.

33 changes: 0 additions & 33 deletions mod/chat/gui_header/chatinput.php

This file was deleted.

74 changes: 0 additions & 74 deletions mod/chat/gui_header/chatmsg.php

This file was deleted.

23 changes: 0 additions & 23 deletions mod/chat/gui_header/index.php

This file was deleted.

92 changes: 39 additions & 53 deletions mod/chat/gui_header_js/chatinput.php
Original file line number Diff line number Diff line change
@@ -1,64 +1,50 @@
<?php
<?php // $Id$

require("../../../config.php");
require("../lib.php");
$nomoodlecookie = true; // Session not needed!

require_variable($chat_sid);
optional_variable($groupid);
optional_variable($chat_pretext, '');
require('../../../config.php');
require('../lib.php');

if (!$chatuser = get_record("chat_users", "sid", $chat_sid)) {
echo "Not logged in!";
die;
}
$chat_sid = required_param('chat_sid', PARAM_ALPHANUM);

if (!$chat = get_record("chat", "id", $chatuser->chatid)) {
error("No chat found");
}

require_login($chat->course);
if (!$chatuser = get_record('chat_users', 'sid', $chat_sid)) {
error('Not logged in!');
}

?>

<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">
<html>
<head>
<title>Message Input</title>

<?php include("$CFG->javascript"); ?>

<script language="Javascript">
<!--
scroll_active = true;
function empty_field_and_submit() {
document.fdummy.chat_message.value=document.f.chat_message.value;
document.fdummy.submit();
document.f.chat_message.value='';
document.f.chat_message.focus();
return false;
}
// -->
</script>
</head>
chat_force_language($chatuser->lang);

<body bgcolor="<?php echo $THEME->body ?>"
OnLoad="document.f.chat_message.focus();document.f.chat_message.select();">

ob_start();
?>
<script type="text/javascript">
<!--
scroll_active = true;
function empty_field_and_submit() {
document.fdummy.chat_message.value=document.f.chat_message.value;
document.fdummy.submit();
document.f.chat_message.value='';
document.f.chat_message.focus();
return false;
}
// -->
</script>
<?php

<form action="../insert.php" method="GET" target="empty" name="f"
OnSubmit="return empty_field_and_submit()">
&gt;&gt;<input type="text" name="chat_message" size="60" value="<?php echo $chat_pretext; ?>" />
<?php helpbutton("chatting", get_string("helpchatting", "chat"), "chat", true, false); ?>
</form>

<form action="../insert.php" method="GET" target="empty" name="fdummy"
OnSubmit="return empty_field_and_submit()">
<input type="hidden" name="chat_sid" value="<?php echo $chat_sid ?>" />
<input type="hidden" name="groupid" value="<?php echo $groupid ?>" />
<input type="hidden" name="chat_version" value="header_js" />
<input type="hidden" name="chat_message" />
</form>
$meta = ob_get_clean();
print_header('', '', '', 'f.chat_message', $meta, false);

?>
<form action="insert.php" method="GET" target="empty" name="f"
OnSubmit="return empty_field_and_submit()">
&gt;&gt;<input type="text" name="chat_message" size="60" value="" />
<?php helpbutton('chatting', get_string('helpchatting', 'chat'), 'chat', true, false); ?>
</form>

<form action="insert.php" method="GET" target="empty" name="fdummy"
OnSubmit="return empty_field_and_submit()">
<input type="hidden" name="chat_sid" value="<?php echo $chat_sid ?>" />
<input type="hidden" name="chat_message" />
</form>
</body>

</html>
</html>
Loading

0 comments on commit 516121b

Please sign in to comment.