3 * Global Search Engine for Moodle
7 * @subpackage search_engine
8 * @author Michael Champanis (mchampan) [cynnical@gmail.com], Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
10 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
12 * This file serves as a splash-screen (entry page) to the indexer script -
13 * it is in place to prevent accidental reindexing which can lead to a loss
14 * of time, amongst other things.
18 * includes and requires
20 require_once('../config.php');
21 require_once($CFG->dirroot
.'/search/lib.php');
23 /// makes inclusions of the Zend Engine more reliable
25 ini_set('include_path', $CFG->dirroot
.DIRECTORY_SEPARATOR
.'search'.PATH_SEPARATOR
.ini_get('include_path'));
27 /// check global search is enabled
31 if (empty($CFG->enableglobalsearch
)) {
32 error(get_string('globalsearchdisabled', 'search'));
35 if (!has_capability('moodle/site:doanything', get_context_instance(CONTEXT_SYSTEM
))) {
36 error(get_string('beadmin', 'search'), $CFG->wwwroot
.'/login/index.php');
39 require_once($CFG->dirroot
.'/search/indexlib.php');
40 $indexinfo = new IndexInfo();
42 if ($indexinfo->valid()) {
43 $strsearch = get_string('search', 'search');
44 $strquery = get_string('stats');
46 $navlinks[] = array('name' => $strsearch, 'link' => "index.php", 'type' => 'misc');
47 $navlinks[] = array('name' => $strquery, 'link' => "stats.php", 'type' => 'misc');
48 $navlinks[] = array('name' => get_string('runindexer','search'), 'link' => null, 'type' => 'misc');
49 // if ($CFG->version <= 2007021541){ // 1.8 branch stable timestamp NOT RELIABLE
50 if (!function_exists('build_navigation')){ // 1.8 branch stable timestamp
53 $navigation = build_navigation($navlinks);
56 print_header("$strsearch", "$site->fullname" , $navigation, "", "", true, " ", navmenu($site));
58 mtrace("<pre>The data directory ($indexinfo->path) contains $indexinfo->filecount files, and\n"
59 ."there are ".$indexinfo->dbcount
." records in the <em>block_search_documents</em> table.\n"
61 ."This indicates that you have already succesfully indexed this site. Follow the link\n"
62 ."if you are sure that you want to continue indexing - this will replace any existing\n"
63 ."index data (no Moodle data is affected).\n"
65 ."You are encouraged to use the 'Test indexing' script before continuing onto\n"
66 ."indexing - this will check if the modules are set up correctly. Please correct\n"
67 ."any errors before proceeding.\n"
69 ."<a href='tests/index.php'>Test indexing</a> or "
70 ."<a href='indexer.php?areyousure=yes'>Continue indexing</a> or <a href='index.php'>Back to query page</a>."
75 header('Location: indexer.php?areyousure=yes');