Skip to content

Commit 28c609d

Browse files
author
Offerel
committed
Small fix for Classic Skin
1 parent fa7af55 commit 28c609d

File tree

10 files changed

+150
-20
lines changed

10 files changed

+150
-20
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,16 @@
22
Directly integrate elFinder as App in to Roundcube with SSO. You can find elFinder at GitHub (https://github.com/Studio-42/elFinder).
33

44
# Changelog
5+
**v1.2.1**
6+
- Small fix for Classic skin
7+
8+
**v1.2.0**
9+
- You can now add files from the server storage with the hekp of elFinder.
10+
- Fix for wrong path issue
11+
512
**v1.1.0**
613
- There is now a special connector.roundcube.php file, so that you can use this, instead of connector.minimal.php
7-
- Configuration of basepath is no done in config.inc.php
14+
- Configuration of basepath is now done in config.inc.php
815
- 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.
916

1017
**v1.0.1**

client.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
66
rcmail.env.selected_attachment = p.id;
77
}
88
});
9+
10+
var fbutton = $("#compose-attachments").contents().find("a");
11+
fbutton.after("<a class='button' tabindex='2' href='#' onclick='cform();'>" + rcmail.env.elbutton + "</a>");
912
});
1013

1114
function save_one()
@@ -15,6 +18,22 @@ function save_one()
1518
}
1619

1720
function dmessage(response)
18-
{
19-
alert(response.message);
20-
}
21+
{
22+
alert(response.message);
23+
}
24+
25+
function cform()
26+
{
27+
var storage_path = rcmail.env.spath;
28+
var cid = location.search.split('id=')[1];
29+
var specs = "location=no,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=no,toolbar=no,width=840,height=370,";
30+
var elwindow = window.open(storage_path + "elopen.html?id=" + cid,"elopen",specs,false);
31+
}
32+
33+
function elcallback(files,cid,tid)
34+
{
35+
for (id in files) {
36+
rcmail.http_post('storage/elattach', '_tid=' + tid + '&_cid=' + cid + '&_file=' + files[id].path);
37+
}
38+
39+
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"role": "Developer"
1313
}
1414
],
15-
"version": "1.0.1",
15+
"version": "1.2.1",
1616
"repositories": [
1717
{
1818
"type": "composer",

config.inc.php.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ $config['storage_basepath'] = '/mount/some/example_hdd/';
77

88
// folder where attachments should saved if requested
99
$config['storage_attachments'] = 'Attachments';
10+
11+
// Name of your storage
12+
$config['storage_name'] = 'My Files';
1013
?>

elFinder-2.1.30/php/connector.roundcube.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

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

1213
// check if attachment path exists and create if not exist
1314
$attpath = $path.'/'.$rcmail->config->get('storage_attachments', false);
@@ -44,7 +45,7 @@ function access($attr, $path, $data, $volume, $isDir, $relpath) {
4445
'driver' => 'LocalFileSystem', // driver for accessing file system (REQUIRED)
4546
'path' => $path, // path to files (REQUIRED)
4647
'uploadAllow' => array('all'),// Mimetype `image` and `text/plain` allowed to upload
47-
'alias' => 'My Files',
48+
'alias' => $storage_name,
4849
'uploadOrder' => array('deny', 'allow'), // allowed Mimetype `image` and `text/plain` only
4950
'accessControl' => 'access', // disable and hide dot starting files (OPTIONAL)
5051
'tmbPath' => '/tmp',

localization/de_DE.inc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
<?php
2-
$labels = array();
3-
$labels['storage'] = 'Dateien';
4-
$labels['saveattachment'] = 'Auf Server speichern';
1+
<?php
2+
$labels = array();
3+
$labels['storage'] = 'Dateien';
4+
$labels['saveattachment'] = 'Auf Server speichern';
5+
$labels['loadattachment'] = 'Vom Server &ouml;ffnen';
56
?>

localization/en_US.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
$labels = array();
33
$labels['storage'] = 'Files';
44
$labels['saveattachment'] = 'Save on Server';
5+
$labels['loadattachment'] = 'Open from Server';
56
?>

skins/classic/elfinder.css

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1-
#taskbar a.button-elfinder {
1+
#taskbar a.button-storage {
22
background: url(images/user-home.png) 0px 1px no-repeat;
33
}
44

55
.iframebox.storage_ {
66
height: 100%;
7+
}
8+
9+
ul.toolbarmenu li #attachmentmenusave {
10+
background: url("images/user-home-16.png") 0 0 no-repeat;
11+
background-size: 14px 14px;
12+
margin-left: 9px !important;
13+
display: box;
14+
}
15+
16+
ul.toolbarmenu li span.saveatt {
17+
margin-left: -9px;
718
}

skins/larry/elfinder.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
}
1010

1111
ul.toolbarmenu li span.saveatt {
12-
background-position: 0 -1342px;
12+
background: url(images/storage-menu.png) 0 0 no-repeat;
13+
background-size: 16px 16px;
1314
}

storage.php

Lines changed: 94 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Roundcube elfinder Plugin
44
* Integrate elFinder in to Roundcube
55
*
6-
* @version 1.1.0
6+
* @version 1.2.0
77
* @author Offerel
88
* @copyright Copyright (c) 2017, Offerel
99
* @license GNU General Public License, version 3
@@ -16,13 +16,9 @@ function init()
1616
{
1717
$rcmail = rcmail::get_instance();
1818
$this->load_config();
19-
2019
$this->add_texts('localization/', true);
21-
2220
$this->include_stylesheet($this->local_skin_path() . '/elfinder.css');
23-
2421
$this->include_script('client.js');
25-
2622
$this->register_task('storage');
2723

2824
$this->add_button(array(
@@ -36,10 +32,13 @@ function init()
3632
if ($rcmail->task == 'storage') {
3733
$this->register_action('index', array($this, 'action'));
3834
}
39-
40-
$this->add_hook('template_container', array($this, 'add_saveatt_link'));
35+
36+
$this->add_hook('template_container', array($this, 'add_saveatt_link'));
4137

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

4544
public function add_saveatt_link($p)
@@ -70,7 +69,7 @@ public function save_one($args)
7069
}
7170

7271
$uid = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_POST);
73-
$mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST);
72+
$mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST);
7473
$mime_id = rcube_utils::get_input_value('_part', rcube_utils::INPUT_POST);
7574

7675
$message = new rcube_message($uid, $mbox);
@@ -109,5 +108,92 @@ function content($attrib)
109108
$attrib['name'] = $attrib['id'];
110109
return $rcmail->output->frame($attrib);
111110
}
111+
112+
function attach_file()
113+
{
114+
$rcmail = rcmail::get_instance();
115+
116+
$uploadid = rcube_utils::get_input_value('_tid', rcube_utils::INPUT_POST);
117+
$filepath = rcube_utils::get_input_value('_file', rcube_utils::INPUT_POST);
118+
$COMPOSE_ID = rcube_utils::get_input_value('_cid', rcube_utils::INPUT_POST);
119+
$COMPOSE = null;
120+
121+
if ($COMPOSE_ID && $_SESSION['compose_data_'] . $COMPOSE_ID)
122+
{
123+
$SESSION_KEY = 'compose_data_' . $COMPOSE_ID;
124+
$COMPOSE =& $_SESSION[$SESSION_KEY];
125+
}
126+
127+
if (!$COMPOSE) {
128+
die("Invalid session var!");
129+
}
130+
131+
$elpath = $rcmail->config->get('storage_basepath', false).$rcmail->user->get_username().'/files'.substr($filepath, strpos($filepath, "/"));
132+
$rcmail->output->reset();
133+
134+
if (is_file($elpath)) {
135+
$temp_dir = $rcmail->config->get('temp_dir');
136+
$tmpfname = tempnam($temp_dir, 'rcmAttmnt');
137+
copy($elpath, $tmpfname);
138+
139+
$attachment = array(
140+
'path' => $tmpfname,
141+
'size' => filesize($elpath),
142+
'name' => basename($elpath),
143+
'mimetype' => rcube_mime::file_content_type($elpath, basename($elpath)),
144+
'group' => $COMPOSE_ID,
145+
);
146+
147+
$attachment = $rcmail->plugins->exec_hook('attachment_save', $attachment);
148+
$id = $attachment['id'];
149+
150+
$COMPOSE['attachments'][$id] = $attachment;
151+
152+
$rcmail->session->append($SESSION_KEY.'.attachments', $id, $attachment);
153+
154+
if (($icon = $COMPOSE['deleteicon']) && is_file($icon))
155+
{
156+
$button = html::img(array(
157+
'src' => $icon,
158+
'alt' => $rcmail->gettext('delete')
159+
));
160+
}
161+
else {
162+
$button = rcube::Q($rcmail->gettext('delete'));
163+
}
164+
165+
$link_content = sprintf('%s <span class="attachment-size"> (%s)</span>',
166+
rcube::Q($attachment['name']), $rcmail->show_bytes($attachment['size']));
167+
168+
$content_link = html::a(array(
169+
'href' => "#load",
170+
'class' => 'filename',
171+
'onclick' => sprintf("return %s.command('load-attachment','rcmfile%s', this, event)", rcmail_output::JS_OBJECT_NAME, $id),
172+
), $link_content);
173+
174+
$delete_link = html::a(array(
175+
'href' => "#delete",
176+
'onclick' => sprintf("return %s.command('remove-attachment','rcmfile%s', this, event)", rcmail_output::JS_OBJECT_NAME, $id),
177+
'title' => $rcmail->gettext('delete'),
178+
'class' => 'delete',
179+
), $button);
180+
181+
$content = $COMPOSE['icon_pos'] == 'left' ? $delete_link.$content_link : $content_link.$delete_link;
182+
183+
$rcmail->output->command('add2attachment_list', "rcmfile$id", array(
184+
'html' => $content,
185+
'name' => $attachment['name'],
186+
'mimetype' => $attachment['mimetype'],
187+
'classname' => rcube_utils::file2class($attachment['mimetype'], $attachment['name']),
188+
'complete' => true), $uploadid);
189+
190+
$rcmail->output->command('auto_save_start', false);
191+
$rcmail->output->send('iframe');
192+
193+
} else {
194+
$rcmail->output->show_message("\"$filepath\" is not a file", 'error');
195+
$rcmail->output->send('iframe');
196+
}
197+
}
112198
}
113199
?>

0 commit comments

Comments
 (0)