From 35e139d90485fc5a95a1e63ad0a3d72af95dcf17 Mon Sep 17 00:00:00 2001 From: Offerel <14041522+Offerel@users.noreply.github.com> Date: Sat, 17 Feb 2018 21:17:21 +0100 Subject: [PATCH] simplified path configuration --- composer.json | 2 +- config.inc.php.dist | 11 +++++----- elfinder/php/connector.roundcube.php | 6 +++--- storage.php | 31 ++++------------------------ 4 files changed, 14 insertions(+), 36 deletions(-) diff --git a/composer.json b/composer.json index a5de89c..8526bbb 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "role": "Developer" } ], - "version": "1.2.2", + "version": "1.2.3", "repositories": [ { "type": "composer", diff --git a/config.inc.php.dist b/config.inc.php.dist index b8003bf..160523e 100644 --- a/config.inc.php.dist +++ b/config.inc.php.dist @@ -2,15 +2,16 @@ // relative path to elfinder $config['storage_url'] = 'plugins/storage/elfinder/roundcube.html'; -// The path to the storage is computed as follows: $config['storage_basepath'] + + $config['storage_filespath'] -// With such a path, every user has it's own folder. The folder $config['storage_filespath'] as subfolder to the users folder -// do let you manage the files better, since you can so save additional things in this userspace. -$config['storage_basepath'] = '/mount/some/example_hdd/'; -$config['storage_filespath'] = '/files'; +// This is the absolute path to the elfinder root directory. You can use the variable %u as replacement for the Roundcube username +$config['storage_basepath'] = '/mount/some/example_hdd/%u/files/'; // folder where attachments should saved if requested $config['storage_attachments'] = 'Attachments'; // Name of your storage $config['storage_name'] = 'My Files'; + +// If you want to display the calculated path in Roundcube error.log, set this variable to true +// If you set it to false or remove this setting, the calculated path is not shown in the logfile +//$config['storage_debug'] = true; ?> diff --git a/elfinder/php/connector.roundcube.php b/elfinder/php/connector.roundcube.php index 95284a1..5e39c69 100644 --- a/elfinder/php/connector.roundcube.php +++ b/elfinder/php/connector.roundcube.php @@ -7,18 +7,18 @@ $rcmail = rcmail::get_instance(); if (!empty($rcmail->user->ID)) { - $path = $rcmail->config->get('storage_basepath', false).$rcmail->user->get_username().$rcmail->config->get('storage_filespath', false); + $path = str_replace("%u", $rcmail->user->get_username(), $rcmail->config->get('storage_basepath', false)); $storage_name = $rcmail->config->get('storage_name', false); // if the userfolder does not exist yet, create it automatically. if (!is_dir($path)) { if(!mkdir($path, 0774, true)) { - error_log('Plugin Storage: Subfolders for $config[\'storage_basepath\'] ($config[\'storage_filespath\']) failed. Please check your directory permissions.'); + error_log('Plugin Storage: Trying to create not existing folder specified in $config[\'storage_basepath\'] failed. Please check your directory permissions.'); die(); } else - error_log('Plugin Storage: Subfolders for $config[\'storage_basepath\'] ($config[\'storage_filespath\']) auto-created, since they not exists yet'); + error_log('Plugin Storage: Trying to create not existing folder specified in $config[\'storage_basepath\'] failed. Please check your directory permissions.'); } // check if attachment path exists and create if not exist diff --git a/storage.php b/storage.php index 46c3420..94f87aa 100644 --- a/storage.php +++ b/storage.php @@ -3,7 +3,7 @@ * Roundcube elfinder Plugin * Integrate elFinder in to Roundcube * - * @version 1.2.2 + * @version 1.2.3 * @author Offerel * @copyright Copyright (c) 2018, Offerel * @license GNU General Public License, version 3 @@ -42,30 +42,7 @@ public function init() $rcmail->output->set_env('spath', dirname($rcmail->config->get('storage_url', false))."/"); $rcmail->output->set_env('elbutton', $this->gettext('loadattachment')); - } - - function add_nnote() - { - $title = rcube_utils::get_input_value('_title', rcube_utils::INPUT_POST); - $tag_arr = preg_split ('/[\s*,\s*]*,+[\s*,\s*]*/', rcube_utils::get_input_value('_tags', rcube_utils::INPUT_POST)); - $tag_str = implode(",", $tag_arr); - - $inhalt = "$title"; - - $path = $rcmail->config->get('storage_basepath', false).$rcmail->user->get_username().'/files'; - $notespath = $path.'/'.$rcmail->config->get('storage_notes', false); - if (!is_dir($notespath)) - { - mkdir($notespath); - } - - $filepath = $notespath."test.html"; - - $myfile = fopen($filename, "w") or die("Unable to open file!"); - fwrite ($myfile, $inhalt); - fclose ($myfile); - } - + } public function add_saveatt_link($p) { @@ -86,8 +63,8 @@ public function add_saveatt_link($p) public function save_one($args) { $rcmail = rcmail::get_instance(); + $path = str_replace("%u", $rcmail->user->get_username(), $rcmail->config->get('storage_basepath', false)); - $path = $rcmail->config->get('storage_basepath', false).$rcmail->user->get_username().'/files'; $attpath = $path.'/'.$rcmail->config->get('storage_attachments', false); if (!is_dir($attpath)) { @@ -153,7 +130,7 @@ function attach_file() die("Invalid session var!"); } - $elpath = $rcmail->config->get('storage_basepath', false).$rcmail->user->get_username().'/files'.substr($filepath, strpos($filepath, "/")); + $elpath = str_replace("%u", $rcmail->user->get_username(), $rcmail->config->get('storage_basepath', false)).substr($filepath, strpos($filepath, "/")); $rcmail->output->reset(); if (is_file($elpath)) {