$navigation = build_navigation($extranavigation); print_header_simple(get_string('searchresults'), "", $navigation); $querytext = stripslashes(required_param('query', PARAM_RAW)); $query = new ousearch_search($querytext); if (strpos($plugin, 'mod/') === 0) { $modname = substr($plugin, 4); } else { $modname = null; } $query->set_visible_modules_in_course($COURSE, $modname); // Restrict them to the groups they belong to if (!isset($USER->groupmember[$courseid])) { $query->set_group_ids(array()); } else { $query->set_group_ids($USER->groupmember[$courseid]); } // Add exceptions where they can see other groups $query->set_group_exceptions(ousearch_get_group_exceptions($courseid)); $query->set_user_id($USER->id); $query->set_plugin($plugin); ousearch_display_results($query, 'search.php?course=' . $courseid . '&plugin=' . $plugin); //Print advanced search link if ($plugin == 'mod/forumng') { $querytext = rawurlencode($querytext); $options = "course={$courseid}&query={$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>"; } // Footer print_footer();
// Searching for free text with or without filtering author and date range if ($query) { $result = new ousearch_search(stripslashes($query)); // Search all forums if ($allforums) { $result->set_plugin('mod/forumng'); $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;