global $DB;
$page = $DB->get_record('wiki_pages', array('id' => $id));
- $entry = $DB->get_record('wiki_entries', array('id' => $page->wiki));
+ $entry = $DB->get_record('wiki_entries', array('id' => $page->subwikiid));
$coursemodule = $DB->get_field('modules', 'id', array('name' => 'wiki'));
$cm = $DB->get_record('course_modules', array('course' => $entry->course, 'module' => $coursemodule, 'instance' => $entry->wikiid));
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
//returns the var names needed to build a sql query for addition/deletions
function wiki_db_names() {
//[primary id], [table name], [time created field name], [time modified field name], [docsubtype], [additional where conditions for sql]
- return array(array('id', 'wiki_pages', 'timecreated', 'lastmodified', 'standard'));
+ return array(array('id', 'wiki_pages', 'timecreated', 'timemodified', 'standard'));
}
/**
/// mark the time we last updated
set_config('search_indexer_run_date', time());
-
+
+ //mark last update times for mods to now.
+ if ($mods = search_collect_searchables(false, true)){
+ foreach($mods as $mod) {
+ $indexdatestring = 'search_indexer_update_date_'.$mod->name;
+ set_config($indexdatestring, time());
+ }
+ }
/// and the index size
set_config('search_index_size', (int)$index->count());
}
$dbcontrol = new IndexDBControl();
$update_count = 0;
- $indexdate = 0 + @$CFG->search_indexer_update_date;
- $startupdatedate = time();
+ $mainstartupdatedate = time();
/// indexing changed resources
if ($mods = search_collect_searchables(false, true)){
foreach ($mods as $mod) {
+ $indexdate = 0;
+ $indexdatestring = 'search_indexer_update_date_'.$mod->name;
+ $startupdatedate = time();
+ if (isset($CFG->$indexdatestring)) {
+ $indexdate = $CFG->$indexdatestring;
+ }
+
$class_file = $CFG->dirroot.'/search/documents/'.$mod->name.'_document.php';
$get_document_function = $mod->name.'_single_document';
$delete_function = $mod->name.'_delete';
$valuesArray = $db_names_function();
if ($valuesArray){
foreach($valuesArray as $values){
-
- $where = (!empty($values[5])) ? 'AND ('.$values[5].')' : '';
+ $where = (isset($values[5]) and $values[5]!='') ? 'AND ('.$values[5].')' : '';
$itemtypes = ($values[4] != '*' && $values[4] != 'any') ? " AND itemtype = '{$values[4]}' " : '' ;
//TODO: check 'in' syntax with other RDBMS' (add and update.php as well)
doctype = ?
$itemtypes
";
- $docIds = $DB->get_records_sql_menu($query, array($values[1]));
-
+ $docIds = $DB->get_records_sql_menu($query, array($mod->name));
if (!empty($docIds)){
list($usql, $params) = $DB->get_in_or_equal(array_keys($docIds));
$query = "
$updates[] = $delete_function($record->docid, $docIds[$record->docid]);
}
}
-
+
foreach ($updates as $update) {
++$update_count;
//delete old document
+ // change from default text only search to include numerals for this search.
+ Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive());
$doc = $index->find("+docid:{$update->id} +doctype:{$mod->name} +itemtype:{$update->itemtype}");
//get the record, should only be one
//object to insert into db
$dbid = $dbcontrol->addDocument($add);
-
+
//synchronise db with index
$add->addField(Zend_Search_Lucene_Field::Keyword('dbid', $dbid));
mtrace(" Add: $add->title (database id = $add->dbid, moodle instance id = $add->docid)");
else{
mtrace("No types to update.\n");
}
+ //commit changes
+ $index->commit();
+
+ //update index date
+ set_config($indexdatestring, $startupdatedate);
+
mtrace("Finished $mod->name.\n");
}
}
//commit changes
$index->commit();
-
+
//update index date
- set_config('search_indexer_update_date', $startupdatedate);
-
+ set_config('search_indexer_update_date', $mainstartupdatedate);
+
mtrace("Finished $update_count updates");
?>
\ No newline at end of file