/** * @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 ($vlinkHits as $vlinkHit) { $vlink = Database::get()->querySingle("SELECT title, description FROM videolink WHERE id = ?d", $vlinkHit->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($vlink->description) ? "" : "<span class='smaller'>(" . q($vlink->description) . ")</span>"; $tool_content .= "<a href='" . $vlinkHit->url . "' target=_blank>" . q($vlink->title) . "</a><br /> {$desc_text} </td></tr>"; $numLine++; } $tool_content .= "</table>"; $found = true; } } // search in cours_units and unit_resources if ($course_units) { $unitHits = $idx->searchRaw(UnitIndexer::buildQuery($_POST)); $uresHits = $idx->searchRaw(UnitResourceIndexer::buildQuery($_POST)); if (count($unitHits) > 0) { $tool_content .= "<script type='text/javascript' src='../auth/sorttable.js'></script>\n <table width='99%' class='sortable' id='t11' align='left'>\n <tr>\n <th colspan='2' class='left'>{$langCourseUnits}:</th>\n </tr>"; $numLine = 0; foreach ($unitHits as $unitHit) { $unit = Database::get()->querySingle("SELECT title, comments FROM course_units WHERE id = ?d", $unitHit->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>"; $comments_text = empty($unit->comments) ? "" : " " . $unit->comments; $tool_content .= "<a href='" . $unitHit->url . "'>" . q($unit->title) . "</a> {$comments_text} </td></tr>"; $numLine++; } $tool_content .= "</table>"; $found = true; } if (count($uresHits) > 0) {