$cm = $forum->get_course_module();
    $course = $forum->get_course();
    $groupid = forum::get_activity_group($cm, true);
    $forum->require_view($groupid, 0, true);
    forum::search_installed();
    // Search form for header
    $buttontext = $forum->display_search_form($querytext);
    // Display header
    $navigation = array();
    $navigation[] = array('name' => get_string('searchfor', 'block_ousearch', $querytext), 'type' => 'forumng');
    print_header_simple(format_string($forum->get_name()), '', build_navigation($navigation, $cm), '', '', true, $buttontext, navmenu($course, $cm));
    // Display group selector if required
    groups_print_activity_menu($cm, $CFG->wwwroot . '/mod/forumng/search.php?' . $forum->get_link_params(forum::PARAM_HTML) . '&query=' . rawurlencode($querytext));
    $searchurl = 'search.php?' . $forum->get_link_params(forum::PARAM_PLAIN);
    $query = new ousearch_search($querytext);
    $query->set_coursemodule($forum->get_course_module(true));
    if ($groupid && $groupid != forum::NO_GROUPS) {
        $query->set_group_id($groupid);
    }
    ousearch_display_results($query, $searchurl);
    //Print advanced search link
    $options = $forum->get_link_params(forum::PARAM_HTML);
    $options .= '&action=0';
    $options .= $querytext ? '&query=' . rawurlencode($querytext) : '';
    $url = $CFG->wwwroot . '/mod/forumng/advancedsearch.php?' . $options;
    $strlink = get_string('moresearchoptions', 'forumng');
    print "<div class='advanced-search-link'>\n            <a href=\"{$url}\">{$strlink}</a></div>";
    print_footer($course);
} catch (forum_exception $e) {
    forum_utils::handle_exception($e);
}
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
 * @package ouwiki
 */
/** */
require 'basicpage.php';
if (class_exists('ouflags')) {
    require_once '../../local/mobile/ou_lib.php';
    global $OUMOBILESUPPORT;
    $OUMOBILESUPPORT = true;
    ou_set_is_mobile(ou_get_is_mobile_from_cookies());
    if (ou_get_is_mobile()) {
        ou_mobile_configure_theme();
    }
}
ouwiki_print_start($ouwiki, $cm, $course, $subwiki, get_string('searchresults'), $context);
require_once '../../blocks/ousearch/searchlib.php';
$querytext = stripslashes(required_param('query', PARAM_RAW));
$query = new ousearch_search($querytext);
$query->set_coursemodule($cm);
if ($subwiki->groupid) {
    $query->set_group_id($subwiki->groupid);
}
if ($subwiki->userid) {
    $query->set_user_id($subwiki->userid);
}
$foundsomething = ousearch_display_results($query, 'search.php?' . ouwiki_display_wiki_parameters(null, $subwiki, $cm));
// Footer
ouwiki_print_footer($course, $cm, $subwiki, null, 'search.php?query=' . urlencode($querytext), $foundsomething ? null : 'searchfailure', $querytext);
?>

         $result->set_course_id($courseid);
         $result->set_visible_modules_in_course($COURSE);
         // Restrict them to the groups they belong to
         if (!isset($USER->groupmember[$courseid])) {
             $result->set_group_ids(array());
         } else {
             $result->set_group_ids($USER->groupmember[$courseid]);
         }
         // Add exceptions where they can see other groups
         $result->set_group_exceptions(ousearch_get_group_exceptions($courseid));
         $result->set_user_id($USER->id);
     } else {
         // Search this forum
         $result->set_coursemodule($forum->get_course_module(true));
         if ($groupid && $groupid != forum::NO_GROUPS) {
             $result->set_group_id($groupid);
         }
     }
     $result->set_filter('forumng_exclude_words_filter');
     ousearch_display_results($result, $url . $urloptions, $searchtitle);
     // Searching without free text uding author and/or date range
 } elseif ($action) {
     $page = optional_param('page', 0, PARAM_INT);
     $prevpage = $page - FORUMNG_SEARCH_RESULTSPERPAGE;
     $prevrange = $page - FORUMNG_SEARCH_RESULTSPERPAGE + 1 . ' - ' . $page;
     //Get result from db
     if ($allforums) {
         $results = forumng_get_results_for_all_forums($course, $author, $daterangefrom, $daterangeto, $page);
     } else {
         $results = forumng_get_results_for_this_forum($forum, $groupid, $author, $daterangefrom, $daterangeto, $page);
     }