Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-35238 Warn the admin if they are about to overwrite a SCM checkout

  • Loading branch information...
commit 08c3bc006d6e9486547e96ad194bb6ad6ffad885 1 parent 292dbea
@mudrd8mz mudrd8mz authored
View
12 admin/renderer.php
@@ -255,7 +255,7 @@ public function upgrade_plugin_confirm_deploy_page(available_update_deployer $de
$output = '';
$output .= $this->header();
- $output .= $this->container_start('generalbox', 'notice');
+ $output .= $this->container_start('generalbox updateplugin', 'notice');
$a = new stdClass();
if (get_string_manager()->string_exists('pluginname', $updateinfo->component)) {
@@ -272,10 +272,12 @@ public function upgrade_plugin_confirm_deploy_page(available_update_deployer $de
$a->url = $updateinfo->download;
$output .= $this->output->heading(get_string('updatepluginconfirm', 'core_plugin'));
- $output .= $this->output->container(format_text(
- get_string('updatepluginconfirminfo', 'core_plugin', $a) . PHP_EOL . PHP_EOL .
- get_string('updatepluginconfirmwarning', 'core_plugin')
- ));
+ $output .= $this->output->container(format_text(get_string('updatepluginconfirminfo', 'core_plugin', $a)), 'updatepluginconfirminfo');
+ $output .= $this->output->container(get_string('updatepluginconfirmwarning', 'core_plugin', 'updatepluginconfirmwarning'));
+
+ if ($repotype = $deployer->plugin_external_source($data['updateinfo'])) {
+ $output .= $this->output->container(get_string('updatepluginconfirmexternal', 'core_plugin', $repotype), 'updatepluginconfirmexternal');
+ }
$widget = $deployer->make_execution_widget($data['updateinfo']);
$output .= $this->output->render($widget);
View
1  lang/en/plugin.php
@@ -133,6 +133,7 @@
$string['updateavailable_release'] = 'Release {$a}';
$string['updatepluginconfirm'] = 'Plugin update confirmation';
$string['updatepluginconfirminfo'] = 'You are about to install a new version of the plugin <strong>{$a->name}</strong>. A zip package with version {$a->version} of the plugin will be downloaded from <a href="{$a->url}">{$a->url}</a> and extracted to your Moodle installation so it can upgrade your installation.';
+$string['updatepluginconfirmexternal'] = 'It appears that the current version of the plugin has been obtained via source code management system ({$a}) checkout. If you install this update, you will no longer be able to obtain plugin updates from the source code management system. Please ensure that you definitely want to update the plugin before continuing.';
$string['updatepluginconfirmwarning'] = 'Please note that Moodle will not automatically make a backup of your database before the upgrade. We strongly recommend that you make a full snapshot backup now, to cope with the rare case that the new code has bugs that make your site unavailable or even corrupts your database. Proceed at your own risk.';
$string['uninstall'] = 'Uninstall';
$string['version'] = 'Version';
View
27 lib/pluginlib.php
@@ -1544,6 +1544,33 @@ public function can_deploy(available_update_info $info) {
}
/**
+ * Check to see if the current version of the plugin seems to be a checkout of an external repository.
+ *
+ * @param available_update_info $info
+ * @return false|string
+ */
+ public function plugin_external_source(available_update_info $info) {
+
+ $paths = get_plugin_types(true);
+ list($plugintype, $pluginname) = normalize_component($info->component);
+ $pluginroot = $paths[$plugintype].'/'.$pluginname;
+
+ if (is_dir($pluginroot.'/.git')) {
+ return 'git';
+ }
+
+ if (is_dir($pluginroot.'/CVS')) {
+ return 'cvs';
+ }
+
+ if (is_dir($pluginroot.'/.svn')) {
+ return 'svn';
+ }
+
+ return false;
+ }
+
+ /**
* Prepares a renderable widget to confirm installation of an available update.
*
* @param available_update_info $info component version to deploy
View
5 theme/base/style/admin.css
@@ -102,6 +102,11 @@
#page-admin-index .adminwarning.availableupdatesinfo .moodleupdateinfo a {padding-right:1em;}
#page-admin-index .adminwarning.availableupdatesinfo .moodleupdateinfo .separator {border-left:1px dotted #333;}
+#page-admin-index .updateplugin div,
+#page-admin-plugins .updateplugin div {margin-bottom:0.5em;}
+#page-admin-index .updateplugin .updatepluginconfirmexternal,
+#page-admin-plugins .updateplugin .updatepluginconfirmexternal {padding:1em;background-color:#ffd3d9;border:1px solid #EEAAAA}
+
#page-admin-user-user_bulk #users .fgroup {white-space: nowrap;}
#page-admin-report-stats-index .graph {text-align: center;margin-bottom: 1em;}
#page-admin-report-courseoverview-index .graph {text-align: center;margin-bottom: 1em;}
Please sign in to comment.
Something went wrong with that request. Please try again.