]> git.mjollnir.org Git - moodle.git/commitdiff
Starting work on MDL-10533 - Eliminate one totally evil abuse of $SESSION. Also,...
authortjhunt <tjhunt>
Mon, 23 Jul 2007 16:00:36 +0000 (16:00 +0000)
committertjhunt <tjhunt>
Mon, 23 Jul 2007 16:00:36 +0000 (16:00 +0000)
mod/forum/lib.php
mod/forum/search.php

index dd21ffcc74b6d7f0a9a37daa55bb985b2f5179fa..ae86036dd70674aaad3be9ef17fc34489aa05d29 100644 (file)
@@ -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 '<a id="p'.$post->id.'"></a>';
index a15cc94f5b984cad70a0625ff1890293a9aeefc2..80baeee96bcd383645f8a548d9ec18153ba66838 100644 (file)
         }
 
         $fulllink = "<a href=\"discuss.php?d=$post->discussion#p$post->id\">".get_string("postincontext", "forum")."</a>";
-        //search terms already highlighted - fiedorow - 9/2/2005
-        $SESSION->forum_search = true;
 
         // reconstruct the TRUSTTEXT properly after processing
         if ($ttpresent) {
         } 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 "<br />";
     }