diff --git a/lang/en/chat.php b/lang/en/chat.php index 163fb0c6a80..76de69ad46c 100644 --- a/lang/en/chat.php +++ b/lang/en/chat.php @@ -8,6 +8,7 @@ $string['modulenameplural'] = "Chats"; $string['beep'] = "beep"; $string['chatintro'] = "Introduction text"; $string['chatname'] = "Name of this chat room"; +$string['chatreport'] = "Chat report"; $string['currentchats'] = "Currently active chats"; $string['enterchat'] = "Click here to enter the chat"; $string['idle'] = "Idle"; @@ -15,7 +16,11 @@ $string['messagebeepseveryone'] = "\$a beeps everyone!"; $string['messagebeepsyou'] = "\$a has just beeped you!"; $string['messageenter'] = "\$a has just entered this chat"; $string['messageexit'] = "\$a has left this chat"; -$string['savemessages'] = "Number of messages to save"; +$string['neverdeletemessages'] = "Never delete messages"; +$string['savemessages'] = "Save messages"; +$string['sessions'] = "Chat sessions"; $string['strftimemessage'] = "%%H:%%M"; +$string['studentseereports'] = "Allow everyone to see reports"; +$string['viewreport'] = "View chat reports"; ?> diff --git a/mod/chat/db/mysql.php b/mod/chat/db/mysql.php index fe9b6d32658..79e9f94f626 100644 --- a/mod/chat/db/mysql.php +++ b/mod/chat/db/mysql.php @@ -6,7 +6,16 @@ function chat_upgrade($oldversion) { global $CFG; - if ($oldversion < 2002080500) { + if ($oldversion < 2003072100) { + modify_database ("", " INSERT INTO prefix_log_display VALUES ('chat', 'report', 'chat', 'name'); "); + } + + if ($oldversion < 2003072101) { + table_column("chat", "messages", "keepdays", "integer", "10", "unsigned", "0", "not null"); + } + + if ($oldversion < 2003072102) { + table_column("chat", "", "studentlogs", "integer", "4", "unsigned", "0", "not null", "keepdays"); } return true; diff --git a/mod/chat/db/mysql.sql b/mod/chat/db/mysql.sql index 1dd573b90bc..44ee87b4cef 100644 --- a/mod/chat/db/mysql.sql +++ b/mod/chat/db/mysql.sql @@ -7,7 +7,8 @@ CREATE TABLE `prefix_chat` ( `course` int(10) unsigned NOT NULL default '0', `name` varchar(255) NOT NULL default '', `intro` text NOT NULL, - `messages` int(11) NOT NULL default '1000', + `keepdays` int(11) NOT NULL default '0', + `studentlogs` int(4) NOT NULL default '0', `timemodified` int(10) unsigned NOT NULL default '0', PRIMARY KEY (`id`) ) TYPE=MyISAM COMMENT='Each of these is a chat room'; @@ -52,4 +53,5 @@ CREATE TABLE `prefix_chat_users` ( INSERT INTO prefix_log_display VALUES ('chat', 'view', 'chat', 'name'); INSERT INTO prefix_log_display VALUES ('chat', 'add', 'chat', 'name'); INSERT INTO prefix_log_display VALUES ('chat', 'update', 'chat', 'name'); +INSERT INTO prefix_log_display VALUES ('chat', 'report', 'chat', 'name'); diff --git a/mod/chat/insert.php b/mod/chat/insert.php index 780006f6e93..36e70a2306d 100644 --- a/mod/chat/insert.php +++ b/mod/chat/insert.php @@ -18,11 +18,6 @@ require_login($chat->course); - -/// Delete old messages here - - - /// Clean up the message $chat_message = clean_text($chat_message, FORMAT_MOODLE); // Strip bad tags diff --git a/mod/chat/lib.php b/mod/chat/lib.php index c00254473d7..4f9d040ccef 100644 --- a/mod/chat/lib.php +++ b/mod/chat/lib.php @@ -138,6 +138,16 @@ function chat_cron () { chat_delete_old_users(); + /// Delete old messages + if ($chats = get_records("chat")) { + foreach ($chats as $chat) { + if ($chat->keepdays) { + $timeold = time() - ($chat->keepdays * 24 * 3600); + delete_records_select("chat_messages", "chatid = '$chat->id' AND timestamp < '$timeold'"); + } + } + } + return true; } @@ -218,6 +228,7 @@ function chat_delete_old_users() { } } + function chat_browser_detect($HTTP_USER_AGENT) { if(eregi("(opera) ([0-9]{1,2}.[0-9]{1,3}){0,1}", $HTTP_USER_AGENT, $match) diff --git a/mod/chat/mod.html b/mod/chat/mod.html index 44782ae7b32..a225e1051fe 100644 --- a/mod/chat/mod.html +++ b/mod/chat/mod.html @@ -5,8 +5,11 @@ if (!isset($form->intro)) { $form->intro = ""; } - if (!isset($form->messages)) { - $form->messages = 1000; + if (!isset($form->keepdays)) { + $form->keepdays = 30; + } + if (!isset($form->studentlogs)) { + $form->studentlogs = 0; } ?>