From 9af2f862cf0ba1cb19f8b987527366666e2560fd Mon Sep 17 00:00:00 2001 From: rkingdon Date: Fri, 18 Jun 2004 19:01:44 +0000 Subject: [PATCH] Change to the mail option, now a global option. --- mod/dialogue/dialogues.php | 13 +- mod/dialogue/index.php | 1 + mod/dialogue/locallib.php | 767 +++++++++++++++++++++++++++++++++++++ mod/dialogue/view.php | 1 + 4 files changed, 774 insertions(+), 8 deletions(-) create mode 100644 mod/dialogue/locallib.php diff --git a/mod/dialogue/dialogues.php b/mod/dialogue/dialogues.php index 7c0733bcb4f60..0b3339b2f4760 100644 --- a/mod/dialogue/dialogues.php +++ b/mod/dialogue/dialogues.php @@ -15,6 +15,7 @@ require_once("../../config.php"); require_once("lib.php"); + require_once("locallib.php"); require_variable($id); // Course Module ID @@ -134,10 +135,8 @@ $item->conversationid = $conversation->id; $item->userid = $USER->id; $item->timecreated = time(); - // set mailed flag if checkbox is not set - if (empty($_POST['sendthis'])) { - $item->mailed = 1; - } + // 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!"); @@ -197,10 +196,8 @@ $entry->conversationid = $conversation->id; $entry->userid = $USER->id; $entry->timecreated = time(); - // set mailed flag if checkbox is not set - if (empty($_POST['sendthis'])) { - $entry->mailed = 1; - } + // reverse the dialogue default value + $entry->mailed = !$dialogue->maildefault; $entry->text = $_POST['firstentry']; if (!$entry->id = insert_record("dialogue_entries", $entry)) { error("Insert Entries: Could not insert dialogue record!"); diff --git a/mod/dialogue/index.php b/mod/dialogue/index.php index 2208557bd455d..ad9e4af5b571c 100644 --- a/mod/dialogue/index.php +++ b/mod/dialogue/index.php @@ -2,6 +2,7 @@ require_once("../../config.php"); require_once("lib.php"); + require_once("locallib.php"); require_variable($id); // course diff --git a/mod/dialogue/locallib.php b/mod/dialogue/locallib.php new file mode 100644 index 0000000000000..50e8f42287bd2 --- /dev/null +++ b/mod/dialogue/locallib.php @@ -0,0 +1,767 @@ +id OR + recipientid = $user->id) AND lastid != $user->id AND closed = 0"); + } else { + return count_records_select("dialogue_conversations", "(userid = $USER->id OR + recipientid = $USER->id) AND lastid != $USER->id AND closed = 0"); + } +} + + +////////////////////////////////////////////////////////////////////////////////////// +function dialogue_count_closed($dialogue, $user) { + + return count_records_select("dialogue_conversations", "dialogueid = $dialogue->id AND + (userid = $user->id OR recipientid = $user->id) AND closed = 1"); + } + + +////////////////////////////////////////////////////////////////////////////////////// +function dialogue_count_open($dialogue, $user) { + + return count_records_select("dialogue_conversations", "dialogueid = $dialogue->id AND + (userid = $user->id OR recipientid = $user->id) AND closed = 0"); +} + + +////////////////////////////////////////////////////////////////////////////////////// +function dialogue_count_needing_replies_other($dialogue, $user) { +// count [conversations] needing replies [from] other [person] + return count_records_select("dialogue_conversations", "dialogueid = $dialogue->id AND + (userid = $user->id OR recipientid = $user->id) AND lastid = $user->id AND closed = 0"); +} + + +////////////////////////////////////////////////////////////////////////////////////// +function dialogue_count_needing_replies_self($dialogue, $user) { +// count [conversations] needing replies [from] self + + return count_records_select("dialogue_conversations", "dialogueid = $dialogue->id AND + (userid = $user->id OR recipientid = $user->id) AND lastid != $user->id AND closed = 0"); +} + + +////////////////////////////////////////////////////////////////////////////////////// +function dialogue_get_participants($dialogueid) { +//Returns the users with data in one dialogue +//(users with records in dialogue_conversations, creators and receivers) + + global $CFG; + + //Get conversation's creators + $creators = get_records_sql("SELECT DISTINCT u.* + FROM {$CFG->prefix}user u, + {$CFG->prefix}dialogue_conversations c + WHERE c.dialogueid = '$dialogueid' and + u.id = c.userid"); + + //Get conversation's receivers + $receivers = get_records_sql("SELECT DISTINCT u.* + FROM {$CFG->prefix}user u, + {$CFG->prefix}dialogue_conversations c + WHERE c.dialogueid = '$dialogueid' and + u.id = c.recipientid"); + + //Add receivers to creators + if ($receivers) { + foreach ($receivers as $receiver) { + $creators[$receiver->id] = $receiver; + } + } + + //Return creators array (it contains an array of unique users, creators and receivers) + return ($creators); +} + +////////////////////////////////////////////////////////////////////////////////////// +function dialogue_get_available_users($dialogue) { + + if (! $course = get_record("course", "id", $dialogue->course)) { + error("Course is misconfigured"); + } + switch ($dialogue->dialoguetype) { + case 0 : // teacher to student + if (isteacher($course->id)) { + return dialogue_get_available_students($dialogue); + } + else { + return dialogue_get_available_teachers($dialogue); + } + case 1: // student to student + if (isstudent($course->id)) { + return dialogue_get_available_students($dialogue); + } + else { + return; + } + case 2: // everyone + if ($teachers = dialogue_get_available_teachers($dialogue)) { + foreach ($teachers as $userid=>$name) { + $names[$userid] = $name; + } + $names[-1] = "-------------"; + } + if ($students = dialogue_get_available_students($dialogue)) { + foreach ($students as $userid=>$name) { + $names[$userid] = $name; + } + } + if (isset($names)) { + return $names; + } + return; + } +} + + +////////////////////////////////////////////////////////////////////////////////////// +function dialogue_get_available_students($dialogue) { +global $USER; + + if (! $course = get_record("course", "id", $dialogue->course)) { + error("Course is misconfigured"); + } + // get the students on this course (default sort order)... + if ($users = get_course_students($course->id)) { + foreach ($users as $otheruser) { + // ...exclude self and... + if ($USER->id != $otheruser->id) { + // ...any already in any open conversations unless multiple conversations allowed + if ($dialogue->multipleconversations or count_records_select("dialogue_conversations", + "dialogueid = $dialogue->id AND + ((userid = $USER->id AND recipientid = $otheruser->id) OR + (userid = $otheruser->id AND recipientid = $USER->id)) AND closed = 0") == 0) { + $names[$otheruser->id] = fullname($otheruser); + } + } + } + } + if (isset($names)) { + asort($names); + return $names; + } + return; +} + + +////////////////////////////////////////////////////////////////////////////////////// +function dialogue_get_available_teachers($dialogue) { +global $USER; + + if (! $course = get_record("course", "id", $dialogue->course)) { + error("Course is misconfigured"); + } + // get the teachers on this course (default sort order)... + if ($users = get_course_teachers($course->id)) { + // $names[0] = "-----------------------"; + foreach ($users as $otheruser) { + // ...exclude self and ... + if ($USER->id != $otheruser->id) { + // ...any already in open conversations unless multiple conversations allowed + if ($dialogue->multipleconversations or count_records_select("dialogue_conversations", + "dialogueid = $dialogue->id AND ((userid = $USER->id AND + recipientid = $otheruser->id) OR (userid = $otheruser->id AND + recipientid = $USER->id)) AND closed = 0") == 0) { + $names[$otheruser->id] = fullname($otheruser); + } + } + } + } + if (isset($names)) { + asort($names); + return $names; + } + return; +} + + + +////////////////////////////////////////////////////////////////////////////////////// +function dialogue_get_users_done($dialogue) { + global $CFG; + return get_records_sql("SELECT u.* + FROM {$CFG->prefix}user u, + {$CFG->prefix}user_students s, + {$CFG->prefix}user_teachers t, + {$CFG->prefix}dialogue_entries j + WHERE ((s.course = '$dialogue->course' AND s.userid = u.id) + OR (t.course = '$dialogue->course' AND t.userid = u.id)) + AND u.id = j.userid + AND j.dialogue = '$dialogue->id' + ORDER BY j.modified DESC"); +} + + +// OTHER dialogue FUNCTIONS /////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////////////// +function dialogue_list_conversations_closed($dialogue) { +// list the closed for the current user + global $USER; + + if (! $course = get_record("course", "id", $dialogue->course)) { + error("Course is misconfigured"); + } + if (! $cm = get_coursemodule_from_instance("dialogue", $dialogue->id, $course->id)) { + error("Course Module ID was incorrect"); + } + + if ($conversations = dialogue_get_conversations($dialogue, $USER, "closed = 1")) { + // reorder the conversations by (other) name + foreach ($conversations as $conversation) { + if ($USER->id != $conversation->userid) { + if (!$with = get_record("user", "id", $conversation->userid)) { + error("User's record not found"); + } + } + else { + if (!$with = get_record("user", "id", $conversation->recipientid)) { + error("User's record not found"); + } + } + $names[$conversation->id] = fullname($with); + } + asort($names); + + print_simple_box_start(); + $table->head = array (get_string("dialoguewith", "dialogue"), get_string("subject", "dialogue"), + get_string("numberofentries", "dialogue"), get_string("lastentry", "dialogue"), + get_string("status", "dialogue")); + $table->width = "100%"; + $table->align = array ("left", "left", "center", "left", "left"); + $table->size = array ("*", "*", "*", "*", "*"); + $table->cellpadding = 2; + $table->cellspacing = 0; + + foreach ($names as $cid=>$name) { + if (!$conversation = get_record("dialogue_conversations", "id", $cid)) { + error("Closed conversations: could not find conversation record"); + } + $total = dialogue_count_entries($dialogue, $conversation); + $byuser = dialogue_count_entries($dialogue, $conversation, $USER); + if ($conversation->closed) { + $status = get_string("closed", "dialogue"); + } else { + $status = get_string("open", "dialogue"); + } + $table->data[] = array("id&action=showdialogues&cid=$conversation->id\">". + "$name", $conversation->subject, $byuser." ".get_string("of", "dialogue")." ".$total, + userdate($conversation->timemodified), $status); + } + print_table($table); + print_simple_box_end(); + } +} + + +////////////////////////////////////////////////////////////////////////////////////// +function dialogue_list_conversations_other($dialogue) { +// list the conversations of the current user awaiting response from the other person + global $THEME, $USER; + + if (!$course = get_record("course", "id", $dialogue->course)) { + error("Course is misconfigured"); + } + if (!$cm = get_coursemodule_from_instance("dialogue", $dialogue->id, $course->id)) { + error("Course Module ID was incorrect"); + } + + $timenow = time(); + if ($conversations = dialogue_get_conversations($dialogue, $USER, "lastid = $USER->id AND closed = 0")) { + // reorder the conversations by (other) name + foreach ($conversations as $conversation) { + if ($USER->id != $conversation->userid) { + if (!$with = get_record("user", "id", $conversation->userid)) { + error("User's record not found"); + } + } + else { + if (!$with = get_record("user", "id", $conversation->recipientid)) { + error("User's record not found"); + } + } + $names[$conversation->id] = fullname($with); + } + asort($names); + + print_simple_box_start(); + $table->head = array (get_string("dialoguewith", "dialogue"), get_string("subject", "dialogue"), + get_string("numberofentries", "dialogue"), get_string("lastentry", "dialogue"), + get_string("status", "dialogue")); + $table->width = "100%"; + $table->align = array ("left", "left", "center", "left", "left"); + $table->size = array ("*", "*", "*", "*", "*"); + $table->cellpadding = 2; + $table->cellspacing = 0; + + foreach ($names as $cid=>$name) { + if (!$conversation = get_record("dialogue_conversations", "id", $cid)) { + error("Closed conversations: could not find conversation record"); + } + $total = dialogue_count_entries($dialogue, $conversation); + $byuser = dialogue_count_entries($dialogue, $conversation, $USER); + if ($conversation->seenon) { + $status = get_string("seen", "dialogue", format_time($timenow - $conversation->seenon)); + } else { + $status = get_string("notyetseen", "dialogue"); + } + $table->data[] = array("id&action=printdialogue&cid=$conversation->id\">". + "$name", $conversation->subject, $byuser." ".get_string("of", "dialogue")." ".$total, + userdate($conversation->timemodified), $status); + } + print_table($table); + print_simple_box_end(); + } +} + + +////////////////////////////////////////////////////////////////////////////////////// +function dialogue_list_conversations_self($dialogue) { +// list open conversations of the current user awaiting their reply + global $THEME, $USER; + + if (! $course = get_record("course", "id", $dialogue->course)) { + error("Course is misconfigured"); + } + if (! $cm = get_coursemodule_from_instance("dialogue", $dialogue->id, $course->id)) { + error("Course Module ID was incorrect"); + } + + $timenow = time(); + $showbutton = false; + $showemoticon = false; // never show emoticons for now - need to close or reload the popup + // window to get the focus into the correct textarea on the second time round + + echo "
\n"; + echo "\n"; + echo "id\">\n"; + echo "\n"; + + // list the conversations requiring a resonse from this user in full + if ($conversations = dialogue_get_conversations($dialogue, $USER, "lastid != $USER->id AND closed = 0")) { + $showbutton = true; + print_simple_box_start("center"); + foreach ($conversations as $conversation) { + // set seenon if required + if (!$conversation->seenon) { + if (!set_field("dialogue_conversations", "seenon", $timenow, "id", $conversation->id)) { + error("List conversations self: could not set seenon"); + } + } + echo "
\n"; + echo ""; + echo ""; + + if ($entries = get_records_select("dialogue_entries", "conversationid = $conversation->id", "id")) { + foreach ($entries as $entry) { + if ($entry->userid == $USER->id) { + echo "\n"; + } + else { + echo "\n"; + } + } + } + + echo "\n"; + echo ""; + echo "
cellheading2\" valign=\"top\">\n"; + if ($conversation->userid == $USER->id) { + if (!$otheruser = get_record("user", "id", $conversation->recipientid)) { + error("User not found"); + } + } + else { + if (!$otheruser = get_record("user", "id", $conversation->userid)) { + error("User not found"); + } + } + // print_user_picture($user->id, $course->id, $user->picture); + echo "".get_string("dialoguewith", "dialogue", "$otheruser->firstname $otheruser->lastname"). + "cellheading2\">$conversation->subject 
\n"; + echo "
\n"; + if (!$conversation->subject) { + // conversation does not have a subject, show add subject link + echo "id&cid=$conversation->id&pane=2\">". + get_string("addsubject", "dialogue")."\n"; + helpbutton("addsubject", get_string("addsubject", "dialogue"), "dialogue"); + echo "  | "; + } + if (dialogue_count_entries($dialogue, $conversation)) { + echo "id&cid=$conversation->id&pane=1\">". + get_string("close", "dialogue")."\n"; + helpbutton("closedialogue", get_string("close", "dialogue"), "dialogue"); + } + else { + echo " "; + } + echo "
\n"; + echo text_to_html("".get_string("onyouwrote", "dialogue", + userdate($entry->timecreated)).":
".$entry->text); + echo "
body\">\n"; + echo text_to_html("".get_string("onwrote", "dialogue", + userdate($entry->timecreated)." ".$otheruser->firstname). + ":
".$entry->text); + echo "
\n"; + if ($entries) { + echo "".get_string("typereply", "dialogue")."\n"; + } + else { + echo "".get_string("typefirstentry", "dialogue")."\n"; + } + echo "
\n"; + helpbutton("writing", get_string("helpwriting"), "dialogue", true, true); + echo "
"; + if ($showemoticon) { + emoticonhelpbutton("replies", "reply$conversation->id"); + $showemoticon = false; + } + echo "
\n"; + // use a cumbersome name on the textarea as the emoticonhelp doesn't like an "array" name + echo "\n"; + echo "

\n"; + } + print_simple_box_end(); + if ($showbutton) { + echo "
\n"; + echo "
\n"; + } + echo "
\n"; + } +} + + +////////////////////////////////////////////////////////////////////////////////////// +function dialogue_print_conversation($dialogue, $conversation) { +// print a conversation and allow a new entry + global $THEME, $USER; + + if (! $course = get_record("course", "id", $dialogue->course)) { + error("Course is misconfigured"); + } + if (! $cm = get_coursemodule_from_instance("dialogue", $dialogue->id, $course->id)) { + error("Course Module ID was incorrect"); + } + + $timenow = time(); + $showbutton = false; + $showemoticon = false; // never show emoticons for now - need to close or reload the popup + // window to get the focus into the correct textarea on the second time round + + echo "
\n"; + echo "\n"; + echo "id\">\n"; + echo "\n"; + + $showbutton = true; + print_simple_box_start("center", "", $THEME->cellcontent2); + echo "
\n"; + echo ""; + echo "\n"; + + if ($entries = get_records_select("dialogue_entries", "conversationid = $conversation->id", "id")) { + foreach ($entries as $entry) { + if ($entry->userid == $USER->id) { + echo "\n"; + } + echo "\n"; + echo ""; + echo "
cellheading2\" valign=\"top\">\n"; + if ($conversation->userid == $USER->id) { + if (!$otheruser = get_record("user", "id", $conversation->recipientid)) { + error("User not found"); + } + } + else { + if (!$otheruser = get_record("user", "id", $conversation->userid)) { + error("User not found"); + } + } + // print_user_picture($user->id, $course->id, $user->picture); + echo "".get_string("dialoguewith", "dialogue", "$otheruser->firstname $otheruser->lastname"). + "cellheading2\">$conversation->subject 
\n"; + echo "
\n"; + if (!$conversation->subject) { + // conversation does not have a subject, show add subject link + echo "id&cid=$conversation->id&pane=2\">". + get_string("addsubject", "dialogue")."\n"; + helpbutton("addsubject", get_string("addsubject", "dialogue"), "dialogue"); + echo "  | "; + } + echo "id&cid=$conversation->id&pane=2\">". + get_string("close", "dialogue")."\n"; + helpbutton("closedialogue", get_string("close", "dialogue"), "dialogue"); + echo "
\n"; + echo text_to_html("".get_string("onyouwrote", "dialogue", + userdate($entry->timecreated)).":
".$entry->text); + } + else { + echo "
body\">\n"; + echo text_to_html("".get_string("onwrote", "dialogue", + userdate($entry->timecreated)." ".$otheruser->firstname).":
". + $entry->text); + } + } + echo "
". + get_string("typefollowup", "dialogue")."
\n"; + helpbutton("writing", get_string("helpwriting"), "dialogue", true, true); + echo "
"; + if ($showemoticon) { + emoticonhelpbutton("replies", "reply$conversation->id"); + $showemoticon = false; + } + echo "
\n"; + // use a cumbersome name on the textarea as the emoticonhelp doesn't like an "array" name + echo "\n"; + echo "

\n"; + print_simple_box_end(); + if ($showbutton) { + echo "
\n"; + echo "".get_string("sendmailmessages", "dialogue").": \n"; + if ($dialogue->maildefault) { + echo " \n"; + } + else { + echo " \n"; + } + helpbutton("sendmail", get_string("sendmailmessages", "dialogue"), "dialogue"); + echo "
\n"; + } + echo "
\n"; +} + + +////////////////////////////////////////////////////////////////////////////////////// +function dialogue_print_tabbed_heading($tabs) { +// Prints a tabbed heading where one of the tabs highlighted. +// $tabs is an object with several properties. +// $tabs->names is an array of tab names +// $tabs->urls is an array of links +// $tabs->align is an array of column alignments (defaults to "center") +// $tabs->size is an array of column sizes +// $tabs->wrap is an array of "nowrap"s or nothing +// $tabs->highlight is an index (zero based) of "active" heading . +// $tabs->width is an percentage of the page (defualts to 80%) +// $tabs->cellpadding padding on each cell (defaults to 5) + + global $CFG, $THEME; + + if (isset($tabs->names)) { + foreach ($tabs->names as $key => $name) { + if (!empty($tabs->urls[$key])) { + $url =$tabs->urls[$key]; + if ($tabs->highlight == $key) { + $tabcontents[$key] = "$name"; + } else { + $tabcontents[$key] = "$name"; + } + } else { + $tabcontents[$key] = "$name"; + } + } + } + + if (empty($tabs->width)) { + $tabs->width = "80%"; + } + + if (empty($tabs->cellpadding)) { + $tabs->cellpadding = "5"; + } + + // print_simple_box_start("center", "$table->width", "#ffffff", 0); + echo "width\" border=\"0\" valign=\"top\" align=\"center\" "; + echo " cellpadding=\"$tabs->cellpadding\" cellspacing=\"0\" class=\"generaltable\">\n"; + + if (!empty($tabs->names)) { + echo ""; + echo "\n"; + foreach ($tabcontents as $key => $tab) { + if (isset($align[$key])) { + $alignment = "align=\"$align[$key]\""; + } else { + $alignment = "align=\"center\""; + } + if (isset($size[$key])) { + $width = "width=\"$size[$key]\""; + } else { + $width = ""; + } + if (isset($wrap[$key])) { + $wrapping = "no wrap"; + } else { + $wrapping = ""; + } + if ($key == $tabs->highlight) { + echo "\n"; + } else { + echo "\n"; + } + echo "\n"; + } + echo "\n"; + } else { + echo "\n"; + } + // bottom stripe + $ncells = count($tabs->names)*2 +1; + $height = 2; + echo "\n"; + echo "
". + "wwwroot/pix/spacer.gif\" alt=\"\">cellheading2\">$tabcellheading\">$tab". + "wwwroot/pix/spacer.gif\" alt=\"\">
No names specified
cellheading2\">". + "wwwroot/pix/spacer.gif\" alt=\"\">
\n"; + // print_simple_box_end(); + + return true; +} + + + +////////////////////////////////////////////////////////////////////////////////////// +function dialogue_show_conversation($dialogue, $conversation) { + global $THEME, $USER; + + if (! $course = get_record("course", "id", $dialogue->course)) { + error("Course is misconfigured"); + } + if (! $cm = get_coursemodule_from_instance("dialogue", $dialogue->id, $course->id)) { + error("Course Module ID was incorrect"); + } + + $timenow = time(); + print_simple_box_start("center"); + echo "
\n"; + + echo ""; + echo ""; + echo ""; + + if ($entries = get_records_select("dialogue_entries", "conversationid = $conversation->id", "id")) { + foreach ($entries as $entry) { + if ($entry->userid == $USER->id) { + echo "\n"; + } + else { + echo "\n"; + } + } + } + echo "
cellheading2\" valign=\"top\">\n"; + if ($conversation->userid == $USER->id) { + if (!$otheruser = get_record("user", "id", $conversation->recipientid)) { + error("User not found"); + } + } + else { + if (!$otheruser = get_record("user", "id", $conversation->userid)) { + error("User not found"); + } + } + // print_user_picture($user->id, $course->id, $user->picture); + echo "".get_string("dialoguewith", "dialogue", "$otheruser->firstname $otheruser->lastname"). + "cellheading2\" valign=\"top\">$conversation->subject 
\n"; + echo text_to_html("".get_string("onyouwrote", "dialogue", + userdate($entry->timecreated)). + ":
".$entry->text); + echo "
body\">\n"; + echo text_to_html("".get_string("onwrote", "dialogue", + userdate($entry->timecreated)." ".$otheruser->firstname).":
".$entry->text); + echo "

\n"; + print_simple_box_end(); + print_continue("view.php?id=$cm->id&pane=3"); +} + + +////////////////////////////////////////////////////////////////////////////////////// +function dialogue_show_other_conversations($dialogue, $conversation) { +// prints the other CLOSED conversations for this pair of users + global $THEME; + + if (! $course = get_record("course", "id", $dialogue->course)) { + error("Course is misconfigured"); + } + if (! $cm = get_coursemodule_from_instance("dialogue", $dialogue->id, $course->id)) { + error("Course Module ID was incorrect"); + } + + if (!$user = get_record("user", "id", $conversation->userid)) { + error("User not found"); + } + if (!$otheruser = get_record("user", "id", $conversation->recipientid)) { + error("User not found"); + } + + if ($conversations = get_records_select("dialogue_conversations", "dialogueid = $dialogue->id AND + ((userid = $user->id AND recipientid = $otheruser->id) OR (userid = $otheruser->id AND + recipientid = $user->id)) AND closed = 1", "timemodified DESC")) { + if (count($conversations) > 1) { + $timenow = time(); + foreach ($conversations as $otherconversation) { + if ($conversation->id != $otherconversation->id) { + // for this conversation work out which is the other user + if ($otherconversation->userid == $user->id) { + if (!$otheruser = get_record("user", "id", $otherconversation->recipientid)) { + error("Show other conversations: could not get user record"); + } + } + else { + if (!$otheruser = get_record("user", "id", $otherconversation->userid)) { + error("Show other conversations: could not get user record"); + } + } + print_simple_box_start("center"); + echo "
\n"; + + echo ""; + echo ""; + echo ""; + if ($entries = get_records_select("dialogue_entries", + "conversationid = $otherconversation->id", "id")) { + foreach ($entries as $entry) { + if ($entry->userid == $user->id) { + echo "\n"; + } + else { + echo "\n"; + } + } + } + + echo "
cellheading2\" VALIGN=TOP>\n"; + // print_user_picture($otheruser->id, $course->id, $otheruser->picture); + echo "".get_string("dialoguewith", "dialogue", + "$otheruser->firstname $otheruser->lastname")."cellheading2\" valign=\"top\">$otherconversation->subject 
\n"; + echo text_to_html("".get_string("onyouwrote", "dialogue", + userdate($entry->timecreated)).":
".$entry->text); + echo "
body\">\n"; + echo text_to_html("".get_string("onwrote", "dialogue", + userdate($entry->timecreated)." ".$otheruser->firstname). + ":
".$entry->text); + echo "

\n"; + print_simple_box_end(); + } + } + print_continue("view.php?id=$cm->id&pane=3"); + } + } +} + + +?> diff --git a/mod/dialogue/view.php b/mod/dialogue/view.php index 244090a04b19d..31d8bf136f340 100644 --- a/mod/dialogue/view.php +++ b/mod/dialogue/view.php @@ -2,6 +2,7 @@ require_once("../../config.php"); require_once("lib.php"); + require_once("locallib.php"); require_variable($id); // Course Module ID