/** * @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); }
foreach ($linkHits as $linkHit) { $link = Database::get()->querySingle("SELECT title, description FROM link WHERE id = ?d", $linkHit->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>"; $desc_text = empty($link->description) ? "" : "<span class='smaller'>" . $link->description . "</span>"; $tool_content .= "<a href='" . $urlServer . "modules/link/go.php?course=" . course_id_to_code($linkHit->courseid) . "&id={$linkHit->pkid}&url=" . urlencode($linkHit->url) . "' target=_blank> " . q($link->title) . "</a> {$desc_text} </td></tr>"; $numLine++; } $tool_content .= "</table>"; $found = true; } } // search in video and videolinks if ($video) { $videoHits = $idx->searchRaw(VideoIndexer::buildQuery($_POST)); $vlinkHits = $idx->searchRaw(VideolinkIndexer::buildQuery($_POST)); if (count($videoHits) > 0) { $tool_content .= "<script type='text/javascript' src='../auth/sorttable.js'></script>\n <table width='99%' class='sortable' id='t8' align='left'>\n <tr>\n <th colspan='2' class='left'>{$langVideo}:</th>\n </tr>"; $numLine = 0; foreach ($videoHits as $videoHit) { $video = Database::get()->querySingle("SELECT title, description FROM video WHERE id = ?d", $videoHit->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>"; $desc_text = empty($video->description) ? "" : "<span class='smaller'>(" . q($video->description) . ")</span>"; $tool_content .= "<a href='" . $videoHit->url . "' target=_blank>" . q($video->title) . "</a> {$desc_text} </td></tr>"; $numLine++; } $tool_content .= "</table>"; $found = true; } if (count($vlinkHits) > 0) {