/** * @brief search in course * @global Indexer $idx * @param type $searchTerms * @param type $courseId * @param type $anonymous * @return boolean */ function search_in_course($searchTerms, $courseId, $anonymous) { global $idx; $data = array(); $data['search_terms'] = $searchTerms; $data['course_id'] = $courseId; require_once 'announcementindexer.class.php'; $anhits = $idx->searchRaw(AnnouncementIndexer::buildQuery($data, $anonymous)); if (count($anhits) > 0) { return true; } require_once 'agendaindexer.class.php'; $aghits = $idx->searchRaw(AgendaIndexer::buildQuery($data, $anonymous)); if (count($aghits) > 0) { return true; } require_once 'documentindexer.class.php'; $dhits = $idx->searchRaw(DocumentIndexer::buildQuery($data, $anonymous)); if (count($dhits) > 0) { return true; } require_once 'exerciseindexer.class.php'; $exhits = $idx->searchRaw(ExerciseIndexer::buildQuery($data, $anonymous)); if (count($exhits) > 0) { return true; } require_once 'forumindexer.class.php'; $fhits = $idx->searchRaw(ForumIndexer::buildQuery($data, $anonymous)); if (count($fhits) > 0) { return true; } require_once 'forumtopicindexer.class.php'; $fthits = $idx->searchRaw(ForumTopicIndexer::buildQuery($data, $anonymous)); if (count($fthits) > 0) { return true; } require_once 'linkindexer.class.php'; $lhits = $idx->searchRaw(LinkIndexer::buildQuery($data, $anonymous)); if (count($lhits) > 0) { return true; } require_once 'videoindexer.class.php'; $vhits = $idx->searchRaw(VideoIndexer::buildQuery($data, $anonymous)); if (count($vhits) > 0) { return true; } require_once 'videolinkindexer.class.php'; $vlhits = $idx->searchRaw(VideolinkIndexer::buildQuery($data, $anonymous)); if (count($vlhits) > 0) { return true; } require_once 'unitindexer.class.php'; $uhits = $idx->searchRaw(UnitIndexer::buildQuery($data, $anonymous)); if (count($uhits) > 0) { return true; } require_once 'unitresourceindexer.class.php'; $urhits = $idx->searchRaw(UnitResourceIndexer::buildQuery($data, $anonymous)); if (count($urhits) > 0) { return true; } return false; }
/** * Batch remove all index contents related to a Course. * * @param int $courseId */ public function removeAllByCourse($courseId) { if (!get_config('enable_indexing')) { return; } $cidx = new CourseIndexer($this); $cidx->remove($courseId); $aidx = new AnnouncementIndexer($this); $aidx->removeByCourse($courseId); $agdx = new AgendaIndexer($this); $agdx->removeByCourse($courseId); $lidx = new LinkIndexer($this); $lidx->removeByCourse($courseId); $vdx = new VideoIndexer($this); $vdx->removeByCourse($courseId); $vldx = new VideolinkIndexer($this); $vldx->removeByCourse($courseId); $eidx = new ExerciseIndexer($this); $eidx->removeByCourse($courseId); $fidx = new ForumIndexer($this); $fidx->removeByCourse($courseId); $ftdx = new ForumTopicIndexer($this); $ftdx->removeByCourse($courseId); $fpdx = new ForumPostIndexer($this); $fpdx->removeByCourse($courseId); $didx = new DocumentIndexer($this); $didx->removeByCourse($courseId); $uidx = new UnitIndexer($this); $uidx->removeByCourse($courseId); $urdx = new UnitResourceIndexer($this); $urdx->removeByCourse($courseId); $ndx = new NoteIndexer($this); $ndx->removeByCourse($courseId); }
if (isset($_REQUEST['search_terms'])) { $search_terms = addslashes($_REQUEST['search_terms']); } if (empty($search_terms)) { // display form $tool_content .= "\n <form method='post' action='{$_SERVER['SCRIPT_NAME']}'>\n <fieldset>\n <legend>{$langSearchCriteria}</legend>\n <table width='100%' class='tbl'>\n <tr>\n <th class='left' width='120'>{$langOR}</th>\n <td colspan='2'><input name='search_terms' type='text' size='80'/></td>\n </tr>\n <tr>\n <th width='30%' class='left' valign='top' rowspan='4'>{$langSearchIn}</th>\n <td width='35%'><input type='checkbox' name='announcements' checked='checked' />{$langAnnouncements}</td>\n <td width='35%'><input type='checkbox' name='agenda' checked='checked' />{$langAgenda}</td>\n </tr>\n <tr>\n <td><input type='checkbox' name='course_units' checked='checked' />{$langCourseUnits}</td>\n <td><input type='checkbox' name='documents' checked='checked' />{$langDoc}</td>\n </tr>\n <tr>\n <td><input type='checkbox' name='forums' checked='checked' />{$langForums}</td>\n <td><input type='checkbox' name='exercises' checked='checked' />{$langExercices}</td>\n </tr>\n <tr>\n <td><input type='checkbox' name='video' checked='checked' />{$langVideo}</td>\n <td><input type='checkbox' name='links' checked='checked' />{$langLinks}</td>\n </tr>\n <tr>\n <th> </th>\n <td colspan='2' class='right'><input class='btn btn-primary' type='submit' name='submit' value='{$langDoSearch}' /></td>\n </tr>\n </table>\n </fieldset>\n </form>"; } else { // ResourceIndexers require course_id inside the input data array (POST, but we do not want to pass it through the form) $_POST['course_id'] = $course_id; // Search Terms might come from GET, but we want to pass it alltogether with POST in ResourceIndexers $_POST['search_terms'] = $search_terms; $idx = new Indexer(); $tool_content .= "\n <div id=\"operations_container\">\n <ul id='opslist'>\n <li><a href='" . $_SERVER['SCRIPT_NAME'] . "'>{$langNewSearch}</a></li>\n </ul>\n </div>\n <p class='sub_title1'>{$langResults}</p>"; // search in announcements if ($announcements) { $announceHits = $idx->searchRaw(AnnouncementIndexer::buildQuery($_POST)); if (count($announceHits) > 0) { $tool_content .= "<script type='text/javascript' src='../auth/sorttable.js'></script>\n <table width='99%' class='sortable' id='t1' align='left'>\n <tr>\n <th colspan='2'>{$langAnnouncements}:</th>\n </tr>"; $numLine = 0; foreach ($announceHits as $annHit) { $announce = Database::get()->querySingle("SELECT title, content, date FROM announcement WHERE id = ?d", $annHit->pkid); $class = $numLine % 2 ? 'odd' : 'even'; $tool_content .= "<tr class='{$class}'>\n <td width='1' valign='top'><img style='padding-top:3px;' src='{$themeimg}/arrow.png' title='bullet' /></td>\n <td><b><a href='" . $annHit->url . "'>" . q($announce->title) . "</a></b> \n <small>(" . nice_format(claro_format_locale_date($dateFormatLong, strtotime($announce->date))) . ")\n </small><br />" . $announce->content . "</td></tr>"; $numLine++; } $tool_content .= "</table>"; $found = true; } } // search in agenda if ($agenda) {