if (empty($CFG->enableglobalsearch)) { error(get_string('globalsearchdisabled', 'search')); } /* Obsolete with the MOODLE INTERNAL check if (!has_capability('moodle/site:doanything', get_context_instance(CONTEXT_SYSTEM))) { error(get_string('beadmin', 'search'), "$CFG->wwwroot/login/index.php"); } */ try { $index = new Zend_Search_Lucene(SEARCH_INDEX_PATH); } catch (LuceneException $e) { mtrace("Could not construct a valid index. Maybe the first indexation was never made, or files might be corrupted. Run complete indexation again."); return; } $dbcontrol = new IndexDBControl(); $update_count = 0; $indexdate = 0 + @$CFG->search_indexer_update_date; $startupdatedate = time(); /// indexing changed resources mtrace("Starting index update (updates)...\n"); if ($mods = get_records_select('modules')) { $mods = array_merge($mods, search_get_additional_modules()); foreach ($mods as $mod) { $class_file = $CFG->dirroot . '/search/documents/' . $mod->name . '_document.php'; $get_document_function = $mod->name . '_single_document'; $delete_function = $mod->name . '_delete'; $db_names_function = $mod->name . '_db_names'; $updates = array(); if (file_exists($class_file)) { require_once $class_file;
error(get_string('globalsearchdisabled', 'search')); } /* Obsolete with the MOODLE INTERNAL check if (!has_capability('moodle/site:doanything', get_context_instance(CONTEXT_SYSTEM))) { error(get_string('beadmin', 'search'), "$CFG->wwwroot/login/index.php"); } */ /// check for php5 (lib.php) try { $index = new Zend_Search_Lucene(SEARCH_INDEX_PATH); } catch (LuceneException $e) { mtrace("Could not construct a valid index. Maybe the first indexation was never made, or files might be corrupted. Run complete indexation again."); return; } $dbcontrol = new IndexDBControl(); $addition_count = 0; $startindextime = time(); $indexdate = $CFG->search_indexer_run_date; mtrace('Starting index update (additions)...'); mtrace('Index size before: ' . $CFG->search_index_size . "\n"); /// get all modules if ($mods = search_collect_searchables(false, true)) { /// append virtual modules onto array foreach ($mods as $mod) { //build include file and function names $class_file = $CFG->dirroot . '/search/documents/' . $mod->name . '_document.php'; $db_names_function = $mod->name . '_db_names'; $get_document_function = $mod->name . '_single_document'; $get_newrecords_function = $mod->name . '_new_records'; $additions = array();
if (empty($CFG->enableglobalsearch)) { print_error('globalsearchdisabled', 'search'); } /* Obsolete with the MOODLE INTERNAL check if (!has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) { print_error('beadmin', 'search', get_login_url()); } */ try { $index = new Zend_Search_Lucene(SEARCH_INDEX_PATH); } catch (LuceneException $e) { mtrace("Could not construct a valid index. Maybe the first indexation was never made, or files might be corrupted. Run complete indexation again."); return; } $dbcontrol = new IndexDBControl(); $deletion_count = 0; $startcleantime = time(); mtrace('Starting clean-up of removed records...'); mtrace('Index size before: ' . $CFG->search_index_size . "\n"); /// check all modules if ($mods = search_collect_searchables(false, true)) { foreach ($mods as $mod) { //build function names $class_file = $CFG->dirroot . '/search/documents/' . $mod->name . '_document.php'; $delete_function = $mod->name . '_delete'; $db_names_function = $mod->name . '_db_names'; $deletions = array(); if (file_exists($class_file)) { require_once $class_file; //if both required functions exist
/// check for php5 (lib.php) //php5 found, continue including php5-only files //require_once("$CFG->dirroot/search/Zend/Search/Lucene.php"); require_once $CFG->dirroot . '/search/indexlib.php'; mtrace('<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8" /></head><body>'); mtrace('<pre>Server Time: ' . date('r', time()) . "\n"); if (isset($CFG->search_indexer_busy) && $CFG->search_indexer_busy == '1') { //means indexing was not finished previously mtrace("Warning: Indexing was not successfully completed last time, restarting.\n"); } /// turn on busy flag set_config('search_indexer_busy', '1'); //paths $index_path = SEARCH_INDEX_PATH; $index_db_file = "{$CFG->dirroot}/search/db/{$CFG->dbtype}.sql"; $dbcontrol = new IndexDBControl(); /// setup directory in data root if (!file_exists($index_path)) { mtrace("Data directory ({$index_path}) does not exist, attempting to create."); if (!mkdir($index_path, $CFG->directorypermissions)) { search_pexit("Error creating data directory at: {$index_path}. Please correct."); } else { mtrace("Directory successfully created."); } } else { mtrace("Using {$index_path} as data directory."); } Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive()); $index = new Zend_Search_Lucene($index_path, true); /// New regeneration mtrace('Deleting old index entries.');