$prevpage = $page - FORUMNG_SEARCH_RESULTSPERPAGE;
        $prevrange = $page - FORUMNG_SEARCH_RESULTSPERPAGE + 1 . ' - ' . $page;
        // Get result from database query.
        if ($allforums) {
            $results = forumng_get_results_for_all_forums($course, trim($data->author), $data->datefrom, $data->dateto, $page, !empty($data->asmoderator));
        } else {
            $results = forumng_get_results_for_this_forum($forum, $groupid, trim($data->author), $data->datefrom, $data->dateto, $page, !empty($data->asmoderator));
        }
        $nextpage = $page + FORUMNG_SEARCH_RESULTSPERPAGE;
        $linknext = null;
        $linkprev = null;
        if ($results->success) {
            if ($page - FORUMNG_SEARCH_RESULTSPERPAGE + 1 > 0) {
                $url->param('page', $prevpage);
                $linkprev = $url->out(false);
            }
            if ($results->numberofentries == FORUMNG_SEARCH_RESULTSPERPAGE) {
                $url->param('page', $nextpage);
                $linknext = $url->out(false);
            }
        }
        if ($results->done === 1) {
            if ($page - FORUMNG_SEARCH_RESULTSPERPAGE + 1 > 0) {
                $url->param('page', $prevpage);
                $linkprev = $url->out(false);
            }
        }
        print local_ousearch_search::format_results($results, $searchtitle, $page + 1, $linkprev, $prevrange, $linknext, $results->searchtime);
    }
}
print $out->footer();