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();
28 require_once($CFG->libdir . '/pluginlib.php');
31 * Standard HTML output renderer for core_admin subsystem
33 class core_admin_renderer extends plugin_renderer_base {
36 * Display the 'Do you acknowledge the terms of the GPL' page. The first page
38 * @return string HTML to output.
40 public function install_licence_page() {
44 $copyrightnotice = text_to_html(get_string('gpl3'));
45 $copyrightnotice = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $copyrightnotice); // extremely ugly validation hack
47 $continue = new single_button(new moodle_url('/admin/index.php', array('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('/admin/index.php', array('agreelicense' => 1, 'lang' => $CFG->lang)));
102 $output .= $this->notification(get_string('environmentok', 'admin'), 'notifysuccess');
103 $output .= $this->continue_button(new moodle_url('/admin/index.php', array('agreelicense'=>1, 'confirmrelease'=>1, 'lang'=>$CFG->lang)));
106 $output .= $this->footer();
111 * Displays the list of plugins with unsatisfied dependencies
113 * @param double|string|int $version Moodle on-disk version
114 * @param array $failed list of plugins with unsatisfied dependecies
115 * @param moodle_url $reloadurl URL of the page to recheck the dependencies
116 * @return string HTML
118 public function unsatisfied_dependencies_page($version, array $failed, moodle_url $reloadurl) {
121 $output .= $this->header();
122 $output .= $this->heading(get_string('pluginscheck', 'admin'));
123 $output .= $this->warning(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
124 $output .= $this->plugins_check_table(plugin_manager::instance(), $version, array('xdep' => true));
125 $output .= $this->warning(get_string('pluginschecktodo', 'admin'));
126 $output .= $this->continue_button($reloadurl);
128 $output .= $this->footer();
134 * Display the 'You are about to upgrade Moodle' page. The first page
136 * @param string $strnewversion
137 * @param int $maturity
138 * @return string HTML to output.
140 public function upgrade_confirm_page($strnewversion, $maturity) {
143 $continueurl = new moodle_url('/admin/index.php', array('confirmupgrade' => 1));
144 $continue = new single_button($continueurl, get_string('continue'), 'get');
145 $cancelurl = new moodle_url('/admin/index.php');
147 $output .= $this->header();
148 $output .= $this->maturity_warning($maturity);
149 $output .= $this->confirm(get_string('upgradesure', 'admin', $strnewversion), $continue, $cancelurl);
150 $output .= $this->footer();
156 * Display the environment page during the upgrade process.
157 * @param string $release
158 * @param boolean $envstatus final result of env check (true/false)
159 * @param array $environment_results array of results gathered
160 * @return string HTML to output.
162 public function upgrade_environment_page($release, $envstatus, $environment_results) {
166 $output .= $this->header();
167 $output .= $this->heading("Moodle $release");
168 $output .= $this->release_notes_link();
169 $output .= $this->environment_check_table($envstatus, $environment_results);
172 $output .= $this->upgrade_reload(new moodle_url('/admin/index.php'), array('confirmupgrade' => 1));
175 $output .= $this->notification(get_string('environmentok', 'admin'), 'notifysuccess');
177 if (empty($CFG->skiplangupgrade) and current_language() !== 'en') {
178 $output .= $this->box(get_string('langpackwillbeupdated', 'admin'), 'generalbox', 'notice');
181 $output .= $this->continue_button(new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1)));
184 $output .= $this->footer();
190 * Display the upgrade page that lists all the plugins that require attention.
191 * @param plugin_manager $pluginman provides information about the plugins.
192 * @param available_update_checker $checker provides information about available updates.
193 * @param int $version the version of the Moodle code from version.php.
194 * @param bool $showallplugins
195 * @param moodle_url $reloadurl
196 * @param moodle_url $continueurl
197 * @return string HTML to output.
199 public function upgrade_plugin_check_page(plugin_manager $pluginman, available_update_checker $checker,
200 $version, $showallplugins, $reloadurl, $continueurl) {
205 $output .= $this->header();
206 $output .= $this->box_start('generalbox');
207 $output .= $this->container_start('generalbox', 'notice');
208 $output .= html_writer::tag('p', get_string('pluginchecknotice', 'core_plugin'));
209 if (empty($CFG->disableupdatenotifications)) {
210 $output .= $this->container_start('checkforupdates');
211 $output .= $this->single_button(new moodle_url($reloadurl, array('fetchupdates' => 1)), get_string('checkforupdates', 'core_plugin'));
212 if ($timefetched = $checker->get_last_timefetched()) {
213 $output .= $this->container(get_string('checkforupdateslast', 'core_plugin',
214 userdate($timefetched, get_string('strftimedatetime', 'core_langconfig'))));
216 $output .= $this->container_end();
218 $output .= $this->container_end();
220 $output .= $this->plugins_check_table($pluginman, $version, array('full' => $showallplugins));
221 $output .= $this->box_end();
222 $output .= $this->upgrade_reload($reloadurl);
224 if ($pluginman->some_plugins_updatable()) {
225 $output .= $this->container_start('upgradepluginsinfo');
226 $output .= $this->help_icon('upgradepluginsinfo', 'core_admin', get_string('upgradepluginsfirst', 'core_admin'));
227 $output .= $this->container_end();
230 $button = new single_button($continueurl, get_string('upgradestart', 'admin'), 'get');
231 $button->class = 'continuebutton';
232 $output .= $this->render($button);
233 $output .= $this->footer();
239 * Prints a page with a summary of plugin deployment to be confirmed.
241 * @param available_update_deployer $deployer
242 * @param array $data deployer's data package as returned by {@link available_update_deployer::submitted_data()}
245 public function upgrade_plugin_confirm_deploy_page(available_update_deployer $deployer, array $data) {
247 if (!$deployer->initialized()) {
248 throw new coding_exception('Unable to render a page for non-initialized deployer.');
251 if (empty($data['updateinfo'])) {
252 throw new coding_exception('Missing required data component.');
255 $updateinfo = $data['updateinfo'];
258 $output .= $this->header();
259 $output .= $this->container_start('generalbox updateplugin', 'notice');
262 if (get_string_manager()->string_exists('pluginname', $updateinfo->component)) {
263 $a->name = get_string('pluginname', $updateinfo->component);
265 $a->name = $updateinfo->component;
268 if (isset($updateinfo->release)) {
269 $a->version = $updateinfo->release . ' (' . $updateinfo->version . ')';
271 $a->version = $updateinfo->version;
273 $a->url = $updateinfo->download;
275 $output .= $this->output->heading(get_string('updatepluginconfirm', 'core_plugin'));
276 $output .= $this->output->container(format_text(get_string('updatepluginconfirminfo', 'core_plugin', $a)), 'updatepluginconfirminfo');
277 $output .= $this->output->container(get_string('updatepluginconfirmwarning', 'core_plugin', 'updatepluginconfirmwarning'));
279 if ($repotype = $deployer->plugin_external_source($data['updateinfo'])) {
280 $output .= $this->output->container(get_string('updatepluginconfirmexternal', 'core_plugin', $repotype), 'updatepluginconfirmexternal');
283 $widget = $deployer->make_execution_widget($data['updateinfo'], $data['returnurl']);
284 $output .= $this->output->render($widget);
286 $output .= $this->output->single_button($data['callerurl'], get_string('cancel', 'core'), 'get');
288 $output .= $this->container_end();
289 $output .= $this->footer();
295 * Display the admin notifications page.
296 * @param int $maturity
297 * @param bool $insecuredataroot warn dataroot is invalid
298 * @param bool $errorsdisplayed warn invalid dispaly error setting
299 * @param bool $cronoverdue warn cron not running
300 * @param bool $dbproblems warn db has problems
301 * @param bool $maintenancemode warn in maintenance mode
302 * @param bool $buggyiconvnomb warn iconv problems
303 * @param array|null $availableupdates array of available_update_info objects or null
304 * @param int|null $availableupdatesfetch timestamp of the most recent updates fetch or null (unknown)
306 * @return string HTML to output.
308 public function admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed,
309 $cronoverdue, $dbproblems, $maintenancemode, $availableupdates, $availableupdatesfetch,
310 $buggyiconvnomb, $registered) {
314 $output .= $this->header();
315 $output .= $this->maturity_info($maturity);
316 $output .= empty($CFG->disableupdatenotifications) ? $this->available_updates($availableupdates, $availableupdatesfetch) : '';
317 $output .= $this->insecure_dataroot_warning($insecuredataroot);
318 $output .= $this->display_errors_warning($errorsdisplayed);
319 $output .= $this->buggy_iconv_warning($buggyiconvnomb);
320 $output .= $this->cron_overdue_warning($cronoverdue);
321 $output .= $this->db_problems($dbproblems);
322 $output .= $this->maintenance_mode_warning($maintenancemode);
323 $output .= $this->registration_warning($registered);
325 //////////////////////////////////////////////////////////////////////////////////////////////////
326 //// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO HIDE, REMOVE OR MODIFY THIS COPYRIGHT NOTICE ///
327 $output .= $this->moodle_copyright();
328 //////////////////////////////////////////////////////////////////////////////////////////////////
330 $output .= $this->footer();
336 * Display the plugin management page (admin/plugins.php).
338 * The filtering options array may contain following items:
339 * bool contribonly - show only contributed extensions
340 * bool updatesonly - show only plugins with an available update
342 * @param plugin_manager $pluginman
343 * @param available_update_checker $checker
344 * @param array $options filtering options
345 * @return string HTML to output.
347 public function plugin_management_page(plugin_manager $pluginman, available_update_checker $checker, array $options = array()) {
352 $output .= $this->header();
353 $output .= $this->heading(get_string('pluginsoverview', 'core_admin'));
354 $output .= $this->plugins_overview_panel($pluginman, $options);
356 if (empty($CFG->disableupdatenotifications)) {
357 $output .= $this->container_start('checkforupdates');
358 $output .= $this->single_button(
359 new moodle_url($this->page->url, array_merge($options, array('fetchremote' => 1))),
360 get_string('checkforupdates', 'core_plugin')
362 if ($timefetched = $checker->get_last_timefetched()) {
363 $output .= $this->container(get_string('checkforupdateslast', 'core_plugin',
364 userdate($timefetched, get_string('strftimedatetime', 'core_langconfig'))));
366 $output .= $this->container_end();
369 $output .= $this->box($this->plugins_control_panel($pluginman, $options), 'generalbox');
370 $output .= $this->footer();
376 * Display a page to confirm the plugin uninstallation.
378 * @param plugin_manager $pluginman
379 * @param plugininfo_base $pluginfo
380 * @param moodle_url $continueurl URL to continue after confirmation
383 public function plugin_uninstall_confirm_page(plugin_manager $pluginman, plugininfo_base $pluginfo, moodle_url $continueurl) {
386 $pluginname = $pluginman->plugin_name($pluginfo->component);
388 $confirm = '<p>' . get_string('uninstallconfirm', 'core_plugin', array('name' => $pluginname)) . '</p>';
389 if ($extraconfirm = $pluginfo->get_uninstall_extra_warning()) {
390 $confirm .= $extraconfirm;
393 $output .= $this->output->header();
394 $output .= $this->output->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
395 $output .= $this->output->confirm($confirm, $continueurl, $this->page->url);
396 $output .= $this->output->footer();
402 * Display a page with results of plugin uninstallation and offer removal of plugin files.
404 * @param plugin_manager $pluginman
405 * @param plugininfo_base $pluginfo
406 * @param progress_trace_buffer $progress
407 * @param moodle_url $continueurl URL to continue to remove the plugin folder
410 public function plugin_uninstall_results_removable_page(plugin_manager $pluginman, plugininfo_base $pluginfo,
411 progress_trace_buffer $progress, moodle_url $continueurl) {
414 $pluginname = $pluginman->plugin_name($pluginfo->component);
416 // Do not show navigation here, they must click one of the buttons.
417 $this->page->set_pagelayout('maintenance');
418 $this->page->set_cacheable(false);
420 $output .= $this->output->header();
421 $output .= $this->output->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
423 $output .= $this->output->box($progress->get_buffer(), 'generalbox uninstallresultmessage');
425 $confirm = $this->output->container(get_string('uninstalldeleteconfirm', 'core_plugin',
426 array('name' => $pluginname, 'rootdir' => $pluginfo->rootdir)), 'uninstalldeleteconfirm');
428 if ($repotype = $pluginman->plugin_external_source($pluginfo->component)) {
429 $confirm .= $this->output->container(get_string('uninstalldeleteconfirmexternal', 'core_plugin', $repotype),
430 'uninstalldeleteconfirmexternal');
433 // After any uninstall we must execute full upgrade to finish the cleanup!
434 $output .= $this->output->confirm($confirm, $continueurl, new moodle_url('/admin/index.php'));
435 $output .= $this->output->footer();
441 * Display a page with results of plugin uninstallation and inform about the need to remove plugin files manually.
443 * @param plugin_manager $pluginman
444 * @param plugininfo_base $pluginfo
445 * @param progress_trace_buffer $progress
448 public function plugin_uninstall_results_page(plugin_manager $pluginman, plugininfo_base $pluginfo, progress_trace_buffer $progress) {
451 $pluginname = $pluginman->plugin_name($pluginfo->component);
453 $output .= $this->output->header();
454 $output .= $this->output->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
456 $output .= $this->output->box($progress->get_buffer(), 'generalbox uninstallresultmessage');
458 $output .= $this->output->box(get_string('uninstalldelete', 'core_plugin',
459 array('name' => $pluginname, 'rootdir' => $pluginfo->rootdir)), 'generalbox uninstalldelete');
460 $output .= $this->output->continue_button($this->page->url);
461 $output .= $this->output->footer();
467 * Display the plugin management page (admin/environment.php).
468 * @param array $versions
469 * @param string $version
470 * @param boolean $envstatus final result of env check (true/false)
471 * @param array $environment_results array of results gathered
472 * @return string HTML to output.
474 public function environment_check_page($versions, $version, $envstatus, $environment_results) {
476 $output .= $this->header();
478 // Print the component download link
479 $output .= html_writer::tag('div', html_writer::link(
480 new moodle_url('/admin/environment.php', array('action' => 'updatecomponent', 'sesskey' => sesskey())),
481 get_string('updatecomponent', 'admin')),
482 array('class' => 'reportlink'));
485 $output .= $this->heading(get_string('environment', 'admin'));
487 // Box with info and a menu to choose the version.
488 $output .= $this->box_start();
489 $output .= html_writer::tag('div', get_string('adminhelpenvironment'));
490 $select = new single_select(new moodle_url('/admin/environment.php'), 'version', $versions, $version, null);
491 $select->label = get_string('moodleversion');
492 $output .= $this->render($select);
493 $output .= $this->box_end();
496 $output .= $this->environment_check_table($envstatus, $environment_results);
498 $output .= $this->footer();
503 * Output a warning message, of the type that appears on the admin notifications page.
504 * @param string $message the message to display.
505 * @param string $type type class
506 * @return string HTML to output.
508 protected function warning($message, $type = 'warning') {
509 return $this->box($message, 'generalbox admin' . $type);
513 * Render an appropriate message if dataroot is insecure.
514 * @param bool $insecuredataroot
515 * @return string HTML to output.
517 protected function insecure_dataroot_warning($insecuredataroot) {
520 if ($insecuredataroot == INSECURE_DATAROOT_WARNING) {
521 return $this->warning(get_string('datarootsecuritywarning', 'admin', $CFG->dataroot));
523 } else if ($insecuredataroot == INSECURE_DATAROOT_ERROR) {
524 return $this->warning(get_string('datarootsecurityerror', 'admin', $CFG->dataroot), 'error');
532 * Render an appropriate message if dataroot is insecure.
533 * @param bool $errorsdisplayed
534 * @return string HTML to output.
536 protected function display_errors_warning($errorsdisplayed) {
537 if (!$errorsdisplayed) {
541 return $this->warning(get_string('displayerrorswarning', 'admin'));
545 * Render an appropriate message if iconv is buggy and mbstring missing.
546 * @param bool $buggyiconvnomb
547 * @return string HTML to output.
549 protected function buggy_iconv_warning($buggyiconvnomb) {
550 if (!$buggyiconvnomb) {
554 return $this->warning(get_string('warningiconvbuggy', 'admin'));
558 * Render an appropriate message if cron has not been run recently.
559 * @param bool $cronoverdue
560 * @return string HTML to output.
562 public function cron_overdue_warning($cronoverdue) {
567 return $this->warning(get_string('cronwarning', 'admin') . ' ' .
568 $this->help_icon('cron', 'admin'));
572 * Render an appropriate message if there are any problems with the DB set-up.
573 * @param bool $dbproblems
574 * @return string HTML to output.
576 public function db_problems($dbproblems) {
581 return $this->warning($dbproblems);
585 * Render an appropriate message if the site in in maintenance mode.
586 * @param bool $maintenancemode
587 * @return string HTML to output.
589 public function maintenance_mode_warning($maintenancemode) {
590 if (!$maintenancemode) {
594 $url = new moodle_url('/admin/settings.php', array('section' => 'maintenancemode'));
595 $url = $url->out(); // get_string() does not support objects in params
597 return $this->warning(get_string('sitemaintenancewarning2', 'admin', $url));
601 * Display a warning about installing development code if necesary.
602 * @param int $maturity
603 * @return string HTML to output.
605 protected function maturity_warning($maturity) {
606 if ($maturity == MATURITY_STABLE) {
607 return ''; // No worries.
610 $maturitylevel = get_string('maturity' . $maturity, 'admin');
612 $this->container(get_string('maturitycorewarning', 'admin', $maturitylevel)) .
613 $this->container($this->doc_link('admin/versions', get_string('morehelp'))),
614 'generalbox maturitywarning');
618 * Output the copyright notice.
619 * @return string HTML to output.
621 protected function moodle_copyright() {
624 //////////////////////////////////////////////////////////////////////////////////////////////////
625 //// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO HIDE, REMOVE OR MODIFY THIS COPYRIGHT NOTICE ///
626 $copyrighttext = '<a href="http://moodle.org/">Moodle</a> '.
627 '<a href="http://docs.moodle.org/dev/Releases" title="'.$CFG->version.'">'.$CFG->release.'</a><br />'.
628 'Copyright © 1999 onwards, Martin Dougiamas<br />'.
629 'and <a href="http://moodle.org/dev">many other contributors</a>.<br />'.
630 '<a href="http://docs.moodle.org/dev/License">GNU Public License</a>';
631 //////////////////////////////////////////////////////////////////////////////////////////////////
633 return $this->box($copyrighttext, 'copyright');
637 * Display a warning about installing development code if necesary.
638 * @param int $maturity
639 * @return string HTML to output.
641 protected function maturity_info($maturity) {
642 if ($maturity == MATURITY_STABLE) {
643 return ''; // No worries.
646 $maturitylevel = get_string('maturity' . $maturity, 'admin');
648 get_string('maturitycoreinfo', 'admin', $maturitylevel) . ' ' .
649 $this->doc_link('admin/versions', get_string('morehelp')),
650 'generalbox adminwarning maturityinfo maturity'.$maturity);
654 * Displays the info about available Moodle core and plugin updates
656 * The structure of the $updates param has changed since 2.4. It contains not only updates
657 * for the core itself, but also for all other installed plugins.
659 * @param array|null $updates array of (string)component => array of available_update_info objects or null
660 * @param int|null $fetch timestamp of the most recent updates fetch or null (unknown)
663 protected function available_updates($updates, $fetch) {
665 $updateinfo = $this->box_start('generalbox adminwarning availableupdatesinfo');
666 $someupdateavailable = false;
667 if (is_array($updates)) {
668 if (is_array($updates['core'])) {
669 $someupdateavailable = true;
670 $updateinfo .= $this->heading(get_string('updateavailable', 'core_admin'), 3);
671 foreach ($updates['core'] as $update) {
672 $updateinfo .= $this->moodle_available_update_info($update);
675 unset($updates['core']);
676 // If something has left in the $updates array now, it is updates for plugins.
677 if (!empty($updates)) {
678 $someupdateavailable = true;
679 $updateinfo .= $this->heading(get_string('updateavailableforplugin', 'core_admin'), 3);
680 $pluginsoverviewurl = new moodle_url('/admin/plugins.php', array('updatesonly' => 1));
681 $updateinfo .= $this->container(get_string('pluginsoverviewsee', 'core_admin',
682 array('url' => $pluginsoverviewurl->out())));
686 if (!$someupdateavailable) {
688 if ($fetch and ($fetch <= $now) and ($now - $fetch < HOURSECS)) {
689 $updateinfo .= $this->heading(get_string('updateavailablenot', 'core_admin'), 3);
693 $updateinfo .= $this->container_start('checkforupdates');
694 $fetchurl = new moodle_url('/admin/index.php', array('fetchupdates' => 1, 'sesskey' => sesskey(), 'cache' => 1));
695 $updateinfo .= $this->single_button($fetchurl, get_string('checkforupdates', 'core_plugin'));
697 $updateinfo .= $this->container(get_string('checkforupdateslast', 'core_plugin',
698 userdate($fetch, get_string('strftimedatetime', 'core_langconfig'))));
700 $updateinfo .= $this->container_end();
702 $updateinfo .= $this->box_end();
708 * Display a warning about not being registered on Moodle.org if necesary.
710 * @param boolean $registered true if the site is registered on Moodle.org
711 * @return string HTML to output.
713 protected function registration_warning($registered) {
717 $registerbutton = $this->single_button(new moodle_url('/admin/registration/register.php',
718 array('huburl' => HUB_MOODLEORGHUBURL, 'hubname' => 'Moodle.org')),
719 get_string('register', 'admin'));
721 return $this->warning( get_string('registrationwarning', 'admin')
722 . ' ' . $this->help_icon('registration', 'admin') . $registerbutton );
729 * Helper method to render the information about the available Moodle update
731 * @param available_update_info $updateinfo information about the available Moodle core update
733 protected function moodle_available_update_info(available_update_info $updateinfo) {
735 $boxclasses = 'moodleupdateinfo';
738 if (isset($updateinfo->release)) {
739 $info[] = html_writer::tag('span', get_string('updateavailable_release', 'core_admin', $updateinfo->release),
740 array('class' => 'info release'));
743 if (isset($updateinfo->version)) {
744 $info[] = html_writer::tag('span', get_string('updateavailable_version', 'core_admin', $updateinfo->version),
745 array('class' => 'info version'));
748 if (isset($updateinfo->maturity)) {
749 $info[] = html_writer::tag('span', get_string('maturity'.$updateinfo->maturity, 'core_admin'),
750 array('class' => 'info maturity'));
751 $boxclasses .= ' maturity'.$updateinfo->maturity;
754 if (isset($updateinfo->download)) {
755 $info[] = html_writer::link($updateinfo->download, get_string('download'), array('class' => 'info download'));
758 if (isset($updateinfo->url)) {
759 $info[] = html_writer::link($updateinfo->url, get_string('updateavailable_moreinfo', 'core_plugin'),
760 array('class' => 'info more'));
763 $box = $this->output->box_start($boxclasses);
764 $box .= $this->output->box(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $info), '');
765 $box .= $this->output->box_end();
771 * Display a link to the release notes.
772 * @return string HTML to output.
774 protected function release_notes_link() {
775 $releasenoteslink = get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/dev/Releases');
776 $releasenoteslink = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $releasenoteslink); // extremely ugly validation hack
777 return $this->box($releasenoteslink, 'generalbox releasenoteslink');
781 * Display the reload link that appears on several upgrade/install pages.
782 * @return string HTML to output.
784 function upgrade_reload($url) {
785 return html_writer::empty_tag('br') .
786 html_writer::tag('div',
787 html_writer::link($url, $this->pix_icon('i/reload', '', '', array('class' => 'icon icon-pre')) .
788 get_string('reload'), array('title' => get_string('reload'))),
789 array('class' => 'continuebutton')) . html_writer::empty_tag('br');
793 * Displays all known plugins and information about their installation or upgrade
795 * This default implementation renders all plugins into one big table. The rendering
797 * (bool)full = false: whether to display up-to-date plugins, too
798 * (bool)xdep = false: display the plugins with unsatisified dependecies only
800 * @param plugin_manager $pluginman provides information about the plugins.
801 * @param int $version the version of the Moodle code from version.php.
802 * @param array $options rendering options
803 * @return string HTML code
805 public function plugins_check_table(plugin_manager $pluginman, $version, array $options = array()) {
808 $plugininfo = $pluginman->get_plugins();
810 if (empty($plugininfo)) {
814 $options['full'] = isset($options['full']) ? (bool)$options['full'] : false;
815 $options['xdep'] = isset($options['xdep']) ? (bool)$options['xdep'] : false;
817 $table = new html_table();
818 $table->id = 'plugins-check';
819 $table->head = array(
820 get_string('displayname', 'core_plugin'),
821 get_string('rootdir', 'core_plugin'),
822 get_string('source', 'core_plugin'),
823 get_string('versiondb', 'core_plugin'),
824 get_string('versiondisk', 'core_plugin'),
825 get_string('requires', 'core_plugin'),
826 get_string('status', 'core_plugin'),
828 $table->colclasses = array(
829 'displayname', 'rootdir', 'source', 'versiondb', 'versiondisk', 'requires', 'status',
831 $table->data = array();
833 $numofhighlighted = array(); // number of highlighted rows per this subsection
835 foreach ($plugininfo as $type => $plugins) {
837 $header = new html_table_cell($pluginman->plugintype_name_plural($type));
838 $header->header = true;
839 $header->colspan = count($table->head);
840 $header = new html_table_row(array($header));
841 $header->attributes['class'] = 'plugintypeheader type-' . $type;
843 $numofhighlighted[$type] = 0;
845 if (empty($plugins) and $options['full']) {
846 $msg = new html_table_cell(get_string('noneinstalled', 'core_plugin'));
847 $msg->colspan = count($table->head);
848 $row = new html_table_row(array($msg));
849 $row->attributes['class'] .= 'msg msg-noneinstalled';
850 $table->data[] = $header;
851 $table->data[] = $row;
855 $plugintyperows = array();
857 foreach ($plugins as $name => $plugin) {
858 $row = new html_table_row();
859 $row->attributes['class'] = 'type-' . $plugin->type . ' name-' . $plugin->type . '_' . $plugin->name;
861 if ($this->page->theme->resolve_image_location('icon', $plugin->type . '_' . $plugin->name, null)) {
862 $icon = $this->output->pix_icon('icon', '', $plugin->type . '_' . $plugin->name, array('class' => 'smallicon pluginicon'));
864 $icon = $this->output->pix_icon('spacer', '', 'moodle', array('class' => 'smallicon pluginicon noicon'));
866 $displayname = $icon . ' ' . $plugin->displayname;
867 $displayname = new html_table_cell($displayname);
869 $rootdir = new html_table_cell($plugin->get_dir());
871 if ($isstandard = $plugin->is_standard()) {
872 $row->attributes['class'] .= ' standard';
873 $source = new html_table_cell(get_string('sourcestd', 'core_plugin'));
875 $row->attributes['class'] .= ' extension';
876 $source = new html_table_cell(get_string('sourceext', 'core_plugin'));
879 $versiondb = new html_table_cell($plugin->versiondb);
880 $versiondisk = new html_table_cell($plugin->versiondisk);
882 $statuscode = $plugin->get_status();
883 $row->attributes['class'] .= ' status-' . $statuscode;
884 $status = get_string('status_' . $statuscode, 'core_plugin');
886 $availableupdates = $plugin->available_updates();
887 if (!empty($availableupdates) and empty($CFG->disableupdatenotifications)) {
888 foreach ($availableupdates as $availableupdate) {
889 $status .= $this->plugin_available_update_info($availableupdate);
893 $status = new html_table_cell($status);
895 $requires = new html_table_cell($this->required_column($plugin, $pluginman, $version));
897 $statusisboring = in_array($statuscode, array(
898 plugin_manager::PLUGIN_STATUS_NODB, plugin_manager::PLUGIN_STATUS_UPTODATE));
900 $coredependency = $plugin->is_core_dependency_satisfied($version);
901 $otherpluginsdependencies = $pluginman->are_dependencies_satisfied($plugin->get_other_required_plugins());
902 $dependenciesok = $coredependency && $otherpluginsdependencies;
904 if ($options['xdep']) {
905 // we want to see only plugins with failed dependencies
906 if ($dependenciesok) {
910 } else if ($statusisboring and $dependenciesok and empty($availableupdates)) {
911 // no change is going to happen to the plugin - display it only
912 // if the user wants to see the full list
913 if (empty($options['full'])) {
918 // ok, the plugin should be displayed
919 $numofhighlighted[$type]++;
921 $row->cells = array($displayname, $rootdir, $source,
922 $versiondb, $versiondisk, $requires, $status);
923 $plugintyperows[] = $row;
926 if (empty($numofhighlighted[$type]) and empty($options['full'])) {
930 $table->data[] = $header;
931 $table->data = array_merge($table->data, $plugintyperows);
934 $sumofhighlighted = array_sum($numofhighlighted);
936 if ($options['xdep']) {
937 // we do not want to display no heading and links in this mode
940 } else if ($sumofhighlighted == 0) {
941 $out = $this->output->container_start('nonehighlighted', 'plugins-check-info');
942 $out .= $this->output->heading(get_string('nonehighlighted', 'core_plugin'));
943 if (empty($options['full'])) {
944 $out .= html_writer::link(new moodle_url('/admin/index.php',
945 array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 1)),
946 get_string('nonehighlightedinfo', 'core_plugin'));
948 $out .= $this->output->container_end();
951 $out = $this->output->container_start('somehighlighted', 'plugins-check-info');
952 $out .= $this->output->heading(get_string('somehighlighted', 'core_plugin', $sumofhighlighted));
953 if (empty($options['full'])) {
954 $out .= html_writer::link(new moodle_url('/admin/index.php',
955 array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 1)),
956 get_string('somehighlightedinfo', 'core_plugin'));
958 $out .= html_writer::link(new moodle_url('/admin/index.php',
959 array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 0)),
960 get_string('somehighlightedonly', 'core_plugin'));
962 $out .= $this->output->container_end();
965 if ($sumofhighlighted > 0 or $options['full']) {
966 $out .= html_writer::table($table);
973 * Formats the information that needs to go in the 'Requires' column.
974 * @param plugininfo_base $plugin the plugin we are rendering the row for.
975 * @param plugin_manager $pluginman provides data on all the plugins.
976 * @param string $version
977 * @return string HTML code
979 protected function required_column(plugininfo_base $plugin, plugin_manager $pluginman, $version) {
982 if (!empty($plugin->versionrequires)) {
983 if ($plugin->versionrequires <= $version) {
984 $class = 'requires-ok';
986 $class = 'requires-failed';
988 $requires[] = html_writer::tag('li',
989 get_string('moodleversion', 'core_plugin', $plugin->versionrequires),
990 array('class' => $class));
993 foreach ($plugin->get_other_required_plugins() as $component => $requiredversion) {
995 $otherplugin = $pluginman->get_plugin_info($component);
997 if (is_null($otherplugin)) {
999 } else if ($requiredversion != ANY_VERSION and $otherplugin->versiondisk < $requiredversion) {
1004 $class = 'requires-ok';
1006 $class = 'requires-failed';
1009 if ($requiredversion != ANY_VERSION) {
1010 $str = 'otherpluginversion';
1012 $str = 'otherplugin';
1014 $requires[] = html_writer::tag('li',
1015 get_string($str, 'core_plugin',
1016 array('component' => $component, 'version' => $requiredversion)),
1017 array('class' => $class));
1023 return html_writer::tag('ul', implode("\n", $requires));
1027 * Prints an overview about the plugins - number of installed, number of extensions etc.
1029 * @param plugin_manager $pluginman provides information about the plugins
1030 * @param array $options filtering options
1031 * @return string as usually
1033 public function plugins_overview_panel(plugin_manager $pluginman, array $options = array()) {
1036 $plugininfo = $pluginman->get_plugins();
1038 $numtotal = $numdisabled = $numextension = $numupdatable = 0;
1040 foreach ($plugininfo as $type => $plugins) {
1041 foreach ($plugins as $name => $plugin) {
1042 if ($plugin->get_status() === plugin_manager::PLUGIN_STATUS_MISSING) {
1046 if ($plugin->is_enabled() === false) {
1049 if (!$plugin->is_standard()) {
1052 if (empty($CFG->disableupdatenotifications) and $plugin->available_updates()) {
1060 $somefilteractive = false;
1061 $info[] = html_writer::tag('span', get_string('numtotal', 'core_plugin', $numtotal), array('class' => 'info total'));
1062 $info[] = html_writer::tag('span', get_string('numdisabled', 'core_plugin', $numdisabled), array('class' => 'info disabled'));
1063 $info[] = html_writer::tag('span', get_string('numextension', 'core_plugin', $numextension), array('class' => 'info extension'));
1064 if ($numextension > 0) {
1065 if (empty($options['contribonly'])) {
1066 $filter[] = html_writer::link(
1067 new moodle_url($this->page->url, array('contribonly' => 1)),
1068 get_string('filtercontribonly', 'core_plugin'),
1069 array('class' => 'filter-item show-contribonly')
1072 $filter[] = html_writer::tag('span', get_string('filtercontribonlyactive', 'core_plugin'),
1073 array('class' => 'filter-item active show-contribonly'));
1074 $somefilteractive = true;
1077 if ($numupdatable > 0) {
1078 $info[] = html_writer::tag('span', get_string('numupdatable', 'core_plugin', $numupdatable), array('class' => 'info updatable'));
1079 if (empty($options['updatesonly'])) {
1080 $filter[] = html_writer::link(
1081 new moodle_url($this->page->url, array('updatesonly' => 1)),
1082 get_string('filterupdatesonly', 'core_plugin'),
1083 array('class' => 'filter-item show-updatesonly')
1086 $filter[] = html_writer::tag('span', get_string('filterupdatesonlyactive', 'core_plugin'),
1087 array('class' => 'filter-item active show-updatesonly'));
1088 $somefilteractive = true;
1091 if ($somefilteractive) {
1092 $filter[] = html_writer::link($this->page->url, get_string('filterall', 'core_plugin'), array('class' => 'filter-item show-all'));
1095 $output = $this->output->box(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $info), '', 'plugins-overview-panel');
1097 if (!empty($filter)) {
1098 $output .= $this->output->box(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $filter), '', 'plugins-overview-filter');
1105 * Displays all known plugins and links to manage them
1107 * This default implementation renders all plugins into one big table.
1109 * @param plugin_manager $pluginman provides information about the plugins.
1110 * @param array $options filtering options
1111 * @return string HTML code
1113 public function plugins_control_panel(plugin_manager $pluginman, array $options = array()) {
1116 $plugininfo = $pluginman->get_plugins();
1118 // Filter the list of plugins according the options.
1119 if (!empty($options['updatesonly'])) {
1120 $updateable = array();
1121 foreach ($plugininfo as $plugintype => $pluginnames) {
1122 foreach ($pluginnames as $pluginname => $pluginfo) {
1123 if (!empty($pluginfo->availableupdates)) {
1124 foreach ($pluginfo->availableupdates as $pluginavailableupdate) {
1125 if ($pluginavailableupdate->version > $pluginfo->versiondisk) {
1126 $updateable[$plugintype][$pluginname] = $pluginfo;
1132 $plugininfo = $updateable;
1135 if (!empty($options['contribonly'])) {
1136 $contribs = array();
1137 foreach ($plugininfo as $plugintype => $pluginnames) {
1138 foreach ($pluginnames as $pluginname => $pluginfo) {
1139 if (!$pluginfo->is_standard()) {
1140 $contribs[$plugintype][$pluginname] = $pluginfo;
1144 $plugininfo = $contribs;
1147 if (empty($plugininfo)) {
1151 $table = new html_table();
1152 $table->id = 'plugins-control-panel';
1153 $table->head = array(
1154 get_string('displayname', 'core_plugin'),
1155 get_string('source', 'core_plugin'),
1156 get_string('version', 'core_plugin'),
1157 get_string('availability', 'core_plugin'),
1158 get_string('actions', 'core_plugin'),
1159 get_string('notes','core_plugin'),
1161 $table->headspan = array(1, 1, 1, 1, 2, 1);
1162 $table->colclasses = array(
1163 'pluginname', 'source', 'version', 'availability', 'settings', 'uninstall', 'notes'
1166 foreach ($plugininfo as $type => $plugins) {
1168 $header = new html_table_cell($pluginman->plugintype_name_plural($type));
1169 $header->header = true;
1170 $header->colspan = array_sum($table->headspan);
1171 $header = new html_table_row(array($header));
1172 $header->attributes['class'] = 'plugintypeheader type-' . $type;
1173 $table->data[] = $header;
1175 if (empty($plugins)) {
1176 $msg = new html_table_cell(get_string('noneinstalled', 'core_plugin'));
1177 $msg->colspan = array_sum($table->headspan);
1178 $row = new html_table_row(array($msg));
1179 $row->attributes['class'] .= 'msg msg-noneinstalled';
1180 $table->data[] = $row;
1184 foreach ($plugins as $name => $plugin) {
1185 $row = new html_table_row();
1186 $row->attributes['class'] = 'type-' . $plugin->type . ' name-' . $plugin->type . '_' . $plugin->name;
1188 if ($this->page->theme->resolve_image_location('icon', $plugin->type . '_' . $plugin->name)) {
1189 $icon = $this->output->pix_icon('icon', '', $plugin->type . '_' . $plugin->name, array('class' => 'icon pluginicon'));
1191 $icon = $this->output->pix_icon('spacer', '', 'moodle', array('class' => 'icon pluginicon noicon'));
1193 $status = $plugin->get_status();
1194 $row->attributes['class'] .= ' status-'.$status;
1195 if ($status === plugin_manager::PLUGIN_STATUS_MISSING) {
1196 $msg = html_writer::tag('span', get_string('status_missing', 'core_plugin'), array('class' => 'statusmsg'));
1197 } else if ($status === plugin_manager::PLUGIN_STATUS_NEW) {
1198 $msg = html_writer::tag('span', get_string('status_new', 'core_plugin'), array('class' => 'statusmsg'));
1202 $pluginname = html_writer::tag('div', $icon . '' . $plugin->displayname . ' ' . $msg, array('class' => 'displayname')).
1203 html_writer::tag('div', $plugin->component, array('class' => 'componentname'));
1204 $pluginname = new html_table_cell($pluginname);
1206 if ($plugin->is_standard()) {
1207 $row->attributes['class'] .= ' standard';
1208 $source = new html_table_cell(get_string('sourcestd', 'core_plugin'));
1210 $row->attributes['class'] .= ' extension';
1211 $source = new html_table_cell(get_string('sourceext', 'core_plugin'));
1214 $version = new html_table_cell($plugin->versiondb);
1216 $isenabled = $plugin->is_enabled();
1217 if (is_null($isenabled)) {
1218 $availability = new html_table_cell('');
1219 } else if ($isenabled) {
1220 $row->attributes['class'] .= ' enabled';
1221 $availability = new html_table_cell(get_string('pluginenabled', 'core_plugin'));
1223 $row->attributes['class'] .= ' disabled';
1224 $availability = new html_table_cell(get_string('plugindisabled', 'core_plugin'));
1227 $settingsurl = $plugin->get_settings_url();
1228 if (!is_null($settingsurl)) {
1229 $settings = html_writer::link($settingsurl, get_string('settings', 'core_plugin'), array('class' => 'settings'));
1233 $settings = new html_table_cell($settings);
1235 if ($pluginman->can_uninstall_plugin($plugin->component)) {
1236 $uninstallurl = $plugin->get_uninstall_url();
1237 $uninstall = html_writer::link($uninstallurl, get_string('uninstall', 'core_plugin'));
1241 $uninstall = new html_table_cell($uninstall);
1243 $requriedby = $pluginman->other_plugins_that_require($plugin->component);
1245 $requiredby = html_writer::tag('div', get_string('requiredby', 'core_plugin', implode(', ', $requriedby)),
1246 array('class' => 'requiredby'));
1252 if (empty($CFG->disableupdatenotifications) and is_array($plugin->available_updates())) {
1253 foreach ($plugin->available_updates() as $availableupdate) {
1254 $updateinfo .= $this->plugin_available_update_info($availableupdate);
1258 $notes = new html_table_cell($requiredby.$updateinfo);
1260 $row->cells = array(
1261 $pluginname, $source, $version, $availability, $settings, $uninstall, $notes
1263 $table->data[] = $row;
1267 return html_writer::table($table);
1271 * Helper method to render the information about the available plugin update
1273 * The passed objects always provides at least the 'version' property containing
1274 * the (higher) version of the plugin available.
1276 * @param available_update_info $updateinfo information about the available update for the plugin
1278 protected function plugin_available_update_info(available_update_info $updateinfo) {
1280 $boxclasses = 'pluginupdateinfo';
1283 if (isset($updateinfo->release)) {
1284 $info[] = html_writer::tag('span', get_string('updateavailable_release', 'core_plugin', $updateinfo->release),
1285 array('class' => 'info release'));
1288 if (isset($updateinfo->maturity)) {
1289 $info[] = html_writer::tag('span', get_string('maturity'.$updateinfo->maturity, 'core_admin'),
1290 array('class' => 'info maturity'));
1291 $boxclasses .= ' maturity'.$updateinfo->maturity;
1294 if (isset($updateinfo->download)) {
1295 $info[] = html_writer::link($updateinfo->download, get_string('download'), array('class' => 'info download'));
1298 if (isset($updateinfo->url)) {
1299 $info[] = html_writer::link($updateinfo->url, get_string('updateavailable_moreinfo', 'core_plugin'),
1300 array('class' => 'info more'));
1303 $box = $this->output->box_start($boxclasses);
1304 $box .= html_writer::tag('div', get_string('updateavailable', 'core_plugin', $updateinfo->version), array('class' => 'version'));
1305 $box .= $this->output->box(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $info), '');
1307 $deployer = available_update_deployer::instance();
1308 if ($deployer->initialized()) {
1309 $impediments = $deployer->deployment_impediments($updateinfo);
1310 if (empty($impediments)) {
1311 $widget = $deployer->make_confirm_widget($updateinfo);
1312 $box .= $this->output->render($widget);
1314 if (isset($impediments['notwritable'])) {
1315 $box .= $this->output->help_icon('notwritable', 'core_plugin', get_string('notwritable', 'core_plugin'));
1317 if (isset($impediments['notdownloadable'])) {
1318 $box .= $this->output->help_icon('notdownloadable', 'core_plugin', get_string('notdownloadable', 'core_plugin'));
1323 $box .= $this->output->box_end();
1329 * This function will render one beautiful table with all the environmental
1330 * configuration and how it suits Moodle needs.
1332 * @param boolean $result final result of the check (true/false)
1333 * @param array $environment_results array of results gathered
1334 * @return string HTML to output.
1336 public function environment_check_table($result, $environment_results) {
1340 $servertable = new html_table();//table for server checks
1341 $servertable->head = array(
1344 get_string('report'),
1345 get_string('status'),
1347 $servertable->colclasses = array('centeralign name', 'centeralign status', 'leftalign report', 'centeralign info');
1348 $servertable->attributes['class'] = 'admintable environmenttable generaltable';
1349 $servertable->id = 'serverstatus';
1351 $serverdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
1353 $othertable = new html_table();//table for custom checks
1354 $othertable->head = array(
1356 get_string('report'),
1357 get_string('status'),
1359 $othertable->colclasses = array('aligncenter info', 'alignleft report', 'aligncenter status');
1360 $othertable->attributes['class'] = 'admintable environmenttable generaltable';
1361 $othertable->id = 'otherserverstatus';
1363 $otherdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
1365 // Iterate over each environment_result
1367 foreach ($environment_results as $environment_result) {
1369 $warningline = false;
1372 $type = $environment_result->getPart();
1373 $info = $environment_result->getInfo();
1374 $status = $environment_result->getStatus();
1375 $error_code = $environment_result->getErrorCode();
1376 // Process Report field
1377 $rec = new stdClass();
1378 // Something has gone wrong at parsing time
1380 $stringtouse = 'environmentxmlerror';
1381 $rec->error_code = $error_code;
1382 $status = get_string('error');
1388 if ($rec->needed = $environment_result->getNeededVersion()) {
1389 // We are comparing versions
1390 $rec->current = $environment_result->getCurrentVersion();
1391 if ($environment_result->getLevel() == 'required') {
1392 $stringtouse = 'environmentrequireversion';
1394 $stringtouse = 'environmentrecommendversion';
1397 } else if ($environment_result->getPart() == 'custom_check') {
1398 // We are checking installed & enabled things
1399 if ($environment_result->getLevel() == 'required') {
1400 $stringtouse = 'environmentrequirecustomcheck';
1402 $stringtouse = 'environmentrecommendcustomcheck';
1405 } else if ($environment_result->getPart() == 'php_setting') {
1407 $stringtouse = 'environmentsettingok';
1408 } else if ($environment_result->getLevel() == 'required') {
1409 $stringtouse = 'environmentmustfixsetting';
1411 $stringtouse = 'environmentshouldfixsetting';
1415 if ($environment_result->getLevel() == 'required') {
1416 $stringtouse = 'environmentrequireinstall';
1418 $stringtouse = 'environmentrecommendinstall';
1422 // Calculate the status value
1423 if ($environment_result->getBypassStr() != '') { //Handle bypassed result (warning)
1424 $status = get_string('bypassed');
1425 $warningline = true;
1426 } else if ($environment_result->getRestrictStr() != '') { //Handle restricted result (error)
1427 $status = get_string('restricted');
1430 if ($status) { //Handle ok result (ok)
1431 $status = get_string('ok');
1433 if ($environment_result->getLevel() == 'optional') {//Handle check result (warning)
1434 $status = get_string('check');
1435 $warningline = true;
1436 } else { //Handle error result (error)
1437 $status = get_string('check');
1445 $linkparts = array();
1446 $linkparts[] = 'admin/environment';
1447 $linkparts[] = $type;
1449 $linkparts[] = $info;
1451 if (empty($CFG->docroot)) {
1452 $report = get_string($stringtouse, 'admin', $rec);
1454 $report = $this->doc_link(join($linkparts, '/'), get_string($stringtouse, 'admin', $rec));
1457 // Format error or warning line
1458 if ($errorline || $warningline) {
1459 $messagetype = $errorline? 'error':'warn';
1461 $messagetype = 'ok';
1463 $status = '<span class="'.$messagetype.'">'.$status.'</span>';
1464 // Here we'll store all the feedback found
1466 // Append the feedback if there is some
1467 $feedbacktext .= $environment_result->strToReport($environment_result->getFeedbackStr(), $messagetype);
1468 //Append the bypass if there is some
1469 $feedbacktext .= $environment_result->strToReport($environment_result->getBypassStr(), 'warn');
1470 //Append the restrict if there is some
1471 $feedbacktext .= $environment_result->strToReport($environment_result->getRestrictStr(), 'error');
1473 $report .= $feedbacktext;
1475 // Add the row to the table
1476 if ($environment_result->getPart() == 'custom_check'){
1477 $otherdata[$messagetype][] = array ($info, $report, $status);
1479 $serverdata[$messagetype][] = array ($type, $info, $report, $status);
1484 //put errors first in
1485 $servertable->data = array_merge($serverdata['error'], $serverdata['warn'], $serverdata['ok']);
1486 $othertable->data = array_merge($otherdata['error'], $otherdata['warn'], $otherdata['ok']);
1490 $output .= $this->heading(get_string('serverchecks', 'admin'));
1491 $output .= html_writer::table($servertable);
1492 if (count($othertable->data)){
1493 $output .= $this->heading(get_string('customcheck', 'admin'));
1494 $output .= html_writer::table($othertable);
1497 // Finally, if any error has happened, print the summary box
1499 $output .= $this->box(get_string('environmenterrortodo', 'admin'), 'environmentbox errorbox');