Permalink
Browse files

More database tweaks and improved access to forum search engine

  • Loading branch information...
1 parent 7f8dcc6 commit 97485d07268ce03fc079e74d40e80252693ee11d moodler committed Dec 23, 2002
Showing with 57 additions and 33 deletions.
  1. +0 −2 admin/user.php
  2. +2 −1 lib/datalib.php
  3. +4 −2 mod/forum/discuss.php
  4. +10 −9 mod/forum/index.php
  5. +31 −12 mod/forum/lib.php
  6. +7 −7 mod/forum/search.php
  7. +3 −0 mod/forum/view.php
View
@@ -6,8 +6,6 @@
$recordsperpage = 30;
- $db->debug = true;
-
optional_variable($newuser, "");
optional_variable($delete, "");
optional_variable($confirm, "");
View
@@ -754,7 +754,8 @@ function get_users_longtimenosee($cutofftime) {
{$CFG->prefix}user_students s
WHERE u.lastaccess > '0'
AND u.lastaccess < '$cutofftime'
- AND u.id = s.userid");
+ AND u.id = s.userid
+ GROUP BY u.id");
}
View
@@ -58,13 +58,15 @@
$navmiddle = "<A HREF=\"../forum/index.php?id=$course->id\">".get_string("forums", "forum")."</A> -> <A HREF=\"../forum/view.php?f=$forum->id\">$forum->name</A>";
+ $searchform = forum_print_search_form($course, $search, true, "plain");
+
if ($course->category) {
print_header("$course->shortname: $discussion->name", "$course->fullname",
"<A HREF=../../course/view.php?id=$course->id>$course->shortname</A> ->
- $navmiddle -> $navtail", "", "", true, "", navmenu($course, $cm));
+ $navmiddle -> $navtail", "", "", true, $searchform, navmenu($course, $cm));
} else {
print_header("$course->shortname: $discussion->name", "$course->fullname",
- "$navmiddle -> $navtail", "", "", true);
+ "$navmiddle -> $navtail", "", "", true, $searchform, navmenu($course, $cm));
}
forum_print_discussion($course, $forum, $discussion, $post, $displaymode);
View
@@ -25,18 +25,22 @@
add_to_log($course->id, "forum", "view forums", "index.php?id=$course->id");
$strforums = get_string("forums", "forum");
+ $strforum = get_string("forum", "forum");
+ $strdescription = get_string("description");
+ $strdiscussions = get_string("discussions", "forum");
+ $strsubscribed = get_string("subscribed", "forum");
+
+ $searchform = forum_print_search_form($course, "", true, "plain");
if ($course->category) {
print_header("$course->shortname: $strforums", "$course->fullname",
"<A HREF=../../course/view.php?id=$course->id>$course->shortname</A> -> $strforums",
- "", "", true, "", navmenu($course));
+ "", "", true, $searchform, navmenu($course));
} else {
- print_header("$course->shortname: $strforums", "$course->fullname", "$strforums");
+ print_header("$course->shortname: $strforums", "$course->fullname", "$strforums",
+ "", "", true, $searchform, navmenu($course));
}
- $strforum = get_string("forum", "forum");
- $strdescription = get_string("description");
- $strdiscussions = get_string("discussions", "forum");
- $strsubscribed = get_string("subscribed", "forum");
+
$table->head = array ($strforum, $strdescription, $strdiscussions);
$table->align = array ("LEFT", "LEFT", "CENTER");
@@ -145,9 +149,6 @@
}
}
- echo "<DIV ALIGN=CENTER>";
- forum_print_search_form($course, $search);
- echo "</DIV>";
print_footer($course);
View
@@ -408,7 +408,7 @@ function forum_get_child_posts($parent) {
}
-function forum_search_posts($search, $courseid) {
+function forum_search_posts($search, $courseid, $page=0, $recordsperpage=50) {
/// Returns a list of posts that were found
global $CFG;
@@ -418,6 +418,13 @@ function forum_search_posts($search, $courseid) {
$notteacherforum = "";
}
+ if ($CFG->dbtype == "mysql") {
+ $limit = "LIMIT $page,$recordsperpage";
+ } else {
+ $limit = "LIMIT $recordsperpage,$page";
+ }
+
+
return get_records_sql("SELECT p.*,u.firstname,u.lastname,u.email,u.picture
FROM {$CFG->prefix}forum_posts p,
{$CFG->prefix}forum_discussions d,
@@ -429,7 +436,7 @@ function forum_search_posts($search, $courseid) {
AND d.course = '$courseid'
AND d.forum = f.id
$notteacherforum
- ORDER BY p.modified DESC LIMIT 0, 50");
+ ORDER BY p.modified DESC $limit");
}
function forum_get_ratings($postid, $sort="u.firstname ASC") {
@@ -1016,18 +1023,30 @@ function forum_print_mode_form($discussion, $mode) {
echo "</P></CENTER>\n";
}
-function forum_print_search_form($course, $search="", $return=false) {
+function forum_print_search_form($course, $search="", $return=false, $type="") {
global $CFG;
- $output = "<TABLE BORDER=0 CELLPADDING=10 CELLSPACING=0><TR><TD ALIGN=CENTER>";
- $output .= "<FORM NAME=search ACTION=\"$CFG->wwwroot/mod/forum/search.php\">";
- $output .= "<FONT SIZE=\"-1\">";
- $output .= "<INPUT NAME=search TYPE=text SIZE=15 VALUE=\"$search\"><BR>";
- $output .= "<INPUT VALUE=\"".get_string("searchforums", "forum")."\" TYPE=submit>";
- $output .= "</FONT>";
- $output .= "<INPUT NAME=id TYPE=hidden VALUE=\"$course->id\">";
- $output .= "</FORM>";
- $output .= "</TD></TR></TABLE>";
+ if ($type == "plain") {
+ $output = "<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD NOWRAP>";
+ $output .= "<FORM NAME=search ACTION=\"$CFG->wwwroot/mod/forum/search.php\">";
+ $output .= "<FONT SIZE=\"-1\">";
+ $output .= "<INPUT NAME=search TYPE=text SIZE=15 VALUE=\"$search\">";
+ $output .= "<INPUT VALUE=\"".get_string("searchforums", "forum")."\" TYPE=submit>";
+ $output .= "</FONT>";
+ $output .= "<INPUT NAME=id TYPE=hidden VALUE=\"$course->id\">";
+ $output .= "</FORM>";
+ $output .= "</TD></TR></TABLE>";
+ } else {
+ $output = "<TABLE BORDER=0 CELLPADDING=10 CELLSPACING=0><TR><TD ALIGN=CENTER>";
+ $output .= "<FORM NAME=search ACTION=\"$CFG->wwwroot/mod/forum/search.php\">";
+ $output .= "<FONT SIZE=\"-1\">";
+ $output .= "<INPUT NAME=search TYPE=text SIZE=15 VALUE=\"$search\"><BR>";
+ $output .= "<INPUT VALUE=\"".get_string("searchforums", "forum")."\" TYPE=submit>";
+ $output .= "</FONT>";
+ $output .= "<INPUT NAME=id TYPE=hidden VALUE=\"$course->id\">";
+ $output .= "</FORM>";
+ $output .= "</TD></TR></TABLE>";
+ }
if ($return) {
return $output;
View
@@ -22,25 +22,25 @@
$strsearch = get_string("search", "forum");
$strsearchresults = get_string("searchresults", "forum");
+ $searchform = forum_print_search_form($course, $search, true, "plain");
+
if ($search) {
print_header("$course->shortname: $strsearchresults", "$course->fullname",
"<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->
<A HREF=\"index.php?id=$course->id\">$strforums</A> ->
- <A HREF=\"search.php?id=$course->id\">$strsearch</A> -> \"$search\"", "search.search");
+ <A HREF=\"search.php?id=$course->id\">$strsearch</A> -> \"$search\"", "search.search",
+ "", "", $searchform);
} else {
print_header("$course->shortname: $strsearch", "$course->fullname",
"<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->
- <A HREF=\"index.php?id=$course->id\">$strforums</A> -> $strsearch", "search.search");
+ <A HREF=\"index.php?id=$course->id\">$strforums</A> -> $strsearch", "search.search",
+ "", "", $searchform);
}
- echo "<DIV ALIGN=CENTER>";
- forum_print_search_form($course, $search);
- echo "</DIV>";
-
if ($search) {
if (!$posts = forum_search_posts($search, $course->id)) {
- print_heading("<BR>".get_string("nopostscontaining", "forum", $search));
+ print_heading(get_string("nopostscontaining", "forum", $search));
} else {
foreach ($posts as $post) {
View
@@ -40,6 +40,9 @@
error("Must specify a course module or a forum ID");
}
+ if (!$buttontext) {
+ $buttontext = forum_print_search_form($course, $search, true, "plain");
+ }
if ($course->category) {
require_login($course->id);

0 comments on commit 97485d0

Please sign in to comment.