diff --git a/admin/renderer.php b/admin/renderer.php index 6b2e0257942..f4f55b5c7de 100644 --- a/admin/renderer.php +++ b/admin/renderer.php @@ -1616,12 +1616,18 @@ class core_admin_renderer extends plugin_renderer_base { $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; @@ -1664,16 +1670,13 @@ class core_admin_renderer extends plugin_renderer_base { $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'). @@ -1907,7 +1910,7 @@ class core_admin_renderer extends plugin_renderer_base { '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)), diff --git a/lib/classes/plugin_manager.php b/lib/classes/plugin_manager.php index 8de966b2790..e64dd99f244 100644 --- a/lib/classes/plugin_manager.php +++ b/lib/classes/plugin_manager.php @@ -1002,9 +1002,10 @@ class core_plugin_manager { * @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. @@ -1014,7 +1015,7 @@ class core_plugin_manager { } // 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; } @@ -1026,12 +1027,17 @@ class core_plugin_manager { 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; }