Skip to content

Commit

Permalink
MDL-49329 admin: Clean up disabling of plugins code management features
Browse files Browse the repository at this point in the history
The admin setting updateautodeploy no longer exists. The two existing
config.php flags $CFG->disableupdateautodeploy and
$CFG->disableonclickaddoninstall merged into a single one.
  • Loading branch information
mudrd8mz committed Oct 10, 2015
1 parent d9a5b81 commit b0fc789
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 22 deletions.
14 changes: 13 additions & 1 deletion admin/index.php
Expand Up @@ -120,6 +120,18 @@
$installupdatex = optional_param('installupdatex', false, PARAM_BOOL); // Install all available plugin updates.
$confirminstallupdate = optional_param('confirminstallupdate', false, PARAM_BOOL); // Available update(s) install confirmed?
if (!empty($CFG->disableupdateautodeploy)) {
// Invalidate all requests to install plugins via the admin UI.
$newaddonreq = null;
$installdep = null;
$installdepx = false;
$abortupgrade = null;
$abortupgradex = null;
$installupdate = null;
$installupdateversion = null;
$installupdatex = false;
}

// Set up PAGE.
$url = new moodle_url('/admin/index.php');
$url->param('cache', $cache);
Expand All @@ -130,7 +142,7 @@
unset($url);

// Are we returning from an add-on installation request at moodle.org/plugins?
if ($newaddonreq and !$cache and empty($CFG->disableonclickaddoninstall)) {
if ($newaddonreq and !$cache and empty($CFG->disableupdateautodeploy)) {
$target = new moodle_url('/admin/tool/installaddon/index.php', array(
'installaddonrequest' => $newaddonreq,
'confirm' => 0));
Expand Down
4 changes: 0 additions & 4 deletions admin/settings/server.php
Expand Up @@ -215,10 +215,6 @@
$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));
if (empty($CFG->disableupdateautodeploy)) {
$temp->add(new admin_setting_configcheckbox('updateautodeploy', new lang_string('updateautodeploy', 'core_admin'),
new lang_string('updateautodeploy_desc', 'core_admin'), 0));
}
$temp->add(new admin_setting_configselect('updateminmaturity', new lang_string('updateminmaturity', 'core_admin'),
new lang_string('updateminmaturity_desc', 'core_admin'), MATURITY_STABLE,
array(
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/installaddon/index.php
Expand Up @@ -28,7 +28,7 @@

admin_externalpage_setup('tool_installaddon_index');

if (!empty($CFG->disableonclickaddoninstall)) {
if (!empty($CFG->disableupdateautodeploy)) {
notice(get_string('featuredisabled', 'tool_installaddon'));
}

Expand Down
2 changes: 1 addition & 1 deletion admin/tool/installaddon/permcheck.php
Expand Up @@ -36,7 +36,7 @@
die();
}

if (!empty($CFG->disableonclickaddoninstall)) {
if (!empty($CFG->disableupdateautodeploy)) {
header('HTTP/1.1 403 Forbidden');
die();
}
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/installaddon/settings.php
Expand Up @@ -25,7 +25,7 @@

defined('MOODLE_INTERNAL') || die();

if ($hassiteconfig and empty($CFG->disableonclickaddoninstall)) {
if ($hassiteconfig and empty($CFG->disableupdateautodeploy)) {

$ADMIN->add('modules', new admin_externalpage('tool_installaddon_index',
get_string('installaddons', 'tool_installaddon'),
Expand Down
13 changes: 4 additions & 9 deletions config-dist.php
Expand Up @@ -447,17 +447,12 @@
//
// $CFG->disableupdatenotifications = true;
//
// Use the following flag to completely disable the Automatic updates deployment
// feature and hide it from the server administration UI.
// TODO: drop this flag and use disableonclickaddoninstall instead.
//
// $CFG->disableupdateautodeploy = true;
//
// Use the following flag to completely disable the installation of plugins
// (new plugins, available updates and missing dependencies) via the server
// administration UI.
// (new plugins, available updates and missing dependencies) and related
// features (such as cancelling the plugin installation or upgrade) via the
// server administration web interface.
//
// $CFG->disableonclickaddoninstall = true;
// $CFG->disableupdateautodeploy = true;
//
// Use the following flag to disable modifications to scheduled tasks
// whilst still showing the state of tasks.
Expand Down
2 changes: 0 additions & 2 deletions lang/en/admin.php
Expand Up @@ -1093,8 +1093,6 @@
$string['updatenotificationsubject'] = 'Moodle updates are available ({$a->siteurl})';
$string['updateautocheck'] = 'Automatically check for available updates';
$string['updateautocheck_desc'] = 'If enabled, your site will automatically check for available updates for both Moodle code and all additional plugins. If there is a new update available, a notification will be sent to site admins.';
$string['updateautodeploy'] = 'Enable updates deployment';
$string['updateautodeploy_desc'] = 'If enabled, you will be able to download and install available updates directly from Moodle administration pages. Note that your web server process has to have write access into folders with Moodle installation to make this work. That can be seen as a potential security risk.';
$string['updateminmaturity'] = 'Required code maturity';
$string['updateminmaturity_desc'] = 'Notify about available updates only if the available code has the selected maturity level at least. Updates for plugins that do not declare their code maturity level are always reported regardless this setting.';
$string['updatenotifybuilds'] = 'Notify about new builds';
Expand Down
42 changes: 41 additions & 1 deletion lib/classes/plugin_manager.php
Expand Up @@ -946,7 +946,7 @@ public function is_remote_plugin_installable($component, $version, &$reason=null
global $CFG;

// Make sure the feature is not disabled.
if (!empty($CFG->disableonclickaddoninstall)) {
if (!empty($CFG->disableupdateautodeploy)) {
$reason = 'disabled';
return false;
}
Expand Down Expand Up @@ -998,7 +998,11 @@ public function is_remote_plugin_installable($component, $version, &$reason=null
* @return array
*/
public function filter_installable($remoteinfos) {
global $CFG;

if (!empty($CFG->disableupdateautodeploy)) {
return array();
}
if (empty($remoteinfos)) {
return array();
}
Expand Down Expand Up @@ -1072,6 +1076,11 @@ public function get_remote_plugin_info($component, $version, $exactmatch) {
* @return string|bool full path to the file, false on error
*/
public function get_remote_plugin_zip($url, $md5) {
global $CFG;

if (!empty($CFG->disableupdateautodeploy)) {
return false;
}
return $this->get_code_manager()->get_remote_plugin_zip($url, $md5);
}

Expand Down Expand Up @@ -1235,6 +1244,10 @@ public function can_uninstall_plugin($component) {
public function install_plugins(array $plugins, $confirmed, $silent) {
global $CFG, $OUTPUT;

if (!empty($CFG->disableupdateautodeploy)) {
return false;
}

if (empty($plugins)) {
return false;
}
Expand Down Expand Up @@ -1949,6 +1962,11 @@ public function remove_plugin_folder(\core\plugininfo\base $plugin) {
* @return bool
*/
public function can_cancel_plugin_installation(\core\plugininfo\base $plugin) {
global $CFG;

if (!empty($CFG->disableupdateautodeploy)) {
return false;
}

if (empty($plugin) or $plugin->is_standard() or $plugin->is_subplugin()
or !$this->is_plugin_folder_removable($plugin->component)) {
Expand All @@ -1973,6 +1991,13 @@ public function can_cancel_plugin_installation(\core\plugininfo\base $plugin) {
* @return bool
*/
public function can_cancel_plugin_upgrade(\core\plugininfo\base $plugin) {
global $CFG;

if (!empty($CFG->disableupdateautodeploy)) {
// Cancelling the plugin upgrade is actually installation of the
// previously archived version.
return false;
}

if (empty($plugin) or $plugin->is_standard() or $plugin->is_subplugin()
or !$this->is_plugin_folder_removable($plugin->component)) {
Expand All @@ -1998,6 +2023,11 @@ public function can_cancel_plugin_upgrade(\core\plugininfo\base $plugin) {
* @param string $component
*/
public function cancel_plugin_installation($component) {
global $CFG;

if (!empty($CFG->disableupdateautodeploy)) {
return false;
}

$plugin = $this->get_plugin_info($component);

Expand All @@ -2014,6 +2044,11 @@ public function cancel_plugin_installation($component) {
* @return array [(string)component] => (\core\plugininfo\base)plugin
*/
public function list_cancellable_installations() {
global $CFG;

if (!empty($CFG->disableupdateautodeploy)) {
return array();
}

$cancellable = array();
foreach ($this->get_plugins() as $type => $plugins) {
Expand Down Expand Up @@ -2043,6 +2078,11 @@ public function archive_plugin_version(\core\plugininfo\base $plugin) {
* @return array [(string)component] => {(string)->component, (string)->zipfilepath}
*/
public function list_restorable_archives() {
global $CFG;

if (!empty($CFG->disableupdateautodeploy)) {
return false;
}

$codeman = $this->get_code_manager();
$restorable = array();
Expand Down
7 changes: 7 additions & 0 deletions lib/db/upgrade.php
Expand Up @@ -4599,5 +4599,12 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2015100600.00);
}

if ($oldversion < 2015100800.01) {
// The only flag for preventing all plugins installation features is
// now $CFG->disableupdateautodeploy in config.php.
unset_config('updateautodeploy');
upgrade_main_savepoint(true, 2015100800.01);
}

return true;
}
5 changes: 5 additions & 0 deletions lib/setup.php
Expand Up @@ -364,6 +364,11 @@
$CFG->yuipatchedmodules = array(
);

if (!empty($CFG->disableonclickaddoninstall)) {
// This config.php flag has been merged into another one.
$CFG->disableupdateautodeploy = true;
}

// Store settings from config.php in array in $CFG - we can use it later to detect problems and overrides.
if (!isset($CFG->config_php_settings)) {
$CFG->config_php_settings = (array)$CFG;
Expand Down
6 changes: 5 additions & 1 deletion lib/upgradelib.php
Expand Up @@ -2384,12 +2384,16 @@ function check_upgrade_key($upgradekeyhash) {
* @param moodle_url|string|null $return URL to go back on cancelling at the validation screen
*/
function upgrade_install_plugins(array $installable, $confirmed, $heading='', $continue=null, $return=null) {
global $PAGE;
global $CFG, $PAGE;

if (empty($return)) {
$return = $PAGE->url;
}

if (!empty($CFG->disableupdateautodeploy)) {
redirect($return);
}

if (empty($installable)) {
redirect($return);
}
Expand Down
2 changes: 1 addition & 1 deletion version.php
Expand Up @@ -29,7 +29,7 @@

defined('MOODLE_INTERNAL') || die();

$version = 2015100800.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2015100800.01; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.

Expand Down

0 comments on commit b0fc789

Please sign in to comment.