Add hidden upload directory as mail action

This commit is contained in:
nathangray 2020-03-26 13:20:20 -06:00
parent 18c21d4234
commit 93a7166710
6 changed files with 98 additions and 5 deletions

View File

@ -691,6 +691,7 @@ class Sharing
$arr['title'] = lang('Filemanager directory');
break;
case 'shareUploadDir':
case 'mail_shareUploadDir':
$arr['title'] = lang('Upload directory');
break;
}

View File

@ -103,10 +103,7 @@ class HiddenUploadSharing extends Sharing
$path = parent::validate_path($path, $mode);
// Set up anonymous upload directory
if ($action_id == 'shareUploadDir')
{
static::create_hidden_upload($path, $extra);
}
static::create_hidden_upload($path, $extra);
return parent::create($action_id, $path, $mode, $name, $recipients, $extra);
}

View File

@ -290,6 +290,18 @@ class filemanager_ui
$actions['share']['children']['share_mail']['children']['mail_'.$mode]['disableClass'] = 'isDir';
}
}
foreach(Vfs\HiddenUploadSharing::$modes as $mode => $data)
{
$actions['share']['children']['share_mail']['children']['mail_shareUploadDir'] = array(
'caption' => $data['label'],
'hint' => $data['title'],
'icon' => 'upload',
'group' => 3,
'data' => ['share_writable' => $mode],
'enabled' => 'javaScript:app.filemanager.hidden_upload_enabled',
'onExecute' => 'javaScript:app.filemanager.mail_share_link',
);
}
}
// This would be done automatically, but we're overriding

View File

@ -241,6 +241,44 @@ var filemanagerAPP = /** @class */ (function (_super) {
'preset[filemode]': _action.id.substr(5)
});
};
/**
* Mail files action: open compose with already linked files
* We're only interested in hidden upload shares here, open_mail can handle
* the rest
*
* @param {egwAction} _action
* @param {egwActionObject[]} _selected
*/
filemanagerAPP.prototype.mail_share_link = function (_action, _selected) {
if (_action.id !== 'mail_shareUploadDir') {
return this.mail(_action, _selected);
}
var path = this.id2path(_selected[0].id);
this.share_link(_action, _selected, null, false, false, this._mail_link_callback);
return true;
};
/**
* Callback with the share link to append to an email
*
* @param {Object} _data
* @param {String} _data.share_link Link to the share
* @param {String} _data.title Title for the link
* @param {String} [_data.msg] Error message
*/
filemanagerAPP.prototype._mail_link_callback = function (_data) {
debugger;
if (_data.msg || !_data.share_link)
window.egw_refresh(_data.msg, this.appname);
var params = {
'preset[body]': '<a href="' + _data.share_link + '">' + _data.title + '</a>',
'mimeType': 'html' // always open compose in html mode, as attachment links look a lot nicer in html
};
var content = {
mail_htmltext: ['<br /><a href="' + _data.share_link + '">' + _data.title + '</a>'],
mail_plaintext: ["\n" + _data.share_link]
};
return egw.openWithinWindow("mail", "setCompose", content, params, /mail.mail_compose.compose/);
};
/**
* Trigger Upload after each file is uploaded
* @param {type} _event

View File

@ -275,6 +275,51 @@ export class filemanagerAPP extends EgwApp
});
}
/**
* Mail files action: open compose with already linked files
* We're only interested in hidden upload shares here, open_mail can handle
* the rest
*
* @param {egwAction} _action
* @param {egwActionObject[]} _selected
*/
mail_share_link(_action, _selected)
{
if(_action.id !== 'mail_shareUploadDir')
{
return this.mail(_action, _selected);
}
let path = this.id2path(_selected[0].id);
this.share_link(_action, _selected, null, false, false, this._mail_link_callback);
return true;
}
/**
* Callback with the share link to append to an email
*
* @param {Object} _data
* @param {String} _data.share_link Link to the share
* @param {String} _data.title Title for the link
* @param {String} [_data.msg] Error message
*/
_mail_link_callback(_data)
{
debugger;
if (_data.msg || !_data.share_link) window.egw_refresh(_data.msg, this.appname);
let params = {
'preset[body]': '<a href="'+_data.share_link + '">'+_data.title+'</a>',
'mimeType': 'html'// always open compose in html mode, as attachment links look a lot nicer in html
};
let content = {
mail_htmltext: ['<br /><a href="'+_data.share_link + '">'+_data.title+'</a>'],
mail_plaintext: ["\n"+_data.share_link]
};
return egw.openWithinWindow("mail", "setCompose", content, params, /mail.mail_compose.compose/);
}
/**
* Trigger Upload after each file is uploaded
* @param {type} _event

View File

@ -983,7 +983,7 @@ class mail_compose
if (isset($_REQUEST['preset']['file']))
{
$content['filemode'] = !empty($_REQUEST['preset']['filemode']) &&
isset(Vfs\Sharing::$modes[$_REQUEST['preset']['filemode']]) ?
(isset(Vfs\Sharing::$modes[$_REQUEST['preset']['filemode']]) || isset(Vfs\HiddenUploadSharing::$modes[$_REQUEST['preset']['filemode']])) ?
$_REQUEST['preset']['filemode'] : Vfs\Sharing::ATTACH;
$this->addPresetFiles($content, $insertSigOnTop, $alwaysAttachVCardAtCompose);