Skip to content
Browse files

Chat sessions can now be deleted

  • Loading branch information...
1 parent 94d712f commit 27ac57c086fa3573954b8fc8742c094f9f881782 moodler committed Jan 16, 2004
Showing with 48 additions and 10 deletions.
  1. +2 −0 lang/en/chat.php
  2. +46 −10 mod/chat/report.php
View
2 lang/en/chat.php
@@ -12,6 +12,8 @@
$string['configrefreshuserlist'] = 'How often should the list of users be refreshed? (in seconds)';
$string['currentchats'] = 'Active chat sessions';
$string['currentusers'] = 'Current users';
+$string['deletesession'] = 'Delete this session';
+$string['deletesessionsure'] = 'Are you sure you want to delete this session?';
$string['donotusechattime'] = 'Don\'t publish any chat times';
$string['enterchat'] = 'Click here to enter the chat now';
$string['errornousers'] = 'Could not find any users!';
View
56 mod/chat/report.php
@@ -6,8 +6,10 @@
require_once("lib.php");
require_variable($id); // Chat Module ID, or
- optional_variable($start, 0); // Start of period
- optional_variable($end, 0); // End of period
+ optional_variable($start, ""); // Start of period
+ optional_variable($end, ""); // End of period
+ optional_variable($deletesession, ""); // Delete a session
+ optional_variable($confirmdelete, ""); // End of period
if (! $chat = get_record("chat", "id", $id)) {
error("Course module is incorrect");
@@ -22,6 +24,7 @@
require_login($course->id);
$isteacher = isteacher($course->id);
+ $isteacheredit = isteacheredit($course->id);
if (isguest() or (!$isteacher and !$chat->studentlogs)) {
error("You can not view these chat reports");
@@ -39,17 +42,25 @@
$strchat = get_string("modulename", "chat");
$strchatreport = get_string("chatreport", "chat");
$strseesession = get_string("seesession", "chat");
+ $strdeletesession = get_string("deletesession", "chat");
+
/// Print a session if once has been specified
- if ($start and $end) { // Show a full transcript
+ if ($start and $end and !$confirmdelete) { // Show a full transcript
print_header("$course->shortname: $chat->name: $strchatreport", "$course->fullname",
"$navigation <a href=\"index.php?id=$course->id\">$strchats</a> ->
<a href=\"view.php?id=$cm->id\">$chat->name</a> ->
<a href=\"report.php?id=$chat->id\">$strchatreport</a>",
"", "", true, "", navmenu($course, $cm));
+ if ($deletesession and $isteacheredit) {
+ notice_yesno(get_string("deletesessionsure", "chat"),
+ "report.php?id=$chat->id&deletesession=1&confirmdelete=1&start=$start&end=$end",
+ "report.php?id=$chat->id");
+ }
+
if (!$messages = get_records_select("chat_messages", "chatid = $chat->id AND
timestamp >= '$start' AND
timestamp <= '$end'", "timestamp ASC")) {
@@ -66,7 +77,10 @@
print_simple_box_end("center");
}
- print_continue("report.php?id=$chat->id");
+ if (!$deletesession or !$isteacheredit) {
+ print_continue("report.php?id=$chat->id");
+ }
+
print_footer($course);
exit;
}
@@ -82,13 +96,30 @@
print_heading($chat->name.": ".get_string("sessions", "chat"));
- if (!$messages = get_records("chat_messages", "chatid", $chat->id, "timestamp DESC")) {
- print_heading(get_string("nomessages", "chat"));
- print_footer($course);
- exit;
+
+/// Delete a session if one has been specified
+
+ if ($deletesession and $isteacheredit and $confirmdelete and $start and $end) {
+ delete_records_select("chat_messages", "chatid = $chat->id AND
+ timestamp >= '$start' AND
+ timestamp <= '$end'");
+ $strdeleted = get_string("deleted");
+ notify("$strdeleted: ".userdate($start)." --> ". userdate($end));
+ unset($deletesession);
+ }
+
+
+/// Get the messages
+
+ if (empty($messages)) { /// May have already got them above
+ if (!$messages = get_records("chat_messages", "chatid", $chat->id, "timestamp DESC")) {
+ print_heading(get_string("nomessages", "chat"));
+ print_footer($course);
+ exit;
+ }
}
- /// Show all the sessions
+/// Show all the sessions
$sessiongap = 5 * 60; // 5 minutes silence means a new session
$sessionend = 0;
@@ -129,7 +160,12 @@
}
}
- echo "<p align=\"right\"><a href=\"report.php?id=$chat->id&start=$sessionstart&end=$sessionend\">$strseesession</a>";
+ echo "<p align=\"right\">";
+ echo "<a href=\"report.php?id=$chat->id&start=$sessionstart&end=$sessionend\">$strseesession</a>";
+ if ($isteacheredit) {
+ echo "<br /><a href=\"report.php?id=$chat->id&start=$sessionstart&end=$sessionend&deletesession=1\">$strdeletesession</a>";
+ }
+ echo "</p>";
print_simple_box_end();
}

0 comments on commit 27ac57c

Please sign in to comment.
Something went wrong with that request. Please try again.