mirror of
https://github.com/moodle/moodle.git
synced 2025-08-07 01:46:45 +02:00
MDL-14978 removed obsoleted isadmin()
This commit is contained in:
parent
72f563b91c
commit
e3c7f155d8
23 changed files with 432 additions and 263 deletions
|
@ -1,99 +1,147 @@
|
|||
<?php
|
||||
|
||||
/* Used to test if modules/blocks are ready to included in the search index.
|
||||
* Carries out some basic function/file existence tests - the search module
|
||||
* is expected to exist, along with the db schema files and the search data
|
||||
* directory.
|
||||
* */
|
||||
/* Used to test if modules/blocks are ready to included in the search index.
|
||||
* Carries out some basic function/file existence tests - the search module
|
||||
* is expected to exist, along with the db schema files and the search data
|
||||
* directory.
|
||||
**/
|
||||
|
||||
@set_time_limit(0);
|
||||
@ob_implicit_flush(true);
|
||||
@ob_end_flush();
|
||||
@set_time_limit(0);
|
||||
@ob_implicit_flush(true);
|
||||
@ob_end_flush();
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once("$CFG->dirroot/search/lib.php");
|
||||
require_once('../../config.php');
|
||||
require_once("$CFG->dirroot/search/lib.php");
|
||||
|
||||
require_login();
|
||||
|
||||
$strsearch = get_string('search', 'search');
|
||||
$strquery = get_string('stats');
|
||||
/// makes inclusions of the Zend Engine more reliable
|
||||
$separator = (array_key_exists('WINDIR', $_SERVER)) ? ';' : ':' ;
|
||||
ini_set('include_path', $CFG->dirroot.'\search'.$separator.ini_get('include_path'));
|
||||
|
||||
require_login();
|
||||
|
||||
$navlinks[] = array('name' => $strsearch, 'link' => "../index.php", 'type' => 'misc');
|
||||
$navlinks[] = array('name' => $strquery, 'link' => "../stats.php", 'type' => 'misc');
|
||||
$navlinks[] = array('name' => get_string('runindexertest','search'), 'link' => null, 'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
$site = get_site();
|
||||
print_header("$strsearch", "$site->fullname" , $navigation, "", "", true, " ", navmenu($site));
|
||||
|
||||
if (empty($CFG->enableglobalsearch)) {
|
||||
print_error('Global searching is not enabled.');
|
||||
}
|
||||
if (empty($CFG->enableglobalsearch)) {
|
||||
error('Global searching is not enabled.');
|
||||
}
|
||||
|
||||
if (!has_capability('moodle/site:doanything', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
|
||||
} //if
|
||||
|
||||
mtrace('<pre>Server Time: '.date('r',time()));
|
||||
mtrace("Testing global search capabilities:\n");
|
||||
|
||||
$phpversion = phpversion();
|
||||
|
||||
if (!search_check_php5()) {
|
||||
mtrace("ERROR: PHP 5.0.0 or later required (currently using version $phpversion).");
|
||||
exit(0);
|
||||
} else {
|
||||
mtrace("Success: PHP 5.0.0 or later is installed ($phpversion).\n");
|
||||
} //else
|
||||
|
||||
//fix paths for testing
|
||||
set_include_path(get_include_path().":../");
|
||||
require_once("$CFG->dirroot/search/Zend/Search/Lucene.php");
|
||||
|
||||
mtrace("Checking activity modules:\n");
|
||||
|
||||
//the presence of the required search functions -
|
||||
// * mod_iterator
|
||||
// * mod_get_content_for_index
|
||||
//are the sole basis for including a module in the index at the moment.
|
||||
|
||||
/// get all installed modules
|
||||
if ($mods = get_records('modules', '', '', 'name', 'id,name')){
|
||||
|
||||
if (!isadmin()) {
|
||||
print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
|
||||
} //if
|
||||
$searchabletypes = array_values(search_get_document_types());
|
||||
|
||||
mtrace('<pre>Server Time: '.date('r',time()));
|
||||
mtrace("Testing global search capabilities:\n");
|
||||
|
||||
$phpversion = phpversion();
|
||||
|
||||
//fix paths for testing
|
||||
set_include_path(get_include_path().":../");
|
||||
require_once("$CFG->dirroot/search/Zend/Search/Lucene.php");
|
||||
|
||||
mtrace("Checking activity modules:\n");
|
||||
|
||||
//the presence of the required search functions -
|
||||
// * mod_iterator
|
||||
// * mod_get_content_for_index
|
||||
//are the sole basis for including a module in the index at the moment.
|
||||
|
||||
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';
|
||||
foreach($mods as $mod){
|
||||
if (in_array($mod->name, $searchabletypes)){
|
||||
$mod->location = 'internal';
|
||||
$searchables[] = $mod;
|
||||
} else {
|
||||
$documentfile = $CFG->dirroot."/mod/{$mod->name}/search_document.php";
|
||||
$mod->location = 'mod';
|
||||
if (file_exists($documentfile)){
|
||||
$searchables[] = $mod;
|
||||
}
|
||||
}
|
||||
}
|
||||
mtrace(count($searchables).' modules to search in / '.count($mods).' modules found.');
|
||||
}
|
||||
|
||||
/// collects blocks as indexable information may be found in blocks either
|
||||
if ($blocks = get_records('block', '', '', 'name', 'id,name')) {
|
||||
$blocks_searchables = array();
|
||||
// prepend the "block_" prefix to discriminate document type plugins
|
||||
foreach($blocks as $block){
|
||||
$block->dirname = $block->name;
|
||||
$block->name = 'block_'.$block->name;
|
||||
if (in_array('SEARCH_TYPE_'.strtoupper($block->name), $searchabletypes)){
|
||||
$mod->location = 'internal';
|
||||
$blocks_searchables[] = $block;
|
||||
} else {
|
||||
$documentfile = $CFG->dirroot."/blocks/{$block->dirname}/search_document.php";
|
||||
if (file_exists($documentfile)){
|
||||
$mod->location = 'blocks';
|
||||
$blocks_searchables[] = $block;
|
||||
}
|
||||
}
|
||||
}
|
||||
mtrace(count($blocks_searchables).' blocks to search in / '.count($blocks).' blocks found.');
|
||||
$searchables = array_merge($searchables, $blocks_searchables);
|
||||
}
|
||||
|
||||
/// add virtual modules onto the back of the array
|
||||
|
||||
$additional = search_get_additional_modules();
|
||||
mtrace(count($additional).' additional to search in.');
|
||||
$searchables = array_merge($searchables, $additional);
|
||||
|
||||
foreach ($searchables as $mod) {
|
||||
if ($mod->location == 'internal'){
|
||||
$class_file = $CFG->dirroot.'/search/documents/'.$mod->name.'_document.php';
|
||||
} else {
|
||||
$class_file = $CFG->dirroot.'/'.$mod->location.'/'.$mod->name.'/search_document.php';
|
||||
}
|
||||
|
||||
if (file_exists($class_file)) {
|
||||
include_once($class_file);
|
||||
|
||||
|
||||
if (!defined('SEARCH_TYPE_'.strtoupper($mod->name))) {
|
||||
mtrace("ERROR: Constant 'SEARCH_TYPE_".strtoupper($mod->name)."' is not defined in /search/lib.php");
|
||||
mtrace("ERROR: Constant 'SEARCH_TYPE_".strtoupper($mod->name)."' is not defined in search/searchtypes.php or in module");
|
||||
continue;
|
||||
} //if
|
||||
|
||||
}
|
||||
|
||||
$iter_function = $mod->name.'_iterator';
|
||||
$index_function = $mod->name.'_get_content_for_index';
|
||||
|
||||
|
||||
if (function_exists($index_function) && function_exists($iter_function)) {
|
||||
if (is_array($iter_function())) {
|
||||
$documents = $index_function(array_pop($iter_function()));
|
||||
|
||||
|
||||
if (is_array($documents)) {
|
||||
mtrace("Success: '$mod->name' module seems to be ready for indexing.");
|
||||
} else {
|
||||
mtrace("ERROR: $index_function() doesn't seem to be returning an array.");
|
||||
} //else
|
||||
}
|
||||
} else {
|
||||
mtrace("ERROR: $iter_function() doesn't seem to be returning an object array.");
|
||||
} //else
|
||||
}
|
||||
} else {
|
||||
mtrace("ERROR: $iter_function() and/or $index_function() does not exist in $class_file");
|
||||
} //else
|
||||
}
|
||||
} else {
|
||||
mtrace("Notice: $class_file does not exist, this module will not be indexed.");
|
||||
} //else
|
||||
} //foreach
|
||||
} //if
|
||||
|
||||
//finished modules
|
||||
mtrace("\nFinished checking activity modules.");
|
||||
|
||||
//now blocks...
|
||||
//
|
||||
|
||||
mtrace("<br/><a href='../index.php'>Back to query page</a> or <a href='../indexersplash.php'>Start indexing</a>.");
|
||||
mtrace('</pre>');
|
||||
print_footer();
|
||||
?>
|
||||
}
|
||||
}
|
||||
|
||||
//finished modules
|
||||
mtrace("\nFinished checking activity modules.");
|
||||
|
||||
//now blocks...
|
||||
//
|
||||
|
||||
mtrace("<br/><a href='../index.php'>Back to query page</a> or <a href='../indexersplash.php'>Start indexing</a>.");
|
||||
mtrace('</pre>');
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue