Merge branch 'w23_MDL-33007_m23_buggyiconv' of git://github.com/skodak/moodle
[moodle.git] / admin / renderer.php
CommitLineData
b9934a17
DM
1<?php
2// This file is part of Moodle - http://moodle.org/
3//
4// Moodle is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Moodle is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16
17/**
18 * Renderer for core_admin subsystem
19 *
20 * @package core
21 * @subpackage admin
22 * @copyright 2011 David Mudrak <david@moodle.com>
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 */
25
26defined('MOODLE_INTERNAL') || die();
27
28require_once($CFG->libdir . '/pluginlib.php');
29
30/**
31 * Standard HTML output renderer for core_admin subsystem
32 */
33class core_admin_renderer extends plugin_renderer_base {
34
cc359566
TH
35 /**
36 * Display the 'Do you acknowledge the terms of the GPL' page. The first page
37 * during install.
38 * @return string HTML to output.
39 */
40 public function install_licence_page() {
41 global $CFG;
42 $output = '';
43
44 $copyrightnotice = text_to_html(get_string('gpl3'));
45 $copyrightnotice = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $copyrightnotice); // extremely ugly validation hack
46
47 $continue = new single_button(new moodle_url('/admin/index.php', array('lang'=>$CFG->lang, 'agreelicense'=>1)), get_string('continue'), 'get');
48
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();
56
57 return $output;
58 }
59
9008ec16
PS
60 /**
61 * Display page explaining proper upgrade process,
62 * there can not be any PHP file leftovers...
63 *
64 * @return string HTML to output.
65 */
66 public function upgrade_stale_php_files_page() {
67 $output = '';
68 $output .= $this->header();
69 $output .= $this->heading(get_string('upgradestalefiles', 'admin'));
70 $output .= $this->box_start('generalbox', 'notice');
71 $output .= get_string('upgradestalefilesinfo', 'admin', get_docs_url('Upgrading'));
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();
cc359566
TH
76
77 return $output;
78 }
79
80 /**
81 * Display the 'environment check' page that is displayed during install.
8d1da748
PS
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
cc359566
TH
86 * @return string HTML to output.
87 */
8d1da748 88 public function install_environment_page($maturity, $envstatus, $environment_results, $release) {
cc359566
TH
89 global $CFG;
90 $output = '';
91
92 $output .= $this->header();
93 $output .= $this->maturity_warning($maturity);
94 $output .= $this->heading("Moodle $release");
95 $output .= $this->release_notes_link();
96
97 $output .= $this->environment_check_table($envstatus, $environment_results);
98
99 if (!$envstatus) {
100 $output .= $this->upgrade_reload(new moodle_url('/admin/index.php', array('agreelicense' => 1, 'lang' => $CFG->lang)));
101 } else {
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)));
104 }
105
106 $output .= $this->footer();
107 return $output;
108 }
109
39f15cc7
DM
110 /**
111 * Displays the list of plugins with unsatisfied dependencies
112 *
113 * @param double|string|int $version Moodle on-disk version
114 * @param array $failed list of plugins with unsatisfied dependecies
e937c545 115 * @param moodle_url $reloadurl URL of the page to recheck the dependencies
39f15cc7
DM
116 * @return string HTML
117 */
118 public function unsatisfied_dependencies_page($version, array $failed, moodle_url $reloadurl) {
119 $output = '';
120
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);
127
128 $output .= $this->footer();
129
130 return $output;
131 }
132
cc359566
TH
133 /**
134 * Display the 'You are about to upgrade Moodle' page. The first page
135 * during upgrade.
8d1da748
PS
136 * @param string $strnewversion
137 * @param int $maturity
cc359566
TH
138 * @return string HTML to output.
139 */
140 public function upgrade_confirm_page($strnewversion, $maturity) {
141 $output = '';
142
143 $continueurl = new moodle_url('index.php', array('confirmupgrade' => 1));
144 $cancelurl = new moodle_url('index.php');
145
146 $output .= $this->header();
147 $output .= $this->maturity_warning($maturity);
148 $output .= $this->confirm(get_string('upgradesure', 'admin', $strnewversion), $continueurl, $cancelurl);
149 $output .= $this->footer();
150
151 return $output;
152 }
153
154 /**
155 * Display the environment page during the upgrade process.
8d1da748
PS
156 * @param string $release
157 * @param boolean $envstatus final result of env check (true/false)
158 * @param array $environment_results array of results gathered
cc359566
TH
159 * @return string HTML to output.
160 */
161 public function upgrade_environment_page($release, $envstatus, $environment_results) {
162 global $CFG;
163 $output = '';
164
165 $output .= $this->header();
166 $output .= $this->heading("Moodle $release");
167 $output .= $this->release_notes_link();
168 $output .= $this->environment_check_table($envstatus, $environment_results);
169
170 if (!$envstatus) {
171 $output .= $this->upgrade_reload(new moodle_url('/admin/index.php'), array('confirmupgrade' => 1));
172
173 } else {
faadd326 174 $output .= $this->notification(get_string('environmentok', 'admin'), 'notifysuccess');
cc359566
TH
175
176 if (empty($CFG->skiplangupgrade) and current_language() !== 'en') {
177 $output .= $this->box(get_string('langpackwillbeupdated', 'admin'), 'generalbox', 'notice');
178 }
179
180 $output .= $this->continue_button(new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1)));
181 }
182
183 $output .= $this->footer();
184
185 return $output;
186 }
187
188 /**
189 * Display the upgrade page that lists all the plugins that require attention.
8d1da748 190 * @param plugin_manager $pluginman provides information about the plugins.
96dd9237 191 * @param available_update_checker $checker provides information about available updates.
8d1da748
PS
192 * @param int $version the version of the Moodle code from version.php.
193 * @param bool $showallplugins
194 * @param moodle_url $reloadurl
195 * @param moodle_url $continueurl
cc359566
TH
196 * @return string HTML to output.
197 */
96dd9237
DM
198 public function upgrade_plugin_check_page(plugin_manager $pluginman, available_update_checker $checker,
199 $version, $showallplugins, $reloadurl, $continueurl) {
fa1d403f 200 global $CFG;
96dd9237 201
cc359566
TH
202 $output = '';
203
204 $output .= $this->header();
205 $output .= $this->box_start('generalbox');
96dd9237
DM
206 $output .= $this->container_start('generalbox', 'notice');
207 $output .= html_writer::tag('p', get_string('pluginchecknotice', 'core_plugin'));
fa1d403f
DM
208 if (empty($CFG->disableupdatenotifications)) {
209 $output .= $this->container_start('checkforupdates');
210 $output .= $this->single_button(new moodle_url($reloadurl, array('fetchupdates' => 1)), get_string('checkforupdates', 'core_plugin'));
211 if ($timefetched = $checker->get_last_timefetched()) {
212 $output .= $this->container(get_string('checkforupdateslast', 'core_plugin',
213 userdate($timefetched, get_string('strftimedatetime', 'core_langconfig'))));
214 }
215 $output .= $this->container_end();
96dd9237
DM
216 }
217 $output .= $this->container_end();
96dd9237 218
faadd326 219 $output .= $this->plugins_check_table($pluginman, $version, array('full' => $showallplugins));
cc359566
TH
220 $output .= $this->box_end();
221 $output .= $this->upgrade_reload($reloadurl);
222
ead8ba3b
DM
223 if ($pluginman->some_plugins_updatable()) {
224 $output .= $this->container_start('upgradepluginsinfo');
225 $output .= $this->help_icon('upgradepluginsinfo', 'core_admin', get_string('upgradepluginsfirst', 'core_admin'));
226 $output .= $this->container_end();
faadd326 227 }
cc359566 228
ead8ba3b
DM
229 $button = new single_button($continueurl, get_string('upgradestart', 'admin'), 'get');
230 $button->class = 'continuebutton';
231 $output .= $this->render($button);
cc359566
TH
232 $output .= $this->footer();
233
234 return $output;
235 }
236
237 /**
238 * Display the admin notifications page.
8d1da748
PS
239 * @param int $maturity
240 * @param bool $insecuredataroot warn dataroot is invalid
241 * @param bool $errorsdisplayed warn invalid dispaly error setting
242 * @param bool $cronoverdue warn cron not running
243 * @param bool $dbproblems warn db has problems
244 * @param bool $maintenancemode warn in maintenance mode
0aff15c2 245 * @param bool $buggyiconvnomb warn iconv problems
55585f3a
DM
246 * @param array|null $availableupdates array of available_update_info objects or null
247 * @param int|null $availableupdatesfetch timestamp of the most recent updates fetch or null (unknown)
248 *
cc359566
TH
249 * @return string HTML to output.
250 */
251 public function admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed,
0aff15c2 252 $cronoverdue, $dbproblems, $maintenancemode, $availableupdates, $availableupdatesfetch, $buggyiconvnomb) {
4db58f5f 253 global $CFG;
cc359566
TH
254 $output = '';
255
256 $output .= $this->header();
257 $output .= $this->maturity_info($maturity);
4db58f5f 258 $output .= empty($CFG->disableupdatenotifications) ? $this->available_updates($availableupdates, $availableupdatesfetch) : '';
cc359566
TH
259 $output .= $this->insecure_dataroot_warning($insecuredataroot);
260 $output .= $this->display_errors_warning($errorsdisplayed);
0aff15c2 261 $output .= $this->buggy_iconv_warning($buggyiconvnomb);
e3258164 262 $output .= $this->cron_overdue_warning($cronoverdue);
cc359566
TH
263 $output .= $this->db_problems($dbproblems);
264 $output .= $this->maintenance_mode_warning($maintenancemode);
265
266 //////////////////////////////////////////////////////////////////////////////////////////////////
267 //// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO HIDE, REMOVE OR MODIFY THIS COPYRIGHT NOTICE ///
268 $output .= $this->moodle_copyright();
269 //////////////////////////////////////////////////////////////////////////////////////////////////
270
271 $output .= $this->footer();
272
273 return $output;
274 }
275
8342171b
DM
276 /**
277 * Display the plugin management page (admin/plugins.php).
278 *
279 * @param plugin_manager $pluginman
280 * @param available_update_checker $checker
281 * @return string HTML to output.
282 */
283 public function plugin_management_page(plugin_manager $pluginman, available_update_checker $checker) {
7716057f
DM
284 global $CFG;
285
8342171b
DM
286 $output = '';
287
288 $output .= $this->header();
289 $output .= $this->heading(get_string('pluginsoverview', 'core_admin'));
290 $output .= $this->plugins_overview_panel($pluginman);
291
7716057f
DM
292 if (empty($CFG->disableupdatenotifications)) {
293 $output .= $this->container_start('checkforupdates');
294 $output .= $this->single_button(new moodle_url($this->page->url, array('fetchremote' => 1)), get_string('checkforupdates', 'core_plugin'));
295 if ($timefetched = $checker->get_last_timefetched()) {
296 $output .= $this->container(get_string('checkforupdateslast', 'core_plugin',
297 userdate($timefetched, get_string('strftimedatetime', 'core_langconfig'))));
298 }
299 $output .= $this->container_end();
8342171b 300 }
8342171b
DM
301
302 $output .= $this->box($this->plugins_control_panel($pluginman), 'generalbox');
303 $output .= $this->footer();
304
305 return $output;
306 }
307
cc359566
TH
308 /**
309 * Display the plugin management page (admin/environment.php).
8d1da748
PS
310 * @param array $versions
311 * @param string $version
312 * @param boolean $envstatus final result of env check (true/false)
313 * @param array $environment_results array of results gathered
cc359566
TH
314 * @return string HTML to output.
315 */
316 public function environment_check_page($versions, $version, $envstatus, $environment_results) {
317 $output = '';
318 $output .= $this->header();
319
320 // Print the component download link
321 $output .= html_writer::tag('div', html_writer::link(
322 new moodle_url('/admin/environment.php', array('action' => 'updatecomponent', 'sesskey' => sesskey())),
323 get_string('updatecomponent', 'admin')),
324 array('class' => 'reportlink'));
325
326 // Heading.
327 $output .= $this->heading(get_string('environment', 'admin'));
328
329 // Box with info and a menu to choose the version.
330 $output .= $this->box_start();
331 $output .= html_writer::tag('div', get_string('adminhelpenvironment'));
332 $select = new single_select(new moodle_url('/admin/environment.php'), 'version', $versions, $version, null);
333 $select->label = get_string('moodleversion');
334 $output .= $this->render($select);
335 $output .= $this->box_end();
336
337 // The results
338 $output .= $this->environment_check_table($envstatus, $environment_results);
339
340 $output .= $this->footer();
341 return $output;
342 }
343
344 /**
345 * Output a warning message, of the type that appears on the admin notifications page.
346 * @param string $message the message to display.
8d1da748 347 * @param string $type type class
cc359566
TH
348 * @return string HTML to output.
349 */
350 protected function warning($message, $type = 'warning') {
351 return $this->box($message, 'generalbox admin' . $type);
352 }
353
354 /**
355 * Render an appropriate message if dataroot is insecure.
8d1da748 356 * @param bool $insecuredataroot
cc359566
TH
357 * @return string HTML to output.
358 */
359 protected function insecure_dataroot_warning($insecuredataroot) {
360 global $CFG;
361
362 if ($insecuredataroot == INSECURE_DATAROOT_WARNING) {
363 return $this->warning(get_string('datarootsecuritywarning', 'admin', $CFG->dataroot));
364
365 } else if ($insecuredataroot == INSECURE_DATAROOT_ERROR) {
366 return $this->warning(get_string('datarootsecurityerror', 'admin', $CFG->dataroot), 'error');
367
368 } else {
369 return '';
370 }
371 }
372
373 /**
374 * Render an appropriate message if dataroot is insecure.
8d1da748 375 * @param bool $errorsdisplayed
cc359566
TH
376 * @return string HTML to output.
377 */
378 protected function display_errors_warning($errorsdisplayed) {
379 if (!$errorsdisplayed) {
380 return '';
381 }
382
383 return $this->warning(get_string('displayerrorswarning', 'admin'));
384 }
385
0aff15c2
PS
386 /**
387 * Render an appropriate message if iconv is buggy and mbstring missing.
388 * @param bool $buggyiconvnomb
389 * @return string HTML to output.
390 */
391 protected function buggy_iconv_warning($buggyiconvnomb) {
392 if (!$buggyiconvnomb) {
393 return '';
394 }
395
396 return $this->warning(get_string('warningiconvbuggy', 'admin'));
397 }
398
cc359566
TH
399 /**
400 * Render an appropriate message if cron has not been run recently.
8d1da748 401 * @param bool $cronoverdue
cc359566
TH
402 * @return string HTML to output.
403 */
404 public function cron_overdue_warning($cronoverdue) {
405 if (!$cronoverdue) {
406 return '';
407 }
408
409 return $this->warning(get_string('cronwarning', 'admin') . '&nbsp;' .
410 $this->help_icon('cron', 'admin'));
411 }
412
413 /**
414 * Render an appropriate message if there are any problems with the DB set-up.
8d1da748 415 * @param bool $dbproblems
cc359566
TH
416 * @return string HTML to output.
417 */
418 public function db_problems($dbproblems) {
419 if (!$dbproblems) {
420 return '';
421 }
422
423 return $this->warning($dbproblems);
424 }
425
426 /**
427 * Render an appropriate message if the site in in maintenance mode.
8d1da748 428 * @param bool $maintenancemode
cc359566
TH
429 * @return string HTML to output.
430 */
431 public function maintenance_mode_warning($maintenancemode) {
432 if (!$maintenancemode) {
433 return '';
434 }
435
ecc2897c
PS
436 $url = new moodle_url('/admin/settings.php', array('section' => 'maintenancemode'));
437 $url = $url->out(); // get_string() does not support objects in params
438
439 return $this->warning(get_string('sitemaintenancewarning2', 'admin', $url));
cc359566
TH
440 }
441
442 /**
443 * Display a warning about installing development code if necesary.
8d1da748 444 * @param int $maturity
cc359566
TH
445 * @return string HTML to output.
446 */
447 protected function maturity_warning($maturity) {
448 if ($maturity == MATURITY_STABLE) {
449 return ''; // No worries.
450 }
451
452 $maturitylevel = get_string('maturity' . $maturity, 'admin');
453 return $this->box(
454 $this->container(get_string('maturitycorewarning', 'admin', $maturitylevel)) .
455 $this->container($this->doc_link('admin/versions', get_string('morehelp'))),
456 'generalbox maturitywarning');
457 }
458
459 /**
460 * Output the copyright notice.
461 * @return string HTML to output.
462 */
463 protected function moodle_copyright() {
464 global $CFG;
465
466 //////////////////////////////////////////////////////////////////////////////////////////////////
467 //// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO HIDE, REMOVE OR MODIFY THIS COPYRIGHT NOTICE ///
468 $copyrighttext = '<a href="http://moodle.org/">Moodle</a> '.
469 '<a href="http://docs.moodle.org/dev/Releases" title="'.$CFG->version.'">'.$CFG->release.'</a><br />'.
470 'Copyright &copy; 1999 onwards, Martin Dougiamas<br />'.
471 'and <a href="http://docs.moodle.org/dev/Credits">many other contributors</a>.<br />'.
472 '<a href="http://docs.moodle.org/dev/License">GNU Public License</a>';
473 //////////////////////////////////////////////////////////////////////////////////////////////////
474
475 return $this->box($copyrighttext, 'copyright');
476 }
477
478 /**
479 * Display a warning about installing development code if necesary.
8d1da748
PS
480 * @param int $maturity
481 * @return string HTML to output.
cc359566
TH
482 */
483 protected function maturity_info($maturity) {
484 if ($maturity == MATURITY_STABLE) {
485 return ''; // No worries.
486 }
487
488 $maturitylevel = get_string('maturity' . $maturity, 'admin');
489 return $this->box(
490 get_string('maturitycoreinfo', 'admin', $maturitylevel) . ' ' .
491 $this->doc_link('admin/versions', get_string('morehelp')),
37f75ad4 492 'generalbox adminwarning maturityinfo maturity'.$maturity);
cc359566
TH
493 }
494
55585f3a
DM
495 /**
496 * Displays the info about available Moodle updates
497 *
498 * @param array|null $updates array of available_update_info objects or null
499 * @param int|null $fetch timestamp of the most recent updates fetch or null (unknown)
500 * @return string
501 */
502 protected function available_updates($updates, $fetch) {
503
504 $updateinfo = $this->box_start('generalbox adminwarning availableupdatesinfo');
505 if (is_array($updates)) {
506 $updateinfo .= $this->heading(get_string('updateavailable', 'core_admin'), 3);
507 foreach ($updates as $update) {
508 $updateinfo .= $this->moodle_available_update_info($update);
509 }
510 } else {
cb1c3291
DM
511 $now = time();
512 if ($fetch and ($fetch <= $now) and ($now - $fetch < HOURSECS)) {
513 $updateinfo .= $this->heading(get_string('updateavailablenot', 'core_admin'), 3);
514 }
55585f3a
DM
515 }
516
517 $updateinfo .= $this->container_start('checkforupdates');
518 $updateinfo .= $this->single_button(new moodle_url($this->page->url, array('fetchupdates' => 1)), get_string('checkforupdates', 'core_plugin'));
519 if ($fetch) {
520 $updateinfo .= $this->container(get_string('checkforupdateslast', 'core_plugin',
521 userdate($fetch, get_string('strftimedatetime', 'core_langconfig'))));
522 }
523 $updateinfo .= $this->container_end();
524
525 $updateinfo .= $this->box_end();
526
527 return $updateinfo;
528 }
529
530 /**
531 * Helper method to render the information about the available Moodle update
532 *
533 * @param available_update_info $updateinfo information about the available Moodle core update
534 */
535 protected function moodle_available_update_info(available_update_info $updateinfo) {
536
537 $boxclasses = 'moodleupdateinfo';
538 $info = array();
539
540 if (isset($updateinfo->release)) {
541 $info[] = html_writer::tag('span', get_string('updateavailable_release', 'core_admin', $updateinfo->release),
542 array('class' => 'info release'));
543 }
544
545 if (isset($updateinfo->version)) {
546 $info[] = html_writer::tag('span', get_string('updateavailable_version', 'core_admin', $updateinfo->version),
547 array('class' => 'info version'));
548 }
549
550 if (isset($updateinfo->maturity)) {
551 $info[] = html_writer::tag('span', get_string('maturity'.$updateinfo->maturity, 'core_admin'),
552 array('class' => 'info maturity'));
553 $boxclasses .= ' maturity'.$updateinfo->maturity;
554 }
555
556 if (isset($updateinfo->download)) {
557 $info[] = html_writer::link($updateinfo->download, get_string('download'), array('class' => 'info download'));
558 }
559
560 if (isset($updateinfo->url)) {
561 $info[] = html_writer::link($updateinfo->url, get_string('updateavailable_moreinfo', 'core_plugin'),
562 array('class' => 'info more'));
563 }
564
565 $box = $this->output->box_start($boxclasses);
566 $box .= $this->output->box(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $info), '');
567 $box .= $this->output->box_end();
568
569 return $box;
570 }
571
cc359566
TH
572 /**
573 * Display a link to the release notes.
8d1da748 574 * @return string HTML to output.
cc359566
TH
575 */
576 protected function release_notes_link() {
577 $releasenoteslink = get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/dev/Releases');
578 $releasenoteslink = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $releasenoteslink); // extremely ugly validation hack
579 return $this->box($releasenoteslink, 'generalbox releasenoteslink');
580 }
581
582 /**
583 * Display the reload link that appears on several upgrade/install pages.
8d1da748 584 * @return string HTML to output.
cc359566
TH
585 */
586 function upgrade_reload($url) {
587 return html_writer::empty_tag('br') .
588 html_writer::tag('div',
589 html_writer::link($url, $this->pix_icon('i/reload', '') .
590 get_string('reload'), array('title' => get_string('reload'))),
591 array('class' => 'continuebutton')) . html_writer::empty_tag('br');
592 }
593
b9934a17
DM
594 /**
595 * Displays all known plugins and information about their installation or upgrade
596 *
597 * This default implementation renders all plugins into one big table. The rendering
598 * options support:
599 * (bool)full = false: whether to display up-to-date plugins, too
39f15cc7 600 * (bool)xdep = false: display the plugins with unsatisified dependecies only
b9934a17 601 *
36ca62ca 602 * @param plugin_manager $pluginman provides information about the plugins.
faadd326 603 * @param int $version the version of the Moodle code from version.php.
b9934a17
DM
604 * @param array $options rendering options
605 * @return string HTML code
606 */
39f15cc7 607 public function plugins_check_table(plugin_manager $pluginman, $version, array $options = array()) {
fa1d403f
DM
608 global $CFG;
609
36ca62ca 610 $plugininfo = $pluginman->get_plugins();
b9934a17
DM
611
612 if (empty($plugininfo)) {
613 return '';
614 }
615
39f15cc7
DM
616 $options['full'] = isset($options['full']) ? (bool)$options['full'] : false;
617 $options['xdep'] = isset($options['xdep']) ? (bool)$options['xdep'] : false;
b9934a17 618
b9934a17
DM
619 $table = new html_table();
620 $table->id = 'plugins-check';
621 $table->head = array(
622 get_string('displayname', 'core_plugin'),
623 get_string('rootdir', 'core_plugin'),
624 get_string('source', 'core_plugin'),
625 get_string('versiondb', 'core_plugin'),
626 get_string('versiondisk', 'core_plugin'),
36ca62ca 627 get_string('requires', 'core_plugin'),
b9934a17
DM
628 get_string('status', 'core_plugin'),
629 );
630 $table->colclasses = array(
36ca62ca 631 'displayname', 'rootdir', 'source', 'versiondb', 'versiondisk', 'requires', 'status',
b9934a17
DM
632 );
633 $table->data = array();
634
635 $numofhighlighted = array(); // number of highlighted rows per this subsection
636
637 foreach ($plugininfo as $type => $plugins) {
638
639 $header = new html_table_cell($pluginman->plugintype_name_plural($type));
640 $header->header = true;
641 $header->colspan = count($table->head);
642 $header = new html_table_row(array($header));
643 $header->attributes['class'] = 'plugintypeheader type-' . $type;
644
645 $numofhighlighted[$type] = 0;
646
647 if (empty($plugins) and $options['full']) {
648 $msg = new html_table_cell(get_string('noneinstalled', 'core_plugin'));
649 $msg->colspan = count($table->head);
650 $row = new html_table_row(array($msg));
651 $row->attributes['class'] .= 'msg msg-noneinstalled';
652 $table->data[] = $header;
653 $table->data[] = $row;
654 continue;
655 }
656
657 $plugintyperows = array();
658
659 foreach ($plugins as $name => $plugin) {
660 $row = new html_table_row();
661 $row->attributes['class'] = 'type-' . $plugin->type . ' name-' . $plugin->type . '_' . $plugin->name;
662
663 if ($this->page->theme->resolve_image_location('icon', $plugin->type . '_' . $plugin->name)) {
664 $icon = $this->output->pix_icon('icon', '', $plugin->type . '_' . $plugin->name, array('class' => 'smallicon pluginicon'));
665 } else {
666 $icon = $this->output->pix_icon('spacer', '', 'moodle', array('class' => 'smallicon pluginicon noicon'));
667 }
668 $displayname = $icon . ' ' . $plugin->displayname;
669 $displayname = new html_table_cell($displayname);
670
671 $rootdir = new html_table_cell($plugin->get_dir());
672
673 if ($isstandard = $plugin->is_standard()) {
674 $row->attributes['class'] .= ' standard';
675 $source = new html_table_cell(get_string('sourcestd', 'core_plugin'));
676 } else {
677 $row->attributes['class'] .= ' extension';
678 $source = new html_table_cell(get_string('sourceext', 'core_plugin'));
679 }
680
681 $versiondb = new html_table_cell($plugin->versiondb);
682 $versiondisk = new html_table_cell($plugin->versiondisk);
683
684 $statuscode = $plugin->get_status();
685 $row->attributes['class'] .= ' status-' . $statuscode;
96dd9237
DM
686 $status = get_string('status_' . $statuscode, 'core_plugin');
687
688 $availableupdates = $plugin->available_updates();
fa1d403f 689 if (!empty($availableupdates) and empty($CFG->disableupdatenotifications)) {
96dd9237
DM
690 foreach ($availableupdates as $availableupdate) {
691 $status .= $this->plugin_available_update_info($availableupdate);
692 }
693 }
b9934a17 694
96dd9237 695 $status = new html_table_cell($status);
b9934a17 696
faadd326 697 $requires = new html_table_cell($this->required_column($plugin, $pluginman, $version));
36ca62ca
TH
698
699 $statusisboring = in_array($statuscode, array(
700 plugin_manager::PLUGIN_STATUS_NODB, plugin_manager::PLUGIN_STATUS_UPTODATE));
e937c545
DM
701
702 $coredependency = $plugin->is_core_dependency_satisfied($version);
703 $otherpluginsdependencies = $pluginman->are_dependencies_satisfied($plugin->get_other_required_plugins());
704 $dependenciesok = $coredependency && $otherpluginsdependencies;
39f15cc7
DM
705
706 if ($options['xdep']) {
707 // we want to see only plugins with failed dependencies
708 if ($dependenciesok) {
709 continue;
710 }
711
712 } else if ($isstandard and $statusisboring and $dependenciesok and empty($availableupdates)) {
713 // no change is going to happen to the plugin - display it only
714 // if the user wants to see the full list
b9934a17
DM
715 if (empty($options['full'])) {
716 continue;
717 }
b9934a17
DM
718 }
719
39f15cc7
DM
720 // ok, the plugin should be displayed
721 $numofhighlighted[$type]++;
722
36ca62ca
TH
723 $row->cells = array($displayname, $rootdir, $source,
724 $versiondb, $versiondisk, $requires, $status);
b9934a17
DM
725 $plugintyperows[] = $row;
726 }
727
728 if (empty($numofhighlighted[$type]) and empty($options['full'])) {
729 continue;
730 }
731
732 $table->data[] = $header;
733 $table->data = array_merge($table->data, $plugintyperows);
734 }
735
736 $sumofhighlighted = array_sum($numofhighlighted);
737
39f15cc7
DM
738 if ($options['xdep']) {
739 // we do not want to display no heading and links in this mode
740 $out = '';
741
742 } else if ($sumofhighlighted == 0) {
b9934a17
DM
743 $out = $this->output->container_start('nonehighlighted', 'plugins-check-info');
744 $out .= $this->output->heading(get_string('nonehighlighted', 'core_plugin'));
745 if (empty($options['full'])) {
746 $out .= html_writer::link(new moodle_url('/admin/index.php',
747 array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 1)),
748 get_string('nonehighlightedinfo', 'core_plugin'));
749 }
750 $out .= $this->output->container_end();
751
752 } else {
753 $out = $this->output->container_start('somehighlighted', 'plugins-check-info');
754 $out .= $this->output->heading(get_string('somehighlighted', 'core_plugin', $sumofhighlighted));
755 if (empty($options['full'])) {
756 $out .= html_writer::link(new moodle_url('/admin/index.php',
757 array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 1)),
758 get_string('somehighlightedinfo', 'core_plugin'));
a687fcac
DM
759 } else {
760 $out .= html_writer::link(new moodle_url('/admin/index.php',
761 array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 0)),
762 get_string('somehighlightedonly', 'core_plugin'));
b9934a17
DM
763 }
764 $out .= $this->output->container_end();
765 }
766
767 if ($sumofhighlighted > 0 or $options['full']) {
768 $out .= html_writer::table($table);
769 }
770
771 return $out;
772 }
773
36ca62ca
TH
774 /**
775 * Formats the information that needs to go in the 'Requires' column.
b6ad8594 776 * @param plugininfo_base $plugin the plugin we are rendering the row for.
36ca62ca 777 * @param plugin_manager $pluginman provides data on all the plugins.
8d1da748
PS
778 * @param string $version
779 * @return string HTML code
36ca62ca 780 */
b6ad8594 781 protected function required_column(plugininfo_base $plugin, plugin_manager $pluginman, $version) {
36ca62ca
TH
782 $requires = array();
783
784 if (!empty($plugin->versionrequires)) {
faadd326 785 if ($plugin->versionrequires <= $version) {
36ca62ca
TH
786 $class = 'requires-ok';
787 } else {
788 $class = 'requires-failed';
789 }
790 $requires[] = html_writer::tag('li',
791 get_string('moodleversion', 'core_plugin', $plugin->versionrequires),
792 array('class' => $class));
793 }
794
795 foreach ($plugin->get_other_required_plugins() as $component => $requiredversion) {
796 $ok = true;
797 $otherplugin = $pluginman->get_plugin_info($component);
798
799 if (is_null($otherplugin)) {
800 $ok = false;
499ff0a9 801 } else if ($requiredversion != ANY_VERSION and $otherplugin->versiondisk < $requiredversion) {
36ca62ca
TH
802 $ok = false;
803 }
804
805 if ($ok) {
806 $class = 'requires-ok';
807 } else {
808 $class = 'requires-failed';
809 }
810
811 if ($requiredversion != ANY_VERSION) {
812 $str = 'otherpluginversion';
813 } else {
814 $str = 'otherplugin';
815 }
816 $requires[] = html_writer::tag('li',
817 get_string($str, 'core_plugin',
818 array('component' => $component, 'version' => $requiredversion)),
819 array('class' => $class));
820 }
821
822 if (!$requires) {
823 return '';
824 }
825 return html_writer::tag('ul', implode("\n", $requires));
826 }
827
d26f3ddd
DM
828 /**
829 * Prints an overview about the plugins - number of installed, number of extensions etc.
830 *
831 * @param plugin_manager $pluginman provides information about the plugins
832 * @return string as usually
833 */
834 public function plugins_overview_panel(plugin_manager $pluginman) {
7716057f
DM
835 global $CFG;
836
d26f3ddd
DM
837 $plugininfo = $pluginman->get_plugins();
838
839 $numtotal = $numdisabled = $numextension = $numupdatable = 0;
840
841 foreach ($plugininfo as $type => $plugins) {
842 foreach ($plugins as $name => $plugin) {
843 if ($plugin->get_status() === plugin_manager::PLUGIN_STATUS_MISSING) {
844 continue;
845 }
846 $numtotal++;
847 if ($plugin->is_enabled() === false) {
848 $numdisabled++;
849 }
850 if (!$plugin->is_standard()) {
851 $numextension++;
852 }
7716057f 853 if (empty($CFG->disableupdatenotifications) and $plugin->available_updates()) {
d26f3ddd
DM
854 $numupdatable++;
855 }
856 }
857 }
858
859 $info = array();
860 $info[] = html_writer::tag('span', get_string('numtotal', 'core_plugin', $numtotal), array('class' => 'info total'));
861 $info[] = html_writer::tag('span', get_string('numdisabled', 'core_plugin', $numdisabled), array('class' => 'info disabled'));
862 $info[] = html_writer::tag('span', get_string('numextension', 'core_plugin', $numextension), array('class' => 'info extension'));
863 if ($numupdatable > 0) {
864 $info[] = html_writer::tag('span', get_string('numupdatable', 'core_plugin', $numupdatable), array('class' => 'info updatable'));
865 }
866
867 return $this->output->box(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $info), '', 'plugins-overview-panel');
868 }
869
b9934a17
DM
870 /**
871 * Displays all known plugins and links to manage them
872 *
873 * This default implementation renders all plugins into one big table.
874 *
36ca62ca 875 * @param plugin_manager $pluginman provides information about the plugins.
b9934a17
DM
876 * @return string HTML code
877 */
36ca62ca 878 public function plugins_control_panel(plugin_manager $pluginman) {
7716057f
DM
879 global $CFG;
880
36ca62ca 881 $plugininfo = $pluginman->get_plugins();
b9934a17
DM
882
883 if (empty($plugininfo)) {
884 return '';
885 }
886
b9934a17
DM
887 $table = new html_table();
888 $table->id = 'plugins-control-panel';
889 $table->head = array(
890 get_string('displayname', 'core_plugin'),
b9934a17
DM
891 get_string('source', 'core_plugin'),
892 get_string('version', 'core_plugin'),
893 get_string('availability', 'core_plugin'),
2b135b05
DM
894 get_string('actions', 'core_plugin'),
895 get_string('notes','core_plugin'),
b9934a17
DM
896 );
897 $table->colclasses = array(
2b135b05 898 'pluginname', 'source', 'version', 'availability', 'actions', 'notes'
b9934a17
DM
899 );
900
901 foreach ($plugininfo as $type => $plugins) {
902
903 $header = new html_table_cell($pluginman->plugintype_name_plural($type));
904 $header->header = true;
905 $header->colspan = count($table->head);
906 $header = new html_table_row(array($header));
907 $header->attributes['class'] = 'plugintypeheader type-' . $type;
908 $table->data[] = $header;
909
910 if (empty($plugins)) {
911 $msg = new html_table_cell(get_string('noneinstalled', 'core_plugin'));
912 $msg->colspan = count($table->head);
913 $row = new html_table_row(array($msg));
914 $row->attributes['class'] .= 'msg msg-noneinstalled';
915 $table->data[] = $row;
916 continue;
917 }
918
919 foreach ($plugins as $name => $plugin) {
920 $row = new html_table_row();
921 $row->attributes['class'] = 'type-' . $plugin->type . ' name-' . $plugin->type . '_' . $plugin->name;
922
923 if ($this->page->theme->resolve_image_location('icon', $plugin->type . '_' . $plugin->name)) {
924 $icon = $this->output->pix_icon('icon', '', $plugin->type . '_' . $plugin->name, array('class' => 'smallicon pluginicon'));
925 } else {
926 $icon = $this->output->pix_icon('spacer', '', 'moodle', array('class' => 'smallicon pluginicon noicon'));
927 }
928 if ($plugin->get_status() === plugin_manager::PLUGIN_STATUS_MISSING) {
929 $msg = html_writer::tag('span', get_string('status_missing', 'core_plugin'), array('class' => 'notifyproblem'));
930 $row->attributes['class'] .= ' missingfromdisk';
931 } else {
932 $msg = '';
933 }
2b135b05
DM
934 $pluginname = html_writer::tag('div', $icon . ' ' . $plugin->displayname . ' ' . $msg, array('class' => 'displayname')).
935 html_writer::tag('div', $plugin->component, array('class' => 'componentname'));
936 $pluginname = new html_table_cell($pluginname);
b9934a17
DM
937
938 if ($plugin->is_standard()) {
939 $row->attributes['class'] .= ' standard';
940 $source = new html_table_cell(get_string('sourcestd', 'core_plugin'));
941 } else {
942 $row->attributes['class'] .= ' extension';
943 $source = new html_table_cell(get_string('sourceext', 'core_plugin'));
944 }
945
946 $version = new html_table_cell($plugin->versiondb);
947
948 $isenabled = $plugin->is_enabled();
949 if (is_null($isenabled)) {
950 $availability = new html_table_cell('');
951 } else if ($isenabled) {
952 $row->attributes['class'] .= ' enabled';
953 $icon = $this->output->pix_icon('i/hide', get_string('pluginenabled', 'core_plugin'));
954 $availability = new html_table_cell($icon . ' ' . get_string('pluginenabled', 'core_plugin'));
955 } else {
956 $row->attributes['class'] .= ' disabled';
957 $icon = $this->output->pix_icon('i/show', get_string('plugindisabled', 'core_plugin'));
958 $availability = new html_table_cell($icon . ' ' . get_string('plugindisabled', 'core_plugin'));
959 }
960
2b135b05
DM
961 $actions = array();
962
b9934a17 963 $settingsurl = $plugin->get_settings_url();
2b135b05
DM
964 if (!is_null($settingsurl)) {
965 $actions[] = html_writer::link($settingsurl, get_string('settings', 'core_plugin'), array('class' => 'settings'));
b9934a17
DM
966 }
967
968 $uninstallurl = $plugin->get_uninstall_url();
2b135b05
DM
969 if (!is_null($uninstallurl)) {
970 $actions[] = html_writer::link($uninstallurl, get_string('uninstall', 'core_plugin'), array('class' => 'uninstall'));
971 }
972
973 $actions = new html_table_cell(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $actions));
974
828788f0 975 $requriedby = $pluginman->other_plugins_that_require($plugin->component);
2b135b05
DM
976 if ($requriedby) {
977 $requiredby = html_writer::tag('div', get_string('requiredby', 'core_plugin', implode(', ', $requriedby)),
978 array('class' => 'requiredby'));
b9934a17 979 } else {
2b135b05 980 $requiredby = '';
b9934a17
DM
981 }
982
7d8de6d8 983 $updateinfo = '';
7716057f 984 if (empty($CFG->disableupdatenotifications) and is_array($plugin->available_updates())) {
7d8de6d8
DM
985 foreach ($plugin->available_updates() as $availableupdate) {
986 $updateinfo .= $this->plugin_available_update_info($availableupdate);
987 }
3204daea
DM
988 }
989
990 $notes = new html_table_cell($requiredby.$updateinfo);
2b135b05 991
b9934a17 992 $row->cells = array(
2b135b05 993 $pluginname, $source, $version, $availability, $actions, $notes
b9934a17
DM
994 );
995 $table->data[] = $row;
996 }
997 }
998
999 return html_writer::table($table);
1000 }
da2fdc3f 1001
3204daea 1002 /**
e7611389 1003 * Helper method to render the information about the available plugin update
3204daea
DM
1004 *
1005 * The passed objects always provides at least the 'version' property containing
7d8de6d8 1006 * the (higher) version of the plugin available.
3204daea 1007 *
7d8de6d8 1008 * @param available_update_info $updateinfo information about the available update for the plugin
3204daea 1009 */
7d8de6d8 1010 protected function plugin_available_update_info(available_update_info $updateinfo) {
3204daea 1011
e7611389 1012 $boxclasses = 'pluginupdateinfo';
3204daea
DM
1013 $info = array();
1014
1015 if (isset($updateinfo->release)) {
1016 $info[] = html_writer::tag('span', get_string('updateavailable_release', 'core_plugin', $updateinfo->release),
1017 array('class' => 'info release'));
1018 }
1019
1020 if (isset($updateinfo->maturity)) {
1021 $info[] = html_writer::tag('span', get_string('maturity'.$updateinfo->maturity, 'core_admin'),
1022 array('class' => 'info maturity'));
e7611389 1023 $boxclasses .= ' maturity'.$updateinfo->maturity;
3204daea
DM
1024 }
1025
1026 if (isset($updateinfo->download)) {
1027 $info[] = html_writer::link($updateinfo->download, get_string('download'), array('class' => 'info download'));
1028 }
1029
1030 if (isset($updateinfo->url)) {
1031 $info[] = html_writer::link($updateinfo->url, get_string('updateavailable_moreinfo', 'core_plugin'),
1032 array('class' => 'info more'));
1033 }
1034
e7611389
DM
1035 $box = $this->output->box_start($boxclasses);
1036 $box .= html_writer::tag('div', get_string('updateavailable', 'core_plugin', $updateinfo->version), array('class' => 'version'));
1037 $box .= $this->output->box(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $info), '');
3204daea
DM
1038 $box .= $this->output->box_end();
1039
1040 return $box;
1041 }
1042
da2fdc3f 1043 /**
cc359566
TH
1044 * This function will render one beautiful table with all the environmental
1045 * configuration and how it suits Moodle needs.
1046 *
1047 * @param boolean $result final result of the check (true/false)
1048 * @param array $environment_results array of results gathered
1049 * @return string HTML to output.
da2fdc3f 1050 */
cc359566
TH
1051 public function environment_check_table($result, $environment_results) {
1052 global $CFG;
1053
1054 // Table headers
1055 $servertable = new html_table();//table for server checks
1056 $servertable->head = array(
1057 get_string('name'),
1058 get_string('info'),
1059 get_string('report'),
1060 get_string('status'),
1061 );
1062 $servertable->align = array('center', 'center', 'left', 'center');
1063 $servertable->wrap = array('nowrap', '', '', 'nowrap');
1064 $servertable->size = array('10', 10, '100%', '10');
1065 $servertable->attributes['class'] = 'environmenttable generaltable';
1066
1067 $serverdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
1068
1069 $othertable = new html_table();//table for custom checks
1070 $othertable->head = array(
1071 get_string('info'),
1072 get_string('report'),
1073 get_string('status'),
1074 );
1075 $othertable->align = array('center', 'left', 'center');
1076 $othertable->wrap = array('', '', 'nowrap');
1077 $othertable->size = array(10, '100%', '10');
1078 $othertable->attributes['class'] = 'environmenttable generaltable';
1079
1080 $otherdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
1081
1082 // Iterate over each environment_result
1083 $continue = true;
1084 foreach ($environment_results as $environment_result) {
1085 $errorline = false;
1086 $warningline = false;
1087 $stringtouse = '';
1088 if ($continue) {
1089 $type = $environment_result->getPart();
1090 $info = $environment_result->getInfo();
1091 $status = $environment_result->getStatus();
1092 $error_code = $environment_result->getErrorCode();
1093 // Process Report field
1094 $rec = new stdClass();
1095 // Something has gone wrong at parsing time
1096 if ($error_code) {
1097 $stringtouse = 'environmentxmlerror';
1098 $rec->error_code = $error_code;
1099 $status = get_string('error');
1100 $errorline = true;
1101 $continue = false;
1102 }
1103
1104 if ($continue) {
1105 if ($rec->needed = $environment_result->getNeededVersion()) {
1106 // We are comparing versions
1107 $rec->current = $environment_result->getCurrentVersion();
1108 if ($environment_result->getLevel() == 'required') {
1109 $stringtouse = 'environmentrequireversion';
1110 } else {
1111 $stringtouse = 'environmentrecommendversion';
1112 }
1113
1114 } else if ($environment_result->getPart() == 'custom_check') {
1115 // We are checking installed & enabled things
1116 if ($environment_result->getLevel() == 'required') {
1117 $stringtouse = 'environmentrequirecustomcheck';
1118 } else {
1119 $stringtouse = 'environmentrecommendcustomcheck';
1120 }
1121
1122 } else if ($environment_result->getPart() == 'php_setting') {
1123 if ($status) {
1124 $stringtouse = 'environmentsettingok';
1125 } else if ($environment_result->getLevel() == 'required') {
1126 $stringtouse = 'environmentmustfixsetting';
1127 } else {
1128 $stringtouse = 'environmentshouldfixsetting';
1129 }
1130
1131 } else {
1132 if ($environment_result->getLevel() == 'required') {
1133 $stringtouse = 'environmentrequireinstall';
1134 } else {
1135 $stringtouse = 'environmentrecommendinstall';
1136 }
1137 }
1138
1139 // Calculate the status value
1140 if ($environment_result->getBypassStr() != '') { //Handle bypassed result (warning)
1141 $status = get_string('bypassed');
1142 $warningline = true;
1143 } else if ($environment_result->getRestrictStr() != '') { //Handle restricted result (error)
1144 $status = get_string('restricted');
1145 $errorline = true;
1146 } else {
1147 if ($status) { //Handle ok result (ok)
1148 $status = get_string('ok');
1149 } else {
1150 if ($environment_result->getLevel() == 'optional') {//Handle check result (warning)
1151 $status = get_string('check');
1152 $warningline = true;
1153 } else { //Handle error result (error)
1154 $status = get_string('check');
1155 $errorline = true;
1156 }
1157 }
1158 }
1159 }
1160
1161 // Build the text
1162 $linkparts = array();
1163 $linkparts[] = 'admin/environment';
1164 $linkparts[] = $type;
1165 if (!empty($info)){
1166 $linkparts[] = $info;
1167 }
1168 if (empty($CFG->docroot)) {
1169 $report = get_string($stringtouse, 'admin', $rec);
1170 } else {
1171 $report = $this->doc_link(join($linkparts, '/'), get_string($stringtouse, 'admin', $rec));
1172 }
1173
1174 // Format error or warning line
1175 if ($errorline || $warningline) {
1176 $messagetype = $errorline? 'error':'warn';
1177 } else {
1178 $messagetype = 'ok';
1179 }
1180 $status = '<span class="'.$messagetype.'">'.$status.'</span>';
1181 // Here we'll store all the feedback found
1182 $feedbacktext = '';
1183 // Append the feedback if there is some
1184 $feedbacktext .= $environment_result->strToReport($environment_result->getFeedbackStr(), $messagetype);
1185 //Append the bypass if there is some
1186 $feedbacktext .= $environment_result->strToReport($environment_result->getBypassStr(), 'warn');
1187 //Append the restrict if there is some
1188 $feedbacktext .= $environment_result->strToReport($environment_result->getRestrictStr(), 'error');
1189
1190 $report .= $feedbacktext;
1191
1192 // Add the row to the table
1193 if ($environment_result->getPart() == 'custom_check'){
1194 $otherdata[$messagetype][] = array ($info, $report, $status);
1195 } else {
1196 $serverdata[$messagetype][] = array ($type, $info, $report, $status);
1197 }
1198 }
1199 }
1200
1201 //put errors first in
1202 $servertable->data = array_merge($serverdata['error'], $serverdata['warn'], $serverdata['ok']);
1203 $othertable->data = array_merge($otherdata['error'], $otherdata['warn'], $otherdata['ok']);
1204
1205 // Print table
1206 $output = '';
1207 $output .= $this->heading(get_string('serverchecks', 'admin'));
1208 $output .= html_writer::table($servertable);
1209 if (count($othertable->data)){
1210 $output .= $this->heading(get_string('customcheck', 'admin'));
1211 $output .= html_writer::table($othertable);
1212 }
1213
1214 // Finally, if any error has happened, print the summary box
1215 if (!$result) {
1216 $output .= $this->box(get_string('environmenterrortodo', 'admin'), 'environmentbox errorbox');
1217 }
1218
1219 return $output;
da2fdc3f 1220 }
b9934a17 1221}