course)) { error("Course is misconfigured"); } require_login($course->id); if (! $dialogue = get_record("dialogue", "id", $cm->instance)) { error("Course module dialogue is incorrect"); } require_login($course->id); $navigation = ""; if ($course->category) { $navigation = "id\">$course->shortname ->"; } $strdialogues = get_string("modulenameplural", "dialogue"); $strdialogue = get_string("modulename", "dialogue"); // ... print the header and... print_header("$course->shortname: $dialogue->name", "$course->fullname", "$navigation id>$strdialogues -> id\">$dialogue->name", "", "", true); require_variable($action); // need something to do! /************** close conversation ************************************/ if ($action == 'closeconversation') { if (empty($_GET['cid'])) { error("Close dialogue: Missing conversation id"); } else { $conversationid = $_GET['cid']; } if (!set_field("dialogue_conversations", "closed", 1, "id", $conversationid)) { error("Close dialogue: unable to set closed"); } if (!set_field("dialogue_conversations", "lastid", $USER->id, "id", $conversationid)) { error("Close dialogue: unable to set lastid"); } $pane=$_GET['pane']; add_to_log($course->id, "dialogue", "closed", "view.php?id=$cm->id", "$conversationid"); redirect("view.php?id=$cm->id&pane=$pane", get_string("dialogueclosed", "dialogue")); } /****************** confirm close ************************************/ elseif ($action == 'confirmclose' ) { if (empty($_GET['cid'])) { error("Confirm Close: conversation id missing"); } if (!$conversation = get_record("dialogue_conversations", "id", $_GET['cid'])) { error("Confirm close: cannot get conversation record"); } if ($conversation->userid == $USER->id) { if (!$user = get_record("user", "id", $conversation->recipientid)) { error("Confirm Close: cannot get recipient record"); } } else { if (!$user = get_record("user", "id", $conversation->userid)) { error("Confirm Close: cannot get user record"); } } $pane = $_GET['pane']; notice_yesno(get_string("confirmclosure", "dialogue", fullname($user)), "dialogues.php?action=closeconversation&id=$cm->id&cid=$conversation->id&pane=$pane", "view.php?id=$cm->id&pane=$pane"); } /****************** get subject ************************************/ elseif ($action == 'getsubject' ) { if (empty($_GET['cid'])) { error("Confirm Close: conversation id missing"); } print_heading(get_string("addsubject", "dialogue")); echo "
\n"; } /****************** insert conversation entries ******************************/ elseif ($action == 'insertentries' ) { $timenow = time(); $n = 0; // get all the open conversations for this user if ($conversations = dialogue_get_conversations($dialogue, $USER, "closed = 0")) { foreach ($conversations as $conversation) { $textarea_name = "reply$conversation->id"; if (!empty($_POST[$textarea_name])) { unset($item); $item->dialogueid = $dialogue->id; $item->conversationid = $conversation->id; $item->userid = $USER->id; $item->timecreated = time(); // reverse the dialogue mail default $item->mailed = !$dialogue->maildefault; $item->text = $_POST[$textarea_name]; if (!$item->id = insert_record("dialogue_entries", $item)) { error("Insert Entries: Could not insert dialogue record!"); } if (!set_field("dialogue_conversations", "lastid", $USER->id, "id", $conversation->id)) { error("Insert Dialogue Entries: could not set lastid"); } if (!set_field("dialogue_conversations", "timemodified", $timenow, "id", $conversation->id)) { error("Insert Dialogue Entries: could not set lastid"); } // reset seenon time if (!set_field("dialogue_conversations", "seenon", 0, "id", $conversation->id)) { error("Insert Dialogue Entries: could not reset seenon"); } add_to_log($course->id, "dialogue", "add entry", "view.php?id=$cm->id", "$item->id"); $n++; } } } redirect("view.php?id=$cm->id&pane={$_POST['pane']}", get_string("numberofentriesadded", "dialogue", $n)); } /****************** list closed conversations *********************************/ elseif ($action == 'listclosed') { echo "