Permalink
Browse files

MDL-34099 Report available updates for plugins at admin/index.php

The Notifications (admin/index.php) page has now information about
available updates for core and eventually plugins, too. Note that the
structure of the available updates array changed. This breaks backward
compatibility for eventual 3rd renderers out there (not expected
though).
  • Loading branch information...
1 parent 067200e commit 966bd7852ea70151c8b297e0158ed9c5841ada0d @mudrd8mz mudrd8mz committed Sep 13, 2012
Showing with 47 additions and 7 deletions.
  1. +22 −1 admin/index.php
  2. +24 −6 admin/renderer.php
  3. +1 −0 lang/en/admin.php
View
@@ -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€');
View
@@ -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);
View
@@ -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 <a href="{$a->url}">plugins overview</a> page for more details.';
$string['profilecategory'] = 'Category';
$string['profilecategoryname'] = 'Category name (must be unique)';
$string['profilecategorynamenotunique'] = 'This category name is already in use';

0 comments on commit 966bd78

Please sign in to comment.