diff --git a/admin/index.php b/admin/index.php index 410cbf6723b82..d3ec395e57444 100644 --- a/admin/index.php +++ b/admin/index.php @@ -416,9 +416,30 @@ $dbproblems = $DB->diagnose(); $maintenancemode = !empty($CFG->maintenance_enabled); +// Available updates for Moodle core $updateschecker = available_update_checker::instance(); -$availableupdates = $updateschecker->get_update_info('core', +$availableupdates = array(); +$availableupdates['core'] = $updateschecker->get_update_info('core', array('minmaturity' => $CFG->updateminmaturity, 'notifybuilds' => $CFG->updatenotifybuilds)); + +// Available updates for contributed plugins +$pluginman = plugin_manager::instance(); +foreach ($pluginman->get_plugins() as $plugintype => $plugintypeinstances) { + foreach ($plugintypeinstances as $pluginname => $plugininfo) { + if (!empty($plugininfo->availableupdates)) { + foreach ($plugininfo->availableupdates as $pluginavailableupdate) { + if ($pluginavailableupdate->version > $plugininfo->versiondisk) { + if (!isset($availableupdates[$plugintype.'_'.$pluginname])) { + $availableupdates[$plugintype.'_'.$pluginname] = array(); + } + $availableupdates[$plugintype.'_'.$pluginname][] = $pluginavailableupdate; + } + } + } + } +} + +// The timestamp of the most recent check for available updates $availableupdatesfetch = $updateschecker->get_last_timefetched(); $buggyiconvnomb = (!function_exists('mb_convert_encoding') and @iconv('UTF-8', 'UTF-8//IGNORE', '100'.chr(130).'€') !== '100€'); diff --git a/admin/renderer.php b/admin/renderer.php index 293bf52f225fb..bf45639be98f5 100644 --- a/admin/renderer.php +++ b/admin/renderer.php @@ -495,21 +495,39 @@ protected function maturity_info($maturity) { } /** - * Displays the info about available Moodle updates + * Displays the info about available Moodle core and plugin updates * - * @param array|null $updates array of available_update_info objects or null + * The structure of the $updates param has changed since 2.4. It contains not only updates + * for the core itself, but also for all other installed plugins. + * + * @param array|null $updates array of (string)component => array of available_update_info objects or null * @param int|null $fetch timestamp of the most recent updates fetch or null (unknown) * @return string */ protected function available_updates($updates, $fetch) { $updateinfo = $this->box_start('generalbox adminwarning availableupdatesinfo'); + $someupdateavailable = false; if (is_array($updates)) { - $updateinfo .= $this->heading(get_string('updateavailable', 'core_admin'), 3); - foreach ($updates as $update) { - $updateinfo .= $this->moodle_available_update_info($update); + if (is_array($updates['core'])) { + $someupdateavailable = true; + $updateinfo .= $this->heading(get_string('updateavailable', 'core_admin'), 3); + foreach ($updates['core'] as $update) { + $updateinfo .= $this->moodle_available_update_info($update); + } } - } else { + unset($updates['core']); + // If something has left in the $updates array now, it is updates for plugins. + if (!empty($updates)) { + $someupdateavailable = true; + $updateinfo .= $this->heading(get_string('updateavailableforplugin', 'core_admin'), 3); + $pluginsoverviewurl = new moodle_url('/admin/plugins.php', array('updatesonly' => 1)); + $updateinfo .= $this->container(get_string('pluginsoverviewsee', 'core_admin', + array('url' => $pluginsoverviewurl->out()))); + } + } + + if (!$someupdateavailable) { $now = time(); if ($fetch and ($fetch <= $now) and ($now - $fetch < HOURSECS)) { $updateinfo .= $this->heading(get_string('updateavailablenot', 'core_admin'), 3); diff --git a/lang/en/admin.php b/lang/en/admin.php index c2ae229d47763..a0c322603b6ff 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -774,6 +774,7 @@ $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'; +$string['pluginsoverviewsee'] = 'See plugins overview page for more details.'; $string['profilecategory'] = 'Category'; $string['profilecategoryname'] = 'Category name (must be unique)'; $string['profilecategorynamenotunique'] = 'This category name is already in use';