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. 4
      main/inc/lib/search/DokeosQuery.php
  5. 23
      main/inc/lib/search/tool_processors/document_processor.class.php
  6. 35
      main/inc/lib/search/tool_processors/learnpath_processor.class.php
  7. 7
      main/inc/lib/search/tool_processors/link_processor.class.php
  8. 12
      main/inc/lib/search/tool_processors/quiz_processor.class.php
  9. 3
      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 // Breadcrumb
$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); $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')); $interbreadcrumb[] = array ('url' => 'specific_fields.php', 'name' => get_lang('SpecificSearchFields'));
$libpath = api_get_path(LIBRARY_PATH); $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); $table_uf_val = Database :: get_main_table(TABLE_MAIN_USER_FIELD_VALUES);
$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); $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')); $interbreadcrumb[] = array ('url' => 'specific_fields.php', 'name' => get_lang('SpecificSearchFields'));
if ($_GET['action']<>'edit') { if ($_GET['action']<>'edit') {
$tool_name = get_lang('AddSpecificSearchField'); $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) ) if ( (count(array_diff($terms, $stored_terms))==0) && (count(array_diff($stored_terms, $terms))==0) )
return FALSE; 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 // compare terms
$doc = $this->get_document($search_did); $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'; 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); $terms = get_specific_field_values_list_by_prefix($prefix, $course_code, $tool_id, $ref_id);
$prefix_terms = array(); $prefix_terms = array();
foreach($terms as $term) foreach($terms as $term) {
{
$prefix_terms[] = $term['value']; $prefix_terms[] = $term['value'];
} }
return $prefix_terms; return $prefix_terms;

@ -73,6 +73,4 @@ function dokeos_preprocess_results($results) {
*/ */
function dokeos_join_queries($query1, $query2=NULL, $op='or') { function dokeos_join_queries($query1, $query2=NULL, $op='or') {
return xapian_join_queries($query1, $query2, $op); 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) { private function get_information($course_id, $doc_id) {
$course_information = api_get_course_info($course_id); $course_information = api_get_course_info($course_id);
$course_id = $course_information['real_id'];
if (!empty($course_information)) { 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);
$doc_table = Database::get_course_table(TABLE_DOCUMENT, $course_information['db_name']); $doc_table = Database::get_course_table(TABLE_DOCUMENT);
$doc_id = Database::escape_string($doc_id); $doc_id = Database::escape_string($doc_id);
$sql = "SELECT * $sql = "SELECT * FROM $doc_table
FROM $doc_table WHERE $doc_table.id = $doc_id AND c_id = $course_id
WHERE $doc_table.id = $doc_id LIMIT 1";
LIMIT 1";
$dk_result = Database::query ($sql); $dk_result = Database::query ($sql);
$sql = "SELECT insert_user_id $sql = "SELECT insert_user_id FROM $item_property_table
FROM $item_property_table WHERE ref = $doc_id AND tool = '". TOOL_DOCUMENT ."' AND c_id = $course_id
WHERE ref = $doc_id LIMIT 1";
AND tool = '". TOOL_DOCUMENT ."'
LIMIT 1";
$name = ''; $name = '';
if ($row = Database::fetch_array ($dk_result)) { if ($row = Database::fetch_array ($dk_result)) {
$name = $row['title']; $name = $row['title'];
@ -108,4 +105,4 @@ class document_processor extends search_processor {
return array(); return array();
} }
} }
} }

@ -86,31 +86,36 @@ class learnpath_processor extends search_processor {
/** /**
* Get learning path information * Get learning path information
*/ */
private function get_information($course_id, $lp_id, $has_document_id=TRUE) { private function get_information($course_id, $lp_id, $has_document_id=TRUE) {
$course_information = api_get_course_info($course_id); $course_information = api_get_course_info($course_id);
$course_id = $course_information['real_id'];
if (!empty($course_information)) { if (!empty($course_information)) {
$lpi_table = Database::get_course_table(TABLE_LP_ITEM, $course_information['db_name']); $lpi_table = Database::get_course_table(TABLE_LP_ITEM);
$lp_table = Database::get_course_table_from_code(TABLE_LP_MAIN, $course_information['db_name']); $lp_table = Database::get_course_table_from_code(TABLE_LP_MAIN);
$doc_table = Database::get_course_table_from_code(TABLE_DOCUMENT, $course_information['db_name']); $doc_table = Database::get_course_table_from_code(TABLE_DOCUMENT);
$lp_id = Database::escape_string($lp_id); $lp_id = Database::escape_string($lp_id);
if ($has_document_id) { if ($has_document_id) {
$sql = "SELECT $lpi_table.id, $lp_table.name, $lp_table.author, $doc_table.path $sql = "SELECT $lpi_table.id, $lp_table.name, $lp_table.author, $doc_table.path
FROM $lp_table, $lpi_table FROM $lp_table, $lpi_table
INNER JOIN $doc_table ON $lpi_table.path = $doc_table.id INNER JOIN $doc_table ON $lpi_table.path = $doc_table.id AND $lpi_table.c_id = $course_id
WHERE $lpi_table.lp_id = $lp_id WHERE $lpi_table.c_id = $course_id AND
AND $lpi_table.display_order = 1 $doc_table.c_id = $course_id AND
AND $lp_table.id = $lpi_table.lp_id $lpi_table.lp_id = $lp_id AND
$lpi_table.display_order = 1 AND
$lp_table.id = $lpi_table.lp_id
LIMIT 1"; LIMIT 1";
} } else {
else {
$sql = "SELECT $lpi_table.id, $lp_table.name, $lp_table.author $sql = "SELECT $lpi_table.id, $lp_table.name, $lp_table.author
FROM $lp_table, $lpi_table FROM $lp_table, $lpi_table
WHERE $lpi_table.lp_id = $lp_id WHERE
AND $lpi_table.display_order = 1 $lpi_table.c_id = $course_id AND
AND $lp_table.id = $lpi_table.lp_id $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"; LIMIT 1";
} }
@ -138,4 +143,4 @@ class learnpath_processor extends search_processor {
return array(); return array();
} }
} }
} }

@ -96,12 +96,13 @@ class link_processor extends search_processor {
*/ */
private function get_information($course_id, $link_id) { private function get_information($course_id, $link_id) {
$course_information = api_get_course_info($course_id); $course_information = api_get_course_info($course_id);
$course_id = $course_information['real_id'];
if (!empty($course_information)) { 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); $link_id = Database::escape_string($link_id);
$sql = "SELECT insert_user_id FROM $item_property_table $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"; LIMIT 1";
$name = get_lang('Links'); $name = get_lang('Links');
@ -123,4 +124,4 @@ class link_processor extends search_processor {
return array(); return array();
} }
} }
} }

@ -106,16 +106,18 @@ class quiz_processor extends search_processor {
*/ */
private function get_information($course_id, $exercise_id) { private function get_information($course_id, $exercise_id) {
$course_information = api_get_course_info($course_id); $course_information = api_get_course_info($course_id);
$course_id = $course_information['real_id'];
if (!empty($course_information)) { if (!empty($course_information)) {
$exercise_table = Database::get_course_table(TABLE_QUIZ_TEST, $course_information['db_name']); $exercise_table = Database::get_course_table(TABLE_QUIZ_TEST);
$item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY, $course_information['db_name']); $item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
$exercise_id = intval($exercise_id); $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); $dk_result = Database::query($sql);
//actually author isn't saved on exercise tool, but prepare for when it's ready //actually author isn't saved on exercise tool, but prepare for when it's ready
$sql = "SELECT insert_user_id FROM $item_property_table $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"; LIMIT 1";
$name = ''; $name = '';
@ -137,4 +139,4 @@ class quiz_processor extends search_processor {
return array(); return array();
} }
} }
} }

@ -25,5 +25,4 @@ abstract class search_processor {
* Process the data sorted by the constructor * Process the data sorted by the constructor
*/ */
abstract protected function process(); abstract protected function process();
} }
?>

@ -12,7 +12,6 @@
/** /**
* Code * 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/search_widget.php';
require api_get_path(LIBRARY_PATH).'search/DokeosQuery.php'; require api_get_path(LIBRARY_PATH).'search/DokeosQuery.php';
require_once api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php'; require_once api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php';

Loading…
Cancel
Save