Merge branch 'MDL-53222_master' of git://github.com/dmonllao/moodle

This commit is contained in:
Dan Poltawski 2016-07-11 11:42:41 +01:00
commit e2f79e330d
21 changed files with 252 additions and 344 deletions

180
admin/searchareas.php Normal file
View File

@ -0,0 +1,180 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Manage global search areas.
*
* @package core_search
* @copyright 2016 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(__DIR__ . '/../config.php');
require_once($CFG->libdir . '/adminlib.php');
admin_externalpage_setup('searchareas');
$areaid = optional_param('areaid', null, PARAM_ALPHAEXT);
$action = optional_param('action', null, PARAM_ALPHA);
try {
$searchmanager = \core_search\manager::instance();
} catch (core_search\engine_exception $searchmanagererror) {
// Continue, we return an error later depending on the requested action.
}
echo $OUTPUT->header();
if ($action) {
require_sesskey();
if ($areaid) {
// We need to check that the area exists.
$area = \core_search\manager::get_search_area($areaid);
if ($area === false) {
throw new moodle_exception('invalidrequest');
}
}
// All actions but enable/disable need the search engine to be ready.
if ($action !== 'enable' && $action !== 'disable') {
if (!empty($searchmanagererror)) {
throw $searchmanagererror;
}
}
switch ($action) {
case 'enable':
$area->set_enabled(true);
echo $OUTPUT->notification(get_string('searchareaenabled', 'admin'), \core\output\notification::NOTIFY_SUCCESS);
break;
case 'disable':
$area->set_enabled(false);
echo $OUTPUT->notification(get_string('searchareadisabled', 'admin'), \core\output\notification::NOTIFY_SUCCESS);
break;
case 'delete':
$search = \core_search\manager::instance();
$search->delete_index($areaid);
echo $OUTPUT->notification(get_string('searchindexdeleted', 'admin'), \core\output\notification::NOTIFY_SUCCESS);
break;
case 'indexall':
$searchmanager->index();
echo $OUTPUT->notification(get_string('searchindexupdated', 'admin'), \core\output\notification::NOTIFY_SUCCESS);
break;
case 'reindexall':
$searchmanager->index(true);
echo $OUTPUT->notification(get_string('searchreindexed', 'admin'), \core\output\notification::NOTIFY_SUCCESS);
break;
case 'deleteall':
$searchmanager->delete_index();
echo $OUTPUT->notification(get_string('searchalldeleted', 'admin'), \core\output\notification::NOTIFY_SUCCESS);
break;
default:
throw new moodle_exception('invalidaction');
break;
}
}
$searchareas = \core_search\manager::get_search_areas_list();
if (empty($searchmanagererror)) {
$areasconfig = $searchmanager->get_areas_config($searchareas);
} else {
$areasconfig = false;
}
if (!empty($searchmanagererror)) {
$errorstr = get_string($searchmanagererror->errorcode, $searchmanagererror->module);
echo $OUTPUT->notification($errorstr, \core\output\notification::NOTIFY_ERROR);
} else {
echo $OUTPUT->notification(get_string('indexinginfo', 'admin'), \core\output\notification::NOTIFY_INFO);
}
$table = new html_table();
$table->id = 'core-search-areas';
$table->head = array(get_string('searcharea', 'search'), get_string('enable'), get_string('newestdocindexed', 'admin'),
get_string('searchlastrun', 'admin'), get_string('searchindexactions', 'admin'));
foreach ($searchareas as $area) {
$areaid = $area->get_area_id();
$columns = array(new html_table_cell($area->get_visible_name()));
if ($area->is_enabled()) {
$columns[] = $OUTPUT->action_icon(admin_searcharea_action_url('disable', $areaid),
new pix_icon('t/hide', get_string('disable'), 'moodle', array('title' => '', 'class' => 'iconsmall')),
null, array('title' => get_string('disable')));
if ($areasconfig) {
$columns[] = $areasconfig[$areaid]->lastindexrun;
if ($areasconfig[$areaid]->indexingstart) {
$timediff = $areasconfig[$areaid]->indexingend - $areasconfig[$areaid]->indexingstart;
$laststatus = $timediff . ' , ' .
$areasconfig[$areaid]->docsprocessed . ' , ' .
$areasconfig[$areaid]->recordsprocessed . ' , ' .
$areasconfig[$areaid]->docsignored;
} else {
$laststatus = '';
}
$columns[] = $laststatus;
$columns[] = html_writer::link(admin_searcharea_action_url('delete', $areaid), 'Delete index');
} else {
$blankrow = new html_table_cell(get_string('searchnotavailable', 'admin'));
$blankrow->colspan = 3;
$columns[] = $blankrow;
}
} else {
$columns[] = $OUTPUT->action_icon(admin_searcharea_action_url('enable', $areaid),
new pix_icon('t/show', get_string('enable'), 'moodle', array('title' => '', 'class' => 'iconsmall')),
null, array('title' => get_string('enable')));
$blankrow = new html_table_cell(get_string('searchareadisabled', 'admin'));
$blankrow->colspan = 3;
$columns[] = $blankrow;
}
$row = new html_table_row($columns);
$table->data[] = $row;
}
// Cross-search area tasks.
$options = array();
if (!empty($searchmanagererror)) {
$options['disabled'] = true;
}
echo $OUTPUT->box_start('search-areas-actions');
echo $OUTPUT->single_button(admin_searcharea_action_url('indexall'), get_string('searchupdateindex', 'admin'), 'get', $options);
echo $OUTPUT->single_button(admin_searcharea_action_url('reindexall'), get_string('searchreindexindex', 'admin'), 'get', $options);
echo $OUTPUT->single_button(admin_searcharea_action_url('deleteall'), get_string('searchdeleteindex', 'admin'), 'get', $options);
echo $OUTPUT->box_end();
echo html_writer::table($table);
echo $OUTPUT->footer();
/**
* Helper for generating url for management actions.
*
* @param string $action
* @param string $areaid
* @return moodle_url
*/
function admin_searcharea_action_url($action, $areaid = false) {
$params = array('action' => $action, 'sesskey' => sesskey());
if ($areaid) {
$params['areaid'] = $areaid;
}
return new moodle_url('/admin/searchareas.php', $params);
}

View File

@ -528,15 +528,9 @@ if ($hassiteconfig) {
$temp->add(new admin_setting_configselect('searchengine',
new lang_string('selectsearchengine', 'admin'), '', 'solr', $engines));
// Enable search areas.
$temp->add(new admin_setting_heading('searchareasheading', new lang_string('availablesearchareas', 'admin'), ''));
$searchareas = \core_search\manager::get_search_areas_list();
foreach ($searchareas as $areaid => $searcharea) {
list($componentname, $varname) = $searcharea->get_config_var_name();
$temp->add(new admin_setting_configcheckbox($componentname . '/' . $varname . '_enabled', $searcharea->get_visible_name(true),
'', 1, 1, 0));
}
$ADMIN->add('searchplugins', $temp);
$ADMIN->add('searchplugins', new admin_externalpage('searchareas', new lang_string('searchareas', 'admin'),
new moodle_url('/admin/searchareas.php')));
core_collator::asort_objects_by_property($pages, 'visiblename');
foreach ($pages as $page) {

View File

@ -65,7 +65,7 @@ $string['authpreventaccountcreation_help'] = 'When a user authenticates, an acco
$string['authsettings'] = 'Manage authentication';
$string['autolang'] = 'Language autodetect';
$string['autologinguests'] = 'Auto-login guests';
$string['availablesearchareas'] = 'Available areas for search';
$string['searchareas'] = 'Search areas';
$string['availableto'] = 'Available to';
$string['availablelicenses'] = 'Available licences';
$string['backgroundcolour'] = 'Transparent colour';
@ -586,6 +586,7 @@ $string['ignore'] = 'Ignore';
$string['includemoduleuserdata'] = 'Include module user data';
$string['incompatibleblocks'] = 'Incompatible blocks';
$string['indexdata'] = 'Index data';
$string['indexinginfo'] = 'The recommended way to index your site\'s contents is using "Global search indexing" scheduled task which runs automatically by Cron.';
$string['installhijacked'] = 'Installation must be finished from the original IP address, sorry.';
$string['installsessionerror'] = 'Can not initialise PHP session, please verify that your browser accepts cookies.';
$string['intlrecommended'] = 'Intl extension is used to improve internationalization support, such as locale aware sorting.';
@ -750,6 +751,7 @@ $string['navshowmycoursecategories_help'] = 'If enabled courses in the users my
$string['navsortmycoursessort'] = 'Sort my courses';
$string['navsortmycoursessort_help'] = 'This determines whether courses are listed under My courses according to the sort order (i.e. the order set in Site administration > Courses > Manage courses and categories) or alphabetically by course setting.';
$string['neverdeleteruns'] = 'Never delete runs';
$string['newestdocindexed'] = 'Newest document indexed';
$string['nobookmarksforuser'] = 'You do not have any bookmarks.';
$string['nodatabase'] = 'No database';
$string['nohttpsformobilewarning'] = 'It is recommended to enable HTTPS with a valid certificate. The Moodle app will always try to use a secured connection first.';
@ -937,10 +939,22 @@ $string['rssglobaldisabled'] = 'Disabled at server level';
$string['save'] = 'Save';
$string['savechanges'] = 'Save changes';
$string['search'] = 'Search';
$string['searchalldeleted'] = 'All indexed contents have been deleted';
$string['searchareaenabled'] = 'Search area enabled';
$string['searchareadisabled'] = 'Search area disabled';
$string['searchdeleteindex'] = 'Delete all indexed contents';
$string['searchengine'] = 'Search engine';
$string['searchindexactions'] = 'Index actions';
$string['searchindexdeleted'] = 'Index deleted';
$string['searchindexupdated'] = 'Search engine contents have been updated';
$string['searchinsettings'] = 'Search in settings';
$string['searchlastrun'] = 'Last run (time, # docs, # records, # ignores)';
$string['searchnotavailable'] = 'Search is not available';
$string['searchreindexed'] = 'All site\'s contents have been reindexed';
$string['searchreindexindex'] = 'Reindex all site contents';
$string['searchresults'] = 'Search results';
$string['searchsetupinfo'] = 'Search setup';
$string['searchupdateindex'] = 'Update indexed contents';
$string['sectionerror'] = 'Section error!';
$string['secureforms'] = 'Use additional form security';
$string['security'] = 'Security';

View File

@ -9715,7 +9715,7 @@ class admin_setting_searchsetupinfo extends admin_setting {
// Available areas.
$row = array();
$url = new moodle_url('/admin/settings.php?section=manageglobalsearch#admin-searchengine');
$url = new moodle_url('/admin/searchareas.php');
$row[0] = '2. ' . html_writer::tag('a', get_string('enablesearchareas', 'admin'),
array('href' => $url));
@ -9750,7 +9750,7 @@ class admin_setting_searchsetupinfo extends admin_setting {
// Indexed data.
$row = array();
$url = new moodle_url('/report/search/index.php#searchindexform');
$url = new moodle_url('/admin/searchareas.php');
$row[0] = '4. ' . html_writer::tag('a', get_string('indexdata', 'admin'), array('href' => $url));
if ($anyindexed) {
$status = html_writer::tag('span', get_string('yes'), array('class' => 'statusok'));

View File

@ -1660,6 +1660,7 @@ class core_plugin_manager {
$plugins = array(
'qformat' => array('blackboard', 'learnwise'),
'enrol' => array('authorize'),
'report' => array('search'),
'tinymce' => array('dragmath'),
'tool' => array('bloglevelupgrade', 'qeupgradehelper', 'timezoneimport'),
'theme' => array('mymobile', 'afterburner', 'anomaly', 'arialist', 'binarius', 'boxxie', 'brick', 'formal_white',
@ -1870,7 +1871,7 @@ class core_plugin_manager {
'report' => array(
'backups', 'competency', 'completion', 'configlog', 'courseoverview', 'eventlist',
'log', 'loglive', 'outline', 'participation', 'progress', 'questioninstances', 'search',
'log', 'loglive', 'outline', 'participation', 'progress', 'questioninstances',
'security', 'stats', 'performance', 'usersessions'
),

View File

@ -2072,5 +2072,16 @@ function xmldb_main_upgrade($oldversion) {
// Moodle v3.1.0 release upgrade line.
// Put any upgrade step following this.
if ($oldversion < 2016070700.01) {
// If someone is emotionally attached to it let's leave the config (basically the version) there.
if (!file_exists($CFG->dirroot . '/report/search/classes/output/form.php')) {
unset_all_config_for_plugin('report_search');
}
// Savepoint reached.
upgrade_main_savepoint(true, 2016070700.01);
}
return true;
}

View File

@ -66,10 +66,10 @@ class mod_book_search_testcase extends advanced_testcase {
// Enabled by default once global search is enabled.
$this->assertTrue($searcharea->is_enabled());
set_config($varname . '_enabled', false, $componentname);
set_config($varname . '_enabled', 0, $componentname);
$this->assertFalse($searcharea->is_enabled());
set_config($varname . '_enabled', true, $componentname);
set_config($varname . '_enabled', 1, $componentname);
$this->assertTrue($searcharea->is_enabled());
}

View File

@ -68,10 +68,10 @@ class mod_forum_search_testcase extends advanced_testcase {
// Enabled by default once global search is enabled.
$this->assertTrue($searcharea->is_enabled());
set_config($varname . '_enabled', false, $componentname);
set_config($varname . '_enabled', 0, $componentname);
$this->assertFalse($searcharea->is_enabled());
set_config($varname . '_enabled', true, $componentname);
set_config($varname . '_enabled', 1, $componentname);
$this->assertTrue($searcharea->is_enabled());
}

View File

@ -67,10 +67,10 @@ class mod_glossary_search_testcase extends advanced_testcase {
// Enabled by default once global search is enabled.
$this->assertTrue($searcharea->is_enabled());
set_config($varname . '_enabled', false, $componentname);
set_config($varname . '_enabled', 0, $componentname);
$this->assertFalse($searcharea->is_enabled());
set_config($varname . '_enabled', true, $componentname);
set_config($varname . '_enabled', 1, $componentname);
$this->assertTrue($searcharea->is_enabled());
}

View File

@ -66,10 +66,10 @@ class mod_wiki_search_testcase extends advanced_testcase {
// Enabled by default once global search is enabled.
$this->assertTrue($searcharea->is_enabled());
set_config($varname . '_enabled', false, $componentname);
set_config($varname . '_enabled', 0, $componentname);
$this->assertFalse($searcharea->is_enabled());
set_config($varname . '_enabled', true, $componentname);
set_config($varname . '_enabled', 1, $componentname);
$this->assertTrue($searcharea->is_enabled());
}

View File

@ -1,75 +0,0 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Global Search admin form definition
*
* @package report_search
* @copyright Prateek Sachan {@link http://prateeksachan.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace report_search\output;
defined('MOODLE_INTERNAL') || die();
require_once("$CFG->libdir/formslib.php");
/**
* Search report form.
*
* @package report_search
* @copyright Prateek Sachan {@link http://prateeksachan.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class form extends \moodleform {
/**
* Form definition.
*
* @return void
*/
public function definition() {
$mform = $this->_form;
$checkboxarray = array();
$checkboxarray[] =& $mform->createElement('checkbox', 'reindex', '', get_string('indexsite', 'report_search'));
$mform->addGroup($checkboxarray, 'reindexcheckbox', '', array(''), false);
$mform->closeHeaderBefore('reindexcheckbox');
$checkboxarray = array();
$checkboxarray[] =& $mform->createElement('checkbox', 'delete', '', get_string('delete', 'report_search'));
$mform->addGroup($checkboxarray, 'deletecheckbox', '', array(''), false);
$mform->closeHeaderBefore('deletecheckbox');
// Only available if delete checked.
$areacheckboxarray = array();
$areacheckboxarray[] =& $mform->createElement('advcheckbox', 'all', '', get_string('entireindex', 'report_search'),
array('group' => 1));
$mform->setDefault('all', true);
foreach ($this->_customdata['searchareas'] as $key => $searcharea) {
$areacheckboxarray[] =& $mform->createElement('advcheckbox', $key, '',
$searcharea->get_visible_name(), array('group' => 2));
}
$mform->addGroup($areacheckboxarray, 'areasadvcheckbox', '', array(' '), false);
$mform->closeHeaderBefore('areasadvcheckbox');
$mform->disabledIf('areasadvcheckbox', 'delete', 'notchecked');
$this->add_action_buttons(false, get_string('execute', 'report_search'));
}
}

View File

@ -1,79 +0,0 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Search report renderer.
*
* @package report_search
* @copyright 2015 David Monllao {@link http://www.davidmonllao.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace report_search\output;
defined('MOODLE_INTERNAL') || die();
/**
* Renderer for search report.
*
* @package report_search
* @copyright 2015 David Monllao {@link http://www.davidmonllao.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class renderer extends \plugin_renderer_base {
/**
* Renders the global search admin interface.
*
* @param \report_search\output\form\admin $form
* @param \core_search\area\base[] $searchareas
* @param \stdClass[] $areasconfig
* @return string HTML
*/
public function render_report($form, $searchareas, $areasconfig) {
$table = new \html_table();
$table->head = array(get_string('searcharea', 'search'), get_string('newestdocindexed', 'report_search'),
get_string('lastrun', 'report_search'));
foreach ($searchareas as $areaid => $searcharea) {
$cname = new \html_table_cell($searcharea->get_visible_name());
$clastrun = new \html_table_cell($areasconfig[$areaid]->lastindexrun);
if ($areasconfig[$areaid]->indexingstart) {
$timediff = $areasconfig[$areaid]->indexingend - $areasconfig[$areaid]->indexingstart;
$ctimetaken = new \html_table_cell($timediff . ' , ' .
$areasconfig[$areaid]->docsprocessed . ' , ' .
$areasconfig[$areaid]->recordsprocessed . ' , ' .
$areasconfig[$areaid]->docsignored);
} else {
$ctimetaken = '';
}
$row = new \html_table_row(array($cname, $clastrun, $ctimetaken));
$table->data[] = $row;
}
// Display the table.
$content = \html_writer::table($table);
// Display the form.
$formcontents = $this->output->heading(get_string('indexform', 'report_search'), 3) .
$this->output->notification(get_string('indexinginfo', 'report_search'), 'notifymessage') . $form->render();
$content .= \html_writer::tag('div', $formcontents, array('id' => 'searchindexform'));
return $content;
}
}

View File

@ -1,88 +0,0 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Global search report
*
* @package report_search
* @copyright Prateek Sachan {@link http://prateeksachan.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(__DIR__ . '/../../config.php');
require_once($CFG->libdir . '/adminlib.php');
admin_externalpage_setup('reportsearch');
$pagetitle = get_string('pluginname', 'report_search');
$PAGE->set_title($pagetitle);
$PAGE->set_heading($pagetitle);
echo $OUTPUT->header();
echo $OUTPUT->heading($pagetitle);
if (\core_search\manager::is_global_search_enabled() === false) {
$renderer = $PAGE->get_renderer('core_search');
echo $renderer->render_search_disabled();
}
$renderer = $PAGE->get_renderer('report_search');
$search = \core_search\manager::instance();
// All enabled components.
$searchareas = $search->get_search_areas_list(true);
$mform = new \report_search\output\form(null, array('searchareas' => $searchareas));
if ($data = $mform->get_data()) {
if (!empty($data->delete)) {
if (!empty($data->all)) {
$search->delete_index();
} else {
$anydelete = false;
// We check that the component exist and is enabled.
foreach ($searchareas as $areaid => $searcharea) {
if (!empty($data->{$areaid})) {
$anydelete = true;
$search->delete_index($areaid);
}
}
}
if (!empty($data->all) || $anydelete) {
echo $OUTPUT->notification(get_string('deleted', 'report_search'), 'notifysuccess');
}
}
if (!empty($data->reindex)) {
// Force full reindex. Quite heavy operation.
$search->index(true);
$search->optimize_index();
echo $OUTPUT->notification(get_string('indexed', 'report_search'), 'notifysuccess');
}
}
// After processing the form as config might change depending on the action.
$areasconfig = $search->get_areas_config($searchareas);
// Ensure that all search areas that we are going to display have config.
$missingareas = array_diff_key($searchareas, $areasconfig);
foreach ($missingareas as $searcharea) {
$search->reset_config($searcharea->get_area_id());
}
echo $renderer->render_report($mform, $searchareas, $areasconfig);
echo $OUTPUT->footer();

View File

@ -1,35 +0,0 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for component 'report_search'
*
* @package report_search
* @copyright 2015 David Monllao {@link http://www.davidmonllao.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['delete'] = 'Delete';
$string['deleted'] = 'Selected indexes deleted';
$string['entireindex'] = 'Entire index';
$string['execute'] = 'Execute';
$string['indexed'] = 'Indexing finished';
$string['indexform'] = 'Indexing';
$string['indexinginfo'] = 'The recommended way to index your site\'s contents is using "Global search indexing" scheduled task which runs automatically by Cron.';
$string['indexsite'] = 'Index all site contents';
$string['lastrun'] = 'Last run (time, # docs, # records, # ignores)';
$string['newestdocindexed'] = 'Newest document indexed';
$string['pluginname'] = 'Global search info';

View File

@ -1,35 +0,0 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Adds the search report link to the admin tree.
*
* @package report_search
* @copyright 2015 David Monllao {@link http://www.davidmonllao.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
if ($hassiteconfig) {
$searchurl = $CFG->wwwroot . '/report/search/index.php';
$ADMIN->add('reports', new admin_externalpage('reportsearch', new lang_string('pluginname', 'report_search'),
$searchurl));
// No report settings.
$settings = null;
}

View File

@ -29,8 +29,8 @@ defined('MOODLE_INTERNAL') || die();
/**
* Base search implementation.
*
* Components and plugins interested in filling the search engine
* with data should extend this class (or any extension of this class)
* Components and plugins interested in filling the search engine with data should extend this class (or any extension of this
* class).
*
* @package core_search
* @copyright 2015 David Monllao {@link http://www.davidmonllao.com}
@ -180,6 +180,10 @@ abstract class base {
$config[$varname . $name] = get_config($componentname, $varname . $name);
}
// Search areas are enabled by default.
if ($config[$varname . '_enabled'] === false) {
$config[$varname . '_enabled'] = 1;
}
return $config;
}
@ -190,7 +194,19 @@ abstract class base {
*/
public function is_enabled() {
list($componentname, $varname) = $this->get_config_var_name();
return (bool)get_config($componentname, $varname . '_enabled');
$value = get_config($componentname, $varname . '_enabled');
// Search areas are enabled by default.
if ($value === false) {
$value = 1;
}
return (bool)$value;
}
public function set_enabled($isenabled) {
list($componentname, $varname) = $this->get_config_var_name();
return set_config($varname . '_enabled', $isenabled, $componentname);
}
/**

View File

@ -682,7 +682,6 @@ class manager {
*/
public function get_areas_config($searchareas) {
$allconfigs = get_config('search');
$vars = array('indexingstart', 'indexingend', 'lastindexrun', 'docsignored', 'docsprocessed', 'recordsprocessed');
$configsettings = array();

View File

@ -81,12 +81,12 @@ class search_manager_testcase extends advanced_testcase {
$this->assertArrayHasKey($this->forumpostareaid, \core_search\manager::get_search_areas_list(true));
list($componentname, $varname) = $searcharea->get_config_var_name();
set_config($varname . '_enabled', false, $componentname);
set_config($varname . '_enabled', 0, $componentname);
\core_search\manager::clear_static();
$this->assertArrayNotHasKey('mod_forum', \core_search\manager::get_search_areas_list(true));
set_config($varname . '_enabled', true, $componentname);
set_config($varname . '_enabled', 1, $componentname);
// Although the result is wrong, we want to check that \core_search\manager::get_search_areas_list returns cached results.
$this->assertArrayNotHasKey($this->forumpostareaid, \core_search\manager::get_search_areas_list(true));
@ -127,10 +127,11 @@ class search_manager_testcase extends advanced_testcase {
// We clean it all but enabled components.
$search->reset_config($this->forumpostareaid);
$this->assertEquals(1, get_config($componentname, $varname . '_enabled'));
$this->assertEquals(0, get_config($componentname, $varname . '_indexingstart'));
$this->assertEquals(0, get_config($componentname, $varname . '_indexingend'));
$this->assertEquals(0, get_config($componentname, $varname . '_lastindexrun'));
$config = $searcharea->get_config();
$this->assertEquals(1, $config[$varname . '_enabled']);
$this->assertEquals(0, $config[$varname . '_indexingstart']);
$this->assertEquals(0, $config[$varname . '_indexingend']);
$this->assertEquals(0, $config[$varname . '_lastindexrun']);
// No caching.
$configs = $search->get_areas_config(array($this->forumpostareaid => $searcharea));
$this->assertEquals(0, $configs[$this->forumpostareaid]->indexingstart);

View File

@ -69,3 +69,7 @@
.navbar .search-input-wrapper > form {
margin: 5px 0 5px 25px;
}
.search-areas-actions > div {
display: inline-block;
}

File diff suppressed because one or more lines are too long

View File

@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2016070700.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2016070700.01; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.