Example #1
0
        break;
}
echo '<div class="user-content">';
if ($course->id == SITEID) {
    if (empty($CFG->forceloginforprofiles) || isloggedin()) {
        // Search throughout the whole site.
        $searchcourse = 0;
    } else {
        $searchcourse = SITEID;
    }
} else {
    // Search only for posts the user made in this course.
    $searchcourse = $course->id;
}
// Get the posts.
if ($posts = forum_search_posts($searchterms, $searchcourse, $page * $perpage, $perpage, $totalcount, $extrasql)) {
    print_paging_bar($totalcount, $page, $perpage, "user.php?id={$user->id}&amp;course={$course->id}&amp;mode={$mode}&amp;perpage={$perpage}&amp;");
    $discussions = array();
    $forums = array();
    $cms = array();
    foreach ($posts as $post) {
        if (!isset($discussions[$post->discussion])) {
            if (!($discussion = get_record('forum_discussions', 'id', $post->discussion))) {
                error('Discussion ID was incorrect');
            }
            $discussions[$post->discussion] = $discussion;
        } else {
            $discussion = $discussions[$post->discussion];
        }
        if (!isset($forums[$discussion->forum])) {
            if (!($forum = get_record('forum', 'id', $discussion->forum))) {
Example #2
0
    $PAGE->navbar->add($strforums, new moodle_url('/mod/forum/index.php', array('id' => $course->id)));
    $PAGE->navbar->add(get_string('advancedsearch', 'forum'));
    $PAGE->set_title($strsearch);
    $PAGE->set_heading($course->fullname);
    echo $OUTPUT->header();
    forum_print_big_search_form($course);
    echo $OUTPUT->footer();
    exit;
}
/// We need to do a search now and print results
$searchterms = str_replace('forumid:', 'instance:', $search);
$searchterms = explode(' ', $searchterms);
$searchform = forum_search_form($course, $search);
$PAGE->navbar->add($strsearch, new moodle_url('/mod/forum/search.php', array('id' => $course->id)));
$PAGE->navbar->add(s($search, true));
if (!($posts = forum_search_posts($searchterms, $course->id, $page * $perpage, $perpage, $totalcount))) {
    $PAGE->set_title($strsearchresults);
    $PAGE->set_heading($course->fullname);
    echo $OUTPUT->header();
    echo $OUTPUT->heading(get_string("nopostscontaining", "forum", $search));
    if (!$individualparams) {
        $words = $search;
    }
    forum_print_big_search_form($course);
    echo $OUTPUT->footer();
    exit;
}
//including this here to prevent it being included if there are no search results
require_once $CFG->dirroot . '/rating/lib.php';
//set up the ratings information that will be the same for all posts
$ratingoptions = new stdClass();