aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/plugins/extension/admin.php4
-rw-r--r--lib/plugins/extension/helper/extension.php14
-rw-r--r--lib/plugins/extension/helper/gui.php4
-rw-r--r--lib/plugins/extension/lang/en/lang.php1
4 files changed, 16 insertions, 7 deletions
diff --git a/lib/plugins/extension/admin.php b/lib/plugins/extension/admin.php
index ded688a9b..8ba862298 100644
--- a/lib/plugins/extension/admin.php
+++ b/lib/plugins/extension/admin.php
@@ -127,7 +127,7 @@ class admin_plugin_extension extends DokuWiki_Admin_Plugin
}
send_redirect($this->gui->tabURL('', [], '&', true));
} elseif ($INPUT->post->str('installurl') && checkSecurityToken()) {
- $installed = $extension->installFromURL($INPUT->post->str('installurl'));
+ $installed = $extension->installFromURL($INPUT->post->str('installurl'), $INPUT->post->bool('overwrite'));
foreach ($installed as $ext => $info) {
msg(sprintf(
$this->getLang('msg_'.$info['type'].'_'.$info['action'].'_success'),
@@ -136,7 +136,7 @@ class admin_plugin_extension extends DokuWiki_Admin_Plugin
}
send_redirect($this->gui->tabURL('', [], '&', true));
} elseif (isset($_FILES['installfile']) && checkSecurityToken()) {
- $installed = $extension->installFromUpload('installfile');
+ $installed = $extension->installFromUpload('installfile', $INPUT->post->bool('overwrite'));
foreach ($installed as $ext => $info) {
msg(sprintf(
$this->getLang('msg_'.$info['type'].'_'.$info['action'].'_success'),
diff --git a/lib/plugins/extension/helper/extension.php b/lib/plugins/extension/helper/extension.php
index 3e7087eba..fdbb14b3d 100644
--- a/lib/plugins/extension/helper/extension.php
+++ b/lib/plugins/extension/helper/extension.php
@@ -615,10 +615,11 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
* Install an extension from a user upload
*
* @param string $field name of the upload file
+ * @param boolean $overwrite overwrite folder if the extension name is the same
* @throws Exception when something goes wrong
* @return array The list of installed extensions
*/
- public function installFromUpload($field)
+ public function installFromUpload($field, $overwrite = true)
{
if ($_FILES[$field]['error']) {
throw new Exception($this->getLang('msg_upload_failed').' ('.$_FILES[$field]['error'].')');
@@ -637,7 +638,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
}
try {
- $installed = $this->installArchive("$tmp/upload.archive", true, $basename);
+ $installed = $this->installArchive("$tmp/upload.archive", $overwrite, $basename);
$this->updateManagerData('', $installed);
$this->removeDeletedfiles($installed);
// purge cache
@@ -652,14 +653,15 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
* Install an extension from a remote URL
*
* @param string $url
+ * @param boolean $overwrite overwrite folder if the extension name is the same
* @throws Exception when something goes wrong
* @return array The list of installed extensions
*/
- public function installFromURL($url)
+ public function installFromURL($url, $overwrite = true)
{
try {
$path = $this->download($url);
- $installed = $this->installArchive($path, true);
+ $installed = $this->installArchive($path, $overwrite);
$this->updateManagerData($url, $installed);
$this->removeDeletedfiles($installed);
@@ -1040,7 +1042,9 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
// check to make sure we aren't overwriting anything
$target = $target_base_dir.$item['base'];
if (!$overwrite && file_exists($target)) {
- // TODO remember our settings, ask the user to confirm overwrite
+ // this info message is not being exposed via exception,
+ // so that it's not interrupting the installation
+ msg(sprintf($this->getLang('msg_nooverwrite'), $item['base']));
continue;
}
diff --git a/lib/plugins/extension/helper/gui.php b/lib/plugins/extension/helper/gui.php
index d02c02a89..919eb2c0b 100644
--- a/lib/plugins/extension/helper/gui.php
+++ b/lib/plugins/extension/helper/gui.php
@@ -148,6 +148,7 @@ class helper_plugin_extension_gui extends DokuWiki_Plugin
*/
public function tabInstall()
{
+ global $lang;
echo '<div class="panelHeader">';
echo $this->locale_xhtml('intro_install');
echo '</div>';
@@ -166,6 +167,9 @@ class helper_plugin_extension_gui extends DokuWiki_Plugin
->addClass('block')
->attrs(['type' => 'file']);
$form->addTag('br');
+ $form->addCheckbox('overwrite', $lang['js']['media_overwrt'])
+ ->addClass('block');
+ $form->addTag('br');
$form->addButton('', $this->getLang('btn_install'))
->attrs(['type' => 'submit', 'title' => $this->getLang('btn_install')]);
$form->addTagClose('div');
diff --git a/lib/plugins/extension/lang/en/lang.php b/lib/plugins/extension/lang/en/lang.php
index 79f643629..f9753ae4d 100644
--- a/lib/plugins/extension/lang/en/lang.php
+++ b/lib/plugins/extension/lang/en/lang.php
@@ -76,6 +76,7 @@ $lang['msg_template_update_success'] = 'Template %s updated successfully';
$lang['msg_plugin_install_success'] = 'Plugin %s installed successfully';
$lang['msg_plugin_update_success'] = 'Plugin %s updated successfully';
$lang['msg_upload_failed'] = 'Uploading the file failed';
+$lang['msg_nooverwrite'] = 'Extension %s already exists so it is not being overwritten; to overwrite, tick the overwrite option';
$lang['missing_dependency'] = '<strong>Missing or disabled dependency:</strong> %s';
$lang['security_issue'] = '<strong>Security Issue:</strong> %s';