diff --git a/admin/index.php b/admin/index.php index 6ef4b206b51..5b01be2749b 100644 --- a/admin/index.php +++ b/admin/index.php @@ -240,7 +240,9 @@ if ($version > $CFG->version) { // upgrade if ($fetchupdates) { // no sesskey support guaranteed here - available_update_checker::instance()->fetch(); + if (empty($CFG->disableupdatenotifications)) { + available_update_checker::instance()->fetch(); + } redirect($reloadurl); } diff --git a/admin/renderer.php b/admin/renderer.php index f6a2c111f4e..05521fa2c71 100644 --- a/admin/renderer.php +++ b/admin/renderer.php @@ -174,6 +174,7 @@ class core_admin_renderer extends plugin_renderer_base { */ public function upgrade_plugin_check_page(plugin_manager $pluginman, available_update_checker $checker, $version, $showallplugins, $reloadurl, $continueurl) { + global $CFG; $output = ''; @@ -181,14 +182,16 @@ class core_admin_renderer extends plugin_renderer_base { $output .= $this->box_start('generalbox'); $output .= $this->container_start('generalbox', 'notice'); $output .= html_writer::tag('p', get_string('pluginchecknotice', 'core_plugin')); - $output .= $this->container_start('checkforupdates'); - $output .= $this->single_button(new moodle_url($reloadurl, array('fetchupdates' => 1)), get_string('checkforupdates', 'core_plugin')); - if ($timefetched = $checker->get_last_timefetched()) { - $output .= $this->container(get_string('checkforupdateslast', 'core_plugin', - userdate($timefetched, get_string('strftimedatetime', 'core_langconfig')))); + if (empty($CFG->disableupdatenotifications)) { + $output .= $this->container_start('checkforupdates'); + $output .= $this->single_button(new moodle_url($reloadurl, array('fetchupdates' => 1)), get_string('checkforupdates', 'core_plugin')); + if ($timefetched = $checker->get_last_timefetched()) { + $output .= $this->container(get_string('checkforupdateslast', 'core_plugin', + userdate($timefetched, get_string('strftimedatetime', 'core_langconfig')))); + } + $output .= $this->container_end(); } $output .= $this->container_end(); - $output .= $this->container_end(); $output .= $this->plugins_check_table($pluginman, $version, array('full' => $showallplugins)); $output .= $this->box_end(); @@ -227,11 +230,12 @@ class core_admin_renderer extends plugin_renderer_base { */ public function admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed, $cronoverdue, $dbproblems, $maintenancemode, $availableupdates, $availableupdatesfetch) { + global $CFG; $output = ''; $output .= $this->header(); $output .= $this->maturity_info($maturity); - $output .= $this->available_updates($availableupdates, $availableupdatesfetch); + $output .= empty($CFG->disableupdatenotifications) ? $this->available_updates($availableupdates, $availableupdatesfetch) : ''; $output .= $this->insecure_dataroot_warning($insecuredataroot); $output .= $this->display_errors_warning($errorsdisplayed); $output .= $this->cron_overdue_warning($cronoverdue); @@ -256,19 +260,23 @@ class core_admin_renderer extends plugin_renderer_base { * @return string HTML to output. */ public function plugin_management_page(plugin_manager $pluginman, available_update_checker $checker) { + global $CFG; + $output = ''; $output .= $this->header(); $output .= $this->heading(get_string('pluginsoverview', 'core_admin')); $output .= $this->plugins_overview_panel($pluginman); - $output .= $this->container_start('checkforupdates'); - $output .= $this->single_button(new moodle_url($this->page->url, array('fetchremote' => 1)), get_string('checkforupdates', 'core_plugin')); - if ($timefetched = $checker->get_last_timefetched()) { - $output .= $this->container(get_string('checkforupdateslast', 'core_plugin', - userdate($timefetched, get_string('strftimedatetime', 'core_langconfig')))); + if (empty($CFG->disableupdatenotifications)) { + $output .= $this->container_start('checkforupdates'); + $output .= $this->single_button(new moodle_url($this->page->url, array('fetchremote' => 1)), get_string('checkforupdates', 'core_plugin')); + if ($timefetched = $checker->get_last_timefetched()) { + $output .= $this->container(get_string('checkforupdateslast', 'core_plugin', + userdate($timefetched, get_string('strftimedatetime', 'core_langconfig')))); + } + $output .= $this->container_end(); } - $output .= $this->container_end(); $output .= $this->box($this->plugins_control_panel($pluginman), 'generalbox'); $output .= $this->footer(); @@ -559,6 +567,8 @@ class core_admin_renderer extends plugin_renderer_base { * @return string HTML code */ public function plugins_check_table(plugin_manager $pluginman, $version, array $options = null) { + global $CFG; + $plugininfo = $pluginman->get_plugins(); if (empty($plugininfo)) { @@ -641,7 +651,7 @@ class core_admin_renderer extends plugin_renderer_base { $status = get_string('status_' . $statuscode, 'core_plugin'); $availableupdates = $plugin->available_updates(); - if (!empty($availableupdates)) { + if (!empty($availableupdates) and empty($CFG->disableupdatenotifications)) { foreach ($availableupdates as $availableupdate) { $status .= $this->plugin_available_update_info($availableupdate); } @@ -771,6 +781,8 @@ class core_admin_renderer extends plugin_renderer_base { * @return string as usually */ public function plugins_overview_panel(plugin_manager $pluginman) { + global $CFG; + $plugininfo = $pluginman->get_plugins(); $numtotal = $numdisabled = $numextension = $numupdatable = 0; @@ -787,7 +799,7 @@ class core_admin_renderer extends plugin_renderer_base { if (!$plugin->is_standard()) { $numextension++; } - if ($plugin->available_updates()) { + if (empty($CFG->disableupdatenotifications) and $plugin->available_updates()) { $numupdatable++; } } @@ -813,6 +825,8 @@ class core_admin_renderer extends plugin_renderer_base { * @return string HTML code */ public function plugins_control_panel(plugin_manager $pluginman) { + global $CFG; + $plugininfo = $pluginman->get_plugins(); if (empty($plugininfo)) { @@ -916,7 +930,7 @@ class core_admin_renderer extends plugin_renderer_base { } $updateinfo = ''; - if (is_array($plugin->available_updates())) { + if (empty($CFG->disableupdatenotifications) and is_array($plugin->available_updates())) { foreach ($plugin->available_updates() as $availableupdate) { $updateinfo .= $this->plugin_available_update_info($availableupdate); } diff --git a/admin/settings/server.php b/admin/settings/server.php index b8b674cc41f..0188b6db4f8 100644 --- a/admin/settings/server.php +++ b/admin/settings/server.php @@ -222,19 +222,21 @@ $ADMIN->add('server', $temp); $ADMIN->add('server', new admin_externalpage('adminregistration', new lang_string('registration','admin'), "$CFG->wwwroot/$CFG->admin/registration/index.php")); // "update notifications" settingpage -$temp = new admin_settingpage('updatenotifications', new lang_string('updatenotifications', 'core_admin')); -$temp->add(new admin_setting_configcheckbox('updateautocheck', new lang_string('updateautocheck', 'core_admin'), - new lang_string('updateautocheck_desc', 'core_admin'), 1)); -$temp->add(new admin_setting_configselect('updateminmaturity', new lang_string('updateminmaturity', 'core_admin'), - new lang_string('updateminmaturity_desc', 'core_admin'), MATURITY_STABLE, - array( - MATURITY_ALPHA => new lang_string('maturity'.MATURITY_ALPHA, 'core_admin'), - MATURITY_BETA => new lang_string('maturity'.MATURITY_BETA, 'core_admin'), - MATURITY_RC => new lang_string('maturity'.MATURITY_RC, 'core_admin'), - MATURITY_STABLE => new lang_string('maturity'.MATURITY_STABLE, 'core_admin'), - ))); -$temp->add(new admin_setting_configcheckbox('updatenotifybuilds', new lang_string('updatenotifybuilds', 'core_admin'), - new lang_string('updatenotifybuilds_desc', 'core_admin'), 0)); -$ADMIN->add('server', $temp); +if (empty($CFG->disableupdatenotifications)) { + $temp = new admin_settingpage('updatenotifications', new lang_string('updatenotifications', 'core_admin')); + $temp->add(new admin_setting_configcheckbox('updateautocheck', new lang_string('updateautocheck', 'core_admin'), + new lang_string('updateautocheck_desc', 'core_admin'), 1)); + $temp->add(new admin_setting_configselect('updateminmaturity', new lang_string('updateminmaturity', 'core_admin'), + new lang_string('updateminmaturity_desc', 'core_admin'), MATURITY_STABLE, + array( + MATURITY_ALPHA => new lang_string('maturity'.MATURITY_ALPHA, 'core_admin'), + MATURITY_BETA => new lang_string('maturity'.MATURITY_BETA, 'core_admin'), + MATURITY_RC => new lang_string('maturity'.MATURITY_RC, 'core_admin'), + MATURITY_STABLE => new lang_string('maturity'.MATURITY_STABLE, 'core_admin'), + ))); + $temp->add(new admin_setting_configcheckbox('updatenotifybuilds', new lang_string('updatenotifybuilds', 'core_admin'), + new lang_string('updatenotifybuilds_desc', 'core_admin'), 0)); + $ADMIN->add('server', $temp); +} } // end of speedup diff --git a/config-dist.php b/config-dist.php index 986d2ba92c8..e82d7bd38c3 100644 --- a/config-dist.php +++ b/config-dist.php @@ -431,6 +431,11 @@ $CFG->admin = 'admin'; // // $CFG->cssoptimiserpretty = true; // +// Use the following flag to completely disable the Available update notifications +// feature and hide it from the server administration UI. +// +// $CFG->disableupdatenotifications = true; +// //========================================================================= // 8. SETTINGS FOR DEVELOPMENT SERVERS - not intended for production use!!! //========================================================================= diff --git a/lib/cronlib.php b/lib/cronlib.php index f02769d7a39..b05e34f87c9 100644 --- a/lib/cronlib.php +++ b/lib/cronlib.php @@ -382,9 +382,11 @@ function cron_run() { mtrace(get_string('siteupdatesend', 'hub')); // If enabled, fetch information about available updates and eventually notify site admins - require_once($CFG->libdir.'/pluginlib.php'); - $updateschecker = available_update_checker::instance(); - $updateschecker->cron(); + if (empty($CFG->disableupdatenotifications)) { + require_once($CFG->libdir.'/pluginlib.php'); + $updateschecker = available_update_checker::instance(); + $updateschecker->cron(); + } //cleanup old session linked tokens //deletes the session linked tokens that are over a day old. diff --git a/lib/pluginlib.php b/lib/pluginlib.php index 38ac61c4f7d..8a19144cf61 100644 --- a/lib/pluginlib.php +++ b/lib/pluginlib.php @@ -97,6 +97,7 @@ class plugin_manager { * the values are the corresponding objects extending {@link plugininfo_base} */ public function get_plugins($disablecache=false) { + global $CFG; if ($disablecache or is_null($this->pluginsinfo)) { $this->pluginsinfo = array(); @@ -118,8 +119,7 @@ class plugin_manager { $this->pluginsinfo[$plugintype] = $plugins; } - // TODO: MDL-20438 verify this is the correct solution/replace - if (!during_initial_install()) { + if (empty($CFG->disableupdatenotifications) and !during_initial_install()) { // append the information about available updates provided by {@link available_update_checker()} $provider = available_update_checker::instance(); foreach ($this->pluginsinfo as $plugintype => $plugins) {