Skip to content

Commit

Permalink
Merge branch 'MDL-32610-hide-updates' of git://github.com/mudrd8mz/mo…
Browse files Browse the repository at this point in the history
…odle
  • Loading branch information
Sam Hemelryk committed May 17, 2012
2 parents bcc52e7 + fef693c commit 1220843
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 36 deletions.
4 changes: 3 additions & 1 deletion admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@

if ($fetchupdates) {
// no sesskey support guaranteed here
available_update_checker::instance()->fetch();
if (empty($CFG->disableupdatenotifications)) {
available_update_checker::instance()->fetch();
}
redirect($reloadurl);
}

Expand Down
46 changes: 30 additions & 16 deletions admin/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,21 +174,24 @@ public function upgrade_environment_page($release, $envstatus, $environment_resu
*/
public function upgrade_plugin_check_page(plugin_manager $pluginman, available_update_checker $checker,
$version, $showallplugins, $reloadurl, $continueurl) {
global $CFG;

$output = '';

$output .= $this->header();
$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();
Expand Down Expand Up @@ -227,11 +230,12 @@ public function upgrade_plugin_check_page(plugin_manager $pluginman, available_u
*/
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);
Expand All @@ -256,19 +260,23 @@ public function admin_notifications_page($maturity, $insecuredataroot, $errorsdi
* @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();
Expand Down Expand Up @@ -559,6 +567,8 @@ function upgrade_reload($url) {
* @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)) {
Expand Down Expand Up @@ -641,7 +651,7 @@ public function plugins_check_table(plugin_manager $pluginman, $version, array $
$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);
}
Expand Down Expand Up @@ -771,6 +781,8 @@ protected function required_column(plugininfo_base $plugin, plugin_manager $plug
* @return string as usually
*/
public function plugins_overview_panel(plugin_manager $pluginman) {
global $CFG;

$plugininfo = $pluginman->get_plugins();

$numtotal = $numdisabled = $numextension = $numupdatable = 0;
Expand All @@ -787,7 +799,7 @@ public function plugins_overview_panel(plugin_manager $pluginman) {
if (!$plugin->is_standard()) {
$numextension++;
}
if ($plugin->available_updates()) {
if (empty($CFG->disableupdatenotifications) and $plugin->available_updates()) {
$numupdatable++;
}
}
Expand All @@ -813,6 +825,8 @@ public function plugins_overview_panel(plugin_manager $pluginman) {
* @return string HTML code
*/
public function plugins_control_panel(plugin_manager $pluginman) {
global $CFG;

$plugininfo = $pluginman->get_plugins();

if (empty($plugininfo)) {
Expand Down Expand Up @@ -916,7 +930,7 @@ public function plugins_control_panel(plugin_manager $pluginman) {
}

$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);
}
Expand Down
30 changes: 16 additions & 14 deletions admin/settings/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,19 +222,21 @@
$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
5 changes: 5 additions & 0 deletions config-dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,11 @@
//
// $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!!!
//=========================================================================
Expand Down
8 changes: 5 additions & 3 deletions lib/cronlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions lib/pluginlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public static function instance() {
* 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();
Expand All @@ -118,8 +119,7 @@ public function get_plugins($disablecache=false) {
$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) {
Expand Down

0 comments on commit 1220843

Please sign in to comment.