forked from extern/egroupware
WIP attachment handling via mime-registry
This commit is contained in:
parent
5687471b1c
commit
ffceb37973
@ -45,7 +45,7 @@ class calendar_hooks
|
||||
'mime' => array(
|
||||
'text/calendar' => array(
|
||||
'menuaction' => 'calendar.calendar_uiforms.edit',
|
||||
'mime_id' => 'ical_vfs',
|
||||
'mime_url' => 'ical_url',
|
||||
'mime_popup' => '750x400',
|
||||
),
|
||||
),
|
||||
|
@ -1213,11 +1213,36 @@ class calendar_uiforms extends calendar_ui
|
||||
unset($event['participants']);
|
||||
return $this->process_edit($event);
|
||||
}
|
||||
if (!empty($_GET['ical']) || !empty($_GET['ical_vfs']) && egw_vfs::file_exists($_GET['ical_vfs']))
|
||||
// vfs path passed in --> url
|
||||
if (!empty($_GET['ical_vfs']) && egw_vfs::file_exists($_GET['ical_vfs']))
|
||||
{
|
||||
$_GET['ical_url'] = egw_vfs::PREFIX.$_GET['ical_vfs'];
|
||||
}
|
||||
// url passed in --> read it making sure to prepend own host if it starts with a /
|
||||
if (!empty($_GET['ical_url']))
|
||||
{
|
||||
$schema = (string)parse_url($_GET['ical_url'], PHP_URL_SCHEME);
|
||||
switch($schema)
|
||||
{
|
||||
case '': // own url with webserver_url is a path
|
||||
$_GET['ical_url'] = ($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$_GET['ical_url'];
|
||||
// fall through
|
||||
case 'vfs':
|
||||
case 'http':
|
||||
case 'https':
|
||||
$_GET['ical'] = file_get_contents($_GET['ical_url']);
|
||||
break;
|
||||
default:
|
||||
error_log(__METHOD__."() Error: importing the iCal: unsupported schema '$schema'");
|
||||
$msg = lang('Error: importing the iCal').': '.lang('unsupported schema').' '.$schema;
|
||||
$event =& $this->default_add_event();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!empty($_GET['ical']))
|
||||
{
|
||||
$ical = new calendar_ical();
|
||||
$ical_string = !empty($_GET['ical']) ? $_GET['ical'] : file_get_contents(egw_vfs::PREFIX.$_GET['ical_vfs']);
|
||||
if (!($events = $ical->icaltoegw($ical_string, '', 'utf-8')) || count($events) != 1)
|
||||
if (!($events = $ical->icaltoegw($_GET['ical_url'], '', 'utf-8')) || count($events) != 1)
|
||||
{
|
||||
error_log(__METHOD__."('$_GET[ical]') error parsing iCal!");
|
||||
$msg = lang('Error: importing the iCal');
|
||||
@ -1245,7 +1270,6 @@ class calendar_uiforms extends calendar_ui
|
||||
//error_log(__METHOD__."(...) parsed as ".array2string($event));
|
||||
}
|
||||
unset($ical);
|
||||
unset($ical_string);
|
||||
}
|
||||
elseif (!$cal_id || $cal_id && !($event = $this->bo->read($cal_id)))
|
||||
{
|
||||
|
@ -3386,14 +3386,14 @@ class mail_ui
|
||||
$draftFolder = $this->mail_bo->getDraftFolder(false);
|
||||
$importID = mail_bo::getRandomString();
|
||||
// name should be set to meet the requirements of checkFileBasics
|
||||
if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && (!isset($formData['name']) || empty($formData['name'])))
|
||||
if (in_array(parse_url($formData['file'],PHP_URL_SCHEME), array('vfs', 'http', 'https')) && (!isset($formData['name']) || empty($formData['name'])))
|
||||
{
|
||||
$buff = explode('/',$formData['file']);
|
||||
$suffix = '';
|
||||
if (is_array($buff)) $formData['name'] = array_pop($buff); // take the last part as name
|
||||
}
|
||||
// type should be set to meet the requirements of checkFileBasics
|
||||
if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && (!isset($formData['type']) || empty($formData['type'])))
|
||||
if (in_array(parse_url($formData['file'],PHP_URL_SCHEME), array('vfs', 'http', 'https')) && (!isset($formData['type']) || empty($formData['type'])))
|
||||
{
|
||||
$buff = explode('.',$formData['file']);
|
||||
$suffix = '';
|
||||
@ -3401,7 +3401,7 @@ class mail_ui
|
||||
if (!empty($suffix)) $formData['type'] = mime_magic::ext2mime($suffix);
|
||||
}
|
||||
// size should be set to meet the requirements of checkFileBasics
|
||||
if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && !isset($formData['size']))
|
||||
if (in_array(parse_url($formData['file'],PHP_URL_SCHEME), array('vfs', 'http', 'https')) && !isset($formData['size']))
|
||||
{
|
||||
$formData['size'] = strlen($formData['file']); // set some size, to meet requirements of checkFileBasics
|
||||
}
|
||||
|
@ -73,8 +73,7 @@
|
||||
* 'entries' => 'Contacts', // Optional name for multiple entries of app, eg. "contacts" used instead of appname
|
||||
* 'mime' => array( // Optional register mime-types application can open
|
||||
* 'text/something' => array(
|
||||
* 'mime_id' => 'path', // one of id (path) or url is required!
|
||||
* 'mime_url' => 'url',
|
||||
* 'mime_url' => 'url', // required (!)
|
||||
* 'menuaction' => 'app.class.method', // method to call
|
||||
* 'mime_popup' => '400x300', // optional size of popup
|
||||
* 'mime_target' => '_self', // optional target, default _blank
|
||||
|
@ -164,9 +164,6 @@ egw.extend('links', egw.MODULE_GLOBAL, function()
|
||||
case 'mime_url':
|
||||
data[mime_info.mime_url] = 'vfs://default' + path;
|
||||
break;
|
||||
case 'mime_id':
|
||||
data[mime_info.mime_id] = path;
|
||||
break;
|
||||
default:
|
||||
data[attr] = mime_info[attr];
|
||||
}
|
||||
|
@ -243,8 +243,9 @@ egw.extend('open', egw.MODULE_WND_LOCAL, function(_egw, _wnd)
|
||||
* @param {string} _target_app app-name for opener
|
||||
* @param {boolean} _check_popup_blocker TRUE check if browser pop-up blocker is on/off, FALSE no check
|
||||
* - This option only makes sense to be enabled when the open_link requested without user interaction
|
||||
* @param {string} _mime_type if given, we check if any app has registered a mime-handler for that type and use it
|
||||
*/
|
||||
open_link: function(_link, _target, _popup, _target_app, _check_popup_blocker)
|
||||
open_link: function(_link, _target, _popup, _target_app, _check_popup_blocker, _mime_type)
|
||||
{
|
||||
// Log for debugging purposes - don't use navigation here to avoid
|
||||
// flooding log with details already captured by egw.open()
|
||||
@ -278,6 +279,23 @@ egw.extend('open', egw.MODULE_WND_LOCAL, function(_egw, _wnd)
|
||||
{
|
||||
url = this.webserverUrl + url;
|
||||
}
|
||||
var mime_info = _mime_type ? this.get_mime_info(_mime_type) : undefined;
|
||||
if (mime_info && mime_info[mime_info.mime_url])
|
||||
{
|
||||
if (mime_info.mime_popup)
|
||||
{
|
||||
_popup = mime_info.mime_popup;
|
||||
delete mime_info.mime_popup;
|
||||
}
|
||||
if (mime_info.mime_target)
|
||||
{
|
||||
_target = mime_info.mime_target;
|
||||
delete mime_info.mime_target;
|
||||
}
|
||||
mime_info[mime_info.mime_url] = url;
|
||||
delete mime_info.mime_url;
|
||||
url = egw.link('/index.php', mime_info);
|
||||
}
|
||||
if (_popup)
|
||||
{
|
||||
var w_h = _popup.split('x');
|
||||
|
Loading…
Reference in New Issue
Block a user