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 * Standard HTML output 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
25 class core_admin_renderer
extends plugin_renderer_base
{
28 * Display the 'Do you acknowledge the terms of the GPL' page. The first page
30 * @return string HTML to output.
32 public function install_licence_page() {
36 $copyrightnotice = text_to_html(get_string('gpl3'));
37 $copyrightnotice = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $copyrightnotice); // extremely ugly validation hack
39 $continue = new single_button(new moodle_url($this->page
->url
, array(
40 'lang' => $CFG->lang
, 'agreelicense' => 1)), get_string('continue'), 'get');
42 $output .= $this->header();
43 $output .= $this->heading('<a href="http://moodle.org">Moodle</a> - Modular Object-Oriented Dynamic Learning Environment');
44 $output .= $this->heading(get_string('copyrightnotice'));
45 $output .= $this->box($copyrightnotice, 'copyrightnotice');
46 $output .= html_writer
::empty_tag('br');
47 $output .= $this->confirm(get_string('doyouagree'), $continue, "https://moodledev.io/general/license");
48 $output .= $this->footer();
54 * Display page explaining proper upgrade process,
55 * there can not be any PHP file leftovers...
57 * @return string HTML to output.
59 public function upgrade_stale_php_files_page() {
61 $output .= $this->header();
62 $output .= $this->heading(get_string('upgradestalefiles', 'admin'));
63 $output .= $this->box_start('generalbox', 'notice');
64 $output .= format_text(get_string('upgradestalefilesinfo', 'admin', get_docs_url('Upgrading')), FORMAT_MARKDOWN
);
65 $output .= html_writer
::empty_tag('br');
66 $output .= html_writer
::tag('div', $this->single_button($this->page
->url
, get_string('reload'), 'get'), array('class' => 'buttons'));
67 $output .= $this->box_end();
68 $output .= $this->footer();
74 * Display the 'environment check' page that is displayed during install.
75 * @param int $maturity
76 * @param boolean $envstatus final result of the check (true/false)
77 * @param array $environment_results array of results gathered
78 * @param string $release moodle release
79 * @return string HTML to output.
81 public function install_environment_page($maturity, $envstatus, $environment_results, $release) {
85 $output .= $this->header();
86 $output .= $this->maturity_warning($maturity);
87 $output .= $this->heading("Moodle $release");
88 $output .= $this->release_notes_link();
90 $output .= $this->environment_check_table($envstatus, $environment_results);
93 $output .= $this->upgrade_reload(new moodle_url($this->page
->url
, array('agreelicense' => 1, 'lang' => $CFG->lang
)));
95 $output .= $this->notification(get_string('environmentok', 'admin'), 'notifysuccess');
96 $output .= $this->continue_button(new moodle_url($this->page
->url
, array(
97 'agreelicense' => 1, 'confirmrelease' => 1, 'lang' => $CFG->lang
)));
100 $output .= $this->footer();
105 * Displays the list of plugins with unsatisfied dependencies
107 * @param double|string|int $version Moodle on-disk version
108 * @param array $failed list of plugins with unsatisfied dependecies
109 * @param moodle_url $reloadurl URL of the page to recheck the dependencies
110 * @return string HTML
112 public function unsatisfied_dependencies_page($version, array $failed, moodle_url
$reloadurl) {
115 $output .= $this->header();
116 $output .= $this->heading(get_string('pluginscheck', 'admin'));
117 $output .= $this->warning(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
118 $output .= $this->plugins_check_table(core_plugin_manager
::instance(), $version, array('xdep' => true));
119 $output .= $this->warning(get_string('pluginschecktodo', 'admin'));
120 $output .= $this->continue_button($reloadurl);
122 $output .= $this->footer();
128 * Display the 'You are about to upgrade Moodle' page. The first page
130 * @param string $strnewversion
131 * @param int $maturity
132 * @param string $testsite
133 * @return string HTML to output.
135 public function upgrade_confirm_page($strnewversion, $maturity, $testsite) {
138 $continueurl = new moodle_url($this->page
->url
, array('confirmupgrade' => 1, 'cache' => 0));
139 $continue = new single_button($continueurl, get_string('continue'), 'get');
140 $cancelurl = new moodle_url('/admin/index.php');
142 $output .= $this->header();
143 $output .= $this->maturity_warning($maturity);
144 $output .= $this->test_site_warning($testsite);
145 $output .= $this->confirm(get_string('upgradesure', 'admin', $strnewversion), $continue, $cancelurl);
146 $output .= $this->footer();
152 * Display the environment page during the upgrade process.
153 * @param string $release
154 * @param boolean $envstatus final result of env check (true/false)
155 * @param array $environment_results array of results gathered
156 * @return string HTML to output.
158 public function upgrade_environment_page($release, $envstatus, $environment_results) {
162 $output .= $this->header();
163 $output .= $this->heading("Moodle $release");
164 $output .= $this->release_notes_link();
165 $output .= $this->environment_check_table($envstatus, $environment_results);
168 $output .= $this->upgrade_reload(new moodle_url($this->page
->url
, array('confirmupgrade' => 1, 'cache' => 0)));
171 $output .= $this->notification(get_string('environmentok', 'admin'), 'notifysuccess');
173 if (empty($CFG->skiplangupgrade
) and current_language() !== 'en') {
174 $output .= $this->box(get_string('langpackwillbeupdated', 'admin'), 'generalbox', 'notice');
177 $output .= $this->continue_button(new moodle_url($this->page
->url
, array(
178 'confirmupgrade' => 1, 'confirmrelease' => 1, 'cache' => 0)));
181 $output .= $this->footer();
187 * Display the upgrade page that lists all the plugins that require attention.
188 * @param core_plugin_manager $pluginman provides information about the plugins.
189 * @param \core\update\checker $checker provides information about available updates.
190 * @param int $version the version of the Moodle code from version.php.
191 * @param bool $showallplugins
192 * @param moodle_url $reloadurl
193 * @param moodle_url $continueurl
194 * @return string HTML to output.
196 public function upgrade_plugin_check_page(core_plugin_manager
$pluginman, \core\update\checker
$checker,
197 $version, $showallplugins, $reloadurl, $continueurl) {
201 $output .= $this->header();
202 $output .= $this->box_start('generalbox', 'plugins-check-page');
203 $output .= html_writer
::tag('p', get_string('pluginchecknotice', 'core_plugin'), array('class' => 'page-description'));
204 $output .= $this->check_for_updates_button($checker, $reloadurl);
205 $output .= $this->missing_dependencies($pluginman);
206 $output .= $this->plugins_check_table($pluginman, $version, array('full' => $showallplugins));
207 $output .= $this->box_end();
208 $output .= $this->upgrade_reload($reloadurl);
210 if ($pluginman->some_plugins_updatable()) {
211 $output .= $this->container_start('upgradepluginsinfo');
212 $output .= $this->help_icon('upgradepluginsinfo', 'core_admin', get_string('upgradepluginsfirst', 'core_admin'));
213 $output .= $this->container_end();
216 $button = new single_button($continueurl, get_string('upgradestart', 'admin'), 'get', single_button
::BUTTON_PRIMARY
);
217 $button->class = 'continuebutton';
218 $output .= $this->render($button);
219 $output .= $this->footer();
225 * Display a page to confirm plugin installation cancelation.
227 * @param array $abortable list of \core\update\plugininfo
228 * @param moodle_url $continue
231 public function upgrade_confirm_abort_install_page(array $abortable, moodle_url
$continue) {
233 $pluginman = core_plugin_manager
::instance();
235 if (empty($abortable)) {
236 // The UI should not allow this.
237 throw new moodle_exception('err_no_plugin_install_abortable', 'core_plugin');
240 $out = $this->output
->header();
241 $out .= $this->output
->heading(get_string('cancelinstallhead', 'core_plugin'), 3);
242 $out .= $this->output
->container(get_string('cancelinstallinfo', 'core_plugin'), 'cancelinstallinfo');
244 foreach ($abortable as $pluginfo) {
245 $out .= $this->output
->heading($pluginfo->displayname
.' ('.$pluginfo->component
.')', 4);
246 $out .= $this->output
->container(get_string('cancelinstallinfodir', 'core_plugin', $pluginfo->rootdir
));
247 if ($repotype = $pluginman->plugin_external_source($pluginfo->component
)) {
248 $out .= $this->output
->container(get_string('uninstalldeleteconfirmexternal', 'core_plugin', $repotype),
249 'alert alert-warning mt-2');
253 $out .= $this->plugins_management_confirm_buttons($continue, $this->page
->url
);
254 $out .= $this->output
->footer();
260 * Display the admin notifications page.
261 * @param int $maturity
262 * @param bool $insecuredataroot warn dataroot is invalid
263 * @param bool $errorsdisplayed warn invalid dispaly error setting
264 * @param bool $cronoverdue warn cron not running
265 * @param bool $dbproblems warn db has problems
266 * @param bool $maintenancemode warn in maintenance mode
267 * @param bool $buggyiconvnomb warn iconv problems
268 * @param array|null $availableupdates array of \core\update\info objects or null
269 * @param int|null $availableupdatesfetch timestamp of the most recent updates fetch or null (unknown)
270 * @param string[] $cachewarnings An array containing warnings from the Cache API.
271 * @param array $eventshandlers Events 1 API handlers.
272 * @param bool $themedesignermode Warn about the theme designer mode.
273 * @param bool $devlibdir Warn about development libs directory presence.
274 * @param bool $mobileconfigured Whether the mobile web services have been enabled
275 * @param bool $overridetossl Whether or not ssl is being forced.
276 * @param bool $invalidforgottenpasswordurl Whether the forgotten password URL does not link to a valid URL.
277 * @param bool $croninfrequent If true, warn that cron hasn't run in the past few minutes
278 * @param bool $showcampaigncontent Whether the campaign content should be visible or not.
279 * @param bool $showfeedbackencouragement Whether the feedback encouragement content should be displayed or not.
280 * @param bool $showservicesandsupport Whether the services and support content should be displayed or not.
281 * @param string $xmlrpcwarning XML-RPC deprecation warning message.
283 * @return string HTML to output.
285 public function admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed,
286 $cronoverdue, $dbproblems, $maintenancemode, $availableupdates, $availableupdatesfetch,
287 $buggyiconvnomb, $registered, array $cachewarnings = array(), $eventshandlers = 0,
288 $themedesignermode = false, $devlibdir = false, $mobileconfigured = false,
289 $overridetossl = false, $invalidforgottenpasswordurl = false, $croninfrequent = false,
290 $showcampaigncontent = false, bool $showfeedbackencouragement = false, bool $showservicesandsupport = false,
291 $xmlrpcwarning = '') {
296 $output .= $this->header();
297 $output .= $this->output
->heading(get_string('notifications', 'admin'));
298 $output .= $this->upgrade_news_message();
299 $output .= $this->maturity_info($maturity);
300 $output .= empty($CFG->disableupdatenotifications
) ?
$this->available_updates($availableupdates, $availableupdatesfetch) : '';
301 $output .= $this->insecure_dataroot_warning($insecuredataroot);
302 $output .= $this->development_libs_directories_warning($devlibdir);
303 $output .= $this->themedesignermode_warning($themedesignermode);
304 $output .= $this->display_errors_warning($errorsdisplayed);
305 $output .= $this->buggy_iconv_warning($buggyiconvnomb);
306 $output .= $this->cron_overdue_warning($cronoverdue);
307 $output .= $this->cron_infrequent_warning($croninfrequent);
308 $output .= $this->db_problems($dbproblems);
309 $output .= $this->maintenance_mode_warning($maintenancemode);
310 $output .= $this->overridetossl_warning($overridetossl);
311 $output .= $this->cache_warnings($cachewarnings);
312 $output .= $this->events_handlers($eventshandlers);
313 $output .= $this->registration_warning($registered);
314 $output .= $this->mobile_configuration_warning($mobileconfigured);
315 $output .= $this->forgotten_password_url_warning($invalidforgottenpasswordurl);
316 $output .= $this->mnet_deprecation_warning($xmlrpcwarning);
317 $output .= $this->userfeedback_encouragement($showfeedbackencouragement);
318 $output .= $this->services_and_support_content($showservicesandsupport);
319 $output .= $this->campaign_content($showcampaigncontent);
321 //////////////////////////////////////////////////////////////////////////////////////////////////
322 //// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO HIDE, REMOVE OR MODIFY THIS COPYRIGHT NOTICE ///
323 $output .= $this->moodle_copyright();
324 //////////////////////////////////////////////////////////////////////////////////////////////////
326 $output .= $this->footer();
332 * Display the plugin management page (admin/plugins.php).
334 * The filtering options array may contain following items:
335 * bool contribonly - show only contributed extensions
336 * bool updatesonly - show only plugins with an available update
338 * @param core_plugin_manager $pluginman
339 * @param \core\update\checker $checker
340 * @param array $options filtering options
341 * @return string HTML to output.
343 public function plugin_management_page(core_plugin_manager
$pluginman, \core\update\checker
$checker, array $options = array()) {
347 $output .= $this->header();
348 $output .= $this->heading(get_string('pluginsoverview', 'core_admin'));
349 $output .= $this->check_for_updates_button($checker, $this->page
->url
);
350 $output .= $this->plugins_overview_panel($pluginman, $options);
351 $output .= $this->plugins_control_panel($pluginman, $options);
352 $output .= $this->footer();
358 * Renders a button to fetch for available updates.
360 * @param \core\update\checker $checker
361 * @param moodle_url $reloadurl
362 * @return string HTML
364 public function check_for_updates_button(\core\update\checker
$checker, $reloadurl) {
368 if ($checker->enabled()) {
369 $output .= $this->container_start('checkforupdates mb-4');
370 $output .= $this->single_button(
371 new moodle_url($reloadurl, array('fetchupdates' => 1)),
372 get_string('checkforupdates', 'core_plugin')
374 if ($timefetched = $checker->get_last_timefetched()) {
375 $timefetched = userdate($timefetched, get_string('strftimedatetime', 'core_langconfig'));
376 $output .= $this->container(get_string('checkforupdateslast', 'core_plugin', $timefetched),
377 'lasttimefetched small text-muted mt-1');
379 $output .= $this->container_end();
386 * Display a page to confirm the plugin uninstallation.
388 * @param core_plugin_manager $pluginman
389 * @param \core\plugininfo\base $pluginfo
390 * @param moodle_url $continueurl URL to continue after confirmation
391 * @param moodle_url $cancelurl URL to to go if cancelled
394 public function plugin_uninstall_confirm_page(core_plugin_manager
$pluginman, \core\plugininfo\base
$pluginfo, moodle_url
$continueurl, moodle_url
$cancelurl) {
397 $pluginname = $pluginman->plugin_name($pluginfo->component
);
399 $confirm = '<p>' . get_string('uninstallconfirm', 'core_plugin', array('name' => $pluginname)) . '</p>';
400 if ($extraconfirm = $pluginfo->get_uninstall_extra_warning()) {
401 $confirm .= $extraconfirm;
404 $output .= $this->output
->header();
405 $output .= $this->output
->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
406 $output .= $this->output
->confirm($confirm, $continueurl, $cancelurl);
407 $output .= $this->output
->footer();
413 * Display a page with results of plugin uninstallation and offer removal of plugin files.
415 * @param core_plugin_manager $pluginman
416 * @param \core\plugininfo\base $pluginfo
417 * @param progress_trace_buffer $progress
418 * @param moodle_url $continueurl URL to continue to remove the plugin folder
421 public function plugin_uninstall_results_removable_page(core_plugin_manager
$pluginman, \core\plugininfo\base
$pluginfo,
422 progress_trace_buffer
$progress, moodle_url
$continueurl) {
425 $pluginname = $pluginman->plugin_name($pluginfo->component
);
427 // Do not show navigation here, they must click one of the buttons.
428 $this->page
->set_pagelayout('maintenance');
429 $this->page
->set_cacheable(false);
431 $output .= $this->output
->header();
432 $output .= $this->output
->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
434 $output .= $this->output
->box($progress->get_buffer(), 'generalbox uninstallresultmessage');
436 $confirm = $this->output
->container(get_string('uninstalldeleteconfirm', 'core_plugin',
437 array('name' => $pluginname, 'rootdir' => $pluginfo->rootdir
)), 'uninstalldeleteconfirm');
439 if ($repotype = $pluginman->plugin_external_source($pluginfo->component
)) {
440 $confirm .= $this->output
->container(get_string('uninstalldeleteconfirmexternal', 'core_plugin', $repotype),
441 'alert alert-warning mt-2');
444 // After any uninstall we must execute full upgrade to finish the cleanup!
445 $output .= $this->output
->confirm($confirm, $continueurl, new moodle_url('/admin/index.php'));
446 $output .= $this->output
->footer();
452 * Display a page with results of plugin uninstallation and inform about the need to remove plugin files manually.
454 * @param core_plugin_manager $pluginman
455 * @param \core\plugininfo\base $pluginfo
456 * @param progress_trace_buffer $progress
459 public function plugin_uninstall_results_page(core_plugin_manager
$pluginman, \core\plugininfo\base
$pluginfo, progress_trace_buffer
$progress) {
462 $pluginname = $pluginfo->component
;
464 $output .= $this->output
->header();
465 $output .= $this->output
->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
467 $output .= $this->output
->box($progress->get_buffer(), 'generalbox uninstallresultmessage');
469 $output .= $this->output
->box(get_string('uninstalldelete', 'core_plugin',
470 array('name' => $pluginname, 'rootdir' => $pluginfo->rootdir
)), 'generalbox uninstalldelete');
471 $output .= $this->output
->continue_button(new moodle_url('/admin/index.php'));
472 $output .= $this->output
->footer();
478 * Display the plugin management page (admin/environment.php).
479 * @param array $versions
480 * @param string $version
481 * @param boolean $envstatus final result of env check (true/false)
482 * @param array $environment_results array of results gathered
483 * @return string HTML to output.
485 public function environment_check_page($versions, $version, $envstatus, $environment_results) {
487 $output .= $this->header();
489 // Print the component download link
490 $output .= html_writer
::tag('div', html_writer
::link(
491 new moodle_url('/admin/environment.php', array('action' => 'updatecomponent', 'sesskey' => sesskey())),
492 get_string('updatecomponent', 'admin')),
493 array('class' => 'reportlink'));
496 $output .= $this->heading(get_string('environment', 'admin'));
498 // Box with info and a menu to choose the version.
499 $output .= $this->box_start();
500 $output .= html_writer
::tag('div', get_string('adminhelpenvironment'));
501 $select = new single_select(new moodle_url('/admin/environment.php'), 'version', $versions, $version, null);
502 $select->label
= get_string('moodleversion');
503 $output .= $this->render($select);
504 $output .= $this->box_end();
507 $output .= $this->environment_check_table($envstatus, $environment_results);
509 $output .= $this->footer();
514 * Output a warning message, of the type that appears on the admin notifications page.
515 * @param string $message the message to display.
516 * @param string $type type class
517 * @return string HTML to output.
519 protected function warning($message, $type = 'warning') {
520 return $this->box($message, 'generalbox alert alert-' . $type);
524 * Render an appropriate message if dataroot is insecure.
525 * @param bool $insecuredataroot
526 * @return string HTML to output.
528 protected function insecure_dataroot_warning($insecuredataroot) {
531 if ($insecuredataroot == INSECURE_DATAROOT_WARNING
) {
532 return $this->warning(get_string('datarootsecuritywarning', 'admin', $CFG->dataroot
));
534 } else if ($insecuredataroot == INSECURE_DATAROOT_ERROR
) {
535 return $this->warning(get_string('datarootsecurityerror', 'admin', $CFG->dataroot
), 'danger');
543 * Render a warning that a directory with development libs is present.
545 * @param bool $devlibdir True if the warning should be displayed.
548 protected function development_libs_directories_warning($devlibdir) {
551 $moreinfo = new moodle_url('/report/security/index.php');
552 $warning = get_string('devlibdirpresent', 'core_admin', ['moreinfourl' => $moreinfo->out()]);
553 return $this->warning($warning, 'danger');
561 * Render an appropriate message if dataroot is insecure.
562 * @param bool $errorsdisplayed
563 * @return string HTML to output.
565 protected function display_errors_warning($errorsdisplayed) {
566 if (!$errorsdisplayed) {
570 return $this->warning(get_string('displayerrorswarning', 'admin'));
574 * Render an appropriate message if themdesignermode is enabled.
575 * @param bool $themedesignermode true if enabled
576 * @return string HTML to output.
578 protected function themedesignermode_warning($themedesignermode) {
579 if (!$themedesignermode) {
583 return $this->warning(get_string('themedesignermodewarning', 'admin'));
587 * Render an appropriate message if iconv is buggy and mbstring missing.
588 * @param bool $buggyiconvnomb
589 * @return string HTML to output.
591 protected function buggy_iconv_warning($buggyiconvnomb) {
592 if (!$buggyiconvnomb) {
596 return $this->warning(get_string('warningiconvbuggy', 'admin'));
600 * Render an appropriate message if cron has not been run recently.
601 * @param bool $cronoverdue
602 * @return string HTML to output.
604 public function cron_overdue_warning($cronoverdue) {
610 $check = new \tool_task\check\
cronrunning();
611 $result = $check->get_result();
612 return $this->warning($result->get_summary() . ' ' . $this->help_icon('cron', 'admin'));
616 * Render an appropriate message if cron is not being run frequently (recommended every minute).
618 * @param bool $croninfrequent
619 * @return string HTML to output.
621 public function cron_infrequent_warning(bool $croninfrequent): string {
624 if (!$croninfrequent) {
628 $check = new \tool_task\check\
cronrunning();
629 $result = $check->get_result();
630 return $this->warning($result->get_summary() . ' ' . $this->help_icon('cron', 'admin'));
634 * Render an appropriate message if there are any problems with the DB set-up.
635 * @param bool $dbproblems
636 * @return string HTML to output.
638 public function db_problems($dbproblems) {
643 return $this->warning($dbproblems);
647 * Renders cache warnings if there are any.
649 * @param string[] $cachewarnings
652 public function cache_warnings(array $cachewarnings) {
653 if (!count($cachewarnings)) {
656 return join("\n", array_map(array($this, 'warning'), $cachewarnings));
660 * Renders events 1 API handlers warning.
662 * @param array $eventshandlers
665 public function events_handlers($eventshandlers) {
666 if ($eventshandlers) {
668 foreach ($eventshandlers as $eventhandler) {
669 $components .= $eventhandler->component
. ', ';
671 $components = rtrim($components, ', ');
672 return $this->warning(get_string('eventshandlersinuse', 'admin', $components));
677 * Render an appropriate message if the site in in maintenance mode.
678 * @param bool $maintenancemode
679 * @return string HTML to output.
681 public function maintenance_mode_warning($maintenancemode) {
682 if (!$maintenancemode) {
686 $url = new moodle_url('/admin/settings.php', array('section' => 'maintenancemode'));
687 $url = $url->out(); // get_string() does not support objects in params
689 return $this->warning(get_string('sitemaintenancewarning2', 'admin', $url));
693 * Render a warning that ssl is forced because the site was on loginhttps.
695 * @param bool $overridetossl Whether or not ssl is being forced.
698 protected function overridetossl_warning($overridetossl) {
699 if (!$overridetossl) {
702 $warning = get_string('overridetossl', 'core_admin');
703 return $this->warning($warning, 'warning');
707 * Display a warning about installing development code if necesary.
708 * @param int $maturity
709 * @return string HTML to output.
711 protected function maturity_warning($maturity) {
712 if ($maturity == MATURITY_STABLE
) {
713 return ''; // No worries.
716 $maturitylevel = get_string('maturity' . $maturity, 'admin');
717 return $this->warning(
718 $this->container(get_string('maturitycorewarning', 'admin', $maturitylevel)) .
719 $this->container($this->doc_link('admin/versions', get_string('morehelp'))),
724 * If necessary, displays a warning about upgrading a test site.
726 * @param string $testsite
727 * @return string HTML
729 protected function test_site_warning($testsite) {
735 $warning = (get_string('testsiteupgradewarning', 'admin', $testsite));
736 return $this->warning($warning, 'danger');
740 * Output the copyright notice.
741 * @return string HTML to output.
743 protected function moodle_copyright() {
746 //////////////////////////////////////////////////////////////////////////////////////////////////
747 //// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO HIDE, REMOVE OR MODIFY THIS COPYRIGHT NOTICE ///
748 $copyrighttext = '<a href="http://moodle.org/">Moodle</a> '.
749 '<a href="https://moodledev.io/general/releases" title="'.$CFG->version
.'">'.$CFG->release
.'</a><br />'.
750 'Copyright © 1999 onwards, Martin Dougiamas<br />'.
751 'and <a href="http://moodle.org/dev">many other contributors</a>.<br />'.
752 '<a href="https://moodledev.io/general/license">GNU Public License</a>';
753 //////////////////////////////////////////////////////////////////////////////////////////////////
755 return $this->box($copyrighttext, 'copyright');
759 * Display a transient notification for important upgrades messages for
762 * @return string HTML to output.
764 protected function upgrade_news_message() {
765 return $this->notification(
766 get_string('importantupdates_content', 'admin'),
769 get_string('importantupdates_title', 'admin'),
775 * Display a warning about installing development code if necesary.
776 * @param int $maturity
777 * @return string HTML to output.
779 protected function maturity_info($maturity) {
780 if ($maturity == MATURITY_STABLE
) {
781 return ''; // No worries.
786 if ($maturity == MATURITY_ALPHA
) {
790 $maturitylevel = get_string('maturity' . $maturity, 'admin');
791 $warningtext = get_string('maturitycoreinfo', 'admin', $maturitylevel);
792 $warningtext .= ' ' . $this->doc_link('admin/versions', get_string('morehelp'));
793 return $this->warning($warningtext, $level);
797 * Displays the info about available Moodle core and plugin updates
799 * The structure of the $updates param has changed since 2.4. It contains not only updates
800 * for the core itself, but also for all other installed plugins.
802 * @param array|null $updates array of (string)component => array of \core\update\info objects or null
803 * @param int|null $fetch timestamp of the most recent updates fetch or null (unknown)
806 protected function available_updates($updates, $fetch) {
809 $someupdateavailable = false;
810 if (is_array($updates)) {
811 if (is_array($updates['core'])) {
812 $someupdateavailable = true;
813 $updateinfo .= $this->heading(get_string('updateavailable', 'core_admin'), 3);
814 foreach ($updates['core'] as $update) {
815 $updateinfo .= $this->moodle_available_update_info($update);
817 $updateinfo .= html_writer
::tag('p', get_string('updateavailablerecommendation', 'core_admin'),
818 array('class' => 'updateavailablerecommendation'));
820 unset($updates['core']);
821 // If something has left in the $updates array now, it is updates for plugins.
822 if (!empty($updates)) {
823 $someupdateavailable = true;
824 $updateinfo .= $this->heading(get_string('updateavailableforplugin', 'core_admin'), 3);
825 $pluginsoverviewurl = new moodle_url('/admin/plugins.php', array('updatesonly' => 1));
826 $updateinfo .= $this->container(get_string('pluginsoverviewsee', 'core_admin',
827 array('url' => $pluginsoverviewurl->out())));
831 if (!$someupdateavailable) {
833 if ($fetch and ($fetch <= $now) and ($now - $fetch < HOURSECS
)) {
834 $updateinfo .= $this->heading(get_string('updateavailablenot', 'core_admin'), 3);
838 $updateinfo .= $this->container_start('checkforupdates mt-1');
839 $fetchurl = new moodle_url('/admin/index.php', array('fetchupdates' => 1, 'sesskey' => sesskey(), 'cache' => 0));
840 $updateinfo .= $this->single_button($fetchurl, get_string('checkforupdates', 'core_plugin'));
842 $updateinfo .= $this->container(get_string('checkforupdateslast', 'core_plugin',
843 userdate($fetch, get_string('strftimedatetime', 'core_langconfig'))));
845 $updateinfo .= $this->container_end();
847 return $this->warning($updateinfo);
851 * Display a warning about not being registered on Moodle.org if necesary.
853 * @param boolean $registered true if the site is registered on Moodle.org
854 * @return string HTML to output.
856 protected function registration_warning($registered) {
858 if (!$registered && site_is_public()) {
859 if (has_capability('moodle/site:config', context_system
::instance())) {
860 $registerbutton = $this->single_button(new moodle_url('/admin/registration/index.php'),
861 get_string('register', 'admin'));
862 $str = 'registrationwarning';
863 $type = 'error alert alert-danger';
865 $registerbutton = '';
866 $str = 'registrationwarningcontactadmin';
870 return $this->warning( get_string($str, 'admin') . ' ' . $registerbutton , $type);
877 * Return an admin page warning if site is not registered with moodle.org
881 public function warn_if_not_registered() {
882 return $this->registration_warning(\core\hub\registration
::is_registered());
886 * Display a warning about the Mobile Web Services being disabled.
888 * @param boolean $mobileconfigured true if mobile web services are enabled
889 * @return string HTML to output.
891 protected function mobile_configuration_warning($mobileconfigured) {
893 if (!$mobileconfigured) {
894 $settingslink = new moodle_url('/admin/search.php', ['query' => 'enablemobilewebservice']);
895 $configurebutton = $this->single_button($settingslink, get_string('enablemobilewebservice', 'admin'), 'get');
896 $output .= $this->warning(get_string('mobilenotconfiguredwarning', 'admin') . ' ' . $configurebutton);
903 * Display campaign content.
905 * @param bool $showcampaigncontent Whether the campaign content should be visible or not.
906 * @return string the campaign content raw html.
908 protected function campaign_content(bool $showcampaigncontent): string {
909 if (!$showcampaigncontent) {
913 $lang = current_language();
914 $url = "https://campaign.moodle.org/current/lms/{$lang}/install/";
917 'iframeid' => 'campaign-content',
918 'title' => get_string('campaign', 'admin'),
921 return $this->render_from_template('core/external_content_banner', $params);
925 * Display services and support content.
927 * @param bool $showservicesandsupport Whether the services and support content should be visible or not.
928 * @return string the campaign content raw html.
930 protected function services_and_support_content(bool $showservicesandsupport): string {
931 if (!$showservicesandsupport) {
935 $lang = current_language();
936 $url = "https://campaign.moodle.org/current/lms/{$lang}/servicesandsupport/";
939 'iframeid' => 'services-support-content',
940 'title' => get_string('supportandservices', 'admin'),
943 return $this->render_from_template('core/external_content_banner', $params);
947 * Display a warning about the forgotten password URL not linking to a valid URL.
949 * @param boolean $invalidforgottenpasswordurl true if the forgotten password URL is not valid
950 * @return string HTML to output.
952 protected function forgotten_password_url_warning($invalidforgottenpasswordurl) {
954 if ($invalidforgottenpasswordurl) {
955 $settingslink = new moodle_url('/admin/settings.php', ['section' => 'manageauths']);
956 $configurebutton = $this->single_button($settingslink, get_string('check', 'moodle'));
957 $output .= $this->warning(get_string('invalidforgottenpasswordurl', 'admin') . ' ' . $configurebutton,
958 'error alert alert-danger');
965 * Helper method to render the information about the available Moodle update
967 * @param \core\update\info $updateinfo information about the available Moodle core update
969 protected function moodle_available_update_info(\core\update\info
$updateinfo) {
971 $boxclasses = 'moodleupdateinfo mb-2';
974 if (isset($updateinfo->release
)) {
975 $info[] = html_writer
::tag('span', get_string('updateavailable_release', 'core_admin', $updateinfo->release
),
976 array('class' => 'info release'));
979 if (isset($updateinfo->version
)) {
980 $info[] = html_writer
::tag('span', get_string('updateavailable_version', 'core_admin', $updateinfo->version
),
981 array('class' => 'info version'));
984 if (isset($updateinfo->maturity
)) {
985 $info[] = html_writer
::tag('span', get_string('maturity'.$updateinfo->maturity
, 'core_admin'),
986 array('class' => 'info maturity'));
987 $boxclasses .= ' maturity'.$updateinfo->maturity
;
990 if (isset($updateinfo->download
)) {
991 $info[] = html_writer
::link($updateinfo->download
, get_string('download'),
992 array('class' => 'info download btn btn-secondary'));
995 if (isset($updateinfo->url
)) {
996 $info[] = html_writer
::link($updateinfo->url
, get_string('updateavailable_moreinfo', 'core_plugin'),
997 array('class' => 'info more'));
1000 $box = $this->output
->container_start($boxclasses);
1001 $box .= $this->output
->container(implode(html_writer
::tag('span', ' | ', array('class' => 'separator')), $info), '');
1002 $box .= $this->output
->container_end();
1008 * Display a link to the release notes.
1009 * @return string HTML to output.
1011 protected function release_notes_link() {
1012 $releasenoteslink = get_string('releasenoteslink', 'admin', 'https://moodledev.io/general/releases');
1013 $releasenoteslink = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $releasenoteslink); // extremely ugly validation hack
1014 return $this->box($releasenoteslink, 'generalbox alert alert-info');
1018 * Display the reload link that appears on several upgrade/install pages.
1019 * @return string HTML to output.
1021 function upgrade_reload($url) {
1022 return html_writer
::empty_tag('br') .
1023 html_writer
::tag('div',
1024 html_writer
::link($url, $this->pix_icon('i/reload', '', '', ['class' => 'icon']) .
1025 get_string('reload'), array('title' => get_string('reload'))),
1026 array('class' => 'continuebutton')) . html_writer
::empty_tag('br');
1030 * Displays all known plugins and information about their installation or upgrade
1032 * This default implementation renders all plugins into one big table. The rendering
1034 * (bool)full = false: whether to display up-to-date plugins, too
1035 * (bool)xdep = false: display the plugins with unsatisified dependecies only
1037 * @param core_plugin_manager $pluginman provides information about the plugins.
1038 * @param int $version the version of the Moodle code from version.php.
1039 * @param array $options rendering options
1040 * @return string HTML code
1042 public function plugins_check_table(core_plugin_manager
$pluginman, $version, array $options = array()) {
1044 $plugininfo = $pluginman->get_plugins();
1046 if (empty($plugininfo)) {
1050 $options['full'] = isset($options['full']) ?
(bool)$options['full'] : false;
1051 $options['xdep'] = isset($options['xdep']) ?
(bool)$options['xdep'] : false;
1053 $table = new html_table();
1054 $table->id
= 'plugins-check';
1055 $table->head
= array(
1056 get_string('displayname', 'core_plugin').' / '.get_string('rootdir', 'core_plugin'),
1057 get_string('versiondb', 'core_plugin'),
1058 get_string('versiondisk', 'core_plugin'),
1059 get_string('requires', 'core_plugin'),
1060 get_string('source', 'core_plugin').' / '.get_string('status', 'core_plugin'),
1062 $table->colclasses
= array(
1063 'displayname', 'versiondb', 'versiondisk', 'requires', 'status',
1065 $table->data
= array();
1067 // Number of displayed plugins per type.
1068 $numdisplayed = array();
1069 // Number of plugins known to the plugin manager.
1071 // Number of plugins requiring attention.
1073 // List of all components we can cancel installation of.
1074 $installabortable = $pluginman->list_cancellable_installations();
1075 // List of all components we can cancel upgrade of.
1076 $upgradeabortable = $pluginman->list_restorable_archives();
1078 foreach ($plugininfo as $type => $plugins) {
1080 $header = new html_table_cell($pluginman->plugintype_name_plural($type));
1081 $header->header
= true;
1082 $header->colspan
= count($table->head
);
1083 $header = new html_table_row(array($header));
1084 $header->attributes
['class'] = 'plugintypeheader type-' . $type;
1086 $numdisplayed[$type] = 0;
1088 if (empty($plugins) and $options['full']) {
1089 $msg = new html_table_cell(get_string('noneinstalled', 'core_plugin'));
1090 $msg->colspan
= count($table->head
);
1091 $row = new html_table_row(array($msg));
1092 $row->attributes
['class'] .= 'msg msg-noneinstalled';
1093 $table->data
[] = $header;
1094 $table->data
[] = $row;
1098 $plugintyperows = array();
1100 foreach ($plugins as $name => $plugin) {
1101 $component = "{$plugin->type}_{$plugin->name}";
1104 $row = new html_table_row();
1105 $row->attributes
['class'] = "type-{$plugin->type} name-{$component}";
1107 $iconidentifier = 'icon';
1108 if ($plugin->type
=== 'mod') {
1109 $iconidentifier = 'monologo';
1112 if ($this->page
->theme
->resolve_image_location($iconidentifier, $component, null)) {
1113 $icon = $this->output
->pix_icon($iconidentifier, '', $component, [
1114 'class' => 'smallicon pluginicon',
1120 $displayname = new html_table_cell(
1122 html_writer
::span($plugin->displayname
, 'pluginname').
1123 html_writer
::div($plugin->get_dir(), 'plugindir text-muted small')
1126 $versiondb = new html_table_cell($plugin->versiondb
);
1127 $versiondisk = new html_table_cell($plugin->versiondisk
);
1129 if ($isstandard = $plugin->is_standard()) {
1130 $row->attributes
['class'] .= ' standard';
1131 $sourcelabel = html_writer
::span(get_string('sourcestd', 'core_plugin'),
1132 'sourcetext badge bg-secondary text-dark');
1134 $row->attributes
['class'] .= ' extension';
1135 $sourcelabel = html_writer
::span(get_string('sourceext', 'core_plugin'), 'sourcetext badge bg-info text-white');
1138 $coredependency = $plugin->is_core_dependency_satisfied($version);
1139 $incompatibledependency = $plugin->is_core_compatible_satisfied($CFG->branch
);
1141 $otherpluginsdependencies = $pluginman->are_dependencies_satisfied($plugin->get_other_required_plugins());
1142 $dependenciesok = $coredependency && $otherpluginsdependencies && $incompatibledependency;
1144 $statuscode = $plugin->get_status();
1145 $row->attributes
['class'] .= ' status-' . $statuscode;
1146 $statusclass = 'statustext badge ';
1147 switch ($statuscode) {
1148 case core_plugin_manager
::PLUGIN_STATUS_NEW
:
1149 $statusclass .= $dependenciesok ?
'bg-success text-white' : 'bg-warning text-dark';
1151 case core_plugin_manager
::PLUGIN_STATUS_UPGRADE
:
1152 $statusclass .= $dependenciesok ?
'bg-info text-white' : 'bg-warning text-dark';
1154 case core_plugin_manager
::PLUGIN_STATUS_MISSING
:
1155 case core_plugin_manager
::PLUGIN_STATUS_DOWNGRADE
:
1156 case core_plugin_manager
::PLUGIN_STATUS_DELETE
:
1157 $statusclass .= 'bg-danger text-white';
1159 case core_plugin_manager
::PLUGIN_STATUS_NODB
:
1160 case core_plugin_manager
::PLUGIN_STATUS_UPTODATE
:
1161 $statusclass .= $dependenciesok ?
'bg-light text-dark' : 'bg-warning text-dark';
1164 $status = html_writer
::span(get_string('status_' . $statuscode, 'core_plugin'), $statusclass);
1166 if (!empty($installabortable[$plugin->component
])) {
1167 $status .= $this->output
->single_button(
1168 new moodle_url($this->page
->url
, array('abortinstall' => $plugin->component
, 'confirmplugincheck' => 0)),
1169 get_string('cancelinstallone', 'core_plugin'),
1171 array('class' => 'actionbutton cancelinstallone d-block mt-1')
1175 if (!empty($upgradeabortable[$plugin->component
])) {
1176 $status .= $this->output
->single_button(
1177 new moodle_url($this->page
->url
, array('abortupgrade' => $plugin->component
)),
1178 get_string('cancelupgradeone', 'core_plugin'),
1180 array('class' => 'actionbutton cancelupgradeone d-block mt-1')
1184 $availableupdates = $plugin->available_updates();
1185 if (!empty($availableupdates)) {
1186 foreach ($availableupdates as $availableupdate) {
1187 $status .= $this->plugin_available_update_info($pluginman, $availableupdate);
1191 $status = new html_table_cell($sourcelabel.' '.$status);
1192 if ($plugin->pluginsupported
!= null) {
1193 $requires = new html_table_cell($this->required_column($plugin, $pluginman, $version, $CFG->branch
));
1195 $requires = new html_table_cell($this->required_column($plugin, $pluginman, $version));
1198 $statusisboring = in_array($statuscode, array(
1199 core_plugin_manager
::PLUGIN_STATUS_NODB
, core_plugin_manager
::PLUGIN_STATUS_UPTODATE
));
1201 if ($options['xdep']) {
1202 // we want to see only plugins with failed dependencies
1203 if ($dependenciesok) {
1207 } else if ($statusisboring and $dependenciesok and empty($availableupdates)) {
1208 // no change is going to happen to the plugin - display it only
1209 // if the user wants to see the full list
1210 if (empty($options['full'])) {
1218 // The plugin should be displayed.
1219 $numdisplayed[$type]++
;
1220 $row->cells
= array($displayname, $versiondb, $versiondisk, $requires, $status);
1221 $plugintyperows[] = $row;
1224 if (empty($numdisplayed[$type]) and empty($options['full'])) {
1228 $table->data
[] = $header;
1229 $table->data
= array_merge($table->data
, $plugintyperows);
1232 // Total number of displayed plugins.
1233 $sumdisplayed = array_sum($numdisplayed);
1235 if ($options['xdep']) {
1236 // At the plugins dependencies check page, display the table only.
1237 return html_writer
::table($table);
1240 $out = $this->output
->container_start('', 'plugins-check-info');
1242 if ($sumdisplayed == 0) {
1243 $out .= $this->output
->heading(get_string('pluginchecknone', 'core_plugin'));
1246 if (empty($options['full'])) {
1247 $out .= $this->output
->heading(get_string('plugincheckattention', 'core_plugin'));
1249 $out .= $this->output
->heading(get_string('plugincheckall', 'core_plugin'));
1253 $out .= $this->output
->container_start('actions mb-2');
1255 $installableupdates = $pluginman->filter_installable($pluginman->available_updates());
1256 if ($installableupdates) {
1257 $out .= $this->output
->single_button(
1258 new moodle_url($this->page
->url
, array('installupdatex' => 1)),
1259 get_string('updateavailableinstallall', 'core_admin', count($installableupdates)),
1261 array('class' => 'singlebutton updateavailableinstallall me-1')
1265 if ($installabortable) {
1266 $out .= $this->output
->single_button(
1267 new moodle_url($this->page
->url
, array('abortinstallx' => 1, 'confirmplugincheck' => 0)),
1268 get_string('cancelinstallall', 'core_plugin', count($installabortable)),
1270 array('class' => 'singlebutton cancelinstallall me-1')
1274 if ($upgradeabortable) {
1275 $out .= $this->output
->single_button(
1276 new moodle_url($this->page
->url
, array('abortupgradex' => 1)),
1277 get_string('cancelupgradeall', 'core_plugin', count($upgradeabortable)),
1279 array('class' => 'singlebutton cancelupgradeall me-1')
1283 $out .= html_writer
::div(html_writer
::link(new moodle_url($this->page
->url
, array('showallplugins' => 0)),
1284 get_string('plugincheckattention', 'core_plugin')).' '.html_writer
::span($sumattention, 'badge bg-light text-dark'),
1285 'btn btn-link me-1');
1287 $out .= html_writer
::div(html_writer
::link(new moodle_url($this->page
->url
, array('showallplugins' => 1)),
1288 get_string('plugincheckall', 'core_plugin')).' '.html_writer
::span($sumtotal, 'badge bg-light text-dark'),
1289 'btn btn-link me-1');
1291 $out .= $this->output
->container_end(); // End of .actions container.
1292 $out .= $this->output
->container_end(); // End of #plugins-check-info container.
1294 if ($sumdisplayed > 0 or $options['full']) {
1295 $out .= html_writer
::table($table);
1302 * Display the continue / cancel widgets for the plugins management pages.
1304 * @param null|moodle_url $continue URL for the continue button, should it be displayed
1305 * @param null|moodle_url $cancel URL for the cancel link, defaults to the current page
1306 * @return string HTML
1308 public function plugins_management_confirm_buttons(?moodle_url
$continue=null, ?moodle_url
$cancel=null) {
1310 $out = html_writer
::start_div('plugins-management-confirm-buttons');
1312 if (!empty($continue)) {
1313 $out .= $this->output
->single_button($continue, get_string('continue'), 'post', array('class' => 'continue'));
1316 if (empty($cancel)) {
1317 $cancel = $this->page
->url
;
1319 $out .= html_writer
::div(html_writer
::link($cancel, get_string('cancel')), 'cancel');
1325 * Displays the information about missing dependencies
1327 * @param core_plugin_manager $pluginman
1330 protected function missing_dependencies(core_plugin_manager
$pluginman) {
1332 $dependencies = $pluginman->missing_dependencies();
1334 if (empty($dependencies)) {
1338 $available = array();
1339 $unavailable = array();
1342 foreach ($dependencies as $component => $remoteinfo) {
1343 if ($remoteinfo === false) {
1344 // The required version is not available. Let us check if there
1345 // is at least some version in the plugins directory.
1346 $remoteinfoanyversion = $pluginman->get_remote_plugin_info($component, ANY_VERSION
, false);
1347 if ($remoteinfoanyversion === false) {
1348 $unknown[$component] = $component;
1350 $unavailable[$component] = $remoteinfoanyversion;
1353 $available[$component] = $remoteinfo;
1357 $out = $this->output
->container_start('plugins-check-dependencies mb-4');
1359 if ($unavailable or $unknown) {
1360 $out .= $this->output
->heading(get_string('misdepsunavail', 'core_plugin'));
1362 $out .= $this->output
->render((new \core\output\notification
(get_string('misdepsunknownlist', 'core_plugin',
1363 implode(', ', $unknown))))->set_show_closebutton(false));
1366 $unavailablelist = array();
1367 foreach ($unavailable as $component => $remoteinfoanyversion) {
1368 $unavailablelistitem = html_writer
::link('https://moodle.org/plugins/view.php?plugin='.$component,
1369 '<strong>'.$remoteinfoanyversion->name
.'</strong>');
1370 if ($remoteinfoanyversion->version
) {
1371 $unavailablelistitem .= ' ('.$component.' > '.$remoteinfoanyversion->version
->version
.')';
1373 $unavailablelistitem .= ' ('.$component.')';
1375 $unavailablelist[] = $unavailablelistitem;
1377 $out .= $this->output
->render((new \core\output\notification
(get_string('misdepsunavaillist', 'core_plugin',
1378 implode(', ', $unavailablelist))))->set_show_closebutton(false));
1380 $out .= $this->output
->container_start('plugins-check-dependencies-actions mb-4');
1381 $out .= ' '.html_writer
::link(new moodle_url('/admin/tool/installaddon/'),
1382 get_string('dependencyuploadmissing', 'core_plugin'), array('class' => 'btn btn-secondary'));
1383 $out .= $this->output
->container_end(); // End of .plugins-check-dependencies-actions container.
1387 $out .= $this->output
->heading(get_string('misdepsavail', 'core_plugin'));
1388 $out .= $this->output
->container_start('plugins-check-dependencies-actions mb-2');
1390 $installable = $pluginman->filter_installable($available);
1392 $out .= $this->output
->single_button(
1393 new moodle_url($this->page
->url
, array('installdepx' => 1)),
1394 get_string('dependencyinstallmissing', 'core_plugin', count($installable)),
1396 array('class' => 'singlebutton dependencyinstallmissing d-inline-block me-1')
1400 $out .= html_writer
::div(html_writer
::link(new moodle_url('/admin/tool/installaddon/'),
1401 get_string('dependencyuploadmissing', 'core_plugin'), array('class' => 'btn btn-link')),
1402 'dependencyuploadmissing d-inline-block me-1');
1404 $out .= $this->output
->container_end(); // End of .plugins-check-dependencies-actions container.
1406 $out .= $this->available_missing_dependencies_list($pluginman, $available);
1409 $out .= $this->output
->container_end(); // End of .plugins-check-dependencies container.
1415 * Displays the list if available missing dependencies.
1417 * @param core_plugin_manager $pluginman
1418 * @param array $dependencies
1421 protected function available_missing_dependencies_list(core_plugin_manager
$pluginman, array $dependencies) {
1424 $table = new html_table();
1425 $table->id
= 'plugins-check-available-dependencies';
1426 $table->head
= array(
1427 get_string('displayname', 'core_plugin'),
1428 get_string('release', 'core_plugin'),
1429 get_string('version', 'core_plugin'),
1430 get_string('supportedmoodleversions', 'core_plugin'),
1431 get_string('info', 'core'),
1433 $table->colclasses
= array('displayname', 'release', 'version', 'supportedmoodleversions', 'info');
1434 $table->data
= array();
1436 foreach ($dependencies as $plugin) {
1438 $supportedmoodles = array();
1439 foreach ($plugin->version
->supportedmoodles
as $moodle) {
1440 if ($CFG->branch
== str_replace('.', '', $moodle->release
)) {
1441 $supportedmoodles[] = html_writer
::span($moodle->release
, 'badge bg-success text-white');
1443 $supportedmoodles[] = html_writer
::span($moodle->release
, 'badge bg-light text-dark');
1447 $requriedby = $pluginman->other_plugins_that_require($plugin->component
);
1449 foreach ($requriedby as $ix => $val) {
1450 $inf = $pluginman->get_plugin_info($val);
1452 $requriedby[$ix] = $inf->displayname
.' ('.$inf->component
.')';
1455 $info = html_writer
::div(
1456 get_string('requiredby', 'core_plugin', implode(', ', $requriedby)),
1463 $info .= $this->output
->container_start('actions');
1465 $info .= html_writer
::div(
1466 html_writer
::link('https://moodle.org/plugins/view.php?plugin='.$plugin->component
,
1467 get_string('misdepinfoplugin', 'core_plugin')),
1468 'misdepinfoplugin d-inline-block me-3 mb-1'
1471 $info .= html_writer
::div(
1472 html_writer
::link('https://moodle.org/plugins/pluginversion.php?id='.$plugin->version
->id
,
1473 get_string('misdepinfoversion', 'core_plugin')),
1474 'misdepinfoversion d-inline-block me-3 mb-1'
1477 $info .= html_writer
::div(html_writer
::link($plugin->version
->downloadurl
, get_string('download')),
1478 'misdepdownload d-inline-block me-3 mb-1');
1480 if ($pluginman->is_remote_plugin_installable($plugin->component
, $plugin->version
->version
, $reason)) {
1481 $info .= $this->output
->single_button(
1482 new moodle_url($this->page
->url
, array('installdep' => $plugin->component
)),
1483 get_string('dependencyinstall', 'core_plugin'),
1485 array('class' => 'singlebutton dependencyinstall me-3 mb-1')
1488 $reasonhelp = $this->info_remote_plugin_not_installable($reason);
1490 $info .= html_writer
::div($reasonhelp, 'reasonhelp dependencyinstall d-inline-block me-3 mb-1');
1494 $info .= $this->output
->container_end(); // End of .actions container.
1496 $table->data
[] = array(
1497 html_writer
::div($plugin->name
, 'name').' '.html_writer
::div($plugin->component
, 'component text-muted small'),
1498 $plugin->version
->release
,
1499 $plugin->version
->version
,
1500 implode(' ', $supportedmoodles),
1505 return html_writer
::table($table);
1509 * Explain why {@link core_plugin_manager::is_remote_plugin_installable()} returned false.
1511 * @param string $reason the reason code as returned by the plugin manager
1514 protected function info_remote_plugin_not_installable($reason) {
1516 if ($reason === 'notwritableplugintype' or $reason === 'notwritableplugin') {
1517 return $this->output
->help_icon('notwritable', 'core_plugin', get_string('notwritable', 'core_plugin'));
1520 if ($reason === 'remoteunavailable') {
1521 return $this->output
->help_icon('notdownloadable', 'core_plugin', get_string('notdownloadable', 'core_plugin'));
1528 * Formats the information that needs to go in the 'Requires' column.
1529 * @param \core\plugininfo\base $plugin the plugin we are rendering the row for.
1530 * @param core_plugin_manager $pluginman provides data on all the plugins.
1531 * @param string $version
1532 * @param int $branch the current Moodle branch
1533 * @return string HTML code
1535 protected function required_column(\core\plugininfo\base
$plugin, core_plugin_manager
$pluginman, $version, $branch = null) {
1537 $requires = array();
1538 $displayuploadlink = false;
1539 $displayupdateslink = false;
1541 $requirements = $pluginman->resolve_requirements($plugin, $version, $branch);
1542 foreach ($requirements as $reqname => $reqinfo) {
1543 if ($reqname === 'core') {
1544 if ($reqinfo->status
== $pluginman::REQUIREMENT_STATUS_OK
) {
1545 $class = 'requires-ok text-muted';
1548 $class = 'requires-failed';
1549 $label = html_writer
::span(get_string('dependencyfails', 'core_plugin'), 'badge bg-danger text-white');
1552 if ($branch != null && !$plugin->is_core_compatible_satisfied($branch)) {
1553 $requires[] = html_writer
::tag('li',
1554 html_writer
::span(get_string('incompatibleversion', 'core_plugin', $branch), 'dep dep-core').
1555 ' '.$label, array('class' => $class));
1557 } else if ($branch != null && $plugin->pluginsupported
!= null) {
1558 $requires[] = html_writer
::tag('li',
1559 html_writer
::span(get_string('moodlebranch', 'core_plugin',
1560 array('min' => $plugin->pluginsupported
[0], 'max' => $plugin->pluginsupported
[1])), 'dep dep-core').
1561 ' '.$label, array('class' => $class));
1563 } else if ($reqinfo->reqver
!= ANY_VERSION
) {
1564 $requires[] = html_writer
::tag('li',
1565 html_writer
::span(get_string('moodleversion', 'core_plugin', $plugin->versionrequires
), 'dep dep-core').
1566 ' '.$label, array('class' => $class));
1572 if ($reqinfo->status
== $pluginman::REQUIREMENT_STATUS_OK
) {
1574 $class = 'requires-ok text-muted';
1576 } else if ($reqinfo->status
== $pluginman::REQUIREMENT_STATUS_MISSING
) {
1577 if ($reqinfo->availability
== $pluginman::REQUIREMENT_AVAILABLE
) {
1578 $label = html_writer
::span(get_string('dependencymissing', 'core_plugin'),
1579 'badge bg-warning text-dark');
1580 $label .= ' '.html_writer
::span(get_string('dependencyavailable', 'core_plugin'),
1581 'badge bg-warning text-dark');
1582 $class = 'requires-failed requires-missing requires-available';
1583 $actions[] = html_writer
::link(
1584 new moodle_url('https://moodle.org/plugins/view.php', array('plugin' => $reqname)),
1585 get_string('misdepinfoplugin', 'core_plugin')
1589 $label = html_writer
::span(get_string('dependencymissing', 'core_plugin'), 'badge bg-danger text-white');
1590 $label .= ' '.html_writer
::span(get_string('dependencyunavailable', 'core_plugin'),
1591 'badge bg-danger text-white');
1592 $class = 'requires-failed requires-missing requires-unavailable';
1594 $displayuploadlink = true;
1596 } else if ($reqinfo->status
== $pluginman::REQUIREMENT_STATUS_OUTDATED
) {
1597 if ($reqinfo->availability
== $pluginman::REQUIREMENT_AVAILABLE
) {
1598 $label = html_writer
::span(get_string('dependencyfails', 'core_plugin'), 'badge bg-warning text-dark');
1599 $label .= ' '.html_writer
::span(get_string('dependencyavailable', 'core_plugin'),
1600 'badge bg-warning text-dark');
1601 $class = 'requires-failed requires-outdated requires-available';
1602 $displayupdateslink = true;
1605 $label = html_writer
::span(get_string('dependencyfails', 'core_plugin'), 'badge bg-danger text-white');
1606 $label .= ' '.html_writer
::span(get_string('dependencyunavailable', 'core_plugin'),
1607 'badge bg-danger text-white');
1608 $class = 'requires-failed requires-outdated requires-unavailable';
1610 $displayuploadlink = true;
1613 if ($reqinfo->reqver
!= ANY_VERSION
) {
1614 $str = 'otherpluginversion';
1616 $str = 'otherplugin';
1619 $requires[] = html_writer
::tag('li', html_writer
::span(
1620 get_string($str, 'core_plugin', array('component' => $reqname, 'version' => $reqinfo->reqver
)),
1621 'dep dep-plugin').' '.$label.' '.html_writer
::span(implode(' | ', $actions), 'actions'),
1622 array('class' => $class)
1631 $out = html_writer
::tag('ul', implode("\n", $requires), array('class' => 'm-0'));
1633 if ($displayuploadlink) {
1634 $out .= html_writer
::div(
1636 new moodle_url('/admin/tool/installaddon/'),
1637 get_string('dependencyuploadmissing', 'core_plugin'),
1638 array('class' => 'btn btn-secondary btn-sm m-1')
1640 'dependencyuploadmissing'
1644 if ($displayupdateslink) {
1645 $out .= html_writer
::div(
1647 new moodle_url($this->page
->url
, array('sesskey' => sesskey(), 'fetchupdates' => 1)),
1648 get_string('checkforupdates', 'core_plugin'),
1649 array('class' => 'btn btn-secondary btn-sm m-1')
1655 // Check if supports is present, and $branch is not in, only if $incompatible check was ok.
1656 if ($plugin->pluginsupported
!= null && $class == 'requires-ok' && $branch != null) {
1657 if ($pluginman->check_explicitly_supported($plugin, $branch) == $pluginman::VERSION_NOT_SUPPORTED
) {
1658 $out .= html_writer
::div(get_string('notsupported', 'core_plugin', $branch));
1667 * Prints an overview about the plugins - number of installed, number of extensions etc.
1669 * @param core_plugin_manager $pluginman provides information about the plugins
1670 * @param array $options filtering options
1671 * @return string as usually
1673 public function plugins_overview_panel(core_plugin_manager
$pluginman, array $options = array()) {
1675 $plugininfo = $pluginman->get_plugins();
1676 $this->page
->requires
->js_call_amd('core_admin/plugins_overview', 'init');
1678 $numtotal = $numextension = $numupdatable = $numinstallable = $nummissing = $numnew = 0;
1680 foreach ($plugininfo as $type => $plugins) {
1681 foreach ($plugins as $name => $plugin) {
1682 if ($res = $plugin->available_updates()) {
1684 foreach ($res as $updateinfo) {
1685 if ($pluginman->is_remote_plugin_installable($updateinfo->component
, $updateinfo->version
, $reason, false)) {
1691 if ($plugin->get_status() === core_plugin_manager
::PLUGIN_STATUS_MISSING
) {
1695 if ($plugin->get_status() === core_plugin_manager
::PLUGIN_STATUS_NEW
) {
1699 if (!$plugin->is_standard()) {
1705 $infoall = html_writer
::link(
1707 get_string('overviewall', 'core_plugin'),
1708 ['title' => get_string('filterall', 'core_plugin'), 'data-filterby' => 'all', 'class' => 'active']
1709 ).' '.html_writer
::span($numtotal, 'badge number number-all');
1711 $infoext = html_writer
::link(
1712 new moodle_url($this->page
->url
, [], 'additional'),
1713 get_string('overviewext', 'core_plugin'),
1714 ['title' => get_string('filtercontribonly', 'core_plugin'), 'data-filterby' => 'additional']
1715 ).' '.html_writer
::span($numextension, 'badge number number-additional');
1717 if ($numupdatable) {
1718 $infoupdatable = html_writer
::link(
1719 new moodle_url($this->page
->url
, [], 'updatable'),
1720 get_string('overviewupdatable', 'core_plugin'),
1721 ['title' => get_string('filterupdatesonly', 'core_plugin'), 'data-filterby' => 'updatable']
1722 ).' '.html_writer
::span($numupdatable, 'badge bg-info text-white number number-updatable');
1724 // No updates, or the notifications disabled.
1725 $infoupdatable = '';
1729 $infonew = html_writer
::link(
1730 new moodle_url($this->page
->url
, [], 'newplugin'),
1731 get_string('status_new', 'plugin'),
1732 ['title' => get_string('filternewpluginsonly', 'core_plugin'), 'data-filterby' => 'newplugin']
1733 ).' '.html_writer
::span($numnew, 'badge bg-success text-white number number-newplugin');
1739 $infomissing = html_writer
::link(
1740 new moodle_url($this->page
->url
, [], 'missing'),
1741 get_string('status_missing', 'plugin'),
1742 ['title' => get_string('filtermissingonly', 'core_plugin'), 'data-filterby' => 'missing']
1743 ).' '.html_writer
::span($nummissing, 'badge bg-danger text-white number number-missing');
1748 $out = html_writer
::start_div('', ['id' => 'plugins-overview-panel']);
1750 if ($numinstallable) {
1751 $out .= $this->output
->single_button(
1752 new moodle_url($this->page
->url
, array('installupdatex' => 1)),
1753 get_string('updateavailableinstallall', 'core_admin', $numinstallable),
1755 array('class' => 'singlebutton updateavailableinstallall')
1759 $out .= html_writer
::div($infoall, 'info info-all').
1760 html_writer
::div($infoext, 'info info-additional').
1761 html_writer
::div($infoupdatable, 'info info-updatable').
1762 html_writer
::div($infonew, 'info info-newplugin').
1763 html_writer
::div($infomissing, 'info info-missing');
1765 $out .= html_writer
::end_div(); // End of #plugins-overview-panel block.
1771 * Displays all known plugins and links to manage them
1773 * This default implementation renders all plugins into one big table.
1775 * @param core_plugin_manager $pluginman provides information about the plugins.
1776 * @param array $options filtering options
1777 * @return string HTML code
1779 public function plugins_control_panel(core_plugin_manager
$pluginman, array $options = array()) {
1781 $plugininfo = $pluginman->get_plugins();
1783 $table = new html_table();
1784 $table->id
= 'plugins-control-panel';
1785 $table->head
= array(
1786 get_string('displayname', 'core_plugin'),
1787 get_string('version', 'core_plugin'),
1788 get_string('availability', 'core_plugin'),
1789 get_string('actions', 'core_plugin'),
1790 get_string('notes','core_plugin'),
1792 $table->headspan
= array(1, 1, 1, 2, 1);
1793 $table->colclasses
= array(
1794 'pluginname', 'version', 'availability', 'settings', 'uninstall', 'notes'
1797 foreach ($plugininfo as $type => $plugins) {
1798 $heading = $pluginman->plugintype_name_plural($type);
1799 $pluginclass = core_plugin_manager
::resolve_plugininfo_class($type);
1800 if ($manageurl = $pluginclass::get_manage_url()) {
1801 $heading .= $this->output
->action_icon($manageurl, new pix_icon('i/settings',
1802 get_string('settings', 'core_plugin')));
1804 $header = new html_table_cell(html_writer
::tag('span', $heading, array('id'=>'plugin_type_cell_'.$type)));
1805 $header->header
= true;
1806 $header->colspan
= array_sum($table->headspan
);
1807 $header = new html_table_row(array($header));
1808 $header->attributes
['class'] = 'plugintypeheader type-' . $type;
1809 $table->data
[] = $header;
1811 if (empty($plugins)) {
1812 $msg = new html_table_cell(get_string('noneinstalled', 'core_plugin'));
1813 $msg->colspan
= array_sum($table->headspan
);
1814 $row = new html_table_row(array($msg));
1815 $row->attributes
['class'] .= 'msg msg-noneinstalled';
1816 $table->data
[] = $row;
1820 foreach ($plugins as $name => $plugin) {
1821 $component = "{$plugin->type}_{$plugin->name}";
1823 $row = new html_table_row();
1824 $row->attributes
['class'] = "type-{$plugin->type} name-{$component}";
1826 $iconidentifier = 'icon';
1827 if ($plugin->type
=== 'mod') {
1828 $iconidentifier = 'monologo';
1831 if ($this->page
->theme
->resolve_image_location($iconidentifier, $component, null)) {
1832 $icon = $this->output
->pix_icon($iconidentifier, '', $component, [
1833 'class' => 'icon pluginicon',
1836 $icon = $this->output
->spacer();
1838 $status = $plugin->get_status();
1839 $row->attributes
['class'] .= ' status-'.$status;
1840 $pluginname = html_writer
::tag('div', $icon.$plugin->displayname
, array('class' => 'displayname')).
1841 html_writer
::tag('div', $plugin->component
, array('class' => 'componentname'));
1842 $pluginname = new html_table_cell($pluginname);
1844 $version = html_writer
::div($plugin->versiondb
, 'versionnumber');
1845 if ((string)$plugin->release
!== '') {
1846 $version = html_writer
::div($plugin->release
, 'release').$version;
1848 $version = new html_table_cell($version);
1850 $isenabled = $plugin->is_enabled();
1851 if (is_null($isenabled)) {
1852 $availability = new html_table_cell('');
1853 } else if ($isenabled) {
1854 $row->attributes
['class'] .= ' enabled';
1855 $availability = new html_table_cell(get_string('pluginenabled', 'core_plugin'));
1857 $row->attributes
['class'] .= ' disabled';
1858 $availability = new html_table_cell(get_string('plugindisabled', 'core_plugin'));
1861 $settingsurl = $plugin->get_settings_url();
1862 if (!is_null($settingsurl)) {
1863 $settings = html_writer
::link($settingsurl, get_string('settings', 'core_plugin'), array('class' => 'settings'));
1867 $settings = new html_table_cell($settings);
1869 if ($uninstallurl = $pluginman->get_uninstall_url($plugin->component
, 'overview')) {
1870 $uninstall = html_writer
::link($uninstallurl, get_string('uninstall', 'core_plugin'));
1874 $uninstall = new html_table_cell($uninstall);
1876 if ($plugin->is_standard()) {
1877 $row->attributes
['class'] .= ' standard';
1880 $row->attributes
['class'] .= ' additional';
1881 $source = html_writer
::div(get_string('sourceext', 'core_plugin'), 'source badge mr-1 bg-info text-white');
1884 if ($status === core_plugin_manager
::PLUGIN_STATUS_MISSING
) {
1885 $row->attributes
['class'] .= ' missing';
1886 $msg = html_writer
::div(get_string('status_missing', 'core_plugin'), 'statusmsg badge bg-danger text-white');
1887 } else if ($status === core_plugin_manager
::PLUGIN_STATUS_NEW
) {
1888 $row->attributes
['class'] .= ' newplugin';
1889 $msg = html_writer
::div(get_string('status_new', 'core_plugin'), 'statusmsg badge bg-success text-white');
1894 $requriedby = $pluginman->other_plugins_that_require($plugin->component
);
1896 $requiredby = html_writer
::tag('div', get_string('requiredby', 'core_plugin', implode(', ', $requriedby)),
1897 array('class' => 'requiredby'));
1903 if (is_array($plugin->available_updates())) {
1904 $row->attributes
['class'] .= ' updatable';
1905 foreach ($plugin->available_updates() as $availableupdate) {
1906 $updateinfo .= $this->plugin_available_update_info($pluginman, $availableupdate);
1910 $notes = new html_table_cell($source.$msg.$requiredby.$updateinfo);
1912 $row->cells
= array(
1913 $pluginname, $version, $availability, $settings, $uninstall, $notes
1915 $table->data
[] = $row;
1919 return html_writer
::table($table);
1923 * Helper method to render the information about the available plugin update
1925 * @param core_plugin_manager $pluginman plugin manager instance
1926 * @param \core\update\info $updateinfo information about the available update for the plugin
1928 protected function plugin_available_update_info(core_plugin_manager
$pluginman, \core\update\info
$updateinfo) {
1930 $boxclasses = 'pluginupdateinfo';
1933 if (isset($updateinfo->release
)) {
1934 $info[] = html_writer
::div(
1935 get_string('updateavailable_release', 'core_plugin', $updateinfo->release
),
1940 if (isset($updateinfo->maturity
)) {
1941 $info[] = html_writer
::div(
1942 get_string('maturity'.$updateinfo->maturity
, 'core_admin'),
1945 $boxclasses .= ' maturity'.$updateinfo->maturity
;
1948 if (isset($updateinfo->download
)) {
1949 $info[] = html_writer
::div(
1950 html_writer
::link($updateinfo->download
, get_string('download')),
1955 if (isset($updateinfo->url
)) {
1956 $info[] = html_writer
::div(
1957 html_writer
::link($updateinfo->url
, get_string('updateavailable_moreinfo', 'core_plugin')),
1962 $box = html_writer
::start_div($boxclasses);
1963 $box .= html_writer
::div(
1964 get_string('updateavailable', 'core_plugin', $updateinfo->version
),
1967 $box .= html_writer
::div(
1968 implode(html_writer
::span(' ', 'separator'), $info),
1972 if ($pluginman->is_remote_plugin_installable($updateinfo->component
, $updateinfo->version
, $reason, false)) {
1973 $box .= $this->output
->single_button(
1974 new moodle_url($this->page
->url
, array('installupdate' => $updateinfo->component
,
1975 'installupdateversion' => $updateinfo->version
)),
1976 get_string('updateavailableinstall', 'core_admin'),
1978 array('class' => 'singlebutton updateavailableinstall')
1981 $reasonhelp = $this->info_remote_plugin_not_installable($reason);
1983 $box .= html_writer
::div($reasonhelp, 'reasonhelp updateavailableinstall');
1986 $box .= html_writer
::end_div();
1992 * This function will render one beautiful table with all the environmental
1993 * configuration and how it suits Moodle needs.
1995 * @param boolean $result final result of the check (true/false)
1996 * @param environment_results[] $environment_results array of results gathered
1997 * @return string HTML to output.
1999 public function environment_check_table($result, $environment_results) {
2003 $servertable = new html_table();//table for server checks
2004 $servertable->head
= array(
2007 get_string('report'),
2008 get_string('plugin'),
2009 get_string('status'),
2011 $servertable->colclasses
= array('centeralign name', 'centeralign info', 'leftalign report', 'leftalign plugin', 'centeralign status');
2012 $servertable->attributes
['class'] = 'admintable environmenttable generaltable table-sm';
2013 $servertable->id
= 'serverstatus';
2015 $serverdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
2017 $othertable = new html_table();//table for custom checks
2018 $othertable->head
= array(
2020 get_string('report'),
2021 get_string('plugin'),
2022 get_string('status'),
2024 $othertable->colclasses
= array('aligncenter info', 'alignleft report', 'alignleft plugin', 'aligncenter status');
2025 $othertable->attributes
['class'] = 'admintable environmenttable generaltable table-sm';
2026 $othertable->id
= 'otherserverstatus';
2028 $otherdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
2030 // Iterate over each environment_result
2032 foreach ($environment_results as $environment_result) {
2034 $warningline = false;
2037 $type = $environment_result->getPart();
2038 $info = $environment_result->getInfo();
2039 $status = $environment_result->getStatus();
2040 $plugin = $environment_result->getPluginName();
2041 $error_code = $environment_result->getErrorCode();
2042 // Process Report field
2043 $rec = new stdClass();
2044 // Something has gone wrong at parsing time
2046 $stringtouse = 'environmentxmlerror';
2047 $rec->error_code
= $error_code;
2048 $status = get_string('error');
2054 if ($rec->needed
= $environment_result->getNeededVersion()) {
2055 // We are comparing versions
2056 $rec->current
= $environment_result->getCurrentVersion();
2057 if ($environment_result->getLevel() == 'required') {
2058 $stringtouse = 'environmentrequireversion';
2060 $stringtouse = 'environmentrecommendversion';
2063 } else if ($environment_result->getPart() == 'custom_check') {
2064 // We are checking installed & enabled things
2065 if ($environment_result->getLevel() == 'required') {
2066 $stringtouse = 'environmentrequirecustomcheck';
2067 } else if ($environment_result->getLevel() == 'optional') {
2068 $stringtouse = 'environmentrecommendcustomcheck';
2070 $stringtouse = 'environmentshouldfixcustomcheck';
2073 } else if ($environment_result->getPart() == 'php_setting') {
2075 $stringtouse = 'environmentsettingok';
2076 } else if ($environment_result->getLevel() == 'required') {
2077 $stringtouse = 'environmentmustfixsetting';
2079 $stringtouse = 'environmentshouldfixsetting';
2083 if ($environment_result->getLevel() == 'required') {
2084 $stringtouse = 'environmentrequireinstall';
2086 $stringtouse = 'environmentrecommendinstall';
2090 // Calculate the status value
2091 if ($environment_result->getBypassStr() != '') { //Handle bypassed result (warning)
2092 $status = get_string('bypassed');
2093 $warningline = true;
2094 } else if ($environment_result->getRestrictStr() != '') { //Handle restricted result (error)
2095 $status = get_string('restricted');
2098 if ($status) { //Handle ok result (ok)
2099 $status = get_string('statusok');
2101 // Handle check result (warning).
2102 if (in_array($environment_result->getLevel(), ['optional', 'recommended'])) {
2103 $status = get_string('check');
2104 $warningline = true;
2105 } else { //Handle error result (error)
2106 $status = get_string('check');
2114 $linkparts = array();
2115 $linkparts[] = 'admin/environment';
2116 $linkparts[] = $type;
2118 $linkparts[] = $info;
2120 // Plugin environments do not have docs pages yet.
2121 if (empty($CFG->docroot
) or $environment_result->plugin
) {
2122 $report = get_string($stringtouse, 'admin', $rec);
2124 $report = $this->doc_link(join('/', $linkparts), get_string($stringtouse, 'admin', $rec), true);
2126 // Enclose report text in div so feedback text will be displayed underneath it.
2127 $report = html_writer
::div($report);
2129 // Format error or warning line
2131 $messagetype = 'error';
2132 $statusclass = 'bg-danger text-white';
2133 } else if ($warningline) {
2134 $messagetype = 'warn';
2135 $statusclass = 'bg-warning text-dark';
2137 $messagetype = 'ok';
2138 $statusclass = 'bg-success text-white';
2140 $status = html_writer
::span($status, 'badge ' . $statusclass);
2141 // Here we'll store all the feedback found
2143 // Append the feedback if there is some
2144 $feedbacktext .= $environment_result->strToReport($environment_result->getFeedbackStr(), $messagetype);
2145 //Append the bypass if there is some
2146 $feedbacktext .= $environment_result->strToReport($environment_result->getBypassStr(), 'warn');
2147 //Append the restrict if there is some
2148 $feedbacktext .= $environment_result->strToReport($environment_result->getRestrictStr(), 'error');
2150 $report .= $feedbacktext;
2152 // Add the row to the table
2153 if ($environment_result->getPart() == 'custom_check'){
2154 $otherdata[$messagetype][] = array ($info, $report, $plugin, $status);
2156 $serverdata[$messagetype][] = array ($type, $info, $report, $plugin, $status);
2161 //put errors first in
2162 $servertable->data
= array_merge($serverdata['error'], $serverdata['warn'], $serverdata['ok']);
2163 $othertable->data
= array_merge($otherdata['error'], $otherdata['warn'], $otherdata['ok']);
2167 $output .= $this->heading(get_string('serverchecks', 'admin'));
2168 $output .= html_writer
::table($servertable);
2169 if (count($othertable->data
)){
2170 $output .= $this->heading(get_string('customcheck', 'admin'));
2171 $output .= html_writer
::table($othertable);
2174 // Finally, if any error has happened, print the summary box
2176 $output .= $this->box(get_string('environmenterrortodo', 'admin'), 'environmentbox errorbox');
2183 * Render a simple page for providing the upgrade key.
2185 * @param moodle_url|string $url
2188 public function upgradekey_form_page($url) {
2191 $output .= $this->header();
2192 $output .= $this->container_start('upgradekeyreq');
2193 $output .= $this->heading(get_string('upgradekeyreq', 'core_admin'));
2194 $output .= html_writer
::start_tag('form', array('method' => 'POST', 'action' => $url));
2195 $output .= html_writer
::empty_tag('input', [
2196 'name' => 'upgradekey',
2197 'type' => 'password',
2198 'class' => 'form-control w-auto',
2200 $output .= html_writer
::empty_tag('input', [
2202 'value' => get_string('submit'),
2203 'class' => 'btn btn-primary mt-3',
2205 $output .= html_writer
::end_tag('form');
2206 $output .= $this->container_end();
2207 $output .= $this->footer();
2213 * Display message about the benefits of registering on Moodle.org
2217 public function moodleorg_registration_message() {
2218 $a = new stdClass();
2219 $a->moreinformation
= '#id_sitestats'; // More information anchor.
2220 $a->moodleapp
= HUB_MOODLEORGHUBURL
. '/solutions/moodle-app/';
2221 $out = format_text(get_string('registerwithmoodleorginfo', 'core_hub', $a), FORMAT_MARKDOWN
);
2223 $out .= html_writer
::link(
2224 HUB_MOODLEORGHUBURL
,
2225 $this->output
->pix_icon('i/stats', '').' '.get_string('registerwithmoodleorginfostats', 'core_hub'),
2226 ['class' => 'btn btn-link', 'role' => 'opener', 'target' => '_href']
2229 $out .= html_writer
::link(
2230 HUB_MOODLEORGHUBURL
.'/sites',
2231 $this->output
->pix_icon('i/location', '').' '.get_string('registerwithmoodleorginfosites', 'core_hub'),
2232 ['class' => 'btn btn-link', 'role' => 'opener', 'target' => '_href']
2235 return $this->output
->box($out);
2239 * Display message about benefits of enabling the user feedback feature.
2241 * @param bool $showfeedbackencouragement Whether the encouragement content should be displayed or not
2244 protected function userfeedback_encouragement(bool $showfeedbackencouragement): string {
2247 if ($showfeedbackencouragement) {
2248 $settingslink = new moodle_url('/admin/settings.php', ['section' => 'userfeedback']);
2249 $output .= $this->warning(get_string('userfeedbackencouragement', 'admin', $settingslink->out()), 'info');
2256 * Display a warning about the deprecation of Mnet.
2258 * @param string $xmlrpcwarning The warning message
2259 * @return string HTML to output.
2261 protected function mnet_deprecation_warning($xmlrpcwarning) {
2262 if (empty($xmlrpcwarning)) {
2266 return $this->warning($xmlrpcwarning);
2270 * Renders the theme selector list.
2272 * @param core_admin\output\theme_selector $themeselector
2273 * @return string HTML
2275 public function theme_selector_list(core_admin\output\theme_selector
$themeselector): string {
2276 $renderable = $themeselector->export_for_template($this);
2277 return $this->render_from_template('core_admin/themeselector/theme_selector', $renderable);