Skip to content

Commit

Permalink
MDL-32329 check for plugin dependencies during the pre-install checking
Browse files Browse the repository at this point in the history
This follows the same path as we have in CLI installers. Plugin
dependencies are checked right after the environment checks and the
install can't continue unless all dependencies are fixed.
  • Loading branch information
mudrd8mz committed May 30, 2012
1 parent 3a2300f commit 39f15cc
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 13 deletions.
14 changes: 14 additions & 0 deletions admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,20 @@
die();
}

// check plugin dependencies
$failed = array();
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
$PAGE->navbar->add(get_string('pluginscheck', 'admin'));
$PAGE->set_title($strinstallation);
$PAGE->set_heading($strinstallation . ' - Moodle ' . $CFG->target_release);

$output = $PAGE->get_renderer('core', 'admin');
$url = new moodle_url('/admin/index.php', array('agreelicense' => 1, 'confirmrelease' => 1, 'lang' => $CFG->lang));
echo $output->unsatisfied_dependencies_page($version, $failed, $url);
die();
}
unset($failed);

//TODO: add a page with list of non-standard plugins here

$strdatabasesetup = get_string('databasesetup');
Expand Down
56 changes: 45 additions & 11 deletions admin/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,28 @@ public function install_environment_page($maturity, $envstatus, $environment_res
return $output;
}

/**
* Displays the list of plugins with unsatisfied dependencies
*
* @param double|string|int $version Moodle on-disk version
* @param array $failed list of plugins with unsatisfied dependecies
* @return string HTML
*/
public function unsatisfied_dependencies_page($version, array $failed, moodle_url $reloadurl) {
$output = '';

$output .= $this->header();
$output .= $this->heading(get_string('pluginscheck', 'admin'));
$output .= $this->warning(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
$output .= $this->plugins_check_table(plugin_manager::instance(), $version, array('xdep' => true));
$output .= $this->warning(get_string('pluginschecktodo', 'admin'));
$output .= $this->continue_button($reloadurl);

$output .= $this->footer();

return $output;
}

/**
* Display the 'You are about to upgrade Moodle' page. The first page
* during upgrade.
Expand Down Expand Up @@ -563,13 +585,14 @@ function upgrade_reload($url) {
* This default implementation renders all plugins into one big table. The rendering
* options support:
* (bool)full = false: whether to display up-to-date plugins, too
* (bool)xdep = false: display the plugins with unsatisified dependecies only
*
* @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_table(plugin_manager $pluginman, $version, array $options = null) {
public function plugins_check_table(plugin_manager $pluginman, $version, array $options = array()) {
global $CFG;

$plugininfo = $pluginman->get_plugins();
Expand All @@ -578,11 +601,8 @@ public function plugins_check_table(plugin_manager $pluginman, $version, array $
return '';
}

if (empty($options)) {
$options = array(
'full' => false,
);
}
$options['full'] = isset($options['full']) ? (bool)$options['full'] : false;
$options['xdep'] = isset($options['xdep']) ? (bool)$options['xdep'] : false;

$table = new html_table();
$table->id = 'plugins-check';
Expand Down Expand Up @@ -667,15 +687,25 @@ public function plugins_check_table(plugin_manager $pluginman, $version, array $
$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 and empty($availableupdates)) {
$plugin->get_other_required_plugins()) && $plugin->is_core_dependency_satisfied($version);

if ($options['xdep']) {
// we want to see only plugins with failed dependencies
if ($dependenciesok) {
continue;
}

} else if ($isstandard and $statusisboring and $dependenciesok and empty($availableupdates)) {
// no change is going to happen to the plugin - display it only
// if the user wants to see the full list
if (empty($options['full'])) {
continue;
}
} else {
$numofhighlighted[$type]++;
}

// ok, the plugin should be displayed
$numofhighlighted[$type]++;

$row->cells = array($displayname, $rootdir, $source,
$versiondb, $versiondisk, $requires, $status);
$plugintyperows[] = $row;
Expand All @@ -691,7 +721,11 @@ public function plugins_check_table(plugin_manager $pluginman, $version, array $

$sumofhighlighted = array_sum($numofhighlighted);

if ($sumofhighlighted == 0) {
if ($options['xdep']) {
// we do not want to display no heading and links in this mode
$out = '';

} else if ($sumofhighlighted == 0) {
$out = $this->output->container_start('nonehighlighted', 'plugins-check-info');
$out .= $this->output->heading(get_string('nonehighlighted', 'core_plugin'));
if (empty($options['full'])) {
Expand Down
1 change: 1 addition & 0 deletions lang/en/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,7 @@
$string['pleaseregister'] = 'Please register your site to remove this button';
$string['plugin'] = 'Plugin';
$string['plugins'] = 'Plugins';
$string['pluginscheck'] = 'Plugin dependencies check';
$string['pluginscheckfailed'] = 'Dependencies check failed for {$a->pluginslist}';
$string['pluginschecktodo'] = 'You must solve all the plugin requirements before proceeding to install this Moodle version!';
$string['pluginsoverview'] = 'Plugins overview';
Expand Down
4 changes: 2 additions & 2 deletions lang/en/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
$string['checkforupdateslast'] = 'Last check done on {$a}';
$string['displayname'] = 'Plugin name';
$string['moodleversion'] = 'Moodle {$a}';
$string['nonehighlighted'] = 'No plugins require your attention during this upgrade';
$string['nonehighlighted'] = 'No plugins require your attention now';
$string['nonehighlightedinfo'] = 'Display the list of all installed plugins anyway';
$string['noneinstalled'] = 'No plugins of this type are installed';
$string['notes'] = 'Notes';
Expand All @@ -52,7 +52,7 @@
$string['requires'] = 'Requires';
$string['rootdir'] = 'Directory';
$string['settings'] = 'Settings';
$string['somehighlighted'] = 'Number of plugins requiring attention during this upgrade: {$a}';
$string['somehighlighted'] = 'Number of plugins requiring your attention: {$a}';
$string['somehighlightedinfo'] = 'Display the full list of installed plugins';
$string['somehighlightedonly'] = 'Display only plugins requiring your attention';
$string['source'] = 'Source';
Expand Down

0 comments on commit 39f15cc

Please sign in to comment.