2002-07-31 14:19:35 +00:00
|
|
|
<?PHP // $Id$
|
|
|
|
|
2003-01-05 14:19:20 +00:00
|
|
|
require_once("../../config.php");
|
|
|
|
require_once("lib.php");
|
2002-07-31 14:19:35 +00:00
|
|
|
|
2002-12-23 09:39:26 +00:00
|
|
|
require_variable($id); // course id
|
|
|
|
optional_variable($search, ""); // search string
|
2002-07-31 14:19:35 +00:00
|
|
|
|
|
|
|
$search = strip_tags($search);
|
|
|
|
|
|
|
|
if (! $course = get_record("course", "id", $id)) {
|
|
|
|
error("Course id is incorrect.");
|
|
|
|
}
|
|
|
|
|
2002-08-03 08:16:31 +00:00
|
|
|
if ($course->category) {
|
|
|
|
require_login($course->id);
|
|
|
|
}
|
2002-07-31 14:19:35 +00:00
|
|
|
|
2002-07-31 16:53:32 +00:00
|
|
|
add_to_log($course->id, "forum", "search", "search.php?id=$course->id&search=$search", "$search");
|
2002-07-31 14:19:35 +00:00
|
|
|
|
2002-11-06 07:40:36 +00:00
|
|
|
$strforums = get_string("modulenameplural", "forum");
|
|
|
|
$strsearch = get_string("search", "forum");
|
|
|
|
$strsearchresults = get_string("searchresults", "forum");
|
|
|
|
|
2002-12-23 15:33:40 +00:00
|
|
|
$searchform = forum_print_search_form($course, $search, true, "plain");
|
|
|
|
|
2002-07-31 14:19:35 +00:00
|
|
|
if ($search) {
|
2002-11-06 07:40:36 +00:00
|
|
|
print_header("$course->shortname: $strsearchresults", "$course->fullname",
|
2002-07-31 14:19:35 +00:00
|
|
|
"<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->
|
2002-11-06 07:40:36 +00:00
|
|
|
<A HREF=\"index.php?id=$course->id\">$strforums</A> ->
|
2002-12-23 15:33:40 +00:00
|
|
|
<A HREF=\"search.php?id=$course->id\">$strsearch</A> -> \"$search\"", "search.search",
|
|
|
|
"", "", $searchform);
|
2002-07-31 14:19:35 +00:00
|
|
|
} else {
|
2002-11-06 07:40:36 +00:00
|
|
|
print_header("$course->shortname: $strsearch", "$course->fullname",
|
2002-07-31 14:19:35 +00:00
|
|
|
"<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->
|
2002-12-23 15:33:40 +00:00
|
|
|
<A HREF=\"index.php?id=$course->id\">$strforums</A> -> $strsearch", "search.search",
|
|
|
|
"", "", $searchform);
|
2002-07-31 14:19:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($search) {
|
|
|
|
|
2002-12-20 14:44:14 +00:00
|
|
|
if (!$posts = forum_search_posts($search, $course->id)) {
|
2002-12-23 15:33:40 +00:00
|
|
|
print_heading(get_string("nopostscontaining", "forum", $search));
|
2002-07-31 14:19:35 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
foreach ($posts as $post) {
|
|
|
|
if (! $discussion = get_record("forum_discussions", "id", $post->discussion)) {
|
|
|
|
error("Discussion ID was incorrect");
|
|
|
|
}
|
|
|
|
if (! $forum = get_record("forum", "id", "$discussion->forum")) {
|
|
|
|
error("Could not find forum $discussion->forum");
|
|
|
|
}
|
|
|
|
|
2002-11-28 09:10:22 +00:00
|
|
|
$post->subject = highlight("$search", $post->subject);
|
|
|
|
$discussion->name = highlight("$search", $discussion->name);
|
|
|
|
|
2002-08-06 17:23:45 +00:00
|
|
|
$fullsubject = "<A HREF=\"view.php?f=$forum->id\">$forum->name</A>";
|
|
|
|
if ($forum->type != "single") {
|
|
|
|
$fullsubject .= " -> <A HREF=\"discuss.php?d=$discussion->id\">$discussion->name</A>";
|
|
|
|
if ($post->parent != 0) {
|
|
|
|
$fullsubject .= " -> <A HREF=\"discuss.php?d=$post->discussion&parent=$post->id\">$post->subject</A>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$post->subject = $fullsubject;
|
2002-07-31 14:19:35 +00:00
|
|
|
$post->message = highlight("$search", $post->message);
|
|
|
|
|
2002-11-06 09:13:19 +00:00
|
|
|
$fulllink = "<P ALIGN=right><A HREF=\"discuss.php?d=$post->discussion&parent=$post->id\">".get_string("postincontext", "forum")."</A></P>";
|
2002-08-01 03:50:27 +00:00
|
|
|
forum_print_post($post, $course->id, false, false, false, false, $fulllink);
|
2002-07-31 14:19:35 +00:00
|
|
|
|
|
|
|
echo "<BR>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
print_footer($course);
|
|
|
|
|
|
|
|
?>
|
|
|
|
|