From 5aab24ef173fd7cc7250386a747b754249fd80b7 Mon Sep 17 00:00:00 2001 From: David Mudrak Date: Tue, 15 May 2012 11:37:59 +0200 Subject: [PATCH 1/6] MDL-32610 config-dist.php has info about $CFG->disableupdatenotifications flag --- config-dist.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config-dist.php b/config-dist.php index 4b3534fa32b..b342ddcfce3 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!!! //========================================================================= From 4fb3a068210a05cb83f8f471c2a372efee8fe191 Mon Sep 17 00:00:00 2001 From: David Mudrak Date: Tue, 15 May 2012 11:39:04 +0200 Subject: [PATCH 2/6] MDL-32610 site administration > server > update notifications section can be hidden --- admin/settings/server.php | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) 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 From 7716057f7de39715dd9c5276f3af6c0451276801 Mon Sep 17 00:00:00 2001 From: David Mudrak Date: Tue, 15 May 2012 13:42:32 +0200 Subject: [PATCH 3/6] MDL-32610 available updates info at the Plugins overview admin page can be hidden --- admin/renderer.php | 24 ++++++++++++++++-------- lib/pluginlib.php | 4 ++-- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/admin/renderer.php b/admin/renderer.php index f6a2c111f4e..f8c408dc5d1 100644 --- a/admin/renderer.php +++ b/admin/renderer.php @@ -256,19 +256,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(); @@ -771,6 +775,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 +793,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 +819,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 +924,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/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) { From fa1d403f2e0002188a6ad17162bd94e36899d359 Mon Sep 17 00:00:00 2001 From: David Mudrak Date: Tue, 15 May 2012 14:23:48 +0200 Subject: [PATCH 4/6] MDL-32610 available updates info at the Plugins check upgrade page can be hidden --- admin/renderer.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/admin/renderer.php b/admin/renderer.php index f8c408dc5d1..9efc5172ee7 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(); @@ -563,6 +566,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)) { @@ -645,7 +650,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); } From 4db58f5fc75e42e19a0b0f7217dbe263f7659010 Mon Sep 17 00:00:00 2001 From: David Mudrak Date: Tue, 15 May 2012 14:30:47 +0200 Subject: [PATCH 5/6] MDL-32610 available updates info at the admin Notifications page can be hidden --- admin/index.php | 4 +++- admin/renderer.php | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) 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 9efc5172ee7..05521fa2c71 100644 --- a/admin/renderer.php +++ b/admin/renderer.php @@ -230,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); From fef693c858686c21ccbd695822af4228872588b0 Mon Sep 17 00:00:00 2001 From: David Mudrak Date: Tue, 15 May 2012 14:32:55 +0200 Subject: [PATCH 6/6] MDL-32610 cron based fetch of available updates can be disabled from config.php --- lib/cronlib.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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.