Fixing the search xapian plugin due the recent changes in the DB see #3910

skala
Julio Montoya 14 years ago
parent 5e77766709
commit 1a8f10cdff
  1. 2
      main/admin/specific_fields.php
  2. 2
      main/admin/specific_fields_add.php
  3. 5
      main/inc/lib/search/DokeosIndexer.class.php
  4. 2
      main/inc/lib/search/DokeosQuery.php
  5. 21
      main/inc/lib/search/tool_processors/document_processor.class.php
  6. 31
      main/inc/lib/search/tool_processors/learnpath_processor.class.php
  7. 5
      main/inc/lib/search/tool_processors/link_processor.class.php
  8. 10
      main/inc/lib/search/tool_processors/quiz_processor.class.php
  9. 1
      main/inc/lib/search/tool_processors/search_processor.class.php
  10. 1
      main/newscorm/lp_list_search.php

@ -17,7 +17,7 @@ api_protect_admin_script();
// Breadcrumb
$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array ('url' => 'settings.php?category=Search', 'name' => get_lang('DokeosConfigSettings'));
$interbreadcrumb[] = array ('url' => 'settings.php?category=Search', 'name' => get_lang('PlatformConfigSettings'));
$interbreadcrumb[] = array ('url' => 'specific_fields.php', 'name' => get_lang('SpecificSearchFields'));
$libpath = api_get_path(LIBRARY_PATH);

@ -29,7 +29,7 @@ $table_uf_opt = Database :: get_main_table(TABLE_MAIN_USER_FIELD_OPTIONS);
$table_uf_val = Database :: get_main_table(TABLE_MAIN_USER_FIELD_VALUES);
$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array ('url' => 'settings.php?category=Search', 'name' => get_lang('DokeosConfigSettings'));
$interbreadcrumb[] = array ('url' => 'settings.php?category=Search', 'name' => get_lang('PlatformConfigSettings'));
$interbreadcrumb[] = array ('url' => 'specific_fields.php', 'name' => get_lang('SpecificSearchFields'));
if ($_GET['action']<>'edit') {
$tool_name = get_lang('AddSpecificSearchField');

@ -38,7 +38,7 @@ class DokeosIndexer extends XapianIndexer {
if ( (count(array_diff($terms, $stored_terms))==0) && (count(array_diff($stored_terms, $terms))==0) )
return FALSE;
require_once(api_get_path(LIBRARY_PATH).'search/xapian/XapianQuery.php');
require_once api_get_path(LIBRARY_PATH).'search/xapian/XapianQuery.php';
// compare terms
$doc = $this->get_document($search_did);
@ -77,8 +77,7 @@ class DokeosIndexer extends XapianIndexer {
require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
$terms = get_specific_field_values_list_by_prefix($prefix, $course_code, $tool_id, $ref_id);
$prefix_terms = array();
foreach($terms as $term)
{
foreach($terms as $term) {
$prefix_terms[] = $term['value'];
}
return $prefix_terms;

@ -74,5 +74,3 @@ function dokeos_preprocess_results($results) {
function dokeos_join_queries($query1, $query2=NULL, $op='or') {
return xapian_join_queries($query1, $query2, $op);
}
?>

@ -67,23 +67,20 @@ class document_processor extends search_processor {
*/
private function get_information($course_id, $doc_id) {
$course_information = api_get_course_info($course_id);
$course_id = $course_information['real_id'];
if (!empty($course_information)) {
$item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY, $course_information['db_name']);
$doc_table = Database::get_course_table(TABLE_DOCUMENT, $course_information['db_name']);
$item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
$doc_table = Database::get_course_table(TABLE_DOCUMENT);
$doc_id = Database::escape_string($doc_id);
$sql = "SELECT *
FROM $doc_table
WHERE $doc_table.id = $doc_id
LIMIT 1";
$sql = "SELECT * FROM $doc_table
WHERE $doc_table.id = $doc_id AND c_id = $course_id
LIMIT 1";
$dk_result = Database::query ($sql);
$sql = "SELECT insert_user_id
FROM $item_property_table
WHERE ref = $doc_id
AND tool = '". TOOL_DOCUMENT ."'
LIMIT 1";
$sql = "SELECT insert_user_id FROM $item_property_table
WHERE ref = $doc_id AND tool = '". TOOL_DOCUMENT ."' AND c_id = $course_id
LIMIT 1";
$name = '';
if ($row = Database::fetch_array ($dk_result)) {
$name = $row['title'];

@ -87,30 +87,35 @@ class learnpath_processor extends search_processor {
* Get learning path information
*/
private function get_information($course_id, $lp_id, $has_document_id=TRUE) {
$course_information = api_get_course_info($course_id);
$course_id = $course_information['real_id'];
if (!empty($course_information)) {
$lpi_table = Database::get_course_table(TABLE_LP_ITEM, $course_information['db_name']);
$lp_table = Database::get_course_table_from_code(TABLE_LP_MAIN, $course_information['db_name']);
$doc_table = Database::get_course_table_from_code(TABLE_DOCUMENT, $course_information['db_name']);
$lpi_table = Database::get_course_table(TABLE_LP_ITEM);
$lp_table = Database::get_course_table_from_code(TABLE_LP_MAIN);
$doc_table = Database::get_course_table_from_code(TABLE_DOCUMENT);
$lp_id = Database::escape_string($lp_id);
if ($has_document_id) {
$sql = "SELECT $lpi_table.id, $lp_table.name, $lp_table.author, $doc_table.path
FROM $lp_table, $lpi_table
INNER JOIN $doc_table ON $lpi_table.path = $doc_table.id
WHERE $lpi_table.lp_id = $lp_id
AND $lpi_table.display_order = 1
AND $lp_table.id = $lpi_table.lp_id
INNER JOIN $doc_table ON $lpi_table.path = $doc_table.id AND $lpi_table.c_id = $course_id
WHERE $lpi_table.c_id = $course_id AND
$doc_table.c_id = $course_id AND
$lpi_table.lp_id = $lp_id AND
$lpi_table.display_order = 1 AND
$lp_table.id = $lpi_table.lp_id
LIMIT 1";
}
else {
} else {
$sql = "SELECT $lpi_table.id, $lp_table.name, $lp_table.author
FROM $lp_table, $lpi_table
WHERE $lpi_table.lp_id = $lp_id
AND $lpi_table.display_order = 1
AND $lp_table.id = $lpi_table.lp_id
WHERE
$lpi_table.c_id = $course_id AND
$lp_table.c_id = $course_id AND
$lpi_table.lp_id = $lp_id AND
$lpi_table.display_order = 1 AND
$lp_table.id = $lpi_table.lp_id
LIMIT 1";
}

@ -96,12 +96,13 @@ class link_processor extends search_processor {
*/
private function get_information($course_id, $link_id) {
$course_information = api_get_course_info($course_id);
$course_id = $course_information['real_id'];
if (!empty($course_information)) {
$item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY, $course_information['db_name']);
$item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
$link_id = Database::escape_string($link_id);
$sql = "SELECT insert_user_id FROM $item_property_table
WHERE ref = $link_id AND tool = '". TOOL_LINK ."'
WHERE ref = $link_id AND tool = '". TOOL_LINK ."' AND c_id = $course_id
LIMIT 1";
$name = get_lang('Links');

@ -106,16 +106,18 @@ class quiz_processor extends search_processor {
*/
private function get_information($course_id, $exercise_id) {
$course_information = api_get_course_info($course_id);
$course_id = $course_information['real_id'];
if (!empty($course_information)) {
$exercise_table = Database::get_course_table(TABLE_QUIZ_TEST, $course_information['db_name']);
$item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY, $course_information['db_name']);
$exercise_table = Database::get_course_table(TABLE_QUIZ_TEST);
$item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
$exercise_id = intval($exercise_id);
$sql = "SELECT * FROM $exercise_table WHERE id = $exercise_id LIMIT 1";
$sql = "SELECT * FROM $exercise_table WHERE id = $exercise_id AND c_id = $course_id LIMIT 1";
$dk_result = Database::query($sql);
//actually author isn't saved on exercise tool, but prepare for when it's ready
$sql = "SELECT insert_user_id FROM $item_property_table
WHERE ref = $doc_id AND tool = '". TOOL_DOCUMENT ."'
WHERE ref = $doc_id AND tool = '". TOOL_DOCUMENT ."' AND c_id = $course_id
LIMIT 1";
$name = '';

@ -26,4 +26,3 @@ abstract class search_processor {
*/
abstract protected function process();
}
?>

@ -12,7 +12,6 @@
/**
* Code
*/
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
require api_get_path(LIBRARY_PATH).'search/search_widget.php';
require api_get_path(LIBRARY_PATH).'search/DokeosQuery.php';
require_once api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php';

Loading…
Cancel
Save