New feature - chat scheduling. Can now set a time for the next chat,
as well as rotating weekly or daily period. Also some small fixes.
This commit is contained in:
+10
-3
@@ -9,9 +9,11 @@ $string['beep'] = "beep";
|
||||
$string['chatintro'] = "Introduction text";
|
||||
$string['chatname'] = "Name of this chat room";
|
||||
$string['chatreport'] = "Chat sessions";
|
||||
$string['chattime'] = "Next chat time";
|
||||
$string['currentchats'] = "Active chat sessions";
|
||||
$string['currentusers'] = "Current users";
|
||||
$string['enterchat'] = "Click here to enter the chat";
|
||||
$string['donotusechattime'] = "Don't publish any chat times";
|
||||
$string['enterchat'] = "Click here to enter the chat now";
|
||||
$string['errornousers'] = "Could not find any users!";
|
||||
$string['idle'] = "Idle";
|
||||
$string['messagebeepseveryone'] = "\$a beeps everyone!";
|
||||
@@ -19,12 +21,17 @@ $string['messagebeepsyou'] = "\$a has just beeped you!";
|
||||
$string['messageenter'] = "\$a has just entered this chat";
|
||||
$string['messageexit'] = "\$a has left this chat";
|
||||
$string['neverdeletemessages'] = "Never delete messages";
|
||||
$string['nextsession'] = "Next scheduled session";
|
||||
$string['nomessages'] = "No messages yet";
|
||||
$string['savemessages'] = "Save messages";
|
||||
$string['repeatnone'] = "No repeats - publish the specified time only";
|
||||
$string['repeatdaily'] = "At the same time every day";
|
||||
$string['repeattimes'] = "Repeat sessions";
|
||||
$string['repeatweekly'] = "At the same time every week";
|
||||
$string['savemessages'] = "Save past sessions";
|
||||
$string['sessions'] = "Chat sessions";
|
||||
$string['seesession'] = "See this session";
|
||||
$string['strftimemessage'] = "%%H:%%M";
|
||||
$string['studentseereports'] = "Everyone can see past sessions";
|
||||
$string['studentseereports'] = "Everyone can view past sessions";
|
||||
$string['viewreport'] = "View past chat sessions";
|
||||
|
||||
?>
|
||||
|
||||
@@ -18,6 +18,11 @@ function chat_upgrade($oldversion) {
|
||||
table_column("chat", "", "studentlogs", "integer", "4", "unsigned", "0", "not null", "keepdays");
|
||||
}
|
||||
|
||||
if ($oldversion < 2003072500) {
|
||||
table_column("chat", "", "chattime", "integer", "10", "unsigned", "0", "not null", "studentlogs");
|
||||
table_column("chat", "", "schedule", "integer", "4", "", "0", "not null", "studentlogs");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ CREATE TABLE `prefix_chat` (
|
||||
`intro` text NOT NULL,
|
||||
`keepdays` int(11) NOT NULL default '0',
|
||||
`studentlogs` int(4) NOT NULL default '0',
|
||||
`chattime` int(10) unsigned NOT NULL default '0',
|
||||
`schedule` 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';
|
||||
@@ -24,7 +26,7 @@ CREATE TABLE `prefix_chat_messages` (
|
||||
`userid` int(10) NOT NULL default '0',
|
||||
`system` int(1) unsigned NOT NULL default '0',
|
||||
`message` text NOT NULL,
|
||||
`timestamp` int(10) NOT NULL default '0',
|
||||
`timestamp` int(10) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `timemodifiedchat` (`timestamp`,`chatid`)
|
||||
) TYPE=MyISAM COMMENT='Stores all the actual chat messages';
|
||||
|
||||
@@ -30,8 +30,8 @@ $strchat = get_string("modulename", "chat");
|
||||
<?php echo "$strchat: $course->shortname: $chat->name" ?>
|
||||
</title>
|
||||
</head>
|
||||
<frameset cols="*,200" border="4" framespacing="no" frameborder="yes" marginwidth="2" marginheight="1">
|
||||
<frameset rows="1,1,*,40" border="0" framespacing="no" frameborder="no" marginwidth="2" marginheight="1">
|
||||
<frameset cols="*,200" border="5" framespacing="no" frameborder="yes" marginwidth="2" marginheight="1">
|
||||
<frameset rows="0,0,*,40" border="0" framespacing="no" frameborder="no" marginwidth="2" marginheight="1">
|
||||
<frame src="../empty.php" NAME="empty" scrolling="no" marginwidth="0" marginheight="0">
|
||||
<frame src="jsupdate.php?chat_sid=<?php echo $chat_sid; ?>&chat_enter=true" scrolling="no" marginwidth="0" marginheight="0">
|
||||
<frame src="chatmsg.php" NAME="msg" scrolling="auto" marginwidth="2" marginheight="1">
|
||||
|
||||
+39
-3
@@ -34,7 +34,8 @@ function chat_add_instance($chat) {
|
||||
|
||||
$chat->timemodified = time();
|
||||
|
||||
# May have to add extra stuff in here #
|
||||
$chat->chattime = make_timestamp($chat->chatyear, $chat->chatmonth, $chat->chatday,
|
||||
$chat->chathour, $chat->chatminute);
|
||||
|
||||
return insert_record("chat", $chat);
|
||||
}
|
||||
@@ -48,7 +49,8 @@ function chat_update_instance($chat) {
|
||||
$chat->timemodified = time();
|
||||
$chat->id = $chat->instance;
|
||||
|
||||
# May have to add extra stuff in here #
|
||||
$chat->chattime = make_timestamp($chat->chatyear, $chat->chatmonth, $chat->chatday,
|
||||
$chat->chathour, $chat->chatminute);
|
||||
|
||||
return update_record("chat", $chat);
|
||||
}
|
||||
@@ -136,6 +138,8 @@ function chat_cron () {
|
||||
|
||||
global $CFG;
|
||||
|
||||
chat_update_chat_times();
|
||||
|
||||
chat_delete_old_users();
|
||||
|
||||
/// Delete old messages
|
||||
@@ -185,7 +189,7 @@ function chat_get_latest_message($chatid) {
|
||||
return get_record_sql("SELECT *
|
||||
FROM {$CFG->prefix}chat_messages
|
||||
WHERE chatid = '$chatid'
|
||||
ORDER BY timestamp DESC");
|
||||
ORDER BY timestamp DESC LIMIT 1");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
@@ -229,6 +233,38 @@ function chat_delete_old_users() {
|
||||
}
|
||||
|
||||
|
||||
function chat_update_chat_times($chatid=0) {
|
||||
/// Updates chat records so that the next chat time is correct
|
||||
|
||||
$timenow = time();
|
||||
if ($chatid) {
|
||||
if (!$chats[] = get_record_select("chat", "id = '$chatid' AND chattime <= '$timenow' AND schedule > '0'")) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (!$chats = get_records_select("chat", "chattime <= '$timenow' AND schedule > '0'")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($chats as $chat) {
|
||||
switch ($chat->schedule) {
|
||||
case 1: // Single event - turn off schedule and disable
|
||||
$chat->chattime = 0;
|
||||
$chat->schedule = 0;
|
||||
break;
|
||||
case 2: // Repeat daily
|
||||
$chat->chattime += 24 * 3600;
|
||||
break;
|
||||
case 3: // Repeat weekly
|
||||
$chat->chattime += 7 * 24 * 3600;
|
||||
break;
|
||||
}
|
||||
update_record("chat", $chat);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function chat_browser_detect($HTTP_USER_AGENT) {
|
||||
|
||||
if(eregi("(opera) ([0-9]{1,2}.[0-9]{1,3}){0,1}", $HTTP_USER_AGENT, $match)
|
||||
|
||||
@@ -38,6 +38,25 @@
|
||||
<textarea name="intro" rows=4 cols=50 wrap="virtual"><?php p($form->intro) ?></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p><b><?php print_string("chattime", "chat") ?>:</b></td>
|
||||
<td><?php
|
||||
print_date_selector("chatday", "chatmonth", "chatyear", $form->chattime);
|
||||
echo " - ";
|
||||
print_time_selector("chathour", "chatminute", $form->chattime);
|
||||
?></td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p><b><?php print_string("repeattimes", "chat") ?>:</b></td>
|
||||
<td><?php
|
||||
unset($options);
|
||||
$options[0] = get_string("donotusechattime", "chat");
|
||||
$options[1] = get_string("repeatnone", "chat");
|
||||
$options[2] = get_string("repeatdaily", "chat");
|
||||
$options[3] = get_string("repeatweekly", "chat");
|
||||
choose_from_menu ($options, "schedule", $form->schedule, "", "", "");
|
||||
?></td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p><b><?php print_string("savemessages", "chat")?>:</b></p>
|
||||
<td>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$module->version = 2003072102; // The (date) version of this module
|
||||
$module->version = 2003072500; // The (date) version of this module
|
||||
$module->cron = 300; // How often should cron check this module (seconds)?
|
||||
|
||||
?>
|
||||
|
||||
+18
-3
@@ -16,12 +16,16 @@
|
||||
if (! $course = get_record("course", "id", $cm->course)) {
|
||||
error("Course is misconfigured");
|
||||
}
|
||||
|
||||
chat_update_chat_times($cm->instance);
|
||||
|
||||
if (! $chat = get_record("chat", "id", $cm->instance)) {
|
||||
error("Course module is incorrect");
|
||||
}
|
||||
|
||||
} else {
|
||||
chat_update_chat_times($c);
|
||||
|
||||
if (! $chat = get_record("chat", "id", $c)) {
|
||||
error("Course module is incorrect");
|
||||
}
|
||||
@@ -48,6 +52,7 @@
|
||||
$strenterchat = get_string("enterchat", "chat");
|
||||
$stridle = get_string("idle", "chat");
|
||||
$strcurrentusers = get_string("currentusers", "chat");
|
||||
$strnextsession = get_string("nextsession", "chat");
|
||||
|
||||
print_header("$course->shortname: $chat->name", "$course->fullname",
|
||||
"$navigation <A HREF=index.php?id=$course->id>$strchats</A> -> $chat->name",
|
||||
@@ -86,9 +91,19 @@
|
||||
"chat$course->id$chat->id", "$strenterchat", 500, 700, $strchat);
|
||||
print_simple_box_end();
|
||||
|
||||
echo "<br />";
|
||||
print_simple_box( text_to_html($chat->intro) , "center");
|
||||
echo "<br />";
|
||||
|
||||
if ($chat->chattime and $chat->schedule) { // A chat is scheduled
|
||||
echo "<p align=center>$strnextsession: ".userdate($chat->chattime)."</p>";
|
||||
} else {
|
||||
echo "<br />";
|
||||
}
|
||||
|
||||
if ($chat->intro) {
|
||||
print_simple_box( text_to_html($chat->intro) , "center");
|
||||
echo "<br />";
|
||||
}
|
||||
|
||||
chat_delete_old_users();
|
||||
|
||||
if ($chatusers = chat_get_users($chat->id)) {
|
||||
$timenow = time();
|
||||
|
||||
Reference in New Issue
Block a user