From: moodler Date: Fri, 16 Jan 2004 13:14:42 +0000 (+0000) Subject: Chat sessions can now be deleted X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=27ac57c086fa3573954b8fc8742c094f9f881782;p=moodle.git Chat sessions can now be deleted --- diff --git a/lang/en/chat.php b/lang/en/chat.php index 105926192d..9413f9d248 100644 --- a/lang/en/chat.php +++ b/lang/en/chat.php @@ -12,6 +12,8 @@ $string['configrefreshroom'] = 'How often should the chat room itself be refresh $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!'; diff --git a/mod/chat/report.php b/mod/chat/report.php index ff9fa95032..9d5a569a1e 100644 --- a/mod/chat/report.php +++ b/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,10 +42,12 @@ $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 id\">$strchats -> @@ -50,6 +55,12 @@ id\">$strchatreport", "", "", 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 "

id&start=$sessionstart&end=$sessionend\">$strseesession"; + echo "

"; + echo "id&start=$sessionstart&end=$sessionend\">$strseesession"; + if ($isteacheredit) { + echo "
id&start=$sessionstart&end=$sessionend&deletesession=1\">$strdeletesession"; + } + echo "

"; print_simple_box_end(); }