diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 9411e291b02..11e4c2eed45 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -533,6 +533,7 @@ $string['newsitems'] = "news items"; $string['newsitemsnumber'] = "News items to show"; $string['never'] = "Never"; $string['neverdeletelogs'] = "Never delete logs"; +$string['next'] = "Next"; $string['no'] = "No"; $string['nocoursesyet'] = "No courses in this category"; $string['noexistingadmins'] = "No existing admins, this is a serious error and you should never have seen this message."; @@ -576,6 +577,7 @@ $string['optional'] = "optional"; $string['order'] = "Order"; $string['other'] = "Other"; $string['outline'] = "Outline"; +$string['page'] = "Page"; $string['parentlanguage'] = ""; $string['participants'] = "Participants"; $string['password'] = "Password"; @@ -649,6 +651,7 @@ $string['scalesstandard'] = "Standard scales"; $string['search'] = "Search"; $string['searchagain'] = "Search again"; $string['searchcourses'] = "Search courses"; +$string['searchhelp'] = "You can search for multiple words at once.
word : find any match of this word within the text.
+word : only exact matching words will be found.
-word : don't include results containing this word.";
$string['searchresults'] = "Search results";
$string['sec'] = "sec";
$string['secs'] = "secs";
diff --git a/lib/weblib.php b/lib/weblib.php
index 6e4ef37ddea..e81979e565e 100644
--- a/lib/weblib.php
+++ b/lib/weblib.php
@@ -1615,6 +1615,29 @@ function obfuscate_mailto($email, $label="") {
obfuscate_text($label));
}
+function print_paging_bar($totalcount, $page, $perpage, $baseurl) {
+/// Prints a single paging bar to provide access to other pages (usually in a search)
+
+ if ($totalcount > $perpage) {
+ echo "
".get_string("page").":"; + $count = 0; + while ($totalcount > 0) { + $displaypage = $count+1; + if ($page == $count) { + echo " $displaypage"; + } else { + echo " $displaypage"; + } + $count++; + $totalcount -= $perpage; + } + $pagenum = $page + 1; + if ($pagenum != $count) { + echo " (".get_string("next").")"; + } + echo "
"; + } +} // vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140: ?> diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 3049a7e447e..a6047abfb6c 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -490,8 +490,11 @@ function forum_get_child_posts($parent) { } -function forum_search_posts($search, $courseid, $page=0, $recordsperpage=50) { -/// Returns a list of posts that were found +function forum_search_posts($searchterms, $courseid, $page=0, $recordsperpage=50, &$totalcount) { +/// Returns a list of posts found using an array of search terms +/// eg word +word -word +/// + global $CFG; if (!isteacher($courseid)) { @@ -527,9 +530,11 @@ function forum_search_posts($search, $courseid, $page=0, $recordsperpage=50) { $messagesearch = ""; $subjectsearch = ""; - $searchterms = explode(" ", $search); // Search for words independently foreach ($searchterms as $searchterm) { + if (strlen($searchterm) < 2) { + continue; + } if ($messagesearch) { $messagesearch .= " AND "; } @@ -551,19 +556,20 @@ function forum_search_posts($search, $courseid, $page=0, $recordsperpage=50) { } } + $selectsql = "{$CFG->prefix}forum_posts p, + {$CFG->prefix}forum_discussions d, + {$CFG->prefix}user u, + {$CFG->prefix}forum f + WHERE ($messagesearch OR $subjectsearch) + AND p.userid = u.id + AND p.discussion = d.id + AND d.course = '$courseid' + AND d.forum = f.id $notteacherforum"; + + $totalcount = count_records_sql("SELECT COUNT(*) FROM $selectsql"); - 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, - {$CFG->prefix}user u, - {$CFG->prefix}forum f - WHERE ($messagesearch OR $subjectsearch) - AND p.userid = u.id - AND p.discussion = d.id - AND d.course = '$courseid' - AND d.forum = f.id - $notteacherforum - ORDER BY p.modified DESC $limit"); + return get_records_sql("SELECT p.*,u.firstname,u.lastname,u.email,u.picture FROM + $selectsql ORDER BY p.modified DESC $limit"); } @@ -1266,34 +1272,34 @@ function forum_print_rating_menu($postid, $userid, $scale) { function forum_print_mode_form($discussion, $mode) { GLOBAL $FORUM_LAYOUT_MODES; - echo ""; + echo "
"; popup_form("discuss.php?d=$discussion&mode=", $FORUM_LAYOUT_MODES, "mode", $mode, ""); - echo "
| "; - $output .= ""; - $output .= " |
| "; + $output .= ""; + $output .= " |
| "; - $output .= ""; - $output .= " |
| "; + $output .= ""; + $output .= " |