Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 401 and 402]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Adds a search area to the queue for indexing. 19 * 20 * @package core_search 21 * @copyright 2017 The Open University 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 define('NO_OUTPUT_BUFFERING', true); 26 27 require(__DIR__ . '/../config.php'); 28 29 // Check access. 30 require_once($CFG->libdir . '/adminlib.php'); 31 32 admin_externalpage_setup('searchareas', '', null, (new moodle_url('/admin/searchreindex.php'))->out(false)); 33 34 // Get area parameter and check it exists. 35 $areaid = required_param('areaid', PARAM_ALPHANUMEXT); 36 $area = \core_search\manager::get_search_area($areaid); 37 if ($area === false) { 38 throw new moodle_exception('invalidrequest'); 39 } 40 $areaname = $area->get_visible_name(); 41 42 $PAGE->set_primary_active_tab('siteadminnode'); 43 $PAGE->set_secondary_active_tab('modules'); 44 45 // Start page output. 46 $heading = get_string('gradualreindex', 'search', ''); 47 $PAGE->set_title($areaname . ' - ' . get_string('gradualreindex', 'search', '')); 48 $PAGE->navbar->add($heading); 49 echo $OUTPUT->header(); 50 echo $OUTPUT->heading($heading); 51 52 // If sesskey is supplied, actually carry out the action. 53 if (optional_param('sesskey', '', PARAM_ALPHANUM)) { 54 require_sesskey(); 55 56 // Get all contexts for search area. This query can take time in large cases. 57 \core_php_time_limit::raise(0); 58 $contextiterator = $area->get_contexts_to_reindex(); 59 60 $progress = new \core\progress\display_if_slow(''); 61 $progress->start_progress($areaname); 62 63 // Request reindexing for each context (with low priority). 64 $count = 0; 65 foreach ($contextiterator as $context) { 66 \core_php_time_limit::raise(30); 67 \core_search\manager::request_index($context, $area->get_area_id(), 68 \core_search\manager::INDEX_PRIORITY_REINDEXING); 69 $progress->progress(); 70 $count++; 71 } 72 73 // Unset the iterator which should close the recordset (if there is one). 74 unset($contextiterator); 75 76 $progress->end_progress(); 77 78 $a = (object)['name' => html_writer::tag('strong', $areaname), 'count' => $count]; 79 echo $OUTPUT->box(get_string('gradualreindex_queued', 'search', $a)); 80 81 echo $OUTPUT->continue_button(new moodle_url('/admin/searchareas.php')); 82 } else { 83 // Display confirmation prompt. 84 echo $OUTPUT->confirm(get_string('gradualreindex_confirm', 'search', html_writer::tag('strong', $areaname)), 85 new single_button(new moodle_url('/admin/searchreindex.php', ['areaid' => $areaid, 86 'sesskey' => sesskey()]), get_string('continue'), 'post', single_button::BUTTON_PRIMARY), 87 new single_button(new moodle_url('/admin/searchareas.php'), get_string('cancel'), 'get')); 88 } 89 90 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body