mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 13:02:07 +02:00
Merge branch 'MDL-29474' of git://github.com/timhunt/moodle
This commit is contained in:
commit
10dd4995da
@ -636,6 +636,23 @@ if (!file_exists($configfile)) {
|
||||
cli_error('Can not create config file.');
|
||||
}
|
||||
|
||||
// Test environment first.
|
||||
list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE);
|
||||
if (!$envstatus) {
|
||||
$errors = environment_get_errors($environment_results);
|
||||
cli_heading(get_string('environment', 'admin'));
|
||||
foreach ($errors as $error) {
|
||||
list($info, $report) = $error;
|
||||
echo "!! $info !!\n$report\n\n";
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Test plugin dependencies.
|
||||
if (!plugin_manager::instance()->all_plugins_ok($version)) {
|
||||
cli_error(get_string('pluginschecktodo', 'admin'));
|
||||
}
|
||||
|
||||
// remember selected language
|
||||
$installlang = $CFG->lang;
|
||||
// return back to original dir before executing setup.php which changes the dir again
|
||||
|
@ -93,8 +93,9 @@ if ($version < $CFG->version) {
|
||||
$oldversion = "$CFG->release ($CFG->version)";
|
||||
$newversion = "$release ($version)";
|
||||
|
||||
// test environment first
|
||||
if (!check_moodle_environment(normalize_version($release), $environment_results, false, ENV_SELECT_RELEASE)) {
|
||||
// Test environment first.
|
||||
list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE);
|
||||
if (!$envstatus) {
|
||||
$errors = environment_get_errors($environment_results);
|
||||
cli_heading(get_string('environment', 'admin'));
|
||||
foreach ($errors as $error) {
|
||||
@ -104,6 +105,11 @@ if (!check_moodle_environment(normalize_version($release), $environment_results,
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Test plugin dependencies.
|
||||
if (!plugin_manager::instance()->all_plugins_ok($version)) {
|
||||
cli_error(get_string('pluginschecktodo', 'admin'));
|
||||
}
|
||||
|
||||
if ($interactive) {
|
||||
$a = new stdClass();
|
||||
$a->oldversion = $oldversion;
|
||||
|
@ -1,137 +1,109 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.com //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
|
||||
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation; either version 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is the admin frontend to execute all the checks available
|
||||
// in the environment.xml file. It includes database, php and
|
||||
// php_extensions. Also, it's possible to update the xml file
|
||||
// from moodle.org be able to check more and more versions.
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
require_once($CFG->libdir.'/componentlib.class.php');
|
||||
|
||||
admin_externalpage_setup('environment');
|
||||
|
||||
/// Parameters
|
||||
$action = optional_param('action', '', PARAM_ACTION);
|
||||
$version = optional_param('version', '', PARAM_FILE); //
|
||||
/**
|
||||
* This file is the admin frontend to execute all the checks available
|
||||
* in the environment.xml file. It includes database, php and
|
||||
* php_extensions. Also, it's possible to update the xml file
|
||||
* from moodle.org be able to check more and more versions.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage admin
|
||||
* @copyright 2006 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
/// Get some strings
|
||||
$stradmin = get_string('administration');
|
||||
$stradminhelpenvironment = get_string("adminhelpenvironment");
|
||||
$strenvironment = get_string('environment', 'admin');
|
||||
$strerror = get_string('error');
|
||||
$strmoodleversion = get_string('moodleversion');
|
||||
$strupdate = get_string('updatecomponent', 'admin');
|
||||
$strupwards = get_string('upwards', 'admin');
|
||||
$strmisc = get_string('miscellaneous');
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
require_once($CFG->libdir.'/componentlib.class.php');
|
||||
|
||||
/// Print the header stuff
|
||||
echo $OUTPUT->header();
|
||||
// Parameters
|
||||
$action = optional_param('action', '', PARAM_ACTION);
|
||||
$version = optional_param('version', '', PARAM_FILE); //
|
||||
|
||||
/// Print the component download link
|
||||
echo '<div class="reportlink"><a href="environment.php?action=updatecomponent&sesskey='.sesskey().'">'.$strupdate.'</a></div>';
|
||||
$extraurlparams = array();
|
||||
if ($version) {
|
||||
$extraurlparams['version'] = $version;
|
||||
}
|
||||
admin_externalpage_setup('environment', '', $extraurlparams);
|
||||
|
||||
echo $OUTPUT->heading($strenvironment);
|
||||
// Handle the 'updatecomponent' action
|
||||
if ($action == 'updatecomponent' && confirm_sesskey()) {
|
||||
// Create component installer and execute it
|
||||
if ($cd = new component_installer('http://download.moodle.org',
|
||||
'environment',
|
||||
'environment.zip')) {
|
||||
$status = $cd->install(); //returns COMPONENT_(ERROR | UPTODATE | INSTALLED)
|
||||
switch ($status) {
|
||||
case COMPONENT_ERROR:
|
||||
if ($cd->get_error() == 'remotedownloaderror') {
|
||||
$a = new stdClass();
|
||||
$a->url = 'http://download.moodle.org/environment/environment.zip';
|
||||
$a->dest = $CFG->dataroot . '/';
|
||||
print_error($cd->get_error(), 'error', $PAGE->url, $a);
|
||||
die();
|
||||
|
||||
/// Handle the 'updatecomponent' action
|
||||
if ($action == 'updatecomponent' && confirm_sesskey()) {
|
||||
/// Create component installer and execute it
|
||||
if ($cd = new component_installer('http://download.moodle.org',
|
||||
'environment',
|
||||
'environment.zip')) {
|
||||
$status = $cd->install(); //returns COMPONENT_(ERROR | UPTODATE | INSTALLED)
|
||||
switch ($status) {
|
||||
case COMPONENT_ERROR:
|
||||
if ($cd->get_error() == 'remotedownloaderror') {
|
||||
$a = new stdClass();
|
||||
$a->url = 'http://download.moodle.org/environment/environment.zip';
|
||||
$a->dest= $CFG->dataroot.'/';
|
||||
echo $OUTPUT->box(get_string($cd->get_error(), 'error', $a), 'errorbox');
|
||||
} else {
|
||||
echo $OUTPUT->box(get_string($cd->get_error(), 'error'), 'errorbox');
|
||||
}
|
||||
break;
|
||||
case COMPONENT_UPTODATE:
|
||||
echo $OUTPUT->box(get_string($cd->get_error(), 'error'));
|
||||
break;
|
||||
case COMPONENT_INSTALLED:
|
||||
echo $OUTPUT->box(get_string('componentinstalled', 'admin'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Start of main box
|
||||
echo $OUTPUT->box_start();
|
||||
|
||||
echo "<div style=\"text-align:center\">".$stradminhelpenvironment."</div><br />";
|
||||
|
||||
/// Get current Moodle version
|
||||
$current_version = $CFG->release;
|
||||
|
||||
/// Calculate list of versions
|
||||
$versions = array();
|
||||
if ($contents = load_environment_xml()) {
|
||||
if ($env_versions = get_list_of_environment_versions($contents)) {
|
||||
/// Set the current version at the beginning
|
||||
$env_version = normalize_version($current_version); //We need this later (for the upwards)
|
||||
$versions[$env_version] = $current_version;
|
||||
/// If no version has been previously selected, default to $current_version
|
||||
if (empty($version)) {
|
||||
$version = $env_version;
|
||||
}
|
||||
///Iterate over each version, adding bigger than current
|
||||
foreach ($env_versions as $env_version) {
|
||||
if (version_compare(normalize_version($current_version), $env_version, '<')) {
|
||||
$versions[$env_version] = $env_version;
|
||||
} else {
|
||||
print_error($cd->get_error(), 'error', $PAGE->url);
|
||||
die();
|
||||
}
|
||||
}
|
||||
/// Add 'upwards' to the last element
|
||||
$versions[$env_version] = $env_version.' '.$strupwards;
|
||||
} else {
|
||||
$versions = array('error' => $strerror);
|
||||
|
||||
case COMPONENT_UPTODATE:
|
||||
redirect($PAGE->url, get_string($cd->get_error(), 'error'));
|
||||
die;
|
||||
|
||||
case COMPONENT_INSTALLED:
|
||||
redirect($PAGE->url, get_string('componentinstalled', 'admin'));
|
||||
die;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Print form and popup menu
|
||||
echo '<div style="text-align:center"> ';
|
||||
$select = new single_select(new moodle_url('/admin/environment.php'), 'version', $versions, $version, null);
|
||||
$select->label = $strmoodleversion;
|
||||
echo $OUTPUT->render($select);
|
||||
echo '</div>';
|
||||
// Get current Moodle version
|
||||
$current_version = $CFG->release;
|
||||
|
||||
/// End of main box
|
||||
echo $OUTPUT->box_end();
|
||||
// Calculate list of versions
|
||||
$versions = array();
|
||||
if ($contents = load_environment_xml()) {
|
||||
if ($env_versions = get_list_of_environment_versions($contents)) {
|
||||
// Set the current version at the beginning
|
||||
$env_version = normalize_version($current_version); //We need this later (for the upwards)
|
||||
$versions[$env_version] = $current_version;
|
||||
// If no version has been previously selected, default to $current_version
|
||||
if (empty($version)) {
|
||||
$version = $env_version;
|
||||
}
|
||||
//Iterate over each version, adding bigger than current
|
||||
foreach ($env_versions as $env_version) {
|
||||
if (version_compare(normalize_version($current_version), $env_version, '<')) {
|
||||
$versions[$env_version] = $env_version;
|
||||
}
|
||||
}
|
||||
// Add 'upwards' to the last element
|
||||
$versions[$env_version] = $env_version.' '.get_string('upwards', 'admin');
|
||||
} else {
|
||||
$versions = array('error' => get_string('error'));
|
||||
}
|
||||
}
|
||||
|
||||
/// Gather and show results
|
||||
$status = check_moodle_environment($version, $environment_results);
|
||||
|
||||
/// Print footer
|
||||
echo $OUTPUT->footer();
|
||||
// Get the results of the environment check.
|
||||
list($envstatus, $environment_results) = check_moodle_environment($version);
|
||||
|
||||
// Display the page.
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->environment_check_page($versions, $version, $envstatus, $environment_results);
|
||||
|
217
admin/index.php
217
admin/index.php
@ -26,7 +26,7 @@
|
||||
// Check that config.php exists, if not then call the install script
|
||||
if (!file_exists('../config.php')) {
|
||||
header('Location: ../install.php');
|
||||
die;
|
||||
die();
|
||||
}
|
||||
|
||||
// Check that PHP is of a sufficient version as soon as possible
|
||||
@ -35,7 +35,7 @@ if (version_compare(phpversion(), '5.3.2') < 0) {
|
||||
// do NOT localise - lang strings would not work here and we CAN NOT move it to later place
|
||||
echo "Moodle 2.1 or later requires at least PHP 5.3.2 (currently using version $phpversion).<br />";
|
||||
echo "Please upgrade your server software or install older Moodle version.";
|
||||
die;
|
||||
die();
|
||||
}
|
||||
|
||||
// make sure iconv is available and actually works
|
||||
@ -47,7 +47,7 @@ if (!function_exists('iconv')) {
|
||||
if (iconv('UTF-8', 'UTF-8//IGNORE', 'abc') !== 'abc') {
|
||||
// known to be broken in mid-2011 MAMP installations
|
||||
echo 'Broken iconv PHP extension detected, installation/upgrade can not continue.';
|
||||
die;
|
||||
die();
|
||||
}
|
||||
|
||||
define('NO_OUTPUT_BUFFERING', true);
|
||||
@ -103,6 +103,11 @@ if (!$version or !$release) {
|
||||
print_error('withoutversion', 'debug'); // without version, stop
|
||||
}
|
||||
|
||||
if (!isset($maturity)) {
|
||||
// Fallback for now. Should probably be removed in the future.
|
||||
$maturity = MATURITY_STABLE;
|
||||
}
|
||||
|
||||
// Turn off xmlstrictheaders during upgrade.
|
||||
$origxmlstrictheaders = !empty($CFG->xmlstrictheaders);
|
||||
$CFG->xmlstrictheaders = false;
|
||||
@ -121,65 +126,41 @@ if (!core_tables_exist()) {
|
||||
|
||||
if (empty($agreelicense)) {
|
||||
$strlicense = get_string('license');
|
||||
|
||||
$PAGE->navbar->add($strlicense);
|
||||
$PAGE->set_title($strinstallation.' - Moodle '.$CFG->target_release);
|
||||
$PAGE->set_heading($strinstallation);
|
||||
$PAGE->set_cacheable(false);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading('<a href="http://moodle.org">Moodle</a> - Modular Object-Oriented Dynamic Learning Environment');
|
||||
echo $OUTPUT->heading(get_string('copyrightnotice'));
|
||||
$copyrightnotice = text_to_html(get_string('gpl3'));
|
||||
$copyrightnotice = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $copyrightnotice); // extremely ugly validation hack
|
||||
echo $OUTPUT->box($copyrightnotice, 'copyrightnotice');
|
||||
echo '<br />';
|
||||
$continue = new single_button(new moodle_url('/admin/index.php', array('lang'=>$CFG->lang, 'agreelicense'=>1)), get_string('continue'), 'get');
|
||||
echo $OUTPUT->confirm(get_string('doyouagree'), $continue, "http://docs.moodle.org/dev/License");
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->install_licence_page();
|
||||
die();
|
||||
}
|
||||
if (empty($confirmrelease)) {
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE);
|
||||
$strcurrentrelease = get_string('currentrelease');
|
||||
|
||||
$PAGE->navbar->add($strcurrentrelease);
|
||||
$PAGE->set_title($strinstallation);
|
||||
$PAGE->set_heading($strinstallation . ' - Moodle ' . $CFG->target_release);
|
||||
$PAGE->set_cacheable(false);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading("Moodle $release");
|
||||
|
||||
if (isset($maturity)) {
|
||||
// main version.php declares moodle code maturity
|
||||
if ($maturity < MATURITY_STABLE) {
|
||||
$maturitylevel = get_string('maturity'.$maturity, 'admin');
|
||||
echo $OUTPUT->box(
|
||||
$OUTPUT->container(get_string('maturitycorewarning', 'admin', $maturitylevel)) .
|
||||
$OUTPUT->container($OUTPUT->doc_link('admin/versions', get_string('morehelp'))),
|
||||
'generalbox maturitywarning');
|
||||
}
|
||||
}
|
||||
|
||||
$releasenoteslink = get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/dev/Releases');
|
||||
$releasenoteslink = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $releasenoteslink); // extremely ugly validation hack
|
||||
echo $OUTPUT->box($releasenoteslink, 'generalbox releasenoteslink');
|
||||
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
if (!check_moodle_environment(normalize_version($release), $environment_results, true, ENV_SELECT_RELEASE)) {
|
||||
print_upgrade_reload("index.php?agreelicense=1&lang=$CFG->lang");
|
||||
} else {
|
||||
echo $OUTPUT->notification(get_string('environmentok', 'admin'), 'notifysuccess');
|
||||
echo $OUTPUT->continue_button(new moodle_url('/admin/index.php', array('agreelicense'=>1, 'confirmrelease'=>1, 'lang'=>$CFG->lang)));
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->install_environment_page($maturity, $envstatus, $environment_results);
|
||||
die();
|
||||
}
|
||||
|
||||
$strdatabasesetup = get_string('databasesetup');
|
||||
upgrade_init_javascript();
|
||||
|
||||
$PAGE->navbar->add($strdatabasesetup);
|
||||
$PAGE->set_title($strinstallation.' - Moodle '.$CFG->target_release);
|
||||
$PAGE->set_heading($strinstallation);
|
||||
$PAGE->set_cacheable(false);
|
||||
echo $OUTPUT->header();
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->header();
|
||||
|
||||
if (!$DB->setup_is_unicodedb()) {
|
||||
if (!$DB->change_db_encoding()) {
|
||||
@ -207,78 +188,45 @@ if ($version > $CFG->version) { // upgrade
|
||||
$PAGE->set_pagelayout('maintenance');
|
||||
$PAGE->set_popup_notification_allowed(false);
|
||||
|
||||
$a->oldversion = "$CFG->release ($CFG->version)";
|
||||
$a->newversion = "$release ($version)";
|
||||
$strdatabasechecking = get_string('databasechecking', '', $a);
|
||||
|
||||
if (empty($confirmupgrade)) {
|
||||
$a->oldversion = "$CFG->release ($CFG->version)";
|
||||
$a->newversion = "$release ($version)";
|
||||
$strdatabasechecking = get_string('databasechecking', '', $a);
|
||||
|
||||
$PAGE->set_title($stradministration);
|
||||
$PAGE->set_heading($strdatabasechecking);
|
||||
$PAGE->set_cacheable(false);
|
||||
echo $OUTPUT->header();
|
||||
if (isset($maturity)) {
|
||||
// main version.php declares moodle code maturity
|
||||
if ($maturity < MATURITY_STABLE) {
|
||||
$maturitylevel = get_string('maturity'.$maturity, 'admin');
|
||||
echo $OUTPUT->box(
|
||||
$OUTPUT->container(get_string('maturitycorewarning', 'admin', $maturitylevel)) .
|
||||
$OUTPUT->container($OUTPUT->doc_link('admin/versions', get_string('morehelp'))),
|
||||
'generalbox maturitywarning');
|
||||
}
|
||||
}
|
||||
$continueurl = new moodle_url('index.php', array('confirmupgrade' => 1));
|
||||
$cancelurl = new moodle_url('index.php');
|
||||
echo $OUTPUT->confirm(get_string('upgradesure', 'admin', $a->newversion), $continueurl, $cancelurl);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->upgrade_confirm_page($a->newversion, $maturity);
|
||||
die();
|
||||
|
||||
} else if (empty($confirmrelease)){
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
list($envstatus, $environment_results) = check_moodle_environment($release, ENV_SELECT_RELEASE);
|
||||
$strcurrentrelease = get_string('currentrelease');
|
||||
|
||||
$PAGE->navbar->add($strcurrentrelease);
|
||||
$PAGE->set_title($strcurrentrelease);
|
||||
$PAGE->set_heading($strcurrentrelease);
|
||||
$PAGE->set_cacheable(false);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading("Moodle $release");
|
||||
$releasenoteslink = get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/dev/Releases');
|
||||
$releasenoteslink = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $releasenoteslink); // extremely ugly validation hack
|
||||
echo $OUTPUT->box($releasenoteslink);
|
||||
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
if (!check_moodle_environment($release, $environment_results, true, ENV_SELECT_RELEASE)) {
|
||||
print_upgrade_reload('index.php?confirmupgrade=1');
|
||||
} else {
|
||||
echo $OUTPUT->notification(get_string('environmentok', 'admin'), 'notifysuccess');
|
||||
if (empty($CFG->skiplangupgrade) and current_language() !== 'en') {
|
||||
echo $OUTPUT->box_start('generalbox', 'notice');
|
||||
print_string('langpackwillbeupdated', 'admin');
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
echo $OUTPUT->continue_button('index.php?confirmupgrade=1&confirmrelease=1');
|
||||
}
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->upgrade_environment_page($release, $envstatus, $environment_results);
|
||||
die();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
|
||||
} elseif (empty($confirmplugins)) {
|
||||
} else if (empty($confirmplugins)) {
|
||||
$strplugincheck = get_string('plugincheck');
|
||||
|
||||
$PAGE->navbar->add($strplugincheck);
|
||||
$PAGE->set_title($strplugincheck);
|
||||
$PAGE->set_heading($strplugincheck);
|
||||
$PAGE->set_cacheable(false);
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
$pluginman = plugin_manager::instance();
|
||||
|
||||
echo $output->header();
|
||||
echo $output->box_start('generalbox');
|
||||
echo $output->container(get_string('pluginchecknotice', 'core_plugin'), 'generalbox', 'notice');
|
||||
echo $output->plugins_check($pluginman->get_plugins(), array('full' => $showallplugins));
|
||||
echo $output->box_end();
|
||||
print_upgrade_reload('index.php?confirmupgrade=1&confirmrelease=1');
|
||||
$button = new single_button(new moodle_url('index.php', array('confirmupgrade'=>1, 'confirmrelease'=>1, 'confirmplugincheck'=>1)), get_string('upgradestart', 'admin'), 'get');
|
||||
$button->class = 'continuebutton';
|
||||
echo $output->render($button);
|
||||
echo $output->footer();
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->upgrade_plugin_check_page(plugin_manager::instance(), $version, $showallplugins,
|
||||
new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1)),
|
||||
new moodle_url('/admin/index.php', array('confirmupgrade'=>1, 'confirmrelease'=>1, 'confirmplugincheck'=>1)));
|
||||
die();
|
||||
|
||||
} else {
|
||||
@ -299,26 +247,19 @@ if (moodle_needs_upgrading()) {
|
||||
if (!$PAGE->headerprinted) {
|
||||
// means core upgrade or installation was not already done
|
||||
if (!$confirmplugins) {
|
||||
$strplugincheck = get_string('plugincheck');
|
||||
|
||||
$PAGE->set_pagelayout('maintenance');
|
||||
$PAGE->set_popup_notification_allowed(false);
|
||||
$strplugincheck = get_string('plugincheck');
|
||||
$PAGE->navbar->add($strplugincheck);
|
||||
$PAGE->set_title($strplugincheck);
|
||||
$PAGE->set_heading($strplugincheck);
|
||||
$PAGE->set_cacheable(false);
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
$pluginman = plugin_manager::instance();
|
||||
|
||||
echo $output->header();
|
||||
echo $output->box_start('generalbox');
|
||||
echo $output->container(get_string('pluginchecknotice', 'core_plugin'), 'generalbox', 'notice');
|
||||
echo $output->plugins_check($pluginman->get_plugins(), array('full' => $showallplugins));
|
||||
echo $output->box_end();
|
||||
print_upgrade_reload('index.php');
|
||||
$button = new single_button(new moodle_url('index.php', array('confirmplugincheck'=>1)), get_string('upgradestart', 'admin'), 'get');
|
||||
$button->class = 'continuebutton';
|
||||
echo $output->render($button);
|
||||
echo $output->footer();
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->upgrade_plugin_check_page(plugin_manager::instance(), $version, $showallplugins,
|
||||
new moodle_url('/admin/index.php'),
|
||||
new moodle_url('/admin/index.php', array('confirmplugincheck'=>1)));
|
||||
die();
|
||||
}
|
||||
}
|
||||
@ -413,58 +354,14 @@ if (any_new_admin_settings($adminroot)){
|
||||
// Everything should now be set up, and the user is an admin
|
||||
|
||||
// Print default admin page with notifications.
|
||||
admin_externalpage_setup('adminnotifications');
|
||||
echo $OUTPUT->header();
|
||||
$errorsdisplayed = defined('WARN_DISPLAY_ERRORS_ENABLED');
|
||||
|
||||
// Unstable code warning
|
||||
if (isset($maturity)) {
|
||||
if ($maturity < MATURITY_STABLE) {
|
||||
$maturitylevel = get_string('maturity'.$maturity, 'admin');
|
||||
echo $OUTPUT->box(
|
||||
get_string('maturitycoreinfo', 'admin', $maturitylevel) . ' ' .
|
||||
$OUTPUT->doc_link('admin/versions', get_string('morehelp')),
|
||||
'generalbox adminwarning maturityinfo');
|
||||
}
|
||||
}
|
||||
|
||||
if ($insecuredataroot == INSECURE_DATAROOT_WARNING) {
|
||||
echo $OUTPUT->box(get_string('datarootsecuritywarning', 'admin', $CFG->dataroot), 'generalbox adminwarning');
|
||||
} else if ($insecuredataroot == INSECURE_DATAROOT_ERROR) {
|
||||
echo $OUTPUT->box(get_string('datarootsecurityerror', 'admin', $CFG->dataroot), 'generalbox adminerror');
|
||||
|
||||
}
|
||||
|
||||
if (defined('WARN_DISPLAY_ERRORS_ENABLED')) {
|
||||
echo $OUTPUT->box(get_string('displayerrorswarning', 'admin'), 'generalbox adminwarning');
|
||||
}
|
||||
|
||||
// If no recently cron run
|
||||
$lastcron = $DB->get_field_sql('SELECT MAX(lastcron) FROM {modules}');
|
||||
if (time() - $lastcron > 3600 * 24) {
|
||||
$helpbutton = $OUTPUT->help_icon('cron', 'admin');
|
||||
echo $OUTPUT->box(get_string('cronwarning', 'admin').' '.$helpbutton, 'generalbox adminwarning');
|
||||
}
|
||||
|
||||
// diagnose DB, especially the sloppy MyISAM tables
|
||||
$diagnose = $DB->diagnose();
|
||||
if ($diagnose !== NULL) {
|
||||
echo $OUTPUT->box($diagnose, 'generalbox adminwarning');
|
||||
}
|
||||
|
||||
// Alert if we are currently in maintenance mode
|
||||
if (!empty($CFG->maintenance_enabled)) {
|
||||
echo $OUTPUT->box(get_string('sitemaintenancewarning2', 'admin', "$CFG->wwwroot/$CFG->admin/settings.php?section=maintenancemode"), 'generalbox adminwarning');
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO HIDE, REMOVE OR MODIFY THIS COPYRIGHT NOTICE ///
|
||||
$copyrighttext = '<a href="http://moodle.org/">Moodle</a> '.
|
||||
'<a href="http://docs.moodle.org/dev/Releases" title="'.$CFG->version.'">'.$CFG->release.'</a><br />'.
|
||||
'Copyright © 1999 onwards, Martin Dougiamas<br />'.
|
||||
'and <a href="http://docs.moodle.org/dev/Credits">many other contributors</a>.<br />'.
|
||||
'<a href="http://docs.moodle.org/dev/License">GNU Public License</a>';
|
||||
echo $OUTPUT->box($copyrighttext, 'copyright');
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
$cronoverdue = ($lastcron < time() - 3600 * 24);
|
||||
$dbproblems = $DB->diagnose();
|
||||
$maintenancemode = !empty($CFG->maintenance_enabled);
|
||||
|
||||
admin_externalpage_setup('adminnotifications');
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed,
|
||||
$cronoverdue, $dbproblems, $maintenancemode);
|
||||
|
@ -31,11 +31,4 @@ require_once($CFG->libdir . '/pluginlib.php');
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
admin_externalpage_setup('pluginsoverview');
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
$pluginman = plugin_manager::instance();
|
||||
|
||||
echo $output->header();
|
||||
echo $output->heading(get_string('pluginsoverview', 'core_admin'));
|
||||
echo $output->box_start('generalbox');
|
||||
echo $output->plugins_control_panel($pluginman->get_plugins());
|
||||
echo $output->box_end();
|
||||
echo $output->footer();
|
||||
echo $output->plugin_management_page(plugin_manager::instance());
|
||||
|
@ -32,6 +32,358 @@ require_once($CFG->libdir . '/pluginlib.php');
|
||||
*/
|
||||
class core_admin_renderer extends plugin_renderer_base {
|
||||
|
||||
/**
|
||||
* Display the 'Do you acknowledge the terms of the GPL' page. The first page
|
||||
* during install.
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
public function install_licence_page() {
|
||||
global $CFG;
|
||||
$output = '';
|
||||
|
||||
$copyrightnotice = text_to_html(get_string('gpl3'));
|
||||
$copyrightnotice = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $copyrightnotice); // extremely ugly validation hack
|
||||
|
||||
$continue = new single_button(new moodle_url('/admin/index.php', array('lang'=>$CFG->lang, 'agreelicense'=>1)), get_string('continue'), 'get');
|
||||
|
||||
$output .= $this->header();
|
||||
$output .= $this->heading('<a href="http://moodle.org">Moodle</a> - Modular Object-Oriented Dynamic Learning Environment');
|
||||
$output .= $this->heading(get_string('copyrightnotice'));
|
||||
$output .= $this->box($copyrightnotice, 'copyrightnotice');
|
||||
$output .= html_writer::empty_tag('br');
|
||||
$output .= $this->confirm(get_string('doyouagree'), $continue, "http://docs.moodle.org/dev/License");
|
||||
$output .= $this->footer();
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the 'environment check' page that is displayed during install.
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
public function install_environment_page($maturity, $envstatus, $environment_results) {
|
||||
global $CFG;
|
||||
$output = '';
|
||||
|
||||
$output .= $this->header();
|
||||
$output .= $this->maturity_warning($maturity);
|
||||
$output .= $this->heading("Moodle $release");
|
||||
$output .= $this->release_notes_link();
|
||||
|
||||
$output .= $this->environment_check_table($envstatus, $environment_results);
|
||||
|
||||
if (!$envstatus) {
|
||||
$output .= $this->upgrade_reload(new moodle_url('/admin/index.php', array('agreelicense' => 1, 'lang' => $CFG->lang)));
|
||||
} else {
|
||||
$output .= $this->notification(get_string('environmentok', 'admin'), 'notifysuccess');
|
||||
$output .= $this->continue_button(new moodle_url('/admin/index.php', array('agreelicense'=>1, 'confirmrelease'=>1, 'lang'=>$CFG->lang)));
|
||||
}
|
||||
|
||||
$output .= $this->footer();
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the 'You are about to upgrade Moodle' page. The first page
|
||||
* during upgrade.
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
public function upgrade_confirm_page($strnewversion, $maturity) {
|
||||
$output = '';
|
||||
|
||||
$continueurl = new moodle_url('index.php', array('confirmupgrade' => 1));
|
||||
$cancelurl = new moodle_url('index.php');
|
||||
|
||||
$output .= $this->header();
|
||||
$output .= $this->maturity_warning($maturity);
|
||||
$output .= $this->confirm(get_string('upgradesure', 'admin', $strnewversion), $continueurl, $cancelurl);
|
||||
$output .= $this->footer();
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the environment page during the upgrade process.
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
public function upgrade_environment_page($release, $envstatus, $environment_results) {
|
||||
global $CFG;
|
||||
$output = '';
|
||||
|
||||
$output .= $this->header();
|
||||
$output .= $this->heading("Moodle $release");
|
||||
$output .= $this->release_notes_link();
|
||||
$output .= $this->environment_check_table($envstatus, $environment_results);
|
||||
|
||||
if (!$envstatus) {
|
||||
$output .= $this->upgrade_reload(new moodle_url('/admin/index.php'), array('confirmupgrade' => 1));
|
||||
|
||||
} else {
|
||||
$output .= $this->notification(get_string('environmentok', 'admin'), 'notifysuccess');
|
||||
|
||||
if (empty($CFG->skiplangupgrade) and current_language() !== 'en') {
|
||||
$output .= $this->box(get_string('langpackwillbeupdated', 'admin'), 'generalbox', 'notice');
|
||||
}
|
||||
|
||||
$output .= $this->continue_button(new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1)));
|
||||
}
|
||||
|
||||
$output .= $this->footer();
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the upgrade page that lists all the plugins that require attention.
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
public function upgrade_plugin_check_page($pluginman, $version, $showallplugins, $reloadurl, $continueurl) {
|
||||
$output = '';
|
||||
|
||||
$output .= $this->header();
|
||||
$output .= $this->box_start('generalbox');
|
||||
$output .= $this->container(get_string('pluginchecknotice', 'core_plugin'), 'generalbox', 'notice');
|
||||
$output .= $this->plugins_check_table($pluginman, $version, array('full' => $showallplugins));
|
||||
$output .= $this->box_end();
|
||||
$output .= $this->upgrade_reload($reloadurl);
|
||||
|
||||
if ($pluginman->all_plugins_ok($version)) {
|
||||
$button = new single_button($continueurl, get_string('upgradestart', 'admin'), 'get');
|
||||
$button->class = 'continuebutton';
|
||||
$output .= $this->render($button);
|
||||
} else {
|
||||
$output .= $this->box(get_string('pluginschecktodo', 'admin'), 'environmentbox errorbox');
|
||||
}
|
||||
|
||||
$output .= $this->footer();
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the admin notifications page.
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
public function admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed,
|
||||
$cronoverdue, $dbproblems, $maintenancemode) {
|
||||
$output = '';
|
||||
|
||||
$output .= $this->header();
|
||||
$output .= $this->maturity_info($maturity);
|
||||
$output .= $this->insecure_dataroot_warning($insecuredataroot);
|
||||
$output .= $this->display_errors_warning($errorsdisplayed);
|
||||
$output .= $this->cron_overdue_warning($errorsdisplayed);
|
||||
$output .= $this->db_problems($dbproblems);
|
||||
$output .= $this->maintenance_mode_warning($maintenancemode);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO HIDE, REMOVE OR MODIFY THIS COPYRIGHT NOTICE ///
|
||||
$output .= $this->moodle_copyright();
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$output .= $this->footer();
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the plugin management page (admin/plugins.php).
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
public function plugin_management_page($pluginman) {
|
||||
$output = '';
|
||||
|
||||
$output .= $this->header();
|
||||
$output .= $this->heading(get_string('pluginsoverview', 'core_admin'));
|
||||
$output .= $this->box_start('generalbox');
|
||||
$output .= $this->plugins_control_panel($pluginman);
|
||||
$output .= $this->box_end();
|
||||
$output .= $this->footer();
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the plugin management page (admin/environment.php).
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
public function environment_check_page($versions, $version, $envstatus, $environment_results) {
|
||||
$output = '';
|
||||
$output .= $this->header();
|
||||
|
||||
// Print the component download link
|
||||
$output .= html_writer::tag('div', html_writer::link(
|
||||
new moodle_url('/admin/environment.php', array('action' => 'updatecomponent', 'sesskey' => sesskey())),
|
||||
get_string('updatecomponent', 'admin')),
|
||||
array('class' => 'reportlink'));
|
||||
|
||||
// Heading.
|
||||
$output .= $this->heading(get_string('environment', 'admin'));
|
||||
|
||||
// Box with info and a menu to choose the version.
|
||||
$output .= $this->box_start();
|
||||
$output .= html_writer::tag('div', get_string('adminhelpenvironment'));
|
||||
$select = new single_select(new moodle_url('/admin/environment.php'), 'version', $versions, $version, null);
|
||||
$select->label = get_string('moodleversion');
|
||||
$output .= $this->render($select);
|
||||
$output .= $this->box_end();
|
||||
|
||||
// The results
|
||||
$output .= $this->environment_check_table($envstatus, $environment_results);
|
||||
|
||||
$output .= $this->footer();
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output a warning message, of the type that appears on the admin notifications page.
|
||||
* @param string $message the message to display.
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
protected function warning($message, $type = 'warning') {
|
||||
return $this->box($message, 'generalbox admin' . $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an appropriate message if dataroot is insecure.
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
protected function insecure_dataroot_warning($insecuredataroot) {
|
||||
global $CFG;
|
||||
|
||||
if ($insecuredataroot == INSECURE_DATAROOT_WARNING) {
|
||||
return $this->warning(get_string('datarootsecuritywarning', 'admin', $CFG->dataroot));
|
||||
|
||||
} else if ($insecuredataroot == INSECURE_DATAROOT_ERROR) {
|
||||
return $this->warning(get_string('datarootsecurityerror', 'admin', $CFG->dataroot), 'error');
|
||||
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an appropriate message if dataroot is insecure.
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
protected function display_errors_warning($errorsdisplayed) {
|
||||
if (!$errorsdisplayed) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->warning(get_string('displayerrorswarning', 'admin'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an appropriate message if cron has not been run recently.
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
public function cron_overdue_warning($cronoverdue) {
|
||||
if (!$cronoverdue) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->warning(get_string('cronwarning', 'admin') . ' ' .
|
||||
$this->help_icon('cron', 'admin'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an appropriate message if there are any problems with the DB set-up.
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
public function db_problems($dbproblems) {
|
||||
if (!$dbproblems) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->warning($dbproblems);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an appropriate message if the site in in maintenance mode.
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
public function maintenance_mode_warning($maintenancemode) {
|
||||
if (!$maintenancemode) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->warning(get_string('sitemaintenancewarning2', 'admin',
|
||||
new moodle_url('/admin/settings.php', array('section' => 'maintenancemode'))));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a warning about installing development code if necesary.
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
protected function maturity_warning($maturity) {
|
||||
if ($maturity == MATURITY_STABLE) {
|
||||
return ''; // No worries.
|
||||
}
|
||||
|
||||
$maturitylevel = get_string('maturity' . $maturity, 'admin');
|
||||
return $this->box(
|
||||
$this->container(get_string('maturitycorewarning', 'admin', $maturitylevel)) .
|
||||
$this->container($this->doc_link('admin/versions', get_string('morehelp'))),
|
||||
'generalbox maturitywarning');
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the copyright notice.
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
protected function moodle_copyright() {
|
||||
global $CFG;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO HIDE, REMOVE OR MODIFY THIS COPYRIGHT NOTICE ///
|
||||
$copyrighttext = '<a href="http://moodle.org/">Moodle</a> '.
|
||||
'<a href="http://docs.moodle.org/dev/Releases" title="'.$CFG->version.'">'.$CFG->release.'</a><br />'.
|
||||
'Copyright © 1999 onwards, Martin Dougiamas<br />'.
|
||||
'and <a href="http://docs.moodle.org/dev/Credits">many other contributors</a>.<br />'.
|
||||
'<a href="http://docs.moodle.org/dev/License">GNU Public License</a>';
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
return $this->box($copyrighttext, 'copyright');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a warning about installing development code if necesary.
|
||||
* @param string HTML to output.
|
||||
*/
|
||||
protected function maturity_info($maturity) {
|
||||
if ($maturity == MATURITY_STABLE) {
|
||||
return ''; // No worries.
|
||||
}
|
||||
|
||||
$maturitylevel = get_string('maturity' . $maturity, 'admin');
|
||||
return $this->box(
|
||||
get_string('maturitycoreinfo', 'admin', $maturitylevel) . ' ' .
|
||||
$this->doc_link('admin/versions', get_string('morehelp')),
|
||||
'generalbox adminwarning maturityinfo');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a link to the release notes.
|
||||
* @param string HTML to output.
|
||||
*/
|
||||
protected function release_notes_link() {
|
||||
$releasenoteslink = get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/dev/Releases');
|
||||
$releasenoteslink = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $releasenoteslink); // extremely ugly validation hack
|
||||
return $this->box($releasenoteslink, 'generalbox releasenoteslink');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the reload link that appears on several upgrade/install pages.
|
||||
*/
|
||||
function upgrade_reload($url) {
|
||||
return html_writer::empty_tag('br') .
|
||||
html_writer::tag('div',
|
||||
html_writer::link($url, $this->pix_icon('i/reload', '') .
|
||||
get_string('reload'), array('title' => get_string('reload'))),
|
||||
array('class' => 'continuebutton')) . html_writer::empty_tag('br');
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays all known plugins and information about their installation or upgrade
|
||||
*
|
||||
@ -39,11 +391,13 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
* options support:
|
||||
* (bool)full = false: whether to display up-to-date plugins, too
|
||||
*
|
||||
* @param array $plugininfo as returned by {@see plugin_manager::get_plugins()}
|
||||
* @param plugin_manager $pluginman provides information about the plugins.
|
||||
* @param int $version the version of the Moodle code from version.php.
|
||||
* @param array $options rendering options
|
||||
* @return string HTML code
|
||||
*/
|
||||
public function plugins_check(array $plugininfo, array $options = null) {
|
||||
public function plugins_check_table(plugin_manager $pluginman, $version, array $options = null) {
|
||||
$plugininfo = $pluginman->get_plugins();
|
||||
|
||||
if (empty($plugininfo)) {
|
||||
return '';
|
||||
@ -55,8 +409,6 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
);
|
||||
}
|
||||
|
||||
$pluginman = plugin_manager::instance();
|
||||
|
||||
$table = new html_table();
|
||||
$table->id = 'plugins-check';
|
||||
$table->head = array(
|
||||
@ -65,10 +417,11 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
get_string('source', 'core_plugin'),
|
||||
get_string('versiondb', 'core_plugin'),
|
||||
get_string('versiondisk', 'core_plugin'),
|
||||
get_string('requires', 'core_plugin'),
|
||||
get_string('status', 'core_plugin'),
|
||||
);
|
||||
$table->colclasses = array(
|
||||
'displayname', 'rootdir', 'source', 'versiondb', 'versiondisk', 'status',
|
||||
'displayname', 'rootdir', 'source', 'versiondb', 'versiondisk', 'requires', 'status',
|
||||
);
|
||||
$table->data = array();
|
||||
|
||||
@ -126,7 +479,13 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
|
||||
$status = new html_table_cell(get_string('status_' . $statuscode, 'core_plugin'));
|
||||
|
||||
if ($isstandard and in_array($statuscode, array(plugin_manager::PLUGIN_STATUS_NODB, plugin_manager::PLUGIN_STATUS_UPTODATE))) {
|
||||
$requires = new html_table_cell($this->required_column($plugin, $pluginman, $version));
|
||||
|
||||
$statusisboring = in_array($statuscode, array(
|
||||
plugin_manager::PLUGIN_STATUS_NODB, plugin_manager::PLUGIN_STATUS_UPTODATE));
|
||||
$dependenciesok = $pluginman->are_dependencies_satisfied(
|
||||
$plugin->get_other_required_plugins());
|
||||
if ($isstandard and $statusisboring and $dependenciesok) {
|
||||
if (empty($options['full'])) {
|
||||
continue;
|
||||
}
|
||||
@ -134,7 +493,8 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$numofhighlighted[$type]++;
|
||||
}
|
||||
|
||||
$row->cells = array($displayname, $rootdir, $source, $versiondb, $versiondisk, $status);
|
||||
$row->cells = array($displayname, $rootdir, $source,
|
||||
$versiondb, $versiondisk, $requires, $status);
|
||||
$plugintyperows[] = $row;
|
||||
}
|
||||
|
||||
@ -176,22 +536,74 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the information that needs to go in the 'Requires' column.
|
||||
* @param plugin_information $plugin the plugin we are rendering the row for.
|
||||
* @param plugin_manager $pluginman provides data on all the plugins.
|
||||
*/
|
||||
protected function required_column($plugin, $pluginman, $version) {
|
||||
$requires = array();
|
||||
|
||||
if (!empty($plugin->versionrequires)) {
|
||||
if ($plugin->versionrequires <= $version) {
|
||||
$class = 'requires-ok';
|
||||
} else {
|
||||
$class = 'requires-failed';
|
||||
}
|
||||
$requires[] = html_writer::tag('li',
|
||||
get_string('moodleversion', 'core_plugin', $plugin->versionrequires),
|
||||
array('class' => $class));
|
||||
}
|
||||
|
||||
foreach ($plugin->get_other_required_plugins() as $component => $requiredversion) {
|
||||
$ok = true;
|
||||
$otherplugin = $pluginman->get_plugin_info($component);
|
||||
|
||||
if (is_null($otherplugin)) {
|
||||
$ok = false;
|
||||
}
|
||||
if ($requiredversion != ANY_VERSION and $otherplugin->versiondb < $requiredversion) {
|
||||
$ok = false;
|
||||
}
|
||||
|
||||
if ($ok) {
|
||||
$class = 'requires-ok';
|
||||
} else {
|
||||
$class = 'requires-failed';
|
||||
}
|
||||
|
||||
if ($requiredversion != ANY_VERSION) {
|
||||
$str = 'otherpluginversion';
|
||||
} else {
|
||||
$str = 'otherplugin';
|
||||
}
|
||||
$requires[] = html_writer::tag('li',
|
||||
get_string($str, 'core_plugin',
|
||||
array('component' => $component, 'version' => $requiredversion)),
|
||||
array('class' => $class));
|
||||
}
|
||||
|
||||
if (!$requires) {
|
||||
return '';
|
||||
}
|
||||
return html_writer::tag('ul', implode("\n", $requires));
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays all known plugins and links to manage them
|
||||
*
|
||||
* This default implementation renders all plugins into one big table.
|
||||
*
|
||||
* @param array $plugininfo as returned by {@see plugin_manager::get_plugins()}
|
||||
* @param plugin_manager $pluginman provides information about the plugins.
|
||||
* @return string HTML code
|
||||
*/
|
||||
public function plugins_control_panel(array $plugininfo) {
|
||||
public function plugins_control_panel(plugin_manager $pluginman) {
|
||||
$plugininfo = $pluginman->get_plugins();
|
||||
|
||||
if (empty($plugininfo)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$pluginman = plugin_manager::instance();
|
||||
|
||||
$table = new html_table();
|
||||
$table->id = 'plugins-control-panel';
|
||||
$table->head = array(
|
||||
@ -293,4 +705,183 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
|
||||
return html_writer::table($table);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will render one beautiful table with all the environmental
|
||||
* configuration and how it suits Moodle needs.
|
||||
*
|
||||
* @param boolean $result final result of the check (true/false)
|
||||
* @param array $environment_results array of results gathered
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
public function environment_check_table($result, $environment_results) {
|
||||
global $CFG;
|
||||
|
||||
// Table headers
|
||||
$servertable = new html_table();//table for server checks
|
||||
$servertable->head = array(
|
||||
get_string('name'),
|
||||
get_string('info'),
|
||||
get_string('report'),
|
||||
get_string('status'),
|
||||
);
|
||||
$servertable->align = array('center', 'center', 'left', 'center');
|
||||
$servertable->wrap = array('nowrap', '', '', 'nowrap');
|
||||
$servertable->size = array('10', 10, '100%', '10');
|
||||
$servertable->attributes['class'] = 'environmenttable generaltable';
|
||||
|
||||
$serverdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
|
||||
|
||||
$othertable = new html_table();//table for custom checks
|
||||
$othertable->head = array(
|
||||
get_string('info'),
|
||||
get_string('report'),
|
||||
get_string('status'),
|
||||
);
|
||||
$othertable->align = array('center', 'left', 'center');
|
||||
$othertable->wrap = array('', '', 'nowrap');
|
||||
$othertable->size = array(10, '100%', '10');
|
||||
$othertable->attributes['class'] = 'environmenttable generaltable';
|
||||
|
||||
$otherdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
|
||||
|
||||
// Iterate over each environment_result
|
||||
$continue = true;
|
||||
foreach ($environment_results as $environment_result) {
|
||||
$errorline = false;
|
||||
$warningline = false;
|
||||
$stringtouse = '';
|
||||
if ($continue) {
|
||||
$type = $environment_result->getPart();
|
||||
$info = $environment_result->getInfo();
|
||||
$status = $environment_result->getStatus();
|
||||
$error_code = $environment_result->getErrorCode();
|
||||
// Process Report field
|
||||
$rec = new stdClass();
|
||||
// Something has gone wrong at parsing time
|
||||
if ($error_code) {
|
||||
$stringtouse = 'environmentxmlerror';
|
||||
$rec->error_code = $error_code;
|
||||
$status = get_string('error');
|
||||
$errorline = true;
|
||||
$continue = false;
|
||||
}
|
||||
|
||||
if ($continue) {
|
||||
if ($rec->needed = $environment_result->getNeededVersion()) {
|
||||
// We are comparing versions
|
||||
$rec->current = $environment_result->getCurrentVersion();
|
||||
if ($environment_result->getLevel() == 'required') {
|
||||
$stringtouse = 'environmentrequireversion';
|
||||
} else {
|
||||
$stringtouse = 'environmentrecommendversion';
|
||||
}
|
||||
|
||||
} else if ($environment_result->getPart() == 'custom_check') {
|
||||
// We are checking installed & enabled things
|
||||
if ($environment_result->getLevel() == 'required') {
|
||||
$stringtouse = 'environmentrequirecustomcheck';
|
||||
} else {
|
||||
$stringtouse = 'environmentrecommendcustomcheck';
|
||||
}
|
||||
|
||||
} else if ($environment_result->getPart() == 'php_setting') {
|
||||
if ($status) {
|
||||
$stringtouse = 'environmentsettingok';
|
||||
} else if ($environment_result->getLevel() == 'required') {
|
||||
$stringtouse = 'environmentmustfixsetting';
|
||||
} else {
|
||||
$stringtouse = 'environmentshouldfixsetting';
|
||||
}
|
||||
|
||||
} else {
|
||||
if ($environment_result->getLevel() == 'required') {
|
||||
$stringtouse = 'environmentrequireinstall';
|
||||
} else {
|
||||
$stringtouse = 'environmentrecommendinstall';
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate the status value
|
||||
if ($environment_result->getBypassStr() != '') { //Handle bypassed result (warning)
|
||||
$status = get_string('bypassed');
|
||||
$warningline = true;
|
||||
} else if ($environment_result->getRestrictStr() != '') { //Handle restricted result (error)
|
||||
$status = get_string('restricted');
|
||||
$errorline = true;
|
||||
} else {
|
||||
if ($status) { //Handle ok result (ok)
|
||||
$status = get_string('ok');
|
||||
} else {
|
||||
if ($environment_result->getLevel() == 'optional') {//Handle check result (warning)
|
||||
$status = get_string('check');
|
||||
$warningline = true;
|
||||
} else { //Handle error result (error)
|
||||
$status = get_string('check');
|
||||
$errorline = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Build the text
|
||||
$linkparts = array();
|
||||
$linkparts[] = 'admin/environment';
|
||||
$linkparts[] = $type;
|
||||
if (!empty($info)){
|
||||
$linkparts[] = $info;
|
||||
}
|
||||
if (empty($CFG->docroot)) {
|
||||
$report = get_string($stringtouse, 'admin', $rec);
|
||||
} else {
|
||||
$report = $this->doc_link(join($linkparts, '/'), get_string($stringtouse, 'admin', $rec));
|
||||
}
|
||||
|
||||
// Format error or warning line
|
||||
if ($errorline || $warningline) {
|
||||
$messagetype = $errorline? 'error':'warn';
|
||||
} else {
|
||||
$messagetype = 'ok';
|
||||
}
|
||||
$status = '<span class="'.$messagetype.'">'.$status.'</span>';
|
||||
// Here we'll store all the feedback found
|
||||
$feedbacktext = '';
|
||||
// Append the feedback if there is some
|
||||
$feedbacktext .= $environment_result->strToReport($environment_result->getFeedbackStr(), $messagetype);
|
||||
//Append the bypass if there is some
|
||||
$feedbacktext .= $environment_result->strToReport($environment_result->getBypassStr(), 'warn');
|
||||
//Append the restrict if there is some
|
||||
$feedbacktext .= $environment_result->strToReport($environment_result->getRestrictStr(), 'error');
|
||||
|
||||
$report .= $feedbacktext;
|
||||
|
||||
// Add the row to the table
|
||||
if ($environment_result->getPart() == 'custom_check'){
|
||||
$otherdata[$messagetype][] = array ($info, $report, $status);
|
||||
} else {
|
||||
$serverdata[$messagetype][] = array ($type, $info, $report, $status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//put errors first in
|
||||
$servertable->data = array_merge($serverdata['error'], $serverdata['warn'], $serverdata['ok']);
|
||||
$othertable->data = array_merge($otherdata['error'], $otherdata['warn'], $otherdata['ok']);
|
||||
|
||||
// Print table
|
||||
$output = '';
|
||||
$output .= $this->heading(get_string('serverchecks', 'admin'));
|
||||
$output .= html_writer::table($servertable);
|
||||
if (count($othertable->data)){
|
||||
$output .= $this->heading(get_string('customcheck', 'admin'));
|
||||
$output .= html_writer::table($othertable);
|
||||
}
|
||||
|
||||
// Finally, if any error has happened, print the summary box
|
||||
if (!$result) {
|
||||
$output .= $this->box(get_string('environmenterrortodo', 'admin'), 'environmentbox errorbox');
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
@ -743,6 +743,7 @@ $string['pleaserefreshregistration'] = 'Your site has been registered with moodl
|
||||
$string['pleaseregister'] = 'Please register your site to remove this button';
|
||||
$string['plugin'] = 'Plugin';
|
||||
$string['plugins'] = 'Plugins';
|
||||
$string['pluginschecktodo'] = 'You must solve all the plugin requirements before proceeding to install this Moodle version!';
|
||||
$string['pluginsoverview'] = 'Plugins overview';
|
||||
$string['profilecategory'] = 'Category';
|
||||
$string['profilecategoryname'] = 'Category name (must be unique)';
|
||||
|
@ -27,9 +27,12 @@ defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$string['availability'] = 'Availability';
|
||||
$string['displayname'] = 'Plugin name';
|
||||
$string['moodleversion'] = 'Moodle {$a}';
|
||||
$string['nonehighlighted'] = 'No plugins require your attention during this upgrade';
|
||||
$string['nonehighlightedinfo'] = 'Display the list of all installed plugins anyway';
|
||||
$string['noneinstalled'] = 'No plugins of this type are installed';
|
||||
$string['otherplugin'] = '{$a->component}';
|
||||
$string['otherpluginversion'] = '{$a->component} ({$a->version})';
|
||||
$string['showall'] = 'Reload and show all plugins';
|
||||
$string['pluginchecknotice'] = 'This page displays plugins that may require your attention during the upgrade. Highlighted items include new plugins that are about to be installed, updated plugins that are about to be upgraded and any missing plugins. Contributed plugins are also highlighted.
|
||||
It is recommended that you check whether there are more recent versions of contributed plugins available and update their source code before continuing with this Moodle upgrade.';
|
||||
@ -37,6 +40,7 @@ $string['plugindisable'] = 'Disable';
|
||||
$string['plugindisabled'] = 'Disabled';
|
||||
$string['pluginenable'] = 'Enable';
|
||||
$string['pluginenabled'] = 'Enabled';
|
||||
$string['requires'] = 'Requires';
|
||||
$string['rootdir'] = 'Directory';
|
||||
$string['settings'] = 'Settings';
|
||||
$string['somehighlighted'] = 'Number of plugins requiring attention during this upgrade: {$a}';
|
||||
|
@ -80,23 +80,19 @@ defined('MOODLE_INTERNAL') || die();
|
||||
define('ENV_SELECT_RELEASE', 2);
|
||||
|
||||
/**
|
||||
* This function will perform the whole check, returning
|
||||
* true or false as final result. Also, he full array of
|
||||
* environment_result will be returned in the parameter list.
|
||||
* The function looks for the best version to compare and
|
||||
* everything. This is the only function that should be called
|
||||
* ever from the rest of Moodle.
|
||||
* This function checks all the requirements defined in environment.xml.
|
||||
*
|
||||
* @staticvar bool $result
|
||||
* @staticvar array $env_results
|
||||
* @staticvar bool $cache_exists
|
||||
*
|
||||
* @param string $version version to check.
|
||||
* @param array $environment_results results array of results checked.
|
||||
* @param boolean $print_table true/false, whether to print the table or just return results array
|
||||
* @param int $env_select one of ENV_SELECT_NEWER | ENV_SELECT_DATAROOT | ENV_SELECT_RELEASE decide xml to use. Default ENV_SELECT_NEWER (BC)
|
||||
* @return boolean true/false, depending of results
|
||||
* @return array with two elements. The first element true/false, depending on
|
||||
* on whether the check passed. The second element is an array of environment_results
|
||||
* objects that has detailed information about the checks and which ones passed.
|
||||
*/
|
||||
function check_moodle_environment($version, &$environment_results, $print_table=true, $env_select=ENV_SELECT_NEWER) {
|
||||
function check_moodle_environment($version, $env_select = ENV_SELECT_NEWER) {
|
||||
|
||||
$status = true;
|
||||
|
||||
@ -140,186 +136,7 @@ function check_moodle_environment($version, &$environment_results, $print_table=
|
||||
$cache_exists = true;
|
||||
} ///End of cache block
|
||||
|
||||
/// If we have decided to print all the information, just do it
|
||||
if ($print_table) {
|
||||
print_moodle_environment($result && $status, $environment_results);
|
||||
}
|
||||
return ($result && $status);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will print one beautiful table with all the environmental
|
||||
* configuration and how it suits Moodle needs.
|
||||
*
|
||||
* @global object
|
||||
* @param boolean $result final result of the check (true/false)
|
||||
* @param array $environment_results array of results gathered
|
||||
* @return void
|
||||
*/
|
||||
function print_moodle_environment($result, $environment_results) {
|
||||
global $CFG, $OUTPUT;
|
||||
|
||||
/// Get some strings
|
||||
$strname = get_string('name');
|
||||
$strinfo = get_string('info');
|
||||
$strreport = get_string('report');
|
||||
$strstatus = get_string('status');
|
||||
$strok = get_string('ok');
|
||||
$strerror = get_string('error');
|
||||
$strcheck = get_string('check');
|
||||
$strbypassed = get_string('bypassed');
|
||||
$strrestricted = get_string('restricted');
|
||||
$strenvironmenterrortodo = get_string('environmenterrortodo', 'admin');
|
||||
/// Table headers
|
||||
$servertable = new html_table();//table for server checks
|
||||
$servertable->head = array ($strname, $strinfo, $strreport, $strstatus);
|
||||
$servertable->align = array ('center', 'center', 'left', 'center');
|
||||
$servertable->wrap = array ('nowrap', '', '', 'nowrap');
|
||||
$servertable->size = array ('10', 10, '100%', '10');
|
||||
$servertable->attributes['class'] = 'environmenttable generaltable';
|
||||
|
||||
$serverdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
|
||||
|
||||
$othertable = new html_table();//table for custom checks
|
||||
$othertable->head = array ($strinfo, $strreport, $strstatus);
|
||||
$othertable->align = array ('center', 'left', 'center');
|
||||
$othertable->wrap = array ('', '', 'nowrap');
|
||||
$othertable->size = array (10, '100%', '10');
|
||||
$othertable->attributes['class'] = 'environmenttable generaltable';
|
||||
|
||||
$otherdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
|
||||
|
||||
/// Iterate over each environment_result
|
||||
$continue = true;
|
||||
foreach ($environment_results as $environment_result) {
|
||||
$errorline = false;
|
||||
$warningline = false;
|
||||
$stringtouse = '';
|
||||
if ($continue) {
|
||||
$type = $environment_result->getPart();
|
||||
$info = $environment_result->getInfo();
|
||||
$status = $environment_result->getStatus();
|
||||
$error_code = $environment_result->getErrorCode();
|
||||
/// Process Report field
|
||||
$rec = new stdClass();
|
||||
/// Something has gone wrong at parsing time
|
||||
if ($error_code) {
|
||||
$stringtouse = 'environmentxmlerror';
|
||||
$rec->error_code = $error_code;
|
||||
$status = $strerror;
|
||||
$errorline = true;
|
||||
$continue = false;
|
||||
}
|
||||
|
||||
if ($continue) {
|
||||
/// We are comparing versions
|
||||
if ($rec->needed = $environment_result->getNeededVersion()) {
|
||||
$rec->current = $environment_result->getCurrentVersion();
|
||||
if ($environment_result->getLevel() == 'required') {
|
||||
$stringtouse = 'environmentrequireversion';
|
||||
} else {
|
||||
$stringtouse = 'environmentrecommendversion';
|
||||
}
|
||||
/// We are checking installed & enabled things
|
||||
} else if ($environment_result->getPart() == 'custom_check') {
|
||||
if ($environment_result->getLevel() == 'required') {
|
||||
$stringtouse = 'environmentrequirecustomcheck';
|
||||
} else {
|
||||
$stringtouse = 'environmentrecommendcustomcheck';
|
||||
}
|
||||
} else if ($environment_result->getPart() == 'php_setting') {
|
||||
if ($status) {
|
||||
$stringtouse = 'environmentsettingok';
|
||||
} else if ($environment_result->getLevel() == 'required') {
|
||||
$stringtouse = 'environmentmustfixsetting';
|
||||
} else {
|
||||
$stringtouse = 'environmentshouldfixsetting';
|
||||
}
|
||||
} else {
|
||||
if ($environment_result->getLevel() == 'required') {
|
||||
$stringtouse = 'environmentrequireinstall';
|
||||
} else {
|
||||
$stringtouse = 'environmentrecommendinstall';
|
||||
}
|
||||
}
|
||||
/// Calculate the status value
|
||||
if ($environment_result->getBypassStr() != '') { //Handle bypassed result (warning)
|
||||
$status = $strbypassed;
|
||||
$warningline = true;
|
||||
} else if ($environment_result->getRestrictStr() != '') { //Handle restricted result (error)
|
||||
$status = $strrestricted;
|
||||
$errorline = true;
|
||||
} else {
|
||||
if ($status) { //Handle ok result (ok)
|
||||
$status = $strok;
|
||||
} else {
|
||||
if ($environment_result->getLevel() == 'optional') {//Handle check result (warning)
|
||||
$status = $strcheck;
|
||||
$warningline = true;
|
||||
} else { //Handle error result (error)
|
||||
$status = $strcheck;
|
||||
$errorline = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Build the text
|
||||
$linkparts = array();
|
||||
$linkparts[] = 'admin/environment';
|
||||
$linkparts[] = $type;
|
||||
if (!empty($info)){
|
||||
$linkparts[] = $info;
|
||||
}
|
||||
if (empty($CFG->docroot)) {
|
||||
$report = get_string($stringtouse, 'admin', $rec);
|
||||
} else {
|
||||
$report = $OUTPUT->doc_link(join($linkparts, '/'), get_string($stringtouse, 'admin', $rec));
|
||||
}
|
||||
|
||||
|
||||
/// Format error or warning line
|
||||
if ($errorline || $warningline) {
|
||||
$messagetype = $errorline? 'error':'warn';
|
||||
} else {
|
||||
$messagetype = 'ok';
|
||||
}
|
||||
$status = '<span class="'.$messagetype.'">'.$status.'</span>';
|
||||
/// Here we'll store all the feedback found
|
||||
$feedbacktext = '';
|
||||
///Append the feedback if there is some
|
||||
$feedbacktext .= $environment_result->strToReport($environment_result->getFeedbackStr(), $messagetype);
|
||||
///Append the bypass if there is some
|
||||
$feedbacktext .= $environment_result->strToReport($environment_result->getBypassStr(), 'warn');
|
||||
///Append the restrict if there is some
|
||||
$feedbacktext .= $environment_result->strToReport($environment_result->getRestrictStr(), 'error');
|
||||
|
||||
$report .= $feedbacktext;
|
||||
/// Add the row to the table
|
||||
|
||||
if ($environment_result->getPart() == 'custom_check'){
|
||||
$otherdata[$messagetype][] = array ($info, $report, $status);
|
||||
} else {
|
||||
$serverdata[$messagetype][] = array ($type, $info, $report, $status);
|
||||
}
|
||||
}
|
||||
}
|
||||
//put errors first in
|
||||
$servertable->data = array_merge($serverdata['error'], $serverdata['warn'], $serverdata['ok']);
|
||||
$othertable->data = array_merge($otherdata['error'], $otherdata['warn'], $otherdata['ok']);
|
||||
|
||||
/// Print table
|
||||
echo $OUTPUT->heading(get_string('serverchecks', 'admin'));
|
||||
echo html_writer::table($servertable);
|
||||
if (count($othertable->data)){
|
||||
echo $OUTPUT->heading(get_string('customcheck', 'admin'));
|
||||
echo html_writer::table($othertable);
|
||||
}
|
||||
|
||||
/// Finally, if any error has happened, print the summary box
|
||||
if (!$result) {
|
||||
echo $OUTPUT->box($strenvironmenterrortodo, 'environmentbox errorbox');
|
||||
}
|
||||
return array($result && $status, $environment_results);
|
||||
}
|
||||
|
||||
|
||||
|
@ -404,7 +404,8 @@ function install_cli_database(array $options, $interactive) {
|
||||
}
|
||||
|
||||
// test environment first
|
||||
if (!check_moodle_environment(normalize_version($release), $environment_results, false, ENV_SELECT_RELEASE)) {
|
||||
list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE);
|
||||
if (!$envstatus) {
|
||||
$errors = environment_get_errors($environment_results);
|
||||
cli_heading(get_string('environment', 'admin'));
|
||||
foreach ($errors as $error) {
|
||||
|
@ -92,7 +92,9 @@ class plugin_manager {
|
||||
* Returns a tree of known plugins and information about them
|
||||
*
|
||||
* @param bool $disablecache force reload, cache can be used otherwise
|
||||
* @return array
|
||||
* @return array 2D array. The first keys are plugin type names (e.g. qtype);
|
||||
* the second keys are the plugin local name (e.g. multichoice); and
|
||||
* the values are the corresponding {@link plugin_information} objects.
|
||||
*/
|
||||
public function get_plugins($disablecache=false) {
|
||||
|
||||
@ -108,8 +110,8 @@ class plugin_manager {
|
||||
} else {
|
||||
$plugintypeclass = 'plugintype_general';
|
||||
}
|
||||
if (!in_array('plugintype_interface', class_implements($plugintypeclass))) {
|
||||
throw new coding_exception('Class ' . $plugintypeclass . ' must implement plugintype_interface');
|
||||
if (!in_array('plugin_information', class_implements($plugintypeclass))) {
|
||||
throw new coding_exception('Class ' . $plugintypeclass . ' must implement plugin_information');
|
||||
}
|
||||
$plugins = call_user_func(array($plugintypeclass, 'get_plugins'), $plugintype, $plugintyperootdir, $plugintypeclass);
|
||||
$this->pluginsinfo[$plugintype] = $plugins;
|
||||
@ -120,12 +122,14 @@ class plugin_manager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns list of plugins that define their subplugins and information about them
|
||||
* Returns list of plugins that define their subplugins and the information
|
||||
* about them from the db/subplugins.php file.
|
||||
*
|
||||
* At the moment, only activity modules can define subplugins.
|
||||
*
|
||||
* @param double $disablecache force reload, cache can be used otherwise
|
||||
* @return array
|
||||
* @param bool $disablecache force reload, cache can be used otherwise
|
||||
* @return array with keys like 'mod_quiz', and values the data from the
|
||||
* corresponding db/subplugins.php file.
|
||||
*/
|
||||
public function get_subplugins($disablecache=false) {
|
||||
|
||||
@ -211,6 +215,62 @@ class plugin_manager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $component frankenstyle component name.
|
||||
* @return plugin_information|null the corresponding plugin information.
|
||||
*/
|
||||
public function get_plugin_info($component) {
|
||||
list($type, $name) = normalize_component($component);
|
||||
$plugins = $this->get_plugins();
|
||||
if (isset($plugins[$type][$name])) {
|
||||
return $plugins[$type][$name];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a dependencies list against the list of installed plugins.
|
||||
* @param array $dependencies compenent name to required version or ANY_VERSION.
|
||||
* @return bool true if all the dependencies are satisfied.
|
||||
*/
|
||||
public function are_dependencies_satisfied($dependencies) {
|
||||
foreach ($dependencies as $component => $requiredversion) {
|
||||
$otherplugin = $this->get_plugin_info($component);
|
||||
if (is_null($otherplugin)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($requiredversion != ANY_VERSION and $otherplugin->versiondb < $requiredversion) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks all dependencies for all installed plugins. Used by install and upgrade.
|
||||
* @param int $moodleversion the version from version.php.
|
||||
* @return bool true if all the dependencies are satisfied for all plugins.
|
||||
*/
|
||||
public function all_plugins_ok($moodleversion) {
|
||||
foreach ($this->get_plugins() as $type => $plugins) {
|
||||
foreach ($plugins as $plugin) {
|
||||
|
||||
if (!empty($plugin->versionrequires) && $plugin->versionrequires > $moodleversion) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$this->are_dependencies_satisfied($plugin->get_other_required_plugins())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a white list of all plugins shipped in the standard Moodle distribution
|
||||
*
|
||||
@ -403,9 +463,13 @@ class plugin_manager {
|
||||
}
|
||||
|
||||
/**
|
||||
* All classes that represent a plugin of some type must implement this interface
|
||||
* Interface for making information about a plugin available.
|
||||
*
|
||||
* Note that most of the useful information is made available in pubic fields,
|
||||
* which cannot be documented in this interface. See the field definitions on
|
||||
* {@link plugintype_base} to find out what information is available.
|
||||
*/
|
||||
interface plugintype_interface {
|
||||
interface plugin_information {
|
||||
|
||||
/**
|
||||
* Gathers and returns the information about all plugins of the given type
|
||||
@ -426,7 +490,7 @@ interface plugintype_interface {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set_display_name();
|
||||
public function init_display_name();
|
||||
|
||||
/**
|
||||
* Sets $versiondisk property to a numerical value representing the
|
||||
@ -438,7 +502,7 @@ interface plugintype_interface {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set_version_disk();
|
||||
public function load_disk_version();
|
||||
|
||||
/**
|
||||
* Sets $versiondb property to a numerical value representing the
|
||||
@ -450,7 +514,7 @@ interface plugintype_interface {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set_version_db();
|
||||
public function load_db_version();
|
||||
|
||||
/**
|
||||
* Sets $versionrequires property to a numerical value representing
|
||||
@ -458,7 +522,7 @@ interface plugintype_interface {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set_version_requires();
|
||||
public function load_required_main_version();
|
||||
|
||||
/**
|
||||
* Sets $source property to one of plugin_manager::PLUGIN_SOURCE_xxx
|
||||
@ -470,7 +534,7 @@ interface plugintype_interface {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set_source();
|
||||
public function init_is_standard();
|
||||
|
||||
/**
|
||||
* Returns true if the plugin is shipped with the official distribution
|
||||
@ -487,6 +551,13 @@ interface plugintype_interface {
|
||||
*/
|
||||
public function get_status();
|
||||
|
||||
/**
|
||||
* Get the list of other plugins that this plugin requires ot be installed.
|
||||
* @return array with keys the frankenstyle plugin name, and values either
|
||||
* a version string (like '2011101700') or the constant ANY_VERSION.
|
||||
*/
|
||||
public function get_other_required_plugins();
|
||||
|
||||
/**
|
||||
* Returns the information about plugin availability
|
||||
*
|
||||
@ -529,6 +600,14 @@ interface plugintype_interface {
|
||||
* @return string
|
||||
*/
|
||||
public function get_dir();
|
||||
|
||||
/**
|
||||
* Return the full path name of a file within the plugin.
|
||||
* No check is made to see if the file exists.
|
||||
* @param string $relativepath e.g. 'version.php'.
|
||||
* @return string e.g. $CFG->dirroot . '/mod/quiz/version.php'.
|
||||
*/
|
||||
public function full_path($relativepath);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -555,13 +634,16 @@ abstract class plugintype_base {
|
||||
public $versiondb;
|
||||
/** @var int|float|string required version of Moodle core */
|
||||
public $versionrequires;
|
||||
/** @var array other plugins that this one depends on.
|
||||
* Lazy-loaded by {@link get_other_required_plugins()} */
|
||||
public $dependencies = null;
|
||||
/** @var int number of instances of the plugin - not supported yet */
|
||||
public $instances;
|
||||
/** @var int order of the plugin among other plugins of the same type - not supported yet */
|
||||
public $sortorder;
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::get_plugins()
|
||||
* @see plugin_information::get_plugins()
|
||||
*/
|
||||
public static function get_plugins($type, $typerootdir, $typeclass) {
|
||||
|
||||
@ -575,11 +657,11 @@ abstract class plugintype_base {
|
||||
$plugin->name = $pluginname;
|
||||
$plugin->rootdir = $pluginrootdir;
|
||||
|
||||
$plugin->set_display_name();
|
||||
$plugin->set_version_disk();
|
||||
$plugin->set_version_db();
|
||||
$plugin->set_version_requires();
|
||||
$plugin->set_source();
|
||||
$plugin->init_display_name();
|
||||
$plugin->load_disk_version();
|
||||
$plugin->load_db_version();
|
||||
$plugin->load_required_main_version();
|
||||
$plugin->init_is_standard();
|
||||
|
||||
$ondisk[$pluginname] = $plugin;
|
||||
}
|
||||
@ -587,9 +669,9 @@ abstract class plugintype_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::set_display_name()
|
||||
* @see plugin_information::init_display_name()
|
||||
*/
|
||||
public function set_display_name() {
|
||||
public function init_display_name() {
|
||||
if (! get_string_manager()->string_exists('pluginname', $this->type . '_' . $this->name)) {
|
||||
$this->displayname = '[pluginname,' . $this->type . '_' . $this->name . ']';
|
||||
} else {
|
||||
@ -598,28 +680,76 @@ abstract class plugintype_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::set_version_disk()
|
||||
* @see plugin_information::full_path()
|
||||
*/
|
||||
public function set_version_disk() {
|
||||
|
||||
public function full_path($relativepath) {
|
||||
if (empty($this->rootdir)) {
|
||||
return;
|
||||
return '';
|
||||
}
|
||||
return $this->rootdir . '/' . $relativepath;
|
||||
}
|
||||
|
||||
$versionfile = $this->rootdir . '/version.php';
|
||||
/**
|
||||
* Load the data from version.php.
|
||||
* @return object the data object defined in version.php.
|
||||
*/
|
||||
protected function load_version_php() {
|
||||
$versionfile = $this->full_path('version.php');
|
||||
|
||||
$plugin = new stdClass();
|
||||
if (is_readable($versionfile)) {
|
||||
include($versionfile);
|
||||
if (isset($plugin->version)) {
|
||||
$this->versiondisk = $plugin->version;
|
||||
}
|
||||
}
|
||||
return $plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugin_information::load_disk_version()
|
||||
*/
|
||||
public function load_disk_version() {
|
||||
$plugin = $this->load_version_php();
|
||||
if (isset($plugin->version)) {
|
||||
$this->versiondisk = $plugin->version;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::set_version_db()
|
||||
* @see plugin_information::load_required_main_version()
|
||||
*/
|
||||
public function set_version_db() {
|
||||
public function load_required_main_version() {
|
||||
$plugin = $this->load_version_php();
|
||||
if (isset($plugin->requires)) {
|
||||
$this->versionrequires = $plugin->requires;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise {@link $dependencies} to the list of other plugins (in any)
|
||||
* that this one requires to be installed.
|
||||
*/
|
||||
protected function load_other_required_plugins() {
|
||||
$plugin = $this->load_version_php();
|
||||
if (!empty($plugin->dependencies)) {
|
||||
$this->dependencies = $plugin->dependencies;
|
||||
} else {
|
||||
$this->dependencies = array(); // By default, no dependencies.
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugin_information::get_other_required_plugins()
|
||||
*/
|
||||
public function get_other_required_plugins() {
|
||||
if (is_null($this->dependencies)) {
|
||||
$this->load_other_required_plugins();
|
||||
}
|
||||
return $this->dependencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugin_information::load_db_version()
|
||||
*/
|
||||
public function load_db_version() {
|
||||
|
||||
if ($ver = self::get_version_from_config_plugins($this->type . '_' . $this->name)) {
|
||||
$this->versiondb = $ver;
|
||||
@ -627,28 +757,9 @@ abstract class plugintype_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::set_version_requires()
|
||||
* @see plugin_information::init_is_standard()
|
||||
*/
|
||||
public function set_version_requires() {
|
||||
|
||||
if (empty($this->rootdir)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$versionfile = $this->rootdir . '/version.php';
|
||||
|
||||
if (is_readable($versionfile)) {
|
||||
include($versionfile);
|
||||
if (isset($plugin->requires)) {
|
||||
$this->versionrequires = $plugin->requires;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::set_source()
|
||||
*/
|
||||
public function set_source() {
|
||||
public function init_is_standard() {
|
||||
|
||||
$standard = plugin_manager::standard_plugins_list($this->type);
|
||||
|
||||
@ -663,14 +774,14 @@ abstract class plugintype_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::is_standard()
|
||||
* @see plugin_information::is_standard()
|
||||
*/
|
||||
public function is_standard() {
|
||||
return $this->source === plugin_manager::PLUGIN_SOURCE_STANDARD;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::get_status()
|
||||
* @see plugin_information::get_status()
|
||||
*/
|
||||
public function get_status() {
|
||||
|
||||
@ -699,28 +810,28 @@ abstract class plugintype_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::is_enabled()
|
||||
* @see plugin_information::is_enabled()
|
||||
*/
|
||||
public function is_enabled() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::get_settings_url()
|
||||
* @see plugin_information::get_settings_url()
|
||||
*/
|
||||
public function get_settings_url() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::get_uninstall_url()
|
||||
* @see plugin_information::get_uninstall_url()
|
||||
*/
|
||||
public function get_uninstall_url() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::get_dir()
|
||||
* @see plugin_information::get_dir()
|
||||
*/
|
||||
public function get_dir() {
|
||||
global $CFG;
|
||||
@ -754,17 +865,17 @@ abstract class plugintype_base {
|
||||
/**
|
||||
* General class for all plugin types that do not have their own class
|
||||
*/
|
||||
class plugintype_general extends plugintype_base implements plugintype_interface {
|
||||
class plugintype_general extends plugintype_base implements plugin_information {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for page side blocks
|
||||
*/
|
||||
class plugintype_block extends plugintype_base implements plugintype_interface {
|
||||
class plugintype_block extends plugintype_base implements plugin_information {
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::get_plugins()
|
||||
* @see plugin_information::get_plugins()
|
||||
*/
|
||||
public static function get_plugins($type, $typerootdir, $typeclass) {
|
||||
|
||||
@ -784,7 +895,7 @@ class plugintype_block extends plugintype_base implements plugintype_interface {
|
||||
$plugin->rootdir = null;
|
||||
$plugin->displayname = $blockname;
|
||||
$plugin->versiondb = $blockinfo->version;
|
||||
$plugin->set_source();
|
||||
$plugin->init_is_standard();
|
||||
|
||||
$blocks[$blockname] = $plugin;
|
||||
}
|
||||
@ -793,9 +904,9 @@ class plugintype_block extends plugintype_base implements plugintype_interface {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::set_display_name()
|
||||
* @see plugin_information::init_display_name()
|
||||
*/
|
||||
public function set_display_name() {
|
||||
public function init_display_name() {
|
||||
|
||||
if (get_string_manager()->string_exists('pluginname', 'block_' . $this->name)) {
|
||||
$this->displayname = get_string('pluginname', 'block_' . $this->name);
|
||||
@ -804,14 +915,14 @@ class plugintype_block extends plugintype_base implements plugintype_interface {
|
||||
$this->displayname = $block->get_title();
|
||||
|
||||
} else {
|
||||
parent::set_display_name();
|
||||
parent::init_display_name();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::set_version_db()
|
||||
* @see plugin_information::load_db_version()
|
||||
*/
|
||||
public function set_version_db() {
|
||||
public function load_db_version() {
|
||||
global $DB;
|
||||
|
||||
$blocksinfo = self::get_blocks_info();
|
||||
@ -821,7 +932,7 @@ class plugintype_block extends plugintype_base implements plugintype_interface {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::is_enabled()
|
||||
* @see plugin_information::is_enabled()
|
||||
*/
|
||||
public function is_enabled() {
|
||||
|
||||
@ -838,7 +949,7 @@ class plugintype_block extends plugintype_base implements plugintype_interface {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::get_settings_url()
|
||||
* @see plugin_information::get_settings_url()
|
||||
*/
|
||||
public function get_settings_url() {
|
||||
|
||||
@ -846,7 +957,7 @@ class plugintype_block extends plugintype_base implements plugintype_interface {
|
||||
return parent::get_settings_url();
|
||||
|
||||
} else if ($block->has_config()) {
|
||||
if (!empty($this->rootdir) and file_exists($this->rootdir . '/settings.php')) {
|
||||
if (file_exists($this->full_path('settings.php'))) {
|
||||
return new moodle_url('/admin/settings.php', array('section' => 'blocksetting' . $this->name));
|
||||
} else {
|
||||
$blocksinfo = self::get_blocks_info();
|
||||
@ -859,7 +970,7 @@ class plugintype_block extends plugintype_base implements plugintype_interface {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::get_uninstall_url()
|
||||
* @see plugin_information::get_uninstall_url()
|
||||
*/
|
||||
public function get_uninstall_url() {
|
||||
|
||||
@ -888,10 +999,10 @@ class plugintype_block extends plugintype_base implements plugintype_interface {
|
||||
/**
|
||||
* Class for text filters
|
||||
*/
|
||||
class plugintype_filter extends plugintype_base implements plugintype_interface {
|
||||
class plugintype_filter extends plugintype_base implements plugin_information {
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::get_plugins()
|
||||
* @see plugin_information::get_plugins()
|
||||
*/
|
||||
public static function get_plugins($type, $typerootdir, $typeclass) {
|
||||
global $CFG, $DB;
|
||||
@ -909,10 +1020,10 @@ class plugintype_filter extends plugintype_base implements plugintype_interface
|
||||
$plugin->rootdir = $CFG->dirroot . '/' . $filterlegacyname;
|
||||
$plugin->displayname = $displayname;
|
||||
|
||||
$plugin->set_version_disk();
|
||||
$plugin->set_version_db();
|
||||
$plugin->set_version_requires();
|
||||
$plugin->set_source();
|
||||
$plugin->load_disk_version();
|
||||
$plugin->load_db_version();
|
||||
$plugin->load_required_main_version();
|
||||
$plugin->init_is_standard();
|
||||
|
||||
$filters[$plugin->name] = $plugin;
|
||||
}
|
||||
@ -945,7 +1056,7 @@ class plugintype_filter extends plugintype_base implements plugintype_interface
|
||||
$plugin->rootdir = $CFG->dirroot . '/' . $info->legacyname;
|
||||
$plugin->displayname = $info->legacyname;
|
||||
|
||||
$plugin->set_version_db();
|
||||
$plugin->load_db_version();
|
||||
|
||||
if (is_null($plugin->versiondb)) {
|
||||
// this is a hack to stimulate 'Missing from disk' error
|
||||
@ -961,40 +1072,26 @@ class plugintype_filter extends plugintype_base implements plugintype_interface
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::set_display_name()
|
||||
* @see plugin_information::init_display_name()
|
||||
*/
|
||||
public function set_display_name() {
|
||||
public function init_display_name() {
|
||||
// do nothing, the name is set in self::get_plugins()
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::set_version_disk()
|
||||
* @see plugintype_base::load_version_php().
|
||||
*/
|
||||
public function set_version_disk() {
|
||||
|
||||
protected function load_version_php() {
|
||||
if (strpos($this->name, 'mod_') === 0) {
|
||||
// filters bundled with modules do not use versioning
|
||||
return;
|
||||
// filters bundled with modules do not have a version.php and so
|
||||
// do not provide their own versioning information.
|
||||
return new stdClass();
|
||||
}
|
||||
|
||||
return parent::set_version_disk();
|
||||
return parent::load_version_php();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::set_version_requires()
|
||||
*/
|
||||
public function set_version_requires() {
|
||||
|
||||
if (strpos($this->name, 'mod_') === 0) {
|
||||
// filters bundled with modules do not use versioning
|
||||
return;
|
||||
}
|
||||
|
||||
return parent::set_version_requires();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::is_enabled()
|
||||
* @see plugin_information::is_enabled()
|
||||
*/
|
||||
public function is_enabled() {
|
||||
|
||||
@ -1016,7 +1113,7 @@ class plugintype_filter extends plugintype_base implements plugintype_interface
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::get_settings_url()
|
||||
* @see plugin_information::get_settings_url()
|
||||
*/
|
||||
public function get_settings_url() {
|
||||
|
||||
@ -1030,7 +1127,7 @@ class plugintype_filter extends plugintype_base implements plugintype_interface
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::get_uninstall_url()
|
||||
* @see plugin_information::get_uninstall_url()
|
||||
*/
|
||||
public function get_uninstall_url() {
|
||||
|
||||
@ -1101,10 +1198,10 @@ class plugintype_filter extends plugintype_base implements plugintype_interface
|
||||
/**
|
||||
* Class for activity modules
|
||||
*/
|
||||
class plugintype_mod extends plugintype_base implements plugintype_interface {
|
||||
class plugintype_mod extends plugintype_base implements plugin_information {
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::get_plugins()
|
||||
* @see plugin_information::get_plugins()
|
||||
*/
|
||||
public static function get_plugins($type, $typerootdir, $typeclass) {
|
||||
|
||||
@ -1124,7 +1221,7 @@ class plugintype_mod extends plugintype_base implements plugintype_interface {
|
||||
$plugin->rootdir = null;
|
||||
$plugin->displayname = $modulename;
|
||||
$plugin->versiondb = $moduleinfo->version;
|
||||
$plugin->set_source();
|
||||
$plugin->init_is_standard();
|
||||
|
||||
$modules[$modulename] = $plugin;
|
||||
}
|
||||
@ -1133,9 +1230,9 @@ class plugintype_mod extends plugintype_base implements plugintype_interface {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::set_display_name()
|
||||
* @see plugin_information::init_display_name()
|
||||
*/
|
||||
public function set_display_name() {
|
||||
public function init_display_name() {
|
||||
if (get_string_manager()->string_exists('pluginname', $this->type . '_' . $this->name)) {
|
||||
$this->displayname = get_string('pluginname', $this->type . '_' . $this->name);
|
||||
} else {
|
||||
@ -1144,28 +1241,23 @@ class plugintype_mod extends plugintype_base implements plugintype_interface {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::set_version_disk()
|
||||
* Load the data from version.php.
|
||||
* @return object the data object defined in version.php.
|
||||
*/
|
||||
public function set_version_disk() {
|
||||
|
||||
if (empty($this->rootdir)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$versionfile = $this->rootdir . '/version.php';
|
||||
protected function load_version_php() {
|
||||
$versionfile = $this->full_path('version.php');
|
||||
|
||||
$module = new stdClass();
|
||||
if (is_readable($versionfile)) {
|
||||
include($versionfile);
|
||||
if (isset($module->version)) {
|
||||
$this->versiondisk = $module->version;
|
||||
}
|
||||
}
|
||||
return $module;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::set_version_db()
|
||||
* @see plugin_information::load_db_version()
|
||||
*/
|
||||
public function set_version_db() {
|
||||
public function load_db_version() {
|
||||
global $DB;
|
||||
|
||||
$modulesinfo = self::get_modules_info();
|
||||
@ -1175,26 +1267,7 @@ class plugintype_mod extends plugintype_base implements plugintype_interface {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::set_version_requires()
|
||||
*/
|
||||
public function set_version_requires() {
|
||||
|
||||
if (empty($this->rootdir)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$versionfile = $this->rootdir . '/version.php';
|
||||
|
||||
if (is_readable($versionfile)) {
|
||||
include($versionfile);
|
||||
if (isset($module->requires)) {
|
||||
$this->versionrequires = $module->requires;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::is_enabled()
|
||||
* @see plugin_information::is_enabled()
|
||||
*/
|
||||
public function is_enabled() {
|
||||
|
||||
@ -1211,11 +1284,11 @@ class plugintype_mod extends plugintype_base implements plugintype_interface {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::get_settings_url()
|
||||
* @see plugin_information::get_settings_url()
|
||||
*/
|
||||
public function get_settings_url() {
|
||||
|
||||
if (!empty($this->rootdir) and (file_exists($this->rootdir . '/settings.php') or file_exists($this->rootdir . '/settingstree.php'))) {
|
||||
if (file_exists($this->full_path('settings.php')) or file_exists($this->full_path('settingstree.php'))) {
|
||||
return new moodle_url('/admin/settings.php', array('section' => 'modsetting' . $this->name));
|
||||
} else {
|
||||
return parent::get_settings_url();
|
||||
@ -1223,7 +1296,7 @@ class plugintype_mod extends plugintype_base implements plugintype_interface {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::get_uninstall_url()
|
||||
* @see plugin_information::get_uninstall_url()
|
||||
*/
|
||||
public function get_uninstall_url() {
|
||||
|
||||
@ -1252,39 +1325,91 @@ class plugintype_mod extends plugintype_base implements plugintype_interface {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Class for question behaviours.
|
||||
*/
|
||||
class plugintype_qbehaviour extends plugintype_base implements plugin_information {
|
||||
|
||||
/**
|
||||
* @see plugintype_base::load_other_required_plugins().
|
||||
*/
|
||||
protected function load_other_required_plugins() {
|
||||
parent::load_other_required_plugins();
|
||||
if (!empty($this->dependencies)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Standard mechanism did not find anything, so try the legacy way.
|
||||
global $CFG;
|
||||
require_once($CFG->libdir . '/questionlib.php');
|
||||
$required = question_engine::get_behaviour_required_behaviours($this->name);
|
||||
foreach ($required as $other) {
|
||||
$this->dependencies['qbehaviour_' . $other] = ANY_VERSION;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Class for question types
|
||||
*/
|
||||
class plugintype_qtype extends plugintype_base implements plugintype_interface {
|
||||
class plugintype_qtype extends plugintype_base implements plugin_information {
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::set_display_name()
|
||||
* @see plugin_information::init_display_name()
|
||||
*/
|
||||
public function set_display_name() {
|
||||
$this->displayname = get_string($this->name, 'qtype_' . $this->name);
|
||||
public function init_display_name() {
|
||||
if (get_string_manager()->string_exists('pluginname', $this->type . '_' . $this->name)) {
|
||||
$this->displayname = get_string('pluginname', $this->type . '_' . $this->name);
|
||||
} else {
|
||||
$this->displayname = get_string($this->name, 'qtype_' . $this->name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_base::load_other_required_plugins().
|
||||
*/
|
||||
protected function load_other_required_plugins() {
|
||||
parent::load_other_required_plugins();
|
||||
if (!empty($this->dependencies)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Standard mechanism did not find anything, so try the legacy way.
|
||||
global $CFG;
|
||||
require_once($CFG->libdir . '/questionlib.php');
|
||||
$required = question_bank::get_qtype($this->name)->requires_qtypes();
|
||||
foreach ($required as $other) {
|
||||
$this->dependencies['qtype_' . $other] = ANY_VERSION;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for question formats
|
||||
*/
|
||||
class plugintype_qformat extends plugintype_base implements plugintype_interface {
|
||||
class plugintype_qformat extends plugintype_base implements plugin_information {
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::set_display_name()
|
||||
* @see plugin_information::init_display_name()
|
||||
*/
|
||||
public function set_display_name() {
|
||||
$this->displayname = get_string($this->name, 'qformat_' . $this->name);
|
||||
public function init_display_name() {
|
||||
if (get_string_manager()->string_exists('pluginname', $this->type . '_' . $this->name)) {
|
||||
$this->displayname = get_string('pluginname', $this->type . '_' . $this->name);
|
||||
} else {
|
||||
$this->displayname = get_string($this->name, 'qformat_' . $this->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for authentication plugins
|
||||
*/
|
||||
class plugintype_auth extends plugintype_base implements plugintype_interface {
|
||||
class plugintype_auth extends plugintype_base implements plugin_information {
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::is_enabled()
|
||||
* @see plugin_information::is_enabled()
|
||||
*/
|
||||
public function is_enabled() {
|
||||
global $CFG;
|
||||
@ -1304,11 +1429,10 @@ class plugintype_auth extends plugintype_base implements plugintype_interface {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::get_settings_url()
|
||||
* @see plugin_information::get_settings_url()
|
||||
*/
|
||||
public function get_settings_url() {
|
||||
|
||||
if (!empty($this->rootdir) and file_exists($this->rootdir . '/settings.php')) {
|
||||
if (file_exists($this->full_path('settings.php'))) {
|
||||
return new moodle_url('/admin/settings.php', array('section' => 'authsetting' . $this->name));
|
||||
} else {
|
||||
return new moodle_url('/admin/auth_config.php', array('auth' => $this->name));
|
||||
@ -1319,7 +1443,7 @@ class plugintype_auth extends plugintype_base implements plugintype_interface {
|
||||
/**
|
||||
* Class for enrolment plugins
|
||||
*/
|
||||
class plugintype_enrol extends plugintype_base implements plugintype_interface {
|
||||
class plugintype_enrol extends plugintype_base implements plugin_information {
|
||||
|
||||
/**
|
||||
* We do not actually need whole enrolment classes here so we do not call
|
||||
@ -1327,7 +1451,7 @@ class plugintype_enrol extends plugintype_base implements plugintype_interface {
|
||||
* results, for example if the enrolment plugin does not contain lib.php
|
||||
* but it is listed in $CFG->enrol_plugins_enabled
|
||||
*
|
||||
* @see plugintype_interface::is_enabled()
|
||||
* @see plugin_information::is_enabled()
|
||||
*/
|
||||
public function is_enabled() {
|
||||
global $CFG;
|
||||
@ -1342,11 +1466,11 @@ class plugintype_enrol extends plugintype_base implements plugintype_interface {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::get_settings_url()
|
||||
* @see plugin_information::get_settings_url()
|
||||
*/
|
||||
public function get_settings_url() {
|
||||
|
||||
if ($this->is_enabled() or (!empty($this->rootdir) and file_exists($this->rootdir . '/settings.php'))) {
|
||||
if ($this->is_enabled() or file_exists($this->full_path('settings.php'))) {
|
||||
return new moodle_url('/admin/settings.php', array('section' => 'enrolsettings' . $this->name));
|
||||
} else {
|
||||
return parent::get_settings_url();
|
||||
@ -1354,7 +1478,7 @@ class plugintype_enrol extends plugintype_base implements plugintype_interface {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::get_uninstall_url()
|
||||
* @see plugin_information::get_uninstall_url()
|
||||
*/
|
||||
public function get_uninstall_url() {
|
||||
return new moodle_url('/admin/enrol.php', array('action' => 'uninstall', 'enrol' => $this->name, 'sesskey' => sesskey()));
|
||||
@ -1364,31 +1488,28 @@ class plugintype_enrol extends plugintype_base implements plugintype_interface {
|
||||
/**
|
||||
* Class for messaging processors
|
||||
*/
|
||||
class plugintype_message extends plugintype_base implements plugintype_interface {
|
||||
class plugintype_message extends plugintype_base implements plugin_information {
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::get_settings_url()
|
||||
* @see plugin_information::get_settings_url()
|
||||
*/
|
||||
public function get_settings_url() {
|
||||
|
||||
if ($this->name === 'jabber') {
|
||||
return new moodle_url('/admin/settings.php', array('section' => 'jabber'));
|
||||
if (file_exists($this->full_path('settings.php')) or file_exists($this->full_path('settingstree.php'))) {
|
||||
return new moodle_url('/admin/settings.php', array('section' => 'messagesetting' . $this->name));
|
||||
} else {
|
||||
return parent::get_settings_url();
|
||||
}
|
||||
|
||||
if ($this->name === 'email') {
|
||||
return new moodle_url('/admin/settings.php', array('section' => 'mail'));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for repositories
|
||||
*/
|
||||
class plugintype_repository extends plugintype_base implements plugintype_interface {
|
||||
class plugintype_repository extends plugintype_base implements plugin_information {
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::is_enabled()
|
||||
* @see plugin_information::is_enabled()
|
||||
*/
|
||||
public function is_enabled() {
|
||||
|
||||
@ -1398,7 +1519,7 @@ class plugintype_repository extends plugintype_base implements plugintype_interf
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::get_settings_url()
|
||||
* @see plugin_information::get_settings_url()
|
||||
*/
|
||||
public function get_settings_url() {
|
||||
|
||||
@ -1430,10 +1551,10 @@ class plugintype_repository extends plugintype_base implements plugintype_interf
|
||||
/**
|
||||
* Class for portfolios
|
||||
*/
|
||||
class plugintype_portfolio extends plugintype_base implements plugintype_interface {
|
||||
class plugintype_portfolio extends plugintype_base implements plugin_information {
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::is_enabled()
|
||||
* @see plugin_information::is_enabled()
|
||||
*/
|
||||
public function is_enabled() {
|
||||
|
||||
@ -1473,10 +1594,10 @@ class plugintype_portfolio extends plugintype_base implements plugintype_interfa
|
||||
/**
|
||||
* Class for themes
|
||||
*/
|
||||
class plugintype_theme extends plugintype_base implements plugintype_interface {
|
||||
class plugintype_theme extends plugintype_base implements plugin_information {
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::is_enabled()
|
||||
* @see plugin_information::is_enabled()
|
||||
*/
|
||||
public function is_enabled() {
|
||||
global $CFG;
|
||||
@ -1493,10 +1614,10 @@ class plugintype_theme extends plugintype_base implements plugintype_interface {
|
||||
/**
|
||||
* Class representing an MNet service
|
||||
*/
|
||||
class plugintype_mnetservice extends plugintype_base implements plugintype_interface {
|
||||
class plugintype_mnetservice extends plugintype_base implements plugin_information {
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::is_enabled()
|
||||
* @see plugin_information::is_enabled()
|
||||
*/
|
||||
public function is_enabled() {
|
||||
global $CFG;
|
||||
@ -1512,7 +1633,7 @@ class plugintype_mnetservice extends plugintype_base implements plugintype_inter
|
||||
/**
|
||||
* Class for admin tool plugins
|
||||
*/
|
||||
class plugintype_tool extends plugintype_base implements plugintype_interface {
|
||||
class plugintype_tool extends plugintype_base implements plugin_information {
|
||||
|
||||
public function get_uninstall_url() {
|
||||
return new moodle_url('/admin/tools.php', array('delete' => $this->name, 'sesskey' => sesskey()));
|
||||
|
@ -1191,29 +1191,27 @@ function question_categorylist($categoryid) {
|
||||
*/
|
||||
function get_import_export_formats($type) {
|
||||
global $CFG;
|
||||
require_once($CFG->dirroot . '/question/format.php');
|
||||
|
||||
$fileformats = get_plugin_list('qformat');
|
||||
$formatclasses = get_plugin_list_with_class('qformat', '', 'format.php');
|
||||
|
||||
$fileformatname = array();
|
||||
require_once($CFG->dirroot . '/question/format.php');
|
||||
foreach ($fileformats as $fileformat => $fdir) {
|
||||
$formatfile = $fdir . '/format.php';
|
||||
if (is_readable($formatfile)) {
|
||||
include_once($formatfile);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
foreach ($formatclasses as $component => $formatclass) {
|
||||
|
||||
$classname = 'qformat_' . $fileformat;
|
||||
$formatclass = new $classname();
|
||||
$format = new $formatclass();
|
||||
if ($type == 'import') {
|
||||
$provided = $formatclass->provide_import();
|
||||
$provided = $format->provide_import();
|
||||
} else {
|
||||
$provided = $formatclass->provide_export();
|
||||
$provided = $format->provide_export();
|
||||
}
|
||||
|
||||
if ($provided) {
|
||||
$fileformatnames[$fileformat] = get_string($fileformat, 'qformat_' . $fileformat);
|
||||
list($notused, $fileformat) = explode('_', $component, 2);
|
||||
if (get_string_manager()->string_exists('pluginname', $component)) {
|
||||
$fileformatnames[$fileformat] = get_string('pluginname', $component);
|
||||
} else {
|
||||
$fileformatnames[$fileformat] = get_string($fileformat, $component);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,12 @@ define('MATURITY_BETA', 100); // feature complete, ready for preview and t
|
||||
define('MATURITY_RC', 150); // tested, will be released unless there are fatal bugs
|
||||
define('MATURITY_STABLE', 200); // ready for production deployment
|
||||
|
||||
/**
|
||||
* Special value that can be used in $plugin->dependencies in version.php files.
|
||||
*/
|
||||
define('ANY_VERSION', 'any');
|
||||
|
||||
|
||||
/**
|
||||
* Simple class. It is usually used instead of stdClass because it looks
|
||||
* more familiar to Java developers ;-) Do not use for type checking of
|
||||
|
@ -1198,18 +1198,6 @@ function upgrade_setup_debug($starting) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @global object
|
||||
*/
|
||||
function print_upgrade_reload($url) {
|
||||
global $OUTPUT;
|
||||
|
||||
echo "<br />";
|
||||
echo '<div class="continuebutton">';
|
||||
echo '<a href="'.$url.'" title="'.get_string('reload').'" ><img src="'.$OUTPUT->pix_url('i/reload') . '" alt="" /> '.get_string('reload').'</a>';
|
||||
echo '</div><br />';
|
||||
}
|
||||
|
||||
function print_upgrade_separator() {
|
||||
if (!CLI_SCRIPT) {
|
||||
echo '<hr />';
|
||||
|
@ -334,6 +334,7 @@ abstract class question_engine {
|
||||
* @return string name from the current language pack.
|
||||
*/
|
||||
public static function get_behaviour_required_behaviours($behaviour) {
|
||||
self::load_behaviour_class($behaviour);
|
||||
$class = 'qbehaviour_' . $behaviour;
|
||||
return $class::get_required_behaviours();
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
require_once(dirname(__FILE__) . '/../config.php');
|
||||
require_once($CFG->dirroot . '/question/editlib.php');
|
||||
require_once($CFG->dirroot . '/question/export_form.php');
|
||||
require_once($CFG->dirroot . '/question/format.php');
|
||||
|
||||
list($thispageurl, $contexts, $cmid, $cm, $module, $pagevars) =
|
||||
question_edit_setup('export', '/question/export.php');
|
||||
|
@ -74,7 +74,11 @@ class question_type {
|
||||
* You should not need to override this method, the default behaviour should be fine.
|
||||
*/
|
||||
public function local_name() {
|
||||
return get_string($this->name(), $this->plugin_name());
|
||||
if (get_string_manager()->string_exists('pluginname', $this->plugin_name())) {
|
||||
$this->displayname = get_string('pluginname', $this->plugin_name());
|
||||
} else {
|
||||
$this->displayname = get_string($this->name(), $this->plugin_name());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -192,6 +192,11 @@
|
||||
#page-admin-index #plugins-check .status-nodb .status {color:#999;}
|
||||
#page-admin-index #plugins-check .status-upgrade .status {background-color:#d2ebff;}
|
||||
#page-admin-index #plugins-check .status-uptodate .status {color:#999;}
|
||||
#page-admin-index #plugins-check .requires ul {font-size:0.7em;margin:0;}
|
||||
#page-admin-index #plugins-check .requires li {display:block;;}
|
||||
#page-admin-index #plugins-check .requires-ok {color:#999;}
|
||||
#page-admin-index #plugins-check .requires-failed {background-color:#ffd3d9;}
|
||||
|
||||
|
||||
/** Plugins management */
|
||||
#page-admin-plugins #plugins-control-panel {margin-left:auto; margin-right:auto;}
|
||||
|
Loading…
x
Reference in New Issue
Block a user