Skip to content

Commit

Permalink
simplified path configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Offerel committed Feb 17, 2018
1 parent b5d0312 commit 35e139d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 36 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"role": "Developer"
}
],
"version": "1.2.2",
"version": "1.2.3",
"repositories": [
{
"type": "composer",
Expand Down
11 changes: 6 additions & 5 deletions config.inc.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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'] + <Rouncube username> + $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;
?>
6 changes: 3 additions & 3 deletions elfinder/php/connector.roundcube.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 4 additions & 27 deletions storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = "<html><head><title>$title</title><meta name=\"keywords\" content=\"$tag_str\" /><meta name=\"author\" content=\"Sebastian Pfohl\" /></head><body></body></html>";

$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)
{
Expand All @@ -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))
{
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit 35e139d

Please sign in to comment.