mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-23 14:28:45 +01:00
* Addressbook: ablity to mail (multiple) vCard via context menu
This commit is contained in:
parent
e927e73560
commit
f84f2c779b
@ -585,7 +585,15 @@ class addressbook_ui extends addressbook_bo
|
||||
$this->prefs['document_dir'], $group, 'Insert in document', 'document_',
|
||||
$this->prefs['default_document'], $this->config['contact_export_limit']
|
||||
);
|
||||
|
||||
if ($GLOBALS['egw_info']['user']['apps']['felamimail'])
|
||||
{
|
||||
$actions['mail'] = array(
|
||||
'caption' => lang('Mail VCard'),
|
||||
'icon' => 'filemanager/mail_post_to',
|
||||
'group' => $group,
|
||||
'onExecute' => 'javaScript:adb_mail_vcard',
|
||||
);
|
||||
}
|
||||
++$group;
|
||||
if (!($tid_filter == 'D' && !$GLOBALS['egw_info']['user']['apps']['admin'] && $this->config['history'] != 'userpurge'))
|
||||
{
|
||||
@ -2192,7 +2200,19 @@ class addressbook_ui extends addressbook_bo
|
||||
*/
|
||||
function js()
|
||||
{
|
||||
list($width,$height) = explode('x',egw_link::get_registry('felamimail','add_popup'));
|
||||
|
||||
return '<script LANGUAGE="JavaScript">
|
||||
function adb_mail_vcard(_action, _elems)
|
||||
{
|
||||
var link = "'.egw::link('/index.php',array('menuaction' => 'felamimail.uicompose.compose')).'";
|
||||
for (var i = 0; i < _elems.length; i++)
|
||||
{
|
||||
link += "&preset[file][]="+encodeURIComponent("vfs://default/apps/addressbook/"+_elems[i].id+"/.entry");
|
||||
}
|
||||
'."egw_openWindowCentered2(link, '_blank', $width, $height, 'yes');".'
|
||||
}
|
||||
|
||||
function adb_get_selection(form)
|
||||
{
|
||||
var use_all = document.getElementById("exec[use_all]");
|
||||
|
@ -201,11 +201,11 @@ class felamimail_bo
|
||||
{
|
||||
if (array_key_exists($selectedID,$identities))
|
||||
{
|
||||
$_profileID = $selectedID;
|
||||
$_profileID = $selectedID;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (array_keys((array)$identities) as $k => $ident)
|
||||
foreach (array_keys((array)$identities) as $k => $ident)
|
||||
{
|
||||
//error_log(__METHOD__.__LINE__.' Testing Identity with ID:'.$ident.' for being provided by emailadmin.');
|
||||
if ($ident <0) $_profileID = $ident;
|
||||
@ -2436,7 +2436,7 @@ class felamimail_bo
|
||||
|
||||
if($try2useCache && (is_array($this->sessionData['folderStatus'][$this->profileID][$_folderName]) &&
|
||||
$this->sessionData['folderStatus'][$this->profileID][$_folderName]['uidValidity'] === $folderStatus['UIDVALIDITY'] &&
|
||||
$this->sessionData['folderStatus'][$this->profileID][$_folderName]['messages'] == $folderStatus['EXISTS'] &&
|
||||
$this->sessionData['folderStatus'][$this->profileID][$_folderName]['messages'] == $folderStatus['EXISTS'] &&
|
||||
$this->sessionData['folderStatus'][$this->profileID][$_folderName]['deleted'] == $eMailListContainsDeletedMessages[$this->profileID][$_folderName] &&
|
||||
$this->sessionData['folderStatus'][$this->profileID][$_folderName]['uidnext'] === $folderStatus['UIDNEXT'] &&
|
||||
$this->sessionData['folderStatus'][$this->profileID][$_folderName]['filter'] === $_filter &&
|
||||
@ -3469,7 +3469,7 @@ class felamimail_bo
|
||||
{
|
||||
//error_log(__METHOD__.__LINE__.' failed for Reason:'.$isError[$_icServerID]);
|
||||
$this->errorMessage = ($isError[$_icServerID]?$isError[$_icServerID]:$this->icServer->_connectionErrorObject->message);
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!is_object($this->mailPreferences))
|
||||
@ -4015,16 +4015,20 @@ class felamimail_bo
|
||||
// check the mimetype by extension. as browsers seem to report crap
|
||||
// maybe its application/octet-stream -> this may mean that we could not determine the type
|
||||
// so we check for the suffix too
|
||||
$buff = explode('.',$_formData['name']);
|
||||
$suffix = '';
|
||||
if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
|
||||
if (!empty($suffix)) $sfxMimeType = mime_magic::ext2mime($suffix);
|
||||
if (!empty($suffix) && !empty($sfxMimeType) &&
|
||||
(strlen(trim($_formData['type']))==0 || (strtolower(trim($_formData['type'])) != $sfxMimeType)))
|
||||
// trust vfs mime-types
|
||||
if (substr($_formData['file'],0,6) !== 'vfs://' || $_formData['type'] == 'application/octet-stream')
|
||||
{
|
||||
error_log(__METHOD__.__LINE__.' Data:'.array2string($_formData));
|
||||
error_log(__METHOD__.__LINE__.' Form reported Mimetype:'.$_formData['type'].' but seems to be:'.$sfxMimeType);
|
||||
$_formData['type'] = $sfxMimeType;
|
||||
$buff = explode('.',$_formData['name']);
|
||||
$suffix = '';
|
||||
if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
|
||||
if (!empty($suffix)) $sfxMimeType = mime_magic::ext2mime($suffix);
|
||||
if (!empty($suffix) && !empty($sfxMimeType) &&
|
||||
(strlen(trim($_formData['type']))==0 || (strtolower(trim($_formData['type'])) != $sfxMimeType)))
|
||||
{
|
||||
error_log(__METHOD__.__LINE__.' Data:'.array2string($_formData));
|
||||
error_log(__METHOD__.__LINE__.' Form reported Mimetype:'.$_formData['type'].' but seems to be:'.$sfxMimeType);
|
||||
$_formData['type'] = $sfxMimeType;
|
||||
}
|
||||
}
|
||||
if (trim($_formData['type']) == '')
|
||||
{
|
||||
@ -4386,7 +4390,7 @@ class felamimail_bo
|
||||
/**
|
||||
* processURL2InlineImages - parses a html text for images, and adds them as inline attachment
|
||||
* we do not use the functionality of the phpmailer here, as phpmailers functionality requires
|
||||
* files to be present within the filesystem, which we do not require as we make this happen
|
||||
* files to be present within the filesystem, which we do not require as we make this happen
|
||||
* (we load the file, and store it temporarily for the use of attaching it to the file send
|
||||
* @param object $_mailObject instance of the egw_mailer/phpmailer Object to be used
|
||||
* @param string $_html2parse the html to parse and to be altered, if conditions meet
|
||||
@ -4547,13 +4551,13 @@ class felamimail_bo
|
||||
if (!empty($AltBody))
|
||||
{
|
||||
$mailObject->IsHTML(true);
|
||||
}
|
||||
}
|
||||
elseif (empty($AltBody) && $mailObject->BodyContentType=='text/html')
|
||||
{
|
||||
$mailObject->IsHTML(true);
|
||||
$AltBody = self::convertHTMLToText($Body,false,$stripalltags=true);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
$mailObject->IsHTML(false);
|
||||
}
|
||||
@ -4618,13 +4622,13 @@ class felamimail_bo
|
||||
if (!empty($AltBody))
|
||||
{
|
||||
$mailObject->IsHTML(true);
|
||||
}
|
||||
}
|
||||
elseif (empty($AltBody) && $mailObject->BodyContentType=='text/html')
|
||||
{
|
||||
$mailObject->IsHTML(true);
|
||||
$AltBody = self::convertHTMLToText($Body,false,$stripalltags=true);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
$mailObject->IsHTML(false);
|
||||
}
|
||||
|
@ -255,9 +255,21 @@
|
||||
{
|
||||
if (parse_url($path,PHP_URL_SCHEME == 'vfs'))
|
||||
{
|
||||
$type = egw_vfs::mime_content_type($path);
|
||||
// special handling for attaching vCard of iCal --> use their link-title as name
|
||||
if (substr($path,-7) != '/.entry' ||
|
||||
!(list($app,$id) = array_slice(explode('/',$path),-3)) ||
|
||||
!($name = egw_link::title($app, $id)))
|
||||
{
|
||||
$name = urldecode(egw_vfs::basename($path));
|
||||
}
|
||||
else
|
||||
{
|
||||
$name .= '.'.mime_magic::mime2ext($type);
|
||||
}
|
||||
$formData = array(
|
||||
'name' => urldecode(egw_vfs::basename($path)),
|
||||
'type' => egw_vfs::mime_content_type($path),
|
||||
'name' => $name,
|
||||
'type' => $type,
|
||||
'file' => $path,
|
||||
'size' => filesize($path),
|
||||
);
|
||||
@ -579,7 +591,7 @@
|
||||
$this->t->set_var("toggle_editormode",'');
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
$this->t->set_var("toggle_editormode", lang("Editor type").": <span><input name=\"_is_html\" value=\"".$ishtml."\" type=\"hidden\" /><input name=\"_editorselect\" onchange=\"fm_toggle_editor(this)\" ".($ishtml ? "checked=\"checked\"" : "")." id=\"_html\" value=\"html\" type=\"radio\"><label for=\"_html\">HTML</label><input name=\"_editorselect\" onchange=\"fm_toggle_editor(this)\" ".($ishtml ? "" : "checked=\"checked\"")." id=\"_plain\" value=\"plain\" type=\"radio\"><label for=\"_plain\">Plain text</label></span>");
|
||||
}
|
||||
$this->t->pparse("out","body_input");
|
||||
|
@ -114,6 +114,7 @@ class links_stream_wrapper extends links_stream_wrapper_parent
|
||||
* This method is called in response to stat() calls on the URL paths associated with the wrapper.
|
||||
*
|
||||
* Reimplemented from sqlfs, as we have to pass the value of check_extends_acl(), due to the lack of late static binding.
|
||||
* And to return vcard for url /apps/addressbook/$id/.entry
|
||||
*
|
||||
* @param string $path
|
||||
* @param int $flags holds additional flags set by the streams API. It can hold one or more of the following values OR'd together:
|
||||
@ -128,7 +129,28 @@ class links_stream_wrapper extends links_stream_wrapper_parent
|
||||
*/
|
||||
static function url_stat ( $url, $flags )
|
||||
{
|
||||
$ret = parent::url_stat($url,$flags,$eacl_check=self::check_extended_acl($url,egw_vfs::READABLE));
|
||||
$eacl_check=self::check_extended_acl($url,egw_vfs::READABLE);
|
||||
if ($eacl_check && substr($url,-7) == '/.entry' &&
|
||||
(list($app) = array_slice(explode('/',$url),-3,1)) && $app === 'addressbook')
|
||||
{
|
||||
$ret = array(
|
||||
'ino' => $info['fs_id'],
|
||||
'name' => '.entry',
|
||||
'mode' => self::MODE_FILE|egw_vfs::READABLE, // required by the stream wrapper
|
||||
'size' => 1024, // fmail does NOT attach files with size 0!
|
||||
'uid' => 0,
|
||||
'gid' => 0,
|
||||
'mtime' => time(),
|
||||
'ctime' => time(),
|
||||
'nlink' => 1,
|
||||
// eGW addition to return some extra values
|
||||
'mime' => $app == 'addressbook' ? 'text/vcard' : 'text/calendar',
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$ret = parent::url_stat($url,$flags,$eacl_check);
|
||||
}
|
||||
if (self::DEBUG) error_log(__METHOD__."('$url', $flags) calling parent::url_stat(,,".array2string($eacl_check).') returning '.array2string($ret));
|
||||
return $ret;
|
||||
}
|
||||
@ -206,6 +228,7 @@ class links_stream_wrapper extends links_stream_wrapper_parent
|
||||
* This method is called immediately after your stream object is created.
|
||||
*
|
||||
* Reimplemented from sqlfs to ensure self::url_stat is called, to fill sqlfs stat cache with our eacl!
|
||||
* And to return vcard for url /apps/addressbook/$id/.entry
|
||||
*
|
||||
* @param string $url URL that was passed to fopen() and that this object is expected to retrieve
|
||||
* @param string $mode mode used to open the file, as detailed for fopen()
|
||||
@ -219,8 +242,25 @@ class links_stream_wrapper extends links_stream_wrapper_parent
|
||||
function stream_open ( $url, $mode, $options, &$opened_path )
|
||||
{
|
||||
// the following call is necessary to fill sqlfs_stream_wrapper::$stat_cache, WITH the extendes ACL!
|
||||
self::url_stat($url,0);
|
||||
$stat = self::url_stat($url,0);
|
||||
//error_log(__METHOD__."('$url', '$mode', $options) stat=".array2string($stat));
|
||||
|
||||
if ($stat && $mode[0] == 'r' && substr($url,-7) === '/.entry')
|
||||
{
|
||||
list($id) = array_slice(explode('/',$url),-2,1);
|
||||
$name = md5($url);
|
||||
$ab_vcard = new addressbook_vcal('addressbook','text/vcard');
|
||||
if (!($GLOBALS[$name] =& $ab_vcard->getVCard($id)))
|
||||
{
|
||||
error_log(__METHOD__."('$url', '$mode', $options) addressbook_vcal::getVCard($id) returned false!");
|
||||
return false;
|
||||
}
|
||||
//error_log(__METHOD__."('$url', '$mode', $options) addressbook_vcal::getVCard($id) returned ".$GLOBALS[$name]);
|
||||
require_once(EGW_API_INC.'/class.global_stream_wrapper.inc.php');
|
||||
$this->opened_stream = fopen('global://'.$name,'r');
|
||||
unset($GLOBALS[$name]); // unset it, so it does not use up memory, once the stream is closed
|
||||
return true;
|
||||
}
|
||||
return parent::stream_open($url,$mode,$options,$opened_path);
|
||||
}
|
||||
|
||||
|
@ -114,6 +114,7 @@ class mime_magic
|
||||
public static function mime2ext($type)
|
||||
{
|
||||
$type = strtolower($type);
|
||||
if (isset(self::$mime_alias_map[$type])) $type = self::$mime_alias_map[$type];
|
||||
$key = array_search($type, self::$mime_extension_map);
|
||||
if (empty($type) || $key === false)
|
||||
{
|
||||
@ -391,7 +392,7 @@ class mime_magic
|
||||
'ustar' => 'application/x-ustar',
|
||||
'vbs' => 'text/plain', //added by skwashd - for obvious reasons
|
||||
'vcd' => 'application/x-cdlink',
|
||||
'vcf' => 'text/x-vcard',
|
||||
'vcf' => 'text/vcard',
|
||||
'vcs' => 'text/calendar',
|
||||
'vfb' => 'text/calendar',
|
||||
'vrml' => 'model/vrml',
|
||||
@ -426,6 +427,12 @@ class mime_magic
|
||||
'z' => 'application/x-compress',
|
||||
'zip' => 'application/zip',
|
||||
);
|
||||
/**
|
||||
* Mapping some old formats to the newer form, or any other aliasing for mime-types
|
||||
*/
|
||||
static $mime_alias_map = array(
|
||||
'text/x-vcard' => 'text/vcard',
|
||||
);
|
||||
|
||||
/**
|
||||
* @deprecated use static parameter mime_magic::$mime_extension_map
|
||||
|
Loading…
Reference in New Issue
Block a user