2 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
18 * Renderer for core_admin subsystem
22 * @copyright 2011 David Mudrak <david@moodle.com>
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 defined('MOODLE_INTERNAL') ||
die();
30 * Standard HTML output renderer for core_admin subsystem
32 class core_admin_renderer
extends plugin_renderer_base
{
35 * Display the 'Do you acknowledge the terms of the GPL' page. The first page
37 * @return string HTML to output.
39 public function install_licence_page() {
43 $copyrightnotice = text_to_html(get_string('gpl3'));
44 $copyrightnotice = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $copyrightnotice); // extremely ugly validation hack
46 $continue = new single_button(new moodle_url($this->page
->url
, array(
47 'lang' => $CFG->lang
, 'agreelicense' => 1)), get_string('continue'), 'get');
49 $output .= $this->header();
50 $output .= $this->heading('<a href="http://moodle.org">Moodle</a> - Modular Object-Oriented Dynamic Learning Environment');
51 $output .= $this->heading(get_string('copyrightnotice'));
52 $output .= $this->box($copyrightnotice, 'copyrightnotice');
53 $output .= html_writer
::empty_tag('br');
54 $output .= $this->confirm(get_string('doyouagree'), $continue, "http://docs.moodle.org/dev/License");
55 $output .= $this->footer();
61 * Display page explaining proper upgrade process,
62 * there can not be any PHP file leftovers...
64 * @return string HTML to output.
66 public function upgrade_stale_php_files_page() {
68 $output .= $this->header();
69 $output .= $this->heading(get_string('upgradestalefiles', 'admin'));
70 $output .= $this->box_start('generalbox', 'notice');
71 $output .= format_text(get_string('upgradestalefilesinfo', 'admin', get_docs_url('Upgrading')), FORMAT_MARKDOWN
);
72 $output .= html_writer
::empty_tag('br');
73 $output .= html_writer
::tag('div', $this->single_button($this->page
->url
, get_string('reload'), 'get'), array('class' => 'buttons'));
74 $output .= $this->box_end();
75 $output .= $this->footer();
81 * Display the 'environment check' page that is displayed during install.
82 * @param int $maturity
83 * @param boolean $envstatus final result of the check (true/false)
84 * @param array $environment_results array of results gathered
85 * @param string $release moodle release
86 * @return string HTML to output.
88 public function install_environment_page($maturity, $envstatus, $environment_results, $release) {
92 $output .= $this->header();
93 $output .= $this->maturity_warning($maturity);
94 $output .= $this->heading("Moodle $release");
95 $output .= $this->release_notes_link();
97 $output .= $this->environment_check_table($envstatus, $environment_results);
100 $output .= $this->upgrade_reload(new moodle_url($this->page
->url
, array('agreelicense' => 1, 'lang' => $CFG->lang
)));
102 $output .= $this->notification(get_string('environmentok', 'admin'), 'notifysuccess');
103 $output .= $this->continue_button(new moodle_url($this->page
->url
, array(
104 'agreelicense' => 1, 'confirmrelease' => 1, 'lang' => $CFG->lang
)));
107 $output .= $this->footer();
112 * Displays the list of plugins with unsatisfied dependencies
114 * @param double|string|int $version Moodle on-disk version
115 * @param array $failed list of plugins with unsatisfied dependecies
116 * @param moodle_url $reloadurl URL of the page to recheck the dependencies
117 * @return string HTML
119 public function unsatisfied_dependencies_page($version, array $failed, moodle_url
$reloadurl) {
122 $output .= $this->header();
123 $output .= $this->heading(get_string('pluginscheck', 'admin'));
124 $output .= $this->warning(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
125 $output .= $this->plugins_check_table(core_plugin_manager
::instance(), $version, array('xdep' => true));
126 $output .= $this->warning(get_string('pluginschecktodo', 'admin'));
127 $output .= $this->continue_button($reloadurl);
129 $output .= $this->footer();
135 * Display the 'You are about to upgrade Moodle' page. The first page
137 * @param string $strnewversion
138 * @param int $maturity
139 * @param string $testsite
140 * @return string HTML to output.
142 public function upgrade_confirm_page($strnewversion, $maturity, $testsite) {
145 $continueurl = new moodle_url($this->page
->url
, array('confirmupgrade' => 1, 'cache' => 0));
146 $continue = new single_button($continueurl, get_string('continue'), 'get');
147 $cancelurl = new moodle_url('/admin/index.php');
149 $output .= $this->header();
150 $output .= $this->maturity_warning($maturity);
151 $output .= $this->test_site_warning($testsite);
152 $output .= $this->confirm(get_string('upgradesure', 'admin', $strnewversion), $continue, $cancelurl);
153 $output .= $this->footer();
159 * Display the environment page during the upgrade process.
160 * @param string $release
161 * @param boolean $envstatus final result of env check (true/false)
162 * @param array $environment_results array of results gathered
163 * @return string HTML to output.
165 public function upgrade_environment_page($release, $envstatus, $environment_results) {
169 $output .= $this->header();
170 $output .= $this->heading("Moodle $release");
171 $output .= $this->release_notes_link();
172 $output .= $this->environment_check_table($envstatus, $environment_results);
175 $output .= $this->upgrade_reload(new moodle_url($this->page
->url
, array('confirmupgrade' => 1, 'cache' => 0)));
178 $output .= $this->notification(get_string('environmentok', 'admin'), 'notifysuccess');
180 if (empty($CFG->skiplangupgrade
) and current_language() !== 'en') {
181 $output .= $this->box(get_string('langpackwillbeupdated', 'admin'), 'generalbox', 'notice');
184 $output .= $this->continue_button(new moodle_url($this->page
->url
, array(
185 'confirmupgrade' => 1, 'confirmrelease' => 1, 'cache' => 0)));
188 $output .= $this->footer();
194 * Display the upgrade page that lists all the plugins that require attention.
195 * @param core_plugin_manager $pluginman provides information about the plugins.
196 * @param \core\update\checker $checker provides information about available updates.
197 * @param int $version the version of the Moodle code from version.php.
198 * @param bool $showallplugins
199 * @param moodle_url $reloadurl
200 * @param moodle_url $continueurl
201 * @return string HTML to output.
203 public function upgrade_plugin_check_page(core_plugin_manager
$pluginman, \core\update\checker
$checker,
204 $version, $showallplugins, $reloadurl, $continueurl) {
208 $output .= $this->header();
209 $output .= $this->box_start('generalbox', 'plugins-check-page');
210 $output .= html_writer
::tag('p', get_string('pluginchecknotice', 'core_plugin'), array('class' => 'page-description'));
211 $output .= $this->check_for_updates_button($checker, $reloadurl);
212 $output .= $this->missing_dependencies($pluginman);
213 $output .= $this->plugins_check_table($pluginman, $version, array('full' => $showallplugins));
214 $output .= $this->box_end();
215 $output .= $this->upgrade_reload($reloadurl);
217 if ($pluginman->some_plugins_updatable()) {
218 $output .= $this->container_start('upgradepluginsinfo');
219 $output .= $this->help_icon('upgradepluginsinfo', 'core_admin', get_string('upgradepluginsfirst', 'core_admin'));
220 $output .= $this->container_end();
223 $button = new single_button($continueurl, get_string('upgradestart', 'admin'), 'get', true);
224 $button->class = 'continuebutton';
225 $output .= $this->render($button);
226 $output .= $this->footer();
232 * Display a page to confirm plugin installation cancelation.
234 * @param array $abortable list of \core\update\plugininfo
235 * @param moodle_url $continue
238 public function upgrade_confirm_abort_install_page(array $abortable, moodle_url
$continue) {
240 $pluginman = core_plugin_manager
::instance();
242 if (empty($abortable)) {
243 // The UI should not allow this.
244 throw new moodle_exception('err_no_plugin_install_abortable', 'core_plugin');
247 $out = $this->output
->header();
248 $out .= $this->output
->heading(get_string('cancelinstallhead', 'core_plugin'), 3);
249 $out .= $this->output
->container(get_string('cancelinstallinfo', 'core_plugin'), 'cancelinstallinfo');
251 foreach ($abortable as $pluginfo) {
252 $out .= $this->output
->heading($pluginfo->displayname
.' ('.$pluginfo->component
.')', 4);
253 $out .= $this->output
->container(get_string('cancelinstallinfodir', 'core_plugin', $pluginfo->rootdir
));
254 if ($repotype = $pluginman->plugin_external_source($pluginfo->component
)) {
255 $out .= $this->output
->container(get_string('uninstalldeleteconfirmexternal', 'core_plugin', $repotype),
256 'alert alert-warning mt-2');
260 $out .= $this->plugins_management_confirm_buttons($continue, $this->page
->url
);
261 $out .= $this->output
->footer();
267 * Display the admin notifications page.
268 * @param int $maturity
269 * @param bool $insecuredataroot warn dataroot is invalid
270 * @param bool $errorsdisplayed warn invalid dispaly error setting
271 * @param bool $cronoverdue warn cron not running
272 * @param bool $dbproblems warn db has problems
273 * @param bool $maintenancemode warn in maintenance mode
274 * @param bool $buggyiconvnomb warn iconv problems
275 * @param array|null $availableupdates array of \core\update\info objects or null
276 * @param int|null $availableupdatesfetch timestamp of the most recent updates fetch or null (unknown)
277 * @param string[] $cachewarnings An array containing warnings from the Cache API.
278 * @param array $eventshandlers Events 1 API handlers.
279 * @param bool $themedesignermode Warn about the theme designer mode.
280 * @param bool $devlibdir Warn about development libs directory presence.
281 * @param bool $mobileconfigured Whether the mobile web services have been enabled
282 * @param bool $overridetossl Whether or not ssl is being forced.
283 * @param bool $invalidforgottenpasswordurl Whether the forgotten password URL does not link to a valid URL.
284 * @param bool $croninfrequent If true, warn that cron hasn't run in the past few minutes
285 * @param bool $showcampaigncontent Whether the campaign content should be visible or not.
286 * @param bool $showfeedbackencouragement Whether the feedback encouragement content should be displayed or not.
287 * @param bool $showservicesandsupport Whether the services and support content should be displayed or not.
288 * @param string $xmlrpcwarning XML-RPC deprecation warning message.
290 * @return string HTML to output.
292 public function admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed,
293 $cronoverdue, $dbproblems, $maintenancemode, $availableupdates, $availableupdatesfetch,
294 $buggyiconvnomb, $registered, array $cachewarnings = array(), $eventshandlers = 0,
295 $themedesignermode = false, $devlibdir = false, $mobileconfigured = false,
296 $overridetossl = false, $invalidforgottenpasswordurl = false, $croninfrequent = false,
297 $showcampaigncontent = false, bool $showfeedbackencouragement = false, bool $showservicesandsupport = false,
298 $xmlrpcwarning = '') {
303 $output .= $this->header();
304 $output .= $this->output
->heading(get_string('notifications', 'admin'));
305 $output .= $this->maturity_info($maturity);
306 $output .= $this->legacy_log_store_writing_error();
307 $output .= empty($CFG->disableupdatenotifications
) ?
$this->available_updates($availableupdates, $availableupdatesfetch) : '';
308 $output .= $this->insecure_dataroot_warning($insecuredataroot);
309 $output .= $this->development_libs_directories_warning($devlibdir);
310 $output .= $this->themedesignermode_warning($themedesignermode);
311 $output .= $this->display_errors_warning($errorsdisplayed);
312 $output .= $this->buggy_iconv_warning($buggyiconvnomb);
313 $output .= $this->cron_overdue_warning($cronoverdue);
314 $output .= $this->cron_infrequent_warning($croninfrequent);
315 $output .= $this->db_problems($dbproblems);
316 $output .= $this->maintenance_mode_warning($maintenancemode);
317 $output .= $this->overridetossl_warning($overridetossl);
318 $output .= $this->cache_warnings($cachewarnings);
319 $output .= $this->events_handlers($eventshandlers);
320 $output .= $this->registration_warning($registered);
321 $output .= $this->mobile_configuration_warning($mobileconfigured);
322 $output .= $this->forgotten_password_url_warning($invalidforgottenpasswordurl);
323 $output .= $this->mnet_deprecation_warning($xmlrpcwarning);
324 $output .= $this->userfeedback_encouragement($showfeedbackencouragement);
325 $output .= $this->services_and_support_content($showservicesandsupport);
326 $output .= $this->campaign_content($showcampaigncontent);
328 //////////////////////////////////////////////////////////////////////////////////////////////////
329 //// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO HIDE, REMOVE OR MODIFY THIS COPYRIGHT NOTICE ///
330 $output .= $this->moodle_copyright();
331 //////////////////////////////////////////////////////////////////////////////////////////////////
333 $output .= $this->footer();
339 * Display the plugin management page (admin/plugins.php).
341 * The filtering options array may contain following items:
342 * bool contribonly - show only contributed extensions
343 * bool updatesonly - show only plugins with an available update
345 * @param core_plugin_manager $pluginman
346 * @param \core\update\checker $checker
347 * @param array $options filtering options
348 * @return string HTML to output.
350 public function plugin_management_page(core_plugin_manager
$pluginman, \core\update\checker
$checker, array $options = array()) {
354 $output .= $this->header();
355 $output .= $this->heading(get_string('pluginsoverview', 'core_admin'));
356 $output .= $this->check_for_updates_button($checker, $this->page
->url
);
357 $output .= $this->plugins_overview_panel($pluginman, $options);
358 $output .= $this->plugins_control_panel($pluginman, $options);
359 $output .= $this->footer();
365 * Renders a button to fetch for available updates.
367 * @param \core\update\checker $checker
368 * @param moodle_url $reloadurl
369 * @return string HTML
371 public function check_for_updates_button(\core\update\checker
$checker, $reloadurl) {
375 if ($checker->enabled()) {
376 $output .= $this->container_start('checkforupdates mb-4');
377 $output .= $this->single_button(
378 new moodle_url($reloadurl, array('fetchupdates' => 1)),
379 get_string('checkforupdates', 'core_plugin')
381 if ($timefetched = $checker->get_last_timefetched()) {
382 $timefetched = userdate($timefetched, get_string('strftimedatetime', 'core_langconfig'));
383 $output .= $this->container(get_string('checkforupdateslast', 'core_plugin', $timefetched),
384 'lasttimefetched small text-muted mt-1');
386 $output .= $this->container_end();
393 * Display a page to confirm the plugin uninstallation.
395 * @param core_plugin_manager $pluginman
396 * @param \core\plugininfo\base $pluginfo
397 * @param moodle_url $continueurl URL to continue after confirmation
398 * @param moodle_url $cancelurl URL to to go if cancelled
401 public function plugin_uninstall_confirm_page(core_plugin_manager
$pluginman, \core\plugininfo\base
$pluginfo, moodle_url
$continueurl, moodle_url
$cancelurl) {
404 $pluginname = $pluginman->plugin_name($pluginfo->component
);
406 $confirm = '<p>' . get_string('uninstallconfirm', 'core_plugin', array('name' => $pluginname)) . '</p>';
407 if ($extraconfirm = $pluginfo->get_uninstall_extra_warning()) {
408 $confirm .= $extraconfirm;
411 $output .= $this->output
->header();
412 $output .= $this->output
->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
413 $output .= $this->output
->confirm($confirm, $continueurl, $cancelurl);
414 $output .= $this->output
->footer();
420 * Display a page with results of plugin uninstallation and offer removal of plugin files.
422 * @param core_plugin_manager $pluginman
423 * @param \core\plugininfo\base $pluginfo
424 * @param progress_trace_buffer $progress
425 * @param moodle_url $continueurl URL to continue to remove the plugin folder
428 public function plugin_uninstall_results_removable_page(core_plugin_manager
$pluginman, \core\plugininfo\base
$pluginfo,
429 progress_trace_buffer
$progress, moodle_url
$continueurl) {
432 $pluginname = $pluginman->plugin_name($pluginfo->component
);
434 // Do not show navigation here, they must click one of the buttons.
435 $this->page
->set_pagelayout('maintenance');
436 $this->page
->set_cacheable(false);
438 $output .= $this->output
->header();
439 $output .= $this->output
->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
441 $output .= $this->output
->box($progress->get_buffer(), 'generalbox uninstallresultmessage');
443 $confirm = $this->output
->container(get_string('uninstalldeleteconfirm', 'core_plugin',
444 array('name' => $pluginname, 'rootdir' => $pluginfo->rootdir
)), 'uninstalldeleteconfirm');
446 if ($repotype = $pluginman->plugin_external_source($pluginfo->component
)) {
447 $confirm .= $this->output
->container(get_string('uninstalldeleteconfirmexternal', 'core_plugin', $repotype),
448 'alert alert-warning mt-2');
451 // After any uninstall we must execute full upgrade to finish the cleanup!
452 $output .= $this->output
->confirm($confirm, $continueurl, new moodle_url('/admin/index.php'));
453 $output .= $this->output
->footer();
459 * Display a page with results of plugin uninstallation and inform about the need to remove plugin files manually.
461 * @param core_plugin_manager $pluginman
462 * @param \core\plugininfo\base $pluginfo
463 * @param progress_trace_buffer $progress
466 public function plugin_uninstall_results_page(core_plugin_manager
$pluginman, \core\plugininfo\base
$pluginfo, progress_trace_buffer
$progress) {
469 $pluginname = $pluginfo->component
;
471 $output .= $this->output
->header();
472 $output .= $this->output
->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
474 $output .= $this->output
->box($progress->get_buffer(), 'generalbox uninstallresultmessage');
476 $output .= $this->output
->box(get_string('uninstalldelete', 'core_plugin',
477 array('name' => $pluginname, 'rootdir' => $pluginfo->rootdir
)), 'generalbox uninstalldelete');
478 $output .= $this->output
->continue_button(new moodle_url('/admin/index.php'));
479 $output .= $this->output
->footer();
485 * Display the plugin management page (admin/environment.php).
486 * @param array $versions
487 * @param string $version
488 * @param boolean $envstatus final result of env check (true/false)
489 * @param array $environment_results array of results gathered
490 * @return string HTML to output.
492 public function environment_check_page($versions, $version, $envstatus, $environment_results) {
494 $output .= $this->header();
496 // Print the component download link
497 $output .= html_writer
::tag('div', html_writer
::link(
498 new moodle_url('/admin/environment.php', array('action' => 'updatecomponent', 'sesskey' => sesskey())),
499 get_string('updatecomponent', 'admin')),
500 array('class' => 'reportlink'));
503 $output .= $this->heading(get_string('environment', 'admin'));
505 // Box with info and a menu to choose the version.
506 $output .= $this->box_start();
507 $output .= html_writer
::tag('div', get_string('adminhelpenvironment'));
508 $select = new single_select(new moodle_url('/admin/environment.php'), 'version', $versions, $version, null);
509 $select->label
= get_string('moodleversion');
510 $output .= $this->render($select);
511 $output .= $this->box_end();
514 $output .= $this->environment_check_table($envstatus, $environment_results);
516 $output .= $this->footer();
521 * Output a warning message, of the type that appears on the admin notifications page.
522 * @param string $message the message to display.
523 * @param string $type type class
524 * @return string HTML to output.
526 protected function warning($message, $type = 'warning') {
527 return $this->box($message, 'generalbox alert alert-' . $type);
531 * Render an appropriate message if dataroot is insecure.
532 * @param bool $insecuredataroot
533 * @return string HTML to output.
535 protected function insecure_dataroot_warning($insecuredataroot) {
538 if ($insecuredataroot == INSECURE_DATAROOT_WARNING
) {
539 return $this->warning(get_string('datarootsecuritywarning', 'admin', $CFG->dataroot
));
541 } else if ($insecuredataroot == INSECURE_DATAROOT_ERROR
) {
542 return $this->warning(get_string('datarootsecurityerror', 'admin', $CFG->dataroot
), 'danger');
550 * Render a warning that a directory with development libs is present.
552 * @param bool $devlibdir True if the warning should be displayed.
555 protected function development_libs_directories_warning($devlibdir) {
558 $moreinfo = new moodle_url('/report/security/index.php');
559 $warning = get_string('devlibdirpresent', 'core_admin', ['moreinfourl' => $moreinfo->out()]);
560 return $this->warning($warning, 'danger');
568 * Render an appropriate message if dataroot is insecure.
569 * @param bool $errorsdisplayed
570 * @return string HTML to output.
572 protected function display_errors_warning($errorsdisplayed) {
573 if (!$errorsdisplayed) {
577 return $this->warning(get_string('displayerrorswarning', 'admin'));
581 * Render an appropriate message if themdesignermode is enabled.
582 * @param bool $themedesignermode true if enabled
583 * @return string HTML to output.
585 protected function themedesignermode_warning($themedesignermode) {
586 if (!$themedesignermode) {
590 return $this->warning(get_string('themedesignermodewarning', 'admin'));
594 * Render an appropriate message if iconv is buggy and mbstring missing.
595 * @param bool $buggyiconvnomb
596 * @return string HTML to output.
598 protected function buggy_iconv_warning($buggyiconvnomb) {
599 if (!$buggyiconvnomb) {
603 return $this->warning(get_string('warningiconvbuggy', 'admin'));
607 * Render an appropriate message if cron has not been run recently.
608 * @param bool $cronoverdue
609 * @return string HTML to output.
611 public function cron_overdue_warning($cronoverdue) {
617 $check = new \tool_task\check\
cronrunning();
618 $result = $check->get_result();
619 return $this->warning($result->get_summary() . ' ' . $this->help_icon('cron', 'admin'));
623 * Render an appropriate message if cron is not being run frequently (recommended every minute).
625 * @param bool $croninfrequent
626 * @return string HTML to output.
628 public function cron_infrequent_warning(bool $croninfrequent) : string {
631 if (!$croninfrequent) {
635 $check = new \tool_task\check\
cronrunning();
636 $result = $check->get_result();
637 return $this->warning($result->get_summary() . ' ' . $this->help_icon('cron', 'admin'));
641 * Render an appropriate message if there are any problems with the DB set-up.
642 * @param bool $dbproblems
643 * @return string HTML to output.
645 public function db_problems($dbproblems) {
650 return $this->warning($dbproblems);
654 * Renders cache warnings if there are any.
656 * @param string[] $cachewarnings
659 public function cache_warnings(array $cachewarnings) {
660 if (!count($cachewarnings)) {
663 return join("\n", array_map(array($this, 'warning'), $cachewarnings));
667 * Renders events 1 API handlers warning.
669 * @param array $eventshandlers
672 public function events_handlers($eventshandlers) {
673 if ($eventshandlers) {
675 foreach ($eventshandlers as $eventhandler) {
676 $components .= $eventhandler->component
. ', ';
678 $components = rtrim($components, ', ');
679 return $this->warning(get_string('eventshandlersinuse', 'admin', $components));
684 * Render an appropriate message if the site in in maintenance mode.
685 * @param bool $maintenancemode
686 * @return string HTML to output.
688 public function maintenance_mode_warning($maintenancemode) {
689 if (!$maintenancemode) {
693 $url = new moodle_url('/admin/settings.php', array('section' => 'maintenancemode'));
694 $url = $url->out(); // get_string() does not support objects in params
696 return $this->warning(get_string('sitemaintenancewarning2', 'admin', $url));
700 * Render a warning that ssl is forced because the site was on loginhttps.
702 * @param bool $overridetossl Whether or not ssl is being forced.
705 protected function overridetossl_warning($overridetossl) {
706 if (!$overridetossl) {
709 $warning = get_string('overridetossl', 'core_admin');
710 return $this->warning($warning, 'warning');
714 * Display a warning about installing development code if necesary.
715 * @param int $maturity
716 * @return string HTML to output.
718 protected function maturity_warning($maturity) {
719 if ($maturity == MATURITY_STABLE
) {
720 return ''; // No worries.
723 $maturitylevel = get_string('maturity' . $maturity, 'admin');
724 return $this->warning(
725 $this->container(get_string('maturitycorewarning', 'admin', $maturitylevel)) .
726 $this->container($this->doc_link('admin/versions', get_string('morehelp'))),
731 * If necessary, displays a warning about upgrading a test site.
733 * @param string $testsite
734 * @return string HTML
736 protected function test_site_warning($testsite) {
742 $warning = (get_string('testsiteupgradewarning', 'admin', $testsite));
743 return $this->warning($warning, 'danger');
747 * Output the copyright notice.
748 * @return string HTML to output.
750 protected function moodle_copyright() {
753 //////////////////////////////////////////////////////////////////////////////////////////////////
754 //// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO HIDE, REMOVE OR MODIFY THIS COPYRIGHT NOTICE ///
755 $copyrighttext = '<a href="http://moodle.org/">Moodle</a> '.
756 '<a href="http://docs.moodle.org/dev/Releases" title="'.$CFG->version
.'">'.$CFG->release
.'</a><br />'.
757 'Copyright © 1999 onwards, Martin Dougiamas<br />'.
758 'and <a href="http://moodle.org/dev">many other contributors</a>.<br />'.
759 '<a href="http://docs.moodle.org/dev/License">GNU Public License</a>';
760 //////////////////////////////////////////////////////////////////////////////////////////////////
762 return $this->box($copyrighttext, 'copyright');
766 * Display a warning about installing development code if necesary.
767 * @param int $maturity
768 * @return string HTML to output.
770 protected function maturity_info($maturity) {
771 if ($maturity == MATURITY_STABLE
) {
772 return ''; // No worries.
777 if ($maturity == MATURITY_ALPHA
) {
781 $maturitylevel = get_string('maturity' . $maturity, 'admin');
782 $warningtext = get_string('maturitycoreinfo', 'admin', $maturitylevel);
783 $warningtext .= ' ' . $this->doc_link('admin/versions', get_string('morehelp'));
784 return $this->warning($warningtext, $level);
788 * Displays the info about available Moodle core and plugin updates
790 * The structure of the $updates param has changed since 2.4. It contains not only updates
791 * for the core itself, but also for all other installed plugins.
793 * @param array|null $updates array of (string)component => array of \core\update\info objects or null
794 * @param int|null $fetch timestamp of the most recent updates fetch or null (unknown)
797 protected function available_updates($updates, $fetch) {
800 $someupdateavailable = false;
801 if (is_array($updates)) {
802 if (is_array($updates['core'])) {
803 $someupdateavailable = true;
804 $updateinfo .= $this->heading(get_string('updateavailable', 'core_admin'), 3);
805 foreach ($updates['core'] as $update) {
806 $updateinfo .= $this->moodle_available_update_info($update);
808 $updateinfo .= html_writer
::tag('p', get_string('updateavailablerecommendation', 'core_admin'),
809 array('class' => 'updateavailablerecommendation'));
811 unset($updates['core']);
812 // If something has left in the $updates array now, it is updates for plugins.
813 if (!empty($updates)) {
814 $someupdateavailable = true;
815 $updateinfo .= $this->heading(get_string('updateavailableforplugin', 'core_admin'), 3);
816 $pluginsoverviewurl = new moodle_url('/admin/plugins.php', array('updatesonly' => 1));
817 $updateinfo .= $this->container(get_string('pluginsoverviewsee', 'core_admin',
818 array('url' => $pluginsoverviewurl->out())));
822 if (!$someupdateavailable) {
824 if ($fetch and ($fetch <= $now) and ($now - $fetch < HOURSECS
)) {
825 $updateinfo .= $this->heading(get_string('updateavailablenot', 'core_admin'), 3);
829 $updateinfo .= $this->container_start('checkforupdates mt-1');
830 $fetchurl = new moodle_url('/admin/index.php', array('fetchupdates' => 1, 'sesskey' => sesskey(), 'cache' => 0));
831 $updateinfo .= $this->single_button($fetchurl, get_string('checkforupdates', 'core_plugin'));
833 $updateinfo .= $this->container(get_string('checkforupdateslast', 'core_plugin',
834 userdate($fetch, get_string('strftimedatetime', 'core_langconfig'))));
836 $updateinfo .= $this->container_end();
838 return $this->warning($updateinfo);
842 * Display a warning about not being registered on Moodle.org if necesary.
844 * @param boolean $registered true if the site is registered on Moodle.org
845 * @return string HTML to output.
847 protected function registration_warning($registered) {
849 if (!$registered && site_is_public()) {
850 if (has_capability('moodle/site:config', context_system
::instance())) {
851 $registerbutton = $this->single_button(new moodle_url('/admin/registration/index.php'),
852 get_string('register', 'admin'));
853 $str = 'registrationwarning';
855 $registerbutton = '';
856 $str = 'registrationwarningcontactadmin';
859 return $this->warning( get_string($str, 'admin')
860 . ' ' . $this->help_icon('registration', 'admin') . $registerbutton ,
861 'error alert alert-danger');
868 * Return an admin page warning if site is not registered with moodle.org
872 public function warn_if_not_registered() {
873 return $this->registration_warning(\core\hub\registration
::is_registered());
877 * Display a warning about the Mobile Web Services being disabled.
879 * @param boolean $mobileconfigured true if mobile web services are enabled
880 * @return string HTML to output.
882 protected function mobile_configuration_warning($mobileconfigured) {
884 if (!$mobileconfigured) {
885 $settingslink = new moodle_url('/admin/settings.php', ['section' => 'mobilesettings']);
886 $configurebutton = $this->single_button($settingslink, get_string('enablemobilewebservice', 'admin'));
887 $output .= $this->warning(get_string('mobilenotconfiguredwarning', 'admin') . ' ' . $configurebutton);
894 * Display campaign content.
896 * @param bool $showcampaigncontent Whether the campaign content should be visible or not.
897 * @return string the campaign content raw html.
899 protected function campaign_content(bool $showcampaigncontent): string {
900 if (!$showcampaigncontent) {
904 $lang = current_language();
905 $url = "https://campaign.moodle.org/current/lms/{$lang}/install/";
908 'iframeid' => 'campaign-content'
911 return $this->render_from_template('core/external_content_banner', $params);
915 * Display services and support content.
917 * @param bool $showservicesandsupport Whether the services and support content should be visible or not.
918 * @return string the campaign content raw html.
920 protected function services_and_support_content(bool $showservicesandsupport): string {
921 if (!$showservicesandsupport) {
925 $lang = current_language();
926 $url = "https://campaign.moodle.org/current/lms/{$lang}/servicesandsupport/";
929 'iframeid' => 'services-support-content'
932 return $this->render_from_template('core/external_content_banner', $params);
936 * Display a warning about the forgotten password URL not linking to a valid URL.
938 * @param boolean $invalidforgottenpasswordurl true if the forgotten password URL is not valid
939 * @return string HTML to output.
941 protected function forgotten_password_url_warning($invalidforgottenpasswordurl) {
943 if ($invalidforgottenpasswordurl) {
944 $settingslink = new moodle_url('/admin/settings.php', ['section' => 'manageauths']);
945 $configurebutton = $this->single_button($settingslink, get_string('check', 'moodle'));
946 $output .= $this->warning(get_string('invalidforgottenpasswordurl', 'admin') . ' ' . $configurebutton,
947 'error alert alert-danger');
954 * Helper method to render the information about the available Moodle update
956 * @param \core\update\info $updateinfo information about the available Moodle core update
958 protected function moodle_available_update_info(\core\update\info
$updateinfo) {
960 $boxclasses = 'moodleupdateinfo mb-2';
963 if (isset($updateinfo->release
)) {
964 $info[] = html_writer
::tag('span', get_string('updateavailable_release', 'core_admin', $updateinfo->release
),
965 array('class' => 'info release'));
968 if (isset($updateinfo->version
)) {
969 $info[] = html_writer
::tag('span', get_string('updateavailable_version', 'core_admin', $updateinfo->version
),
970 array('class' => 'info version'));
973 if (isset($updateinfo->maturity
)) {
974 $info[] = html_writer
::tag('span', get_string('maturity'.$updateinfo->maturity
, 'core_admin'),
975 array('class' => 'info maturity'));
976 $boxclasses .= ' maturity'.$updateinfo->maturity
;
979 if (isset($updateinfo->download
)) {
980 $info[] = html_writer
::link($updateinfo->download
, get_string('download'),
981 array('class' => 'info download btn btn-secondary'));
984 if (isset($updateinfo->url
)) {
985 $info[] = html_writer
::link($updateinfo->url
, get_string('updateavailable_moreinfo', 'core_plugin'),
986 array('class' => 'info more'));
989 $box = $this->output
->container_start($boxclasses);
990 $box .= $this->output
->container(implode(html_writer
::tag('span', ' | ', array('class' => 'separator')), $info), '');
991 $box .= $this->output
->container_end();
997 * Display a link to the release notes.
998 * @return string HTML to output.
1000 protected function release_notes_link() {
1001 $releasenoteslink = get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/dev/Releases');
1002 $releasenoteslink = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $releasenoteslink); // extremely ugly validation hack
1003 return $this->box($releasenoteslink, 'generalbox alert alert-info');
1007 * Display the reload link that appears on several upgrade/install pages.
1008 * @return string HTML to output.
1010 function upgrade_reload($url) {
1011 return html_writer
::empty_tag('br') .
1012 html_writer
::tag('div',
1013 html_writer
::link($url, $this->pix_icon('i/reload', '', '', array('class' => 'icon icon-pre')) .
1014 get_string('reload'), array('title' => get_string('reload'))),
1015 array('class' => 'continuebutton')) . html_writer
::empty_tag('br');
1019 * Displays all known plugins and information about their installation or upgrade
1021 * This default implementation renders all plugins into one big table. The rendering
1023 * (bool)full = false: whether to display up-to-date plugins, too
1024 * (bool)xdep = false: display the plugins with unsatisified dependecies only
1026 * @param core_plugin_manager $pluginman provides information about the plugins.
1027 * @param int $version the version of the Moodle code from version.php.
1028 * @param array $options rendering options
1029 * @return string HTML code
1031 public function plugins_check_table(core_plugin_manager
$pluginman, $version, array $options = array()) {
1033 $plugininfo = $pluginman->get_plugins();
1035 if (empty($plugininfo)) {
1039 $options['full'] = isset($options['full']) ?
(bool)$options['full'] : false;
1040 $options['xdep'] = isset($options['xdep']) ?
(bool)$options['xdep'] : false;
1042 $table = new html_table();
1043 $table->id
= 'plugins-check';
1044 $table->head
= array(
1045 get_string('displayname', 'core_plugin').' / '.get_string('rootdir', 'core_plugin'),
1046 get_string('versiondb', 'core_plugin'),
1047 get_string('versiondisk', 'core_plugin'),
1048 get_string('requires', 'core_plugin'),
1049 get_string('source', 'core_plugin').' / '.get_string('status', 'core_plugin'),
1051 $table->colclasses
= array(
1052 'displayname', 'versiondb', 'versiondisk', 'requires', 'status',
1054 $table->data
= array();
1056 // Number of displayed plugins per type.
1057 $numdisplayed = array();
1058 // Number of plugins known to the plugin manager.
1060 // Number of plugins requiring attention.
1062 // List of all components we can cancel installation of.
1063 $installabortable = $pluginman->list_cancellable_installations();
1064 // List of all components we can cancel upgrade of.
1065 $upgradeabortable = $pluginman->list_restorable_archives();
1067 foreach ($plugininfo as $type => $plugins) {
1069 $header = new html_table_cell($pluginman->plugintype_name_plural($type));
1070 $header->header
= true;
1071 $header->colspan
= count($table->head
);
1072 $header = new html_table_row(array($header));
1073 $header->attributes
['class'] = 'plugintypeheader type-' . $type;
1075 $numdisplayed[$type] = 0;
1077 if (empty($plugins) and $options['full']) {
1078 $msg = new html_table_cell(get_string('noneinstalled', 'core_plugin'));
1079 $msg->colspan
= count($table->head
);
1080 $row = new html_table_row(array($msg));
1081 $row->attributes
['class'] .= 'msg msg-noneinstalled';
1082 $table->data
[] = $header;
1083 $table->data
[] = $row;
1087 $plugintyperows = array();
1089 foreach ($plugins as $name => $plugin) {
1091 $row = new html_table_row();
1092 $row->attributes
['class'] = 'type-' . $plugin->type
. ' name-' . $plugin->type
. '_' . $plugin->name
;
1094 if ($this->page
->theme
->resolve_image_location('icon', $plugin->type
. '_' . $plugin->name
, null)) {
1095 $icon = $this->output
->pix_icon('icon', '', $plugin->type
. '_' . $plugin->name
, array('class' => 'smallicon pluginicon'));
1100 $displayname = new html_table_cell(
1102 html_writer
::span($plugin->displayname
, 'pluginname').
1103 html_writer
::div($plugin->get_dir(), 'plugindir text-muted small')
1106 $versiondb = new html_table_cell($plugin->versiondb
);
1107 $versiondisk = new html_table_cell($plugin->versiondisk
);
1109 if ($isstandard = $plugin->is_standard()) {
1110 $row->attributes
['class'] .= ' standard';
1111 $sourcelabel = html_writer
::span(get_string('sourcestd', 'core_plugin'), 'sourcetext badge badge-secondary');
1113 $row->attributes
['class'] .= ' extension';
1114 $sourcelabel = html_writer
::span(get_string('sourceext', 'core_plugin'), 'sourcetext badge badge-info');
1117 $coredependency = $plugin->is_core_dependency_satisfied($version);
1118 $incompatibledependency = $plugin->is_core_compatible_satisfied($CFG->branch
);
1120 $otherpluginsdependencies = $pluginman->are_dependencies_satisfied($plugin->get_other_required_plugins());
1121 $dependenciesok = $coredependency && $otherpluginsdependencies && $incompatibledependency;
1123 $statuscode = $plugin->get_status();
1124 $row->attributes
['class'] .= ' status-' . $statuscode;
1125 $statusclass = 'statustext badge ';
1126 switch ($statuscode) {
1127 case core_plugin_manager
::PLUGIN_STATUS_NEW
:
1128 $statusclass .= $dependenciesok ?
'badge-success' : 'badge-warning';
1130 case core_plugin_manager
::PLUGIN_STATUS_UPGRADE
:
1131 $statusclass .= $dependenciesok ?
'badge-info' : 'badge-warning';
1133 case core_plugin_manager
::PLUGIN_STATUS_MISSING
:
1134 case core_plugin_manager
::PLUGIN_STATUS_DOWNGRADE
:
1135 case core_plugin_manager
::PLUGIN_STATUS_DELETE
:
1136 $statusclass .= 'badge-danger';
1138 case core_plugin_manager
::PLUGIN_STATUS_NODB
:
1139 case core_plugin_manager
::PLUGIN_STATUS_UPTODATE
:
1140 $statusclass .= $dependenciesok ?
'badge-light' : 'badge-warning';
1143 $status = html_writer
::span(get_string('status_' . $statuscode, 'core_plugin'), $statusclass);
1145 if (!empty($installabortable[$plugin->component
])) {
1146 $status .= $this->output
->single_button(
1147 new moodle_url($this->page
->url
, array('abortinstall' => $plugin->component
, 'confirmplugincheck' => 0)),
1148 get_string('cancelinstallone', 'core_plugin'),
1150 array('class' => 'actionbutton cancelinstallone d-block mt-1')
1154 if (!empty($upgradeabortable[$plugin->component
])) {
1155 $status .= $this->output
->single_button(
1156 new moodle_url($this->page
->url
, array('abortupgrade' => $plugin->component
)),
1157 get_string('cancelupgradeone', 'core_plugin'),
1159 array('class' => 'actionbutton cancelupgradeone d-block mt-1')
1163 $availableupdates = $plugin->available_updates();
1164 if (!empty($availableupdates)) {
1165 foreach ($availableupdates as $availableupdate) {
1166 $status .= $this->plugin_available_update_info($pluginman, $availableupdate);
1170 $status = new html_table_cell($sourcelabel.' '.$status);
1171 if ($plugin->pluginsupported
!= null) {
1172 $requires = new html_table_cell($this->required_column($plugin, $pluginman, $version, $CFG->branch
));
1174 $requires = new html_table_cell($this->required_column($plugin, $pluginman, $version));
1177 $statusisboring = in_array($statuscode, array(
1178 core_plugin_manager
::PLUGIN_STATUS_NODB
, core_plugin_manager
::PLUGIN_STATUS_UPTODATE
));
1180 if ($options['xdep']) {
1181 // we want to see only plugins with failed dependencies
1182 if ($dependenciesok) {
1186 } else if ($statusisboring and $dependenciesok and empty($availableupdates)) {
1187 // no change is going to happen to the plugin - display it only
1188 // if the user wants to see the full list
1189 if (empty($options['full'])) {
1197 // The plugin should be displayed.
1198 $numdisplayed[$type]++
;
1199 $row->cells
= array($displayname, $versiondb, $versiondisk, $requires, $status);
1200 $plugintyperows[] = $row;
1203 if (empty($numdisplayed[$type]) and empty($options['full'])) {
1207 $table->data
[] = $header;
1208 $table->data
= array_merge($table->data
, $plugintyperows);
1211 // Total number of displayed plugins.
1212 $sumdisplayed = array_sum($numdisplayed);
1214 if ($options['xdep']) {
1215 // At the plugins dependencies check page, display the table only.
1216 return html_writer
::table($table);
1219 $out = $this->output
->container_start('', 'plugins-check-info');
1221 if ($sumdisplayed == 0) {
1222 $out .= $this->output
->heading(get_string('pluginchecknone', 'core_plugin'));
1225 if (empty($options['full'])) {
1226 $out .= $this->output
->heading(get_string('plugincheckattention', 'core_plugin'));
1228 $out .= $this->output
->heading(get_string('plugincheckall', 'core_plugin'));
1232 $out .= $this->output
->container_start('actions mb-2');
1234 $installableupdates = $pluginman->filter_installable($pluginman->available_updates());
1235 if ($installableupdates) {
1236 $out .= $this->output
->single_button(
1237 new moodle_url($this->page
->url
, array('installupdatex' => 1)),
1238 get_string('updateavailableinstallall', 'core_admin', count($installableupdates)),
1240 array('class' => 'singlebutton updateavailableinstallall mr-1')
1244 if ($installabortable) {
1245 $out .= $this->output
->single_button(
1246 new moodle_url($this->page
->url
, array('abortinstallx' => 1, 'confirmplugincheck' => 0)),
1247 get_string('cancelinstallall', 'core_plugin', count($installabortable)),
1249 array('class' => 'singlebutton cancelinstallall mr-1')
1253 if ($upgradeabortable) {
1254 $out .= $this->output
->single_button(
1255 new moodle_url($this->page
->url
, array('abortupgradex' => 1)),
1256 get_string('cancelupgradeall', 'core_plugin', count($upgradeabortable)),
1258 array('class' => 'singlebutton cancelupgradeall mr-1')
1262 $out .= html_writer
::div(html_writer
::link(new moodle_url($this->page
->url
, array('showallplugins' => 0)),
1263 get_string('plugincheckattention', 'core_plugin')).' '.html_writer
::span($sumattention, 'badge badge-light'),
1264 'btn btn-link mr-1');
1266 $out .= html_writer
::div(html_writer
::link(new moodle_url($this->page
->url
, array('showallplugins' => 1)),
1267 get_string('plugincheckall', 'core_plugin')).' '.html_writer
::span($sumtotal, 'badge badge-light'),
1268 'btn btn-link mr-1');
1270 $out .= $this->output
->container_end(); // End of .actions container.
1271 $out .= $this->output
->container_end(); // End of #plugins-check-info container.
1273 if ($sumdisplayed > 0 or $options['full']) {
1274 $out .= html_writer
::table($table);
1281 * Display the continue / cancel widgets for the plugins management pages.
1283 * @param null|moodle_url $continue URL for the continue button, should it be displayed
1284 * @param null|moodle_url $cancel URL for the cancel link, defaults to the current page
1285 * @return string HTML
1287 public function plugins_management_confirm_buttons(moodle_url
$continue=null, moodle_url
$cancel=null) {
1289 $out = html_writer
::start_div('plugins-management-confirm-buttons');
1291 if (!empty($continue)) {
1292 $out .= $this->output
->single_button($continue, get_string('continue'), 'post', array('class' => 'continue'));
1295 if (empty($cancel)) {
1296 $cancel = $this->page
->url
;
1298 $out .= html_writer
::div(html_writer
::link($cancel, get_string('cancel')), 'cancel');
1304 * Displays the information about missing dependencies
1306 * @param core_plugin_manager $pluginman
1309 protected function missing_dependencies(core_plugin_manager
$pluginman) {
1311 $dependencies = $pluginman->missing_dependencies();
1313 if (empty($dependencies)) {
1317 $available = array();
1318 $unavailable = array();
1321 foreach ($dependencies as $component => $remoteinfo) {
1322 if ($remoteinfo === false) {
1323 // The required version is not available. Let us check if there
1324 // is at least some version in the plugins directory.
1325 $remoteinfoanyversion = $pluginman->get_remote_plugin_info($component, ANY_VERSION
, false);
1326 if ($remoteinfoanyversion === false) {
1327 $unknown[$component] = $component;
1329 $unavailable[$component] = $remoteinfoanyversion;
1332 $available[$component] = $remoteinfo;
1336 $out = $this->output
->container_start('plugins-check-dependencies mb-4');
1338 if ($unavailable or $unknown) {
1339 $out .= $this->output
->heading(get_string('misdepsunavail', 'core_plugin'));
1341 $out .= $this->output
->render((new \core\output\notification
(get_string('misdepsunknownlist', 'core_plugin',
1342 implode(', ', $unknown))))->set_show_closebutton(false));
1345 $unavailablelist = array();
1346 foreach ($unavailable as $component => $remoteinfoanyversion) {
1347 $unavailablelistitem = html_writer
::link('https://moodle.org/plugins/view.php?plugin='.$component,
1348 '<strong>'.$remoteinfoanyversion->name
.'</strong>');
1349 if ($remoteinfoanyversion->version
) {
1350 $unavailablelistitem .= ' ('.$component.' > '.$remoteinfoanyversion->version
->version
.')';
1352 $unavailablelistitem .= ' ('.$component.')';
1354 $unavailablelist[] = $unavailablelistitem;
1356 $out .= $this->output
->render((new \core\output\notification
(get_string('misdepsunavaillist', 'core_plugin',
1357 implode(', ', $unavailablelist))))->set_show_closebutton(false));
1359 $out .= $this->output
->container_start('plugins-check-dependencies-actions mb-4');
1360 $out .= ' '.html_writer
::link(new moodle_url('/admin/tool/installaddon/'),
1361 get_string('dependencyuploadmissing', 'core_plugin'), array('class' => 'btn btn-secondary'));
1362 $out .= $this->output
->container_end(); // End of .plugins-check-dependencies-actions container.
1366 $out .= $this->output
->heading(get_string('misdepsavail', 'core_plugin'));
1367 $out .= $this->output
->container_start('plugins-check-dependencies-actions mb-2');
1369 $installable = $pluginman->filter_installable($available);
1371 $out .= $this->output
->single_button(
1372 new moodle_url($this->page
->url
, array('installdepx' => 1)),
1373 get_string('dependencyinstallmissing', 'core_plugin', count($installable)),
1375 array('class' => 'singlebutton dependencyinstallmissing d-inline-block mr-1')
1379 $out .= html_writer
::div(html_writer
::link(new moodle_url('/admin/tool/installaddon/'),
1380 get_string('dependencyuploadmissing', 'core_plugin'), array('class' => 'btn btn-link')),
1381 'dependencyuploadmissing d-inline-block mr-1');
1383 $out .= $this->output
->container_end(); // End of .plugins-check-dependencies-actions container.
1385 $out .= $this->available_missing_dependencies_list($pluginman, $available);
1388 $out .= $this->output
->container_end(); // End of .plugins-check-dependencies container.
1394 * Displays the list if available missing dependencies.
1396 * @param core_plugin_manager $pluginman
1397 * @param array $dependencies
1400 protected function available_missing_dependencies_list(core_plugin_manager
$pluginman, array $dependencies) {
1403 $table = new html_table();
1404 $table->id
= 'plugins-check-available-dependencies';
1405 $table->head
= array(
1406 get_string('displayname', 'core_plugin'),
1407 get_string('release', 'core_plugin'),
1408 get_string('version', 'core_plugin'),
1409 get_string('supportedmoodleversions', 'core_plugin'),
1410 get_string('info', 'core'),
1412 $table->colclasses
= array('displayname', 'release', 'version', 'supportedmoodleversions', 'info');
1413 $table->data
= array();
1415 foreach ($dependencies as $plugin) {
1417 $supportedmoodles = array();
1418 foreach ($plugin->version
->supportedmoodles
as $moodle) {
1419 if ($CFG->branch
== str_replace('.', '', $moodle->release
)) {
1420 $supportedmoodles[] = html_writer
::span($moodle->release
, 'badge badge-success');
1422 $supportedmoodles[] = html_writer
::span($moodle->release
, 'badge badge-light');
1426 $requriedby = $pluginman->other_plugins_that_require($plugin->component
);
1428 foreach ($requriedby as $ix => $val) {
1429 $inf = $pluginman->get_plugin_info($val);
1431 $requriedby[$ix] = $inf->displayname
.' ('.$inf->component
.')';
1434 $info = html_writer
::div(
1435 get_string('requiredby', 'core_plugin', implode(', ', $requriedby)),
1442 $info .= $this->output
->container_start('actions');
1444 $info .= html_writer
::div(
1445 html_writer
::link('https://moodle.org/plugins/view.php?plugin='.$plugin->component
,
1446 get_string('misdepinfoplugin', 'core_plugin')),
1447 'misdepinfoplugin d-inline-block mr-3 mb-1'
1450 $info .= html_writer
::div(
1451 html_writer
::link('https://moodle.org/plugins/pluginversion.php?id='.$plugin->version
->id
,
1452 get_string('misdepinfoversion', 'core_plugin')),
1453 'misdepinfoversion d-inline-block mr-3 mb-1'
1456 $info .= html_writer
::div(html_writer
::link($plugin->version
->downloadurl
, get_string('download')),
1457 'misdepdownload d-inline-block mr-3 mb-1');
1459 if ($pluginman->is_remote_plugin_installable($plugin->component
, $plugin->version
->version
, $reason)) {
1460 $info .= $this->output
->single_button(
1461 new moodle_url($this->page
->url
, array('installdep' => $plugin->component
)),
1462 get_string('dependencyinstall', 'core_plugin'),
1464 array('class' => 'singlebutton dependencyinstall mr-3 mb-1')
1467 $reasonhelp = $this->info_remote_plugin_not_installable($reason);
1469 $info .= html_writer
::div($reasonhelp, 'reasonhelp dependencyinstall d-inline-block mr-3 mb-1');
1473 $info .= $this->output
->container_end(); // End of .actions container.
1475 $table->data
[] = array(
1476 html_writer
::div($plugin->name
, 'name').' '.html_writer
::div($plugin->component
, 'component text-muted small'),
1477 $plugin->version
->release
,
1478 $plugin->version
->version
,
1479 implode(' ', $supportedmoodles),
1484 return html_writer
::table($table);
1488 * Explain why {@link core_plugin_manager::is_remote_plugin_installable()} returned false.
1490 * @param string $reason the reason code as returned by the plugin manager
1493 protected function info_remote_plugin_not_installable($reason) {
1495 if ($reason === 'notwritableplugintype' or $reason === 'notwritableplugin') {
1496 return $this->output
->help_icon('notwritable', 'core_plugin', get_string('notwritable', 'core_plugin'));
1499 if ($reason === 'remoteunavailable') {
1500 return $this->output
->help_icon('notdownloadable', 'core_plugin', get_string('notdownloadable', 'core_plugin'));
1507 * Formats the information that needs to go in the 'Requires' column.
1508 * @param \core\plugininfo\base $plugin the plugin we are rendering the row for.
1509 * @param core_plugin_manager $pluginman provides data on all the plugins.
1510 * @param string $version
1511 * @param int $branch the current Moodle branch
1512 * @return string HTML code
1514 protected function required_column(\core\plugininfo\base
$plugin, core_plugin_manager
$pluginman, $version, $branch = null) {
1516 $requires = array();
1517 $displayuploadlink = false;
1518 $displayupdateslink = false;
1520 $requirements = $pluginman->resolve_requirements($plugin, $version, $branch);
1521 foreach ($requirements as $reqname => $reqinfo) {
1522 if ($reqname === 'core') {
1523 if ($reqinfo->status
== $pluginman::REQUIREMENT_STATUS_OK
) {
1524 $class = 'requires-ok text-muted';
1527 $class = 'requires-failed';
1528 $label = html_writer
::span(get_string('dependencyfails', 'core_plugin'), 'badge badge-danger');
1531 if ($branch != null && !$plugin->is_core_compatible_satisfied($branch)) {
1532 $requires[] = html_writer
::tag('li',
1533 html_writer
::span(get_string('incompatibleversion', 'core_plugin', $branch), 'dep dep-core').
1534 ' '.$label, array('class' => $class));
1536 } else if ($branch != null && $plugin->pluginsupported
!= null) {
1537 $requires[] = html_writer
::tag('li',
1538 html_writer
::span(get_string('moodlebranch', 'core_plugin',
1539 array('min' => $plugin->pluginsupported
[0], 'max' => $plugin->pluginsupported
[1])), 'dep dep-core').
1540 ' '.$label, array('class' => $class));
1542 } else if ($reqinfo->reqver
!= ANY_VERSION
) {
1543 $requires[] = html_writer
::tag('li',
1544 html_writer
::span(get_string('moodleversion', 'core_plugin', $plugin->versionrequires
), 'dep dep-core').
1545 ' '.$label, array('class' => $class));
1551 if ($reqinfo->status
== $pluginman::REQUIREMENT_STATUS_OK
) {
1553 $class = 'requires-ok text-muted';
1555 } else if ($reqinfo->status
== $pluginman::REQUIREMENT_STATUS_MISSING
) {
1556 if ($reqinfo->availability
== $pluginman::REQUIREMENT_AVAILABLE
) {
1557 $label = html_writer
::span(get_string('dependencymissing', 'core_plugin'), 'badge badge-warning');
1558 $label .= ' '.html_writer
::span(get_string('dependencyavailable', 'core_plugin'), 'badge badge-warning');
1559 $class = 'requires-failed requires-missing requires-available';
1560 $actions[] = html_writer
::link(
1561 new moodle_url('https://moodle.org/plugins/view.php', array('plugin' => $reqname)),
1562 get_string('misdepinfoplugin', 'core_plugin')
1566 $label = html_writer
::span(get_string('dependencymissing', 'core_plugin'), 'badge badge-danger');
1567 $label .= ' '.html_writer
::span(get_string('dependencyunavailable', 'core_plugin'),
1568 'badge badge-danger');
1569 $class = 'requires-failed requires-missing requires-unavailable';
1571 $displayuploadlink = true;
1573 } else if ($reqinfo->status
== $pluginman::REQUIREMENT_STATUS_OUTDATED
) {
1574 if ($reqinfo->availability
== $pluginman::REQUIREMENT_AVAILABLE
) {
1575 $label = html_writer
::span(get_string('dependencyfails', 'core_plugin'), 'badge badge-warning');
1576 $label .= ' '.html_writer
::span(get_string('dependencyavailable', 'core_plugin'), 'badge badge-warning');
1577 $class = 'requires-failed requires-outdated requires-available';
1578 $displayupdateslink = true;
1581 $label = html_writer
::span(get_string('dependencyfails', 'core_plugin'), 'badge badge-danger');
1582 $label .= ' '.html_writer
::span(get_string('dependencyunavailable', 'core_plugin'),
1583 'badge badge-danger');
1584 $class = 'requires-failed requires-outdated requires-unavailable';
1586 $displayuploadlink = true;
1589 if ($reqinfo->reqver
!= ANY_VERSION
) {
1590 $str = 'otherpluginversion';
1592 $str = 'otherplugin';
1595 $requires[] = html_writer
::tag('li', html_writer
::span(
1596 get_string($str, 'core_plugin', array('component' => $reqname, 'version' => $reqinfo->reqver
)),
1597 'dep dep-plugin').' '.$label.' '.html_writer
::span(implode(' | ', $actions), 'actions'),
1598 array('class' => $class)
1607 $out = html_writer
::tag('ul', implode("\n", $requires), array('class' => 'm-0'));
1609 if ($displayuploadlink) {
1610 $out .= html_writer
::div(
1612 new moodle_url('/admin/tool/installaddon/'),
1613 get_string('dependencyuploadmissing', 'core_plugin'),
1614 array('class' => 'btn btn-secondary btn-sm m-1')
1616 'dependencyuploadmissing'
1620 if ($displayupdateslink) {
1621 $out .= html_writer
::div(
1623 new moodle_url($this->page
->url
, array('sesskey' => sesskey(), 'fetchupdates' => 1)),
1624 get_string('checkforupdates', 'core_plugin'),
1625 array('class' => 'btn btn-secondary btn-sm m-1')
1631 // Check if supports is present, and $branch is not in, only if $incompatible check was ok.
1632 if ($plugin->pluginsupported
!= null && $class == 'requires-ok' && $branch != null) {
1633 if ($pluginman->check_explicitly_supported($plugin, $branch) == $pluginman::VERSION_NOT_SUPPORTED
) {
1634 $out .= html_writer
::div(get_string('notsupported', 'core_plugin', $branch));
1643 * Prints an overview about the plugins - number of installed, number of extensions etc.
1645 * @param core_plugin_manager $pluginman provides information about the plugins
1646 * @param array $options filtering options
1647 * @return string as usually
1649 public function plugins_overview_panel(core_plugin_manager
$pluginman, array $options = array()) {
1651 $plugininfo = $pluginman->get_plugins();
1653 $numtotal = $numextension = $numupdatable = $numinstallable = 0;
1655 foreach ($plugininfo as $type => $plugins) {
1656 foreach ($plugins as $name => $plugin) {
1657 if ($res = $plugin->available_updates()) {
1659 foreach ($res as $updateinfo) {
1660 if ($pluginman->is_remote_plugin_installable($updateinfo->component
, $updateinfo->version
, $reason, false)) {
1666 if ($plugin->get_status() === core_plugin_manager
::PLUGIN_STATUS_MISSING
) {
1670 if (!$plugin->is_standard()) {
1676 $infoall = html_writer
::link(
1677 new moodle_url($this->page
->url
, array('contribonly' => 0, 'updatesonly' => 0)),
1678 get_string('overviewall', 'core_plugin'),
1679 array('title' => get_string('filterall', 'core_plugin'))
1680 ).' '.html_writer
::span($numtotal, 'badge number number-all');
1682 $infoext = html_writer
::link(
1683 new moodle_url($this->page
->url
, array('contribonly' => 1, 'updatesonly' => 0)),
1684 get_string('overviewext', 'core_plugin'),
1685 array('title' => get_string('filtercontribonly', 'core_plugin'))
1686 ).' '.html_writer
::span($numextension, 'badge number number-additional');
1688 if ($numupdatable) {
1689 $infoupdatable = html_writer
::link(
1690 new moodle_url($this->page
->url
, array('contribonly' => 0, 'updatesonly' => 1)),
1691 get_string('overviewupdatable', 'core_plugin'),
1692 array('title' => get_string('filterupdatesonly', 'core_plugin'))
1693 ).' '.html_writer
::span($numupdatable, 'badge badge-info number number-updatable');
1695 // No updates, or the notifications disabled.
1696 $infoupdatable = '';
1699 $out = html_writer
::start_div('', array('id' => 'plugins-overview-panel'));
1701 if (!empty($options['updatesonly'])) {
1702 $out .= $this->output
->heading(get_string('overviewupdatable', 'core_plugin'), 3);
1703 } else if (!empty($options['contribonly'])) {
1704 $out .= $this->output
->heading(get_string('overviewext', 'core_plugin'), 3);
1707 if ($numinstallable) {
1708 $out .= $this->output
->single_button(
1709 new moodle_url($this->page
->url
, array('installupdatex' => 1)),
1710 get_string('updateavailableinstallall', 'core_admin', $numinstallable),
1712 array('class' => 'singlebutton updateavailableinstallall')
1716 $out .= html_writer
::div($infoall, 'info info-all').
1717 html_writer
::div($infoext, 'info info-ext').
1718 html_writer
::div($infoupdatable, 'info info-updatable');
1720 $out .= html_writer
::end_div(); // End of #plugins-overview-panel block.
1726 * Displays all known plugins and links to manage them
1728 * This default implementation renders all plugins into one big table.
1730 * @param core_plugin_manager $pluginman provides information about the plugins.
1731 * @param array $options filtering options
1732 * @return string HTML code
1734 public function plugins_control_panel(core_plugin_manager
$pluginman, array $options = array()) {
1736 $plugininfo = $pluginman->get_plugins();
1738 // Filter the list of plugins according the options.
1739 if (!empty($options['updatesonly'])) {
1740 $updateable = array();
1741 foreach ($plugininfo as $plugintype => $pluginnames) {
1742 foreach ($pluginnames as $pluginname => $pluginfo) {
1743 $pluginavailableupdates = $pluginfo->available_updates();
1744 if (!empty($pluginavailableupdates)) {
1745 foreach ($pluginavailableupdates as $pluginavailableupdate) {
1746 $updateable[$plugintype][$pluginname] = $pluginfo;
1751 $plugininfo = $updateable;
1754 if (!empty($options['contribonly'])) {
1755 $contribs = array();
1756 foreach ($plugininfo as $plugintype => $pluginnames) {
1757 foreach ($pluginnames as $pluginname => $pluginfo) {
1758 if (!$pluginfo->is_standard()) {
1759 $contribs[$plugintype][$pluginname] = $pluginfo;
1763 $plugininfo = $contribs;
1766 if (empty($plugininfo)) {
1770 $table = new html_table();
1771 $table->id
= 'plugins-control-panel';
1772 $table->head
= array(
1773 get_string('displayname', 'core_plugin'),
1774 get_string('version', 'core_plugin'),
1775 get_string('availability', 'core_plugin'),
1776 get_string('actions', 'core_plugin'),
1777 get_string('notes','core_plugin'),
1779 $table->headspan
= array(1, 1, 1, 2, 1);
1780 $table->colclasses
= array(
1781 'pluginname', 'version', 'availability', 'settings', 'uninstall', 'notes'
1784 foreach ($plugininfo as $type => $plugins) {
1785 $heading = $pluginman->plugintype_name_plural($type);
1786 $pluginclass = core_plugin_manager
::resolve_plugininfo_class($type);
1787 if ($manageurl = $pluginclass::get_manage_url()) {
1788 $heading .= $this->output
->action_icon($manageurl, new pix_icon('i/settings',
1789 get_string('settings', 'core_plugin')));
1791 $header = new html_table_cell(html_writer
::tag('span', $heading, array('id'=>'plugin_type_cell_'.$type)));
1792 $header->header
= true;
1793 $header->colspan
= array_sum($table->headspan
);
1794 $header = new html_table_row(array($header));
1795 $header->attributes
['class'] = 'plugintypeheader type-' . $type;
1796 $table->data
[] = $header;
1798 if (empty($plugins)) {
1799 $msg = new html_table_cell(get_string('noneinstalled', 'core_plugin'));
1800 $msg->colspan
= array_sum($table->headspan
);
1801 $row = new html_table_row(array($msg));
1802 $row->attributes
['class'] .= 'msg msg-noneinstalled';
1803 $table->data
[] = $row;
1807 foreach ($plugins as $name => $plugin) {
1808 $row = new html_table_row();
1809 $row->attributes
['class'] = 'type-' . $plugin->type
. ' name-' . $plugin->type
. '_' . $plugin->name
;
1811 if ($this->page
->theme
->resolve_image_location('icon', $plugin->type
. '_' . $plugin->name
, null)) {
1812 $icon = $this->output
->pix_icon('icon', '', $plugin->type
. '_' . $plugin->name
, array('class' => 'icon pluginicon'));
1814 $icon = $this->output
->spacer();
1816 $status = $plugin->get_status();
1817 $row->attributes
['class'] .= ' status-'.$status;
1818 $pluginname = html_writer
::tag('div', $icon.$plugin->displayname
, array('class' => 'displayname')).
1819 html_writer
::tag('div', $plugin->component
, array('class' => 'componentname'));
1820 $pluginname = new html_table_cell($pluginname);
1822 $version = html_writer
::div($plugin->versiondb
, 'versionnumber');
1823 if ((string)$plugin->release
!== '') {
1824 $version = html_writer
::div($plugin->release
, 'release').$version;
1826 $version = new html_table_cell($version);
1828 $isenabled = $plugin->is_enabled();
1829 if (is_null($isenabled)) {
1830 $availability = new html_table_cell('');
1831 } else if ($isenabled) {
1832 $row->attributes
['class'] .= ' enabled';
1833 $availability = new html_table_cell(get_string('pluginenabled', 'core_plugin'));
1835 $row->attributes
['class'] .= ' disabled';
1836 $availability = new html_table_cell(get_string('plugindisabled', 'core_plugin'));
1839 $settingsurl = $plugin->get_settings_url();
1840 if (!is_null($settingsurl)) {
1841 $settings = html_writer
::link($settingsurl, get_string('settings', 'core_plugin'), array('class' => 'settings'));
1845 $settings = new html_table_cell($settings);
1847 if ($uninstallurl = $pluginman->get_uninstall_url($plugin->component
, 'overview')) {
1848 $uninstall = html_writer
::link($uninstallurl, get_string('uninstall', 'core_plugin'));
1852 $uninstall = new html_table_cell($uninstall);
1854 if ($plugin->is_standard()) {
1855 $row->attributes
['class'] .= ' standard';
1858 $row->attributes
['class'] .= ' extension';
1859 $source = html_writer
::div(get_string('sourceext', 'core_plugin'), 'source badge badge-info');
1862 if ($status === core_plugin_manager
::PLUGIN_STATUS_MISSING
) {
1863 $msg = html_writer
::div(get_string('status_missing', 'core_plugin'), 'statusmsg badge badge-danger');
1864 } else if ($status === core_plugin_manager
::PLUGIN_STATUS_NEW
) {
1865 $msg = html_writer
::div(get_string('status_new', 'core_plugin'), 'statusmsg badge badge-success');
1870 $requriedby = $pluginman->other_plugins_that_require($plugin->component
);
1872 $requiredby = html_writer
::tag('div', get_string('requiredby', 'core_plugin', implode(', ', $requriedby)),
1873 array('class' => 'requiredby'));
1879 if (is_array($plugin->available_updates())) {
1880 foreach ($plugin->available_updates() as $availableupdate) {
1881 $updateinfo .= $this->plugin_available_update_info($pluginman, $availableupdate);
1885 $notes = new html_table_cell($source.$msg.$requiredby.$updateinfo);
1887 $row->cells
= array(
1888 $pluginname, $version, $availability, $settings, $uninstall, $notes
1890 $table->data
[] = $row;
1894 return html_writer
::table($table);
1898 * Helper method to render the information about the available plugin update
1900 * @param core_plugin_manager $pluginman plugin manager instance
1901 * @param \core\update\info $updateinfo information about the available update for the plugin
1903 protected function plugin_available_update_info(core_plugin_manager
$pluginman, \core\update\info
$updateinfo) {
1905 $boxclasses = 'pluginupdateinfo';
1908 if (isset($updateinfo->release
)) {
1909 $info[] = html_writer
::div(
1910 get_string('updateavailable_release', 'core_plugin', $updateinfo->release
),
1915 if (isset($updateinfo->maturity
)) {
1916 $info[] = html_writer
::div(
1917 get_string('maturity'.$updateinfo->maturity
, 'core_admin'),
1920 $boxclasses .= ' maturity'.$updateinfo->maturity
;
1923 if (isset($updateinfo->download
)) {
1924 $info[] = html_writer
::div(
1925 html_writer
::link($updateinfo->download
, get_string('download')),
1930 if (isset($updateinfo->url
)) {
1931 $info[] = html_writer
::div(
1932 html_writer
::link($updateinfo->url
, get_string('updateavailable_moreinfo', 'core_plugin')),
1937 $box = html_writer
::start_div($boxclasses);
1938 $box .= html_writer
::div(
1939 get_string('updateavailable', 'core_plugin', $updateinfo->version
),
1942 $box .= html_writer
::div(
1943 implode(html_writer
::span(' ', 'separator'), $info),
1947 if ($pluginman->is_remote_plugin_installable($updateinfo->component
, $updateinfo->version
, $reason, false)) {
1948 $box .= $this->output
->single_button(
1949 new moodle_url($this->page
->url
, array('installupdate' => $updateinfo->component
,
1950 'installupdateversion' => $updateinfo->version
)),
1951 get_string('updateavailableinstall', 'core_admin'),
1953 array('class' => 'singlebutton updateavailableinstall')
1956 $reasonhelp = $this->info_remote_plugin_not_installable($reason);
1958 $box .= html_writer
::div($reasonhelp, 'reasonhelp updateavailableinstall');
1961 $box .= html_writer
::end_div();
1967 * This function will render one beautiful table with all the environmental
1968 * configuration and how it suits Moodle needs.
1970 * @param boolean $result final result of the check (true/false)
1971 * @param environment_results[] $environment_results array of results gathered
1972 * @return string HTML to output.
1974 public function environment_check_table($result, $environment_results) {
1978 $servertable = new html_table();//table for server checks
1979 $servertable->head
= array(
1982 get_string('report'),
1983 get_string('plugin'),
1984 get_string('status'),
1986 $servertable->colclasses
= array('centeralign name', 'centeralign info', 'leftalign report', 'leftalign plugin', 'centeralign status');
1987 $servertable->attributes
['class'] = 'admintable environmenttable generaltable table-sm';
1988 $servertable->id
= 'serverstatus';
1990 $serverdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
1992 $othertable = new html_table();//table for custom checks
1993 $othertable->head
= array(
1995 get_string('report'),
1996 get_string('plugin'),
1997 get_string('status'),
1999 $othertable->colclasses
= array('aligncenter info', 'alignleft report', 'alignleft plugin', 'aligncenter status');
2000 $othertable->attributes
['class'] = 'admintable environmenttable generaltable table-sm';
2001 $othertable->id
= 'otherserverstatus';
2003 $otherdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
2005 // Iterate over each environment_result
2007 foreach ($environment_results as $environment_result) {
2009 $warningline = false;
2012 $type = $environment_result->getPart();
2013 $info = $environment_result->getInfo();
2014 $status = $environment_result->getStatus();
2015 $plugin = $environment_result->getPluginName();
2016 $error_code = $environment_result->getErrorCode();
2017 // Process Report field
2018 $rec = new stdClass();
2019 // Something has gone wrong at parsing time
2021 $stringtouse = 'environmentxmlerror';
2022 $rec->error_code
= $error_code;
2023 $status = get_string('error');
2029 if ($rec->needed
= $environment_result->getNeededVersion()) {
2030 // We are comparing versions
2031 $rec->current
= $environment_result->getCurrentVersion();
2032 if ($environment_result->getLevel() == 'required') {
2033 $stringtouse = 'environmentrequireversion';
2035 $stringtouse = 'environmentrecommendversion';
2038 } else if ($environment_result->getPart() == 'custom_check') {
2039 // We are checking installed & enabled things
2040 if ($environment_result->getLevel() == 'required') {
2041 $stringtouse = 'environmentrequirecustomcheck';
2043 $stringtouse = 'environmentrecommendcustomcheck';
2046 } else if ($environment_result->getPart() == 'php_setting') {
2048 $stringtouse = 'environmentsettingok';
2049 } else if ($environment_result->getLevel() == 'required') {
2050 $stringtouse = 'environmentmustfixsetting';
2052 $stringtouse = 'environmentshouldfixsetting';
2056 if ($environment_result->getLevel() == 'required') {
2057 $stringtouse = 'environmentrequireinstall';
2059 $stringtouse = 'environmentrecommendinstall';
2063 // Calculate the status value
2064 if ($environment_result->getBypassStr() != '') { //Handle bypassed result (warning)
2065 $status = get_string('bypassed');
2066 $warningline = true;
2067 } else if ($environment_result->getRestrictStr() != '') { //Handle restricted result (error)
2068 $status = get_string('restricted');
2071 if ($status) { //Handle ok result (ok)
2072 $status = get_string('ok');
2074 if ($environment_result->getLevel() == 'optional') {//Handle check result (warning)
2075 $status = get_string('check');
2076 $warningline = true;
2077 } else { //Handle error result (error)
2078 $status = get_string('check');
2086 $linkparts = array();
2087 $linkparts[] = 'admin/environment';
2088 $linkparts[] = $type;
2090 $linkparts[] = $info;
2092 // Plugin environments do not have docs pages yet.
2093 if (empty($CFG->docroot
) or $environment_result->plugin
) {
2094 $report = get_string($stringtouse, 'admin', $rec);
2096 $report = $this->doc_link(join('/', $linkparts), get_string($stringtouse, 'admin', $rec), true);
2098 // Enclose report text in div so feedback text will be displayed underneath it.
2099 $report = html_writer
::div($report);
2101 // Format error or warning line
2103 $messagetype = 'error';
2104 $statusclass = 'badge-danger';
2105 } else if ($warningline) {
2106 $messagetype = 'warn';
2107 $statusclass = 'badge-warning';
2109 $messagetype = 'ok';
2110 $statusclass = 'badge-success';
2112 $status = html_writer
::span($status, 'badge ' . $statusclass);
2113 // Here we'll store all the feedback found
2115 // Append the feedback if there is some
2116 $feedbacktext .= $environment_result->strToReport($environment_result->getFeedbackStr(), $messagetype);
2117 //Append the bypass if there is some
2118 $feedbacktext .= $environment_result->strToReport($environment_result->getBypassStr(), 'warn');
2119 //Append the restrict if there is some
2120 $feedbacktext .= $environment_result->strToReport($environment_result->getRestrictStr(), 'error');
2122 $report .= $feedbacktext;
2124 // Add the row to the table
2125 if ($environment_result->getPart() == 'custom_check'){
2126 $otherdata[$messagetype][] = array ($info, $report, $plugin, $status);
2128 $serverdata[$messagetype][] = array ($type, $info, $report, $plugin, $status);
2133 //put errors first in
2134 $servertable->data
= array_merge($serverdata['error'], $serverdata['warn'], $serverdata['ok']);
2135 $othertable->data
= array_merge($otherdata['error'], $otherdata['warn'], $otherdata['ok']);
2139 $output .= $this->heading(get_string('serverchecks', 'admin'));
2140 $output .= html_writer
::table($servertable);
2141 if (count($othertable->data
)){
2142 $output .= $this->heading(get_string('customcheck', 'admin'));
2143 $output .= html_writer
::table($othertable);
2146 // Finally, if any error has happened, print the summary box
2148 $output .= $this->box(get_string('environmenterrortodo', 'admin'), 'environmentbox errorbox');
2155 * Render a simple page for providing the upgrade key.
2157 * @param moodle_url|string $url
2160 public function upgradekey_form_page($url) {
2163 $output .= $this->header();
2164 $output .= $this->container_start('upgradekeyreq');
2165 $output .= $this->heading(get_string('upgradekeyreq', 'core_admin'));
2166 $output .= html_writer
::start_tag('form', array('method' => 'POST', 'action' => $url));
2167 $output .= html_writer
::empty_tag('input', [
2168 'name' => 'upgradekey',
2169 'type' => 'password',
2170 'class' => 'form-control w-auto',
2172 $output .= html_writer
::empty_tag('input', [
2174 'value' => get_string('submit'),
2175 'class' => 'btn btn-primary mt-3',
2177 $output .= html_writer
::end_tag('form');
2178 $output .= $this->container_end();
2179 $output .= $this->footer();
2185 * Check to see if writing to the deprecated legacy log store is enabled.
2187 * @return string An error message if writing to the legacy log store is enabled.
2189 protected function legacy_log_store_writing_error() {
2190 $enabled = get_config('logstore_legacy', 'loglegacy');
2191 $plugins = explode(',', get_config('tool_log', 'enabled_stores'));
2192 $enabled = $enabled && in_array('logstore_legacy', $plugins);
2195 return $this->warning(get_string('legacylogginginuse'));
2200 * Display message about the benefits of registering on Moodle.org
2204 public function moodleorg_registration_message() {
2206 $out = format_text(get_string('registerwithmoodleorginfo', 'core_hub'), FORMAT_MARKDOWN
);
2208 $out .= html_writer
::link(
2209 new moodle_url('/admin/settings.php', ['section' => 'moodleservices']),
2210 $this->output
->pix_icon('i/info', '').' '.get_string('registerwithmoodleorginfoapp', 'core_hub'),
2211 ['class' => 'btn btn-link', 'role' => 'opener', 'target' => '_href']
2214 $out .= html_writer
::link(
2215 HUB_MOODLEORGHUBURL
,
2216 $this->output
->pix_icon('i/stats', '').' '.get_string('registerwithmoodleorginfostats', 'core_hub'),
2217 ['class' => 'btn btn-link', 'role' => 'opener', 'target' => '_href']
2220 $out .= html_writer
::link(
2221 HUB_MOODLEORGHUBURL
.'/sites',
2222 $this->output
->pix_icon('i/location', '').' '.get_string('registerwithmoodleorginfosites', 'core_hub'),
2223 ['class' => 'btn btn-link', 'role' => 'opener', 'target' => '_href']
2226 return $this->output
->box($out);
2230 * Display message about benefits of enabling the user feedback feature.
2232 * @param bool $showfeedbackencouragement Whether the encouragement content should be displayed or not
2235 protected function userfeedback_encouragement(bool $showfeedbackencouragement): string {
2238 if ($showfeedbackencouragement) {
2239 $settingslink = new moodle_url('/admin/settings.php', ['section' => 'userfeedback']);
2240 $output .= $this->warning(get_string('userfeedbackencouragement', 'admin', $settingslink->out()), 'info');
2247 * Display a warning about the deprecation of Mnet.
2249 * @param string $xmlrpcwarning The warning message
2250 * @return string HTML to output.
2252 protected function mnet_deprecation_warning($xmlrpcwarning) {
2253 if (empty($xmlrpcwarning)) {
2257 return $this->warning($xmlrpcwarning);