Skip to content

Commit

Permalink
Small fix for Classic Skin
Browse files Browse the repository at this point in the history
  • Loading branch information
Offerel committed Jan 4, 2018
1 parent fa7af55 commit 28c609d
Show file tree
Hide file tree
Showing 10 changed files with 150 additions and 20 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@
Directly integrate elFinder as App in to Roundcube with SSO. You can find elFinder at GitHub (https://github.com/Studio-42/elFinder).

# Changelog
**v1.2.1**
- Small fix for Classic skin

**v1.2.0**
- You can now add files from the server storage with the hekp of elFinder.
- Fix for wrong path issue

**v1.1.0**
- There is now a special connector.roundcube.php file, so that you can use this, instead of connector.minimal.php
- Configuration of basepath is no done in config.inc.php
- Configuration of basepath is now done in config.inc.php
- It's now possible to save E-Mail Attachments in the configured storage. For this, there is a new config parameter in config.inc.php to specify the right path. If this path doesn't exist, it will be created automatically.

**v1.0.1**
Expand Down
25 changes: 22 additions & 3 deletions client.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
rcmail.env.selected_attachment = p.id;
}
});

var fbutton = $("#compose-attachments").contents().find("a");
fbutton.after("<a class='button' tabindex='2' href='#' onclick='cform();'>" + rcmail.env.elbutton + "</a>");
});

function save_one()
Expand All @@ -15,6 +18,22 @@ function save_one()
}

function dmessage(response)
{
alert(response.message);
}
{
alert(response.message);
}

function cform()
{
var storage_path = rcmail.env.spath;
var cid = location.search.split('id=')[1];
var specs = "location=no,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=no,toolbar=no,width=840,height=370,";
var elwindow = window.open(storage_path + "elopen.html?id=" + cid,"elopen",specs,false);
}

function elcallback(files,cid,tid)
{
for (id in files) {
rcmail.http_post('storage/elattach', '_tid=' + tid + '&_cid=' + cid + '&_file=' + files[id].path);
}

}
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.0.1",
"version": "1.2.1",
"repositories": [
{
"type": "composer",
Expand Down
3 changes: 3 additions & 0 deletions config.inc.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ $config['storage_basepath'] = '/mount/some/example_hdd/';

// folder where attachments should saved if requested
$config['storage_attachments'] = 'Attachments';

// Name of your storage
$config['storage_name'] = 'My Files';
?>
3 changes: 2 additions & 1 deletion elFinder-2.1.30/php/connector.roundcube.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

if (!empty($rcmail->user->ID)) {
$path = $rcmail->config->get('storage_basepath', false).$rcmail->user->get_username().'/files';
$storage_name = $rcmail->user->get_username();

// check if attachment path exists and create if not exist
$attpath = $path.'/'.$rcmail->config->get('storage_attachments', false);
Expand Down Expand Up @@ -44,7 +45,7 @@ function access($attr, $path, $data, $volume, $isDir, $relpath) {
'driver' => 'LocalFileSystem', // driver for accessing file system (REQUIRED)
'path' => $path, // path to files (REQUIRED)
'uploadAllow' => array('all'),// Mimetype `image` and `text/plain` allowed to upload
'alias' => 'My Files',
'alias' => $storage_name,
'uploadOrder' => array('deny', 'allow'), // allowed Mimetype `image` and `text/plain` only
'accessControl' => 'access', // disable and hide dot starting files (OPTIONAL)
'tmbPath' => '/tmp',
Expand Down
9 changes: 5 additions & 4 deletions localization/de_DE.inc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
$labels = array();
$labels['storage'] = 'Dateien';
$labels['saveattachment'] = 'Auf Server speichern';
<?php
$labels = array();
$labels['storage'] = 'Dateien';
$labels['saveattachment'] = 'Auf Server speichern';
$labels['loadattachment'] = 'Vom Server &ouml;ffnen';
?>
1 change: 1 addition & 0 deletions localization/en_US.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
$labels = array();
$labels['storage'] = 'Files';
$labels['saveattachment'] = 'Save on Server';
$labels['loadattachment'] = 'Open from Server';
?>
13 changes: 12 additions & 1 deletion skins/classic/elfinder.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
#taskbar a.button-elfinder {
#taskbar a.button-storage {
background: url(images/user-home.png) 0px 1px no-repeat;
}

.iframebox.storage_ {
height: 100%;
}

ul.toolbarmenu li #attachmentmenusave {
background: url("images/user-home-16.png") 0 0 no-repeat;
background-size: 14px 14px;
margin-left: 9px !important;
display: box;
}

ul.toolbarmenu li span.saveatt {
margin-left: -9px;
}
3 changes: 2 additions & 1 deletion skins/larry/elfinder.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
}

ul.toolbarmenu li span.saveatt {
background-position: 0 -1342px;
background: url(images/storage-menu.png) 0 0 no-repeat;
background-size: 16px 16px;
}
102 changes: 94 additions & 8 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.1.0
* @version 1.2.0
* @author Offerel
* @copyright Copyright (c) 2017, Offerel
* @license GNU General Public License, version 3
Expand All @@ -16,13 +16,9 @@ function init()
{
$rcmail = rcmail::get_instance();
$this->load_config();

$this->add_texts('localization/', true);

$this->include_stylesheet($this->local_skin_path() . '/elfinder.css');

$this->include_script('client.js');

$this->register_task('storage');

$this->add_button(array(
Expand All @@ -36,10 +32,13 @@ function init()
if ($rcmail->task == 'storage') {
$this->register_action('index', array($this, 'action'));
}
$this->add_hook('template_container', array($this, 'add_saveatt_link'));

$this->add_hook('template_container', array($this, 'add_saveatt_link'));

$this->register_action('save_one', array($this, 'save_one'));
$this->register_action('elattach', array($this, 'attach_file'));
$rcmail->output->set_env('spath', dirname($rcmail->config->get('storage_url', false))."/");
$rcmail->output->set_env('elbutton', $this->gettext('loadattachment'));
}

public function add_saveatt_link($p)
Expand Down Expand Up @@ -70,7 +69,7 @@ public function save_one($args)
}

$uid = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_POST);
$mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST);
$mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST);
$mime_id = rcube_utils::get_input_value('_part', rcube_utils::INPUT_POST);

$message = new rcube_message($uid, $mbox);
Expand Down Expand Up @@ -109,5 +108,92 @@ function content($attrib)
$attrib['name'] = $attrib['id'];
return $rcmail->output->frame($attrib);
}

function attach_file()
{
$rcmail = rcmail::get_instance();

$uploadid = rcube_utils::get_input_value('_tid', rcube_utils::INPUT_POST);
$filepath = rcube_utils::get_input_value('_file', rcube_utils::INPUT_POST);
$COMPOSE_ID = rcube_utils::get_input_value('_cid', rcube_utils::INPUT_POST);
$COMPOSE = null;

if ($COMPOSE_ID && $_SESSION['compose_data_'] . $COMPOSE_ID)
{
$SESSION_KEY = 'compose_data_' . $COMPOSE_ID;
$COMPOSE =& $_SESSION[$SESSION_KEY];
}

if (!$COMPOSE) {
die("Invalid session var!");
}

$elpath = $rcmail->config->get('storage_basepath', false).$rcmail->user->get_username().'/files'.substr($filepath, strpos($filepath, "/"));
$rcmail->output->reset();

if (is_file($elpath)) {
$temp_dir = $rcmail->config->get('temp_dir');
$tmpfname = tempnam($temp_dir, 'rcmAttmnt');
copy($elpath, $tmpfname);

$attachment = array(
'path' => $tmpfname,
'size' => filesize($elpath),
'name' => basename($elpath),
'mimetype' => rcube_mime::file_content_type($elpath, basename($elpath)),
'group' => $COMPOSE_ID,
);

$attachment = $rcmail->plugins->exec_hook('attachment_save', $attachment);
$id = $attachment['id'];

$COMPOSE['attachments'][$id] = $attachment;

$rcmail->session->append($SESSION_KEY.'.attachments', $id, $attachment);

if (($icon = $COMPOSE['deleteicon']) && is_file($icon))
{
$button = html::img(array(
'src' => $icon,
'alt' => $rcmail->gettext('delete')
));
}
else {
$button = rcube::Q($rcmail->gettext('delete'));
}

$link_content = sprintf('%s <span class="attachment-size"> (%s)</span>',
rcube::Q($attachment['name']), $rcmail->show_bytes($attachment['size']));

$content_link = html::a(array(
'href' => "#load",
'class' => 'filename',
'onclick' => sprintf("return %s.command('load-attachment','rcmfile%s', this, event)", rcmail_output::JS_OBJECT_NAME, $id),
), $link_content);

$delete_link = html::a(array(
'href' => "#delete",
'onclick' => sprintf("return %s.command('remove-attachment','rcmfile%s', this, event)", rcmail_output::JS_OBJECT_NAME, $id),
'title' => $rcmail->gettext('delete'),
'class' => 'delete',
), $button);

$content = $COMPOSE['icon_pos'] == 'left' ? $delete_link.$content_link : $content_link.$delete_link;

$rcmail->output->command('add2attachment_list', "rcmfile$id", array(
'html' => $content,
'name' => $attachment['name'],
'mimetype' => $attachment['mimetype'],
'classname' => rcube_utils::file2class($attachment['mimetype'], $attachment['name']),
'complete' => true), $uploadid);

$rcmail->output->command('auto_save_start', false);
$rcmail->output->send('iframe');

} else {
$rcmail->output->show_message("\"$filepath\" is not a file", 'error');
$rcmail->output->send('iframe');
}
}
}
?>

0 comments on commit 28c609d

Please sign in to comment.