From 21976af149373ddcc394acf04e67250ce67b84ed Mon Sep 17 00:00:00 2001 From: tjhunt Date: Mon, 23 Jul 2007 16:00:36 +0000 Subject: [PATCH] Starting work on MDL-10533 - Eliminate one totally evil abuse of $SESSION. Also, document forum_print_post. --- mod/forum/lib.php | 26 ++++++++++++++++++++------ mod/forum/search.php | 5 +---- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/mod/forum/lib.php b/mod/forum/lib.php index dd21ffcc74..ae86036dd7 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -2086,14 +2086,29 @@ function forum_make_mail_post(&$post, $user, $touser, $course, return $output; } - /** - * TODO document + * Print a forum post + * + * @param object $post The post to print. + * @param integer $courseid The course this post belongs to. + * @param boolean $ownpost Whether this post belongs to the current user. + * @param boolean $reply Whether to print a 'reply' link at the bottom of the message. + * @param boolean $link Just print a shortened version of the post as a link to the full post. + * @param object $ratings -- I don't really know -- + * @param string $footer Extra stuff to print after the message. + * @param string $highlight Space-separated list of terms to highlight. + * @param int $post_read true, false or -99. If we already know whether this user + * has read this post, pass that in, otherwise, pass in -99, and this + * function will work it out. + * @param boolean $dummyifcantsee When forum_user_can_see_post says that + * the current user can't see this post, if this argument is true + * (the default) then print a dummy 'you can't see this post' post. + * If false, don't output anything at all. */ function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link=false, - $ratings=NULL, $footer="", $highlight="", $post_read=-99) { + $ratings=NULL, $footer="", $highlight="", $post_read=-99, $dummyifcantsee=true) { - global $USER, $CFG, $SESSION; + global $USER, $CFG; static $stredit, $strdelete, $strreply, $strparent, $strprune; static $strpruneheading, $threadedmode; @@ -2108,8 +2123,7 @@ function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link if (!forum_user_can_see_post($post->forum,$post->discussion,$post)) { - if (empty($SESSION->forum_search)) { - // just viewing, return + if (!$dummyifcantsee) { return; } echo ''; diff --git a/mod/forum/search.php b/mod/forum/search.php index a15cc94f5b..80baeee96b 100644 --- a/mod/forum/search.php +++ b/mod/forum/search.php @@ -247,8 +247,6 @@ } $fulllink = "discussion#p$post->id\">".get_string("postincontext", "forum").""; - //search terms already highlighted - fiedorow - 9/2/2005 - $SESSION->forum_search = true; // reconstruct the TRUSTTEXT properly after processing if ($ttpresent) { @@ -256,8 +254,7 @@ } else { $post->message = trusttext_strip($post->message); //make 100% sure TRUSTTEXT marker was not created during processing } - forum_print_post($post, $course->id, false, false, false, false, $fulllink); - unset($SESSION->forum_search); + forum_print_post($post, $course->id, false, false, false, false, $fulllink, '', -99, false); echo "
"; } -- 2.39.5