MDL-29474 prevent install/upgrade if plugin dependancies not met.

This commit is contained in:
Tim Hunt
2011-10-20 11:13:41 +01:00
parent cc359566fe
commit faadd32696
6 changed files with 65 additions and 19 deletions
+22 -2
View File
@@ -235,8 +235,6 @@ class plugin_manager {
* @return bool true if all the dependancies are satisfied.
*/
public function are_dependancies_satisfied($dependancies) {
$installedplugins = $this->get_plugins();
foreach ($dependancies as $component => $requiredversion) {
$otherplugin = $this->get_plugin_info($component);
if (is_null($otherplugin)) {
@@ -251,6 +249,28 @@ class plugin_manager {
return true;
}
/**
* Checks all dependancies for all installed plugins. Used by install and upgrade.
* @param int $moodleversion the version from version.php.
* @return bool true if all the dependancies 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_dependancies_satisfied($plugin->get_other_required_plugins())) {
return false;
}
}
}
return true;
}
/**
* Defines a white list of all plugins shipped in the standard Moodle distribution
*