mirror of
https://github.com/moodle/moodle.git
synced 2025-02-15 13:24:56 +01:00
Moved Embargoed Announcements related search into SQL. So that paging/counting for the search results will be accurate.
This commit is contained in:
parent
f53fba389a
commit
6af7cc2206
@ -1040,7 +1040,7 @@ function forum_search_posts($searchterms, $courseid, $page=0, $recordsperpage=50
|
|||||||
/// Returns a list of posts found using an array of search terms
|
/// Returns a list of posts found using an array of search terms
|
||||||
/// eg word +word -word
|
/// eg word +word -word
|
||||||
///
|
///
|
||||||
global $CFG;
|
global $CFG, $USER;
|
||||||
require_once($CFG->libdir.'/searchlib.php');
|
require_once($CFG->libdir.'/searchlib.php');
|
||||||
|
|
||||||
if (!isteacher($courseid)) {
|
if (!isteacher($courseid)) {
|
||||||
@ -1078,6 +1078,12 @@ function forum_search_posts($searchterms, $courseid, $page=0, $recordsperpage=50
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$timelimit = '';
|
||||||
|
if (!((isadmin() and !empty($CFG->admineditalways)) || isteacher($courseid))) {
|
||||||
|
$now = time();
|
||||||
|
$timelimit = " AND (d.userid = $USER->id || ((d.timestart = 0 || d.timestart <= $now) && (d.timeend = 0 || d.timeend > $now))";
|
||||||
|
}
|
||||||
|
|
||||||
$limit = sql_paging_limit($page, $recordsperpage);
|
$limit = sql_paging_limit($page, $recordsperpage);
|
||||||
|
|
||||||
/// Some differences in syntax for PostgreSQL
|
/// Some differences in syntax for PostgreSQL
|
||||||
@ -1119,7 +1125,7 @@ function forum_search_posts($searchterms, $courseid, $page=0, $recordsperpage=50
|
|||||||
{$CFG->prefix}user u $onlyvisibletable $coursetable
|
{$CFG->prefix}user u $onlyvisibletable $coursetable
|
||||||
WHERE ($messagesearch)
|
WHERE ($messagesearch)
|
||||||
AND p.userid = u.id
|
AND p.userid = u.id
|
||||||
AND p.discussion = d.id $selectcourse $notteacherforum $onlyvisible $selectgroup $extrasql";
|
AND p.discussion = d.id $selectcourse $notteacherforum $onlyvisible $selectgroup $timelimit $extrasql";
|
||||||
|
|
||||||
$totalcount = count_records_sql("SELECT COUNT(*) FROM $selectsql");
|
$totalcount = count_records_sql("SELECT COUNT(*) FROM $selectsql");
|
||||||
|
|
||||||
|
@ -187,16 +187,6 @@
|
|||||||
error("Could not find forum $discussion->forum");
|
error("Could not find forum $discussion->forum");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($forum->type == "news") { // Skip if is hidden
|
|
||||||
if (!((isadmin() and !empty($CFG->admineditalways))
|
|
||||||
|| isteacher($course->id)
|
|
||||||
|| $USER->id == $discussion->userid
|
|
||||||
|| (($discussion->timestart == 0 || $discussion->timestart <= time())
|
|
||||||
&& ($discussion->timeend == 0 || $discussion->timeend > time())))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$post->subject = highlight($strippedsearch, $post->subject);
|
$post->subject = highlight($strippedsearch, $post->subject);
|
||||||
$discussion->name = highlight($strippedsearch, $discussion->name);
|
$discussion->name = highlight($strippedsearch, $discussion->name);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user