MDL-53222 report_search: Delete from core
This commit is contained in:
@@ -1870,7 +1870,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'
|
||||
),
|
||||
|
||||
|
||||
@@ -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'));
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
@@ -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';
|
||||
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user