Skip to content

Commit

Permalink
Merge branch 'MDL-72515-master' of git://github.com/marinaglancy/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Oct 6, 2021
2 parents 2924d7c + 215b5ac commit d6f4f27
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
29 changes: 16 additions & 13 deletions admin/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1616,12 +1616,18 @@ public function plugins_overview_panel(core_plugin_manager $pluginman, array $op

$plugininfo = $pluginman->get_plugins();

$numtotal = $numextension = $numupdatable = 0;
$numtotal = $numextension = $numupdatable = $numinstallable = 0;

foreach ($plugininfo as $type => $plugins) {
foreach ($plugins as $name => $plugin) {
if ($plugin->available_updates()) {
if ($res = $plugin->available_updates()) {
$numupdatable++;
foreach ($res as $updateinfo) {
if ($pluginman->is_remote_plugin_installable($updateinfo->component, $updateinfo->version, $reason, false)) {
$numinstallable++;
break;
}
}
}
if ($plugin->get_status() === core_plugin_manager::PLUGIN_STATUS_MISSING) {
continue;
Expand Down Expand Up @@ -1664,16 +1670,13 @@ public function plugins_overview_panel(core_plugin_manager $pluginman, array $op
$out .= $this->output->heading(get_string('overviewext', 'core_plugin'), 3);
}

if ($numupdatable) {
$installableupdates = $pluginman->filter_installable($pluginman->available_updates());
if ($installableupdates) {
$out .= $this->output->single_button(
new moodle_url($this->page->url, array('installupdatex' => 1)),
get_string('updateavailableinstallall', 'core_admin', count($installableupdates)),
'post',
array('class' => 'singlebutton updateavailableinstallall')
);
}
if ($numinstallable) {
$out .= $this->output->single_button(
new moodle_url($this->page->url, array('installupdatex' => 1)),
get_string('updateavailableinstallall', 'core_admin', $numinstallable),
'post',
array('class' => 'singlebutton updateavailableinstallall')
);
}

$out .= html_writer::div($infoall, 'info info-all').
Expand Down Expand Up @@ -1907,7 +1910,7 @@ protected function plugin_available_update_info(core_plugin_manager $pluginman,
'infos'
);

if ($pluginman->is_remote_plugin_installable($updateinfo->component, $updateinfo->version, $reason)) {
if ($pluginman->is_remote_plugin_installable($updateinfo->component, $updateinfo->version, $reason, false)) {
$box .= $this->output->single_button(
new moodle_url($this->page->url, array('installupdate' => $updateinfo->component,
'installupdateversion' => $updateinfo->version)),
Expand Down
14 changes: 10 additions & 4 deletions lib/classes/plugin_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1002,9 +1002,10 @@ public function is_remote_plugin_available($component, $version, $exactmatch) {
* @param string $component
* @param int $version version number
* @param string $reason returned code of the reason why it is not
* @param bool $checkremote check this version availability on moodle server
* @return boolean
*/
public function is_remote_plugin_installable($component, $version, &$reason=null) {
public function is_remote_plugin_installable($component, $version, &$reason = null, $checkremote = true) {
global $CFG;

// Make sure the feature is not disabled.
Expand All @@ -1014,7 +1015,7 @@ public function is_remote_plugin_installable($component, $version, &$reason=null
}

// Make sure the version is available.
if (!$this->is_remote_plugin_available($component, $version, true)) {
if ($checkremote && !$this->is_remote_plugin_available($component, $version, true)) {
$reason = 'remoteunavailable';
return false;
}
Expand All @@ -1026,12 +1027,17 @@ public function is_remote_plugin_installable($component, $version, &$reason=null
return false;
}

$remoteinfo = $this->get_remote_plugin_info($component, $version, true);
if (!$checkremote) {
$remoteversion = $version;
} else {
$remoteinfo = $this->get_remote_plugin_info($component, $version, true);
$remoteversion = $remoteinfo->version->version;
}
$localinfo = $this->get_plugin_info($component);

if ($localinfo) {
// If the plugin is already present, prevent downgrade.
if ($localinfo->versiondb > $remoteinfo->version->version) {
if ($localinfo->versiondb > $remoteversion) {
$reason = 'cannotdowngrade';
return false;
}
Expand Down

0 comments on commit d6f4f27

Please sign in to comment.