cant store a resource in egw_link::set_data()

This commit is contained in:
Ralf Becker 2015-04-16 07:03:53 +00:00
parent 5a6d9b5fcb
commit 24478fe0d5
2 changed files with 36 additions and 36 deletions

View File

@ -3066,19 +3066,25 @@ class mail_compose
// Get registered hook data of the app called for integration // Get registered hook data of the app called for integration
$hook = $GLOBALS['egw']->hooks->single(array('location'=> 'mail_import'),$app_name); $hook = $GLOBALS['egw']->hooks->single(array('location'=> 'mail_import'),$app_name);
// store mail / eml in temp. file to not have to download it from mail-server again
$eml = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'mail_integrate');
$eml_fp = fopen($eml, 'w');
stream_copy_to_stream($mail->getRaw(), $eml_fp);
fclose($eml_fp);
// Open the app called for integration in a popup // Open the app called for integration in a popup
// and store the mail raw data as egw_data, in order to // and store the mail raw data as egw_data, in order to
// be stored from registered app method later // be stored from registered app method later
egw_framework::popup(egw::link('/index.php', array( egw_framework::popup(egw::link('/index.php', array(
'menuaction' => $hook['menuaction'], 'menuaction' => $hook['menuaction'],
'egw_data' => egw_link::set_data(null,'mail_integration::integrate',array( 'egw_data' => egw_link::set_data(null,'mail_integration::integrate',array(
$app_name,
$mailaddresses, $mailaddresses,
$this->sessionData['subject'], $this->sessionData['subject'],
$this->convertHTMLToText($this->sessionData['body']), $this->convertHTMLToText($this->sessionData['body']),
$this->sessionData['attachments'], $this->sessionData['attachments'],
false, // date false, // date
$mail->getRaw()),true) $eml),true),
'app' => $app_name,
)),'_blank',$hook['popup']); )),'_blank',$hook['popup']);
} }
} }

View File

@ -50,19 +50,18 @@ class mail_integration {
* 'subject' => string * 'subject' => string
* ) * )
* *
* @param string $_app Integrated app name
* @param string $_to_emailAddress * @param string $_to_emailAddress
* @param string $_subject mail subject * @param string $_subject mail subject
* @param string $_body mail message * @param string $_body mail message
* @param array $_attachments attachments * @param array $_attachments attachments
* @param string $_date * @param string $_date
* @param string $_rawMail * @param string $_rawMail path to file with raw mail
* @throws egw_exception_assertion_failed * @throws egw_exception_assertion_failed
*/ */
public static function integrate ($_app='',$_to_emailAddress=false,$_subject=false,$_body=false,$_attachments=false,$_date=false,$_rawMail=null,$_icServerID=null) public static function integrate ($_to_emailAddress=false,$_subject=false,$_body=false,$_attachments=false,$_date=false,$_rawMail=null,$_icServerID=null)
{ {
// App name which is called for integration // App name which is called for integration
$app = !empty($_GET['app'])? $_GET['app']:$_app; $app = isset($GLOBALS['egw_info']['user']['apps'][$_GET['app']])? $_GET['app'] : null;
// Set the date // Set the date
if (!$_date) if (!$_date)
@ -77,7 +76,7 @@ class mail_integration {
$sessionLocation = 'mail'; $sessionLocation = 'mail';
$mailbox = base64_decode($_GET['mailbox']); $mailbox = base64_decode($_GET['mailbox']);
$GLOBALS['egw_info']['flags']['currentapp'] = $_app; $GLOBALS['egw_info']['flags']['currentapp'] = $app;
if (!($GLOBALS['egw_info']['user']['preferences'][$sessionLocation]['saveAsOptions']==='text_only')&&is_array($_attachments)) if (!($GLOBALS['egw_info']['user']['preferences'][$sessionLocation]['saveAsOptions']==='text_only')&&is_array($_attachments))
{ {
@ -141,21 +140,16 @@ class mail_integration {
} }
// this one adds the mail itself (as message/rfc822 (.eml) file) to the app as additional attachment // this one adds the mail itself (as message/rfc822 (.eml) file) to the app as additional attachment
// this is done to have a simple archive functionality (ToDo: opening .eml in email module) // this is done to have a simple archive functionality (ToDo: opening .eml in email module)
if (is_resource($_rawMail) && $GLOBALS['egw_info']['user']['preferences'][$sessionLocation]['saveAsOptions']==='add_raw') if ($GLOBALS['egw_info']['user']['preferences'][$sessionLocation]['saveAsOptions']==='add_raw' &&
$_rawMail && file_exists($_rawMail))
{ {
$subject = mail_bo::adaptSubjectForImport($_subject); $subject = mail_bo::adaptSubjectForImport($_subject);
$attachment_file =tempnam($GLOBALS['egw_info']['server']['temp_dir'],$GLOBALS['egw_info']['flags']['currentapp']."_");
$tmpfile = fopen($attachment_file,'w');
fseek($_rawMail, 0, SEEK_SET);
stream_copy_to_stream($_rawMail, $tmpfile);
fclose($tmpfile);
$size = filesize($attachment_file);
$attachments[] = array( $attachments[] = array(
'name' => trim($subject).'.eml', 'name' => trim($subject).'.eml',
'mimeType' => 'message/rfc822', 'mimeType' => 'message/rfc822',
'type' => 'message/rfc822', 'type' => 'message/rfc822',
'tmp_name' => $attachment_file, 'tmp_name' => $_rawMail,
'size' => $size, 'size' => filesize($_rawMail),
); );
} }
@ -203,7 +197,7 @@ class mail_integration {
$mo = mail_bo::getInstance(true,$icServerID); $mo = mail_bo::getInstance(true,$icServerID);
$mo->openConnection(); $mo->openConnection();
$mo->reopen($mailbox); $mo->reopen($mailbox);
// ToDo check $partid
$mailcontent = mail_bo::get_mailcontent($mo,$uid,$partid,$mailbox,false,true,(!($GLOBALS['egw_info']['user']['preferences'][$sessionLocation]['saveAsOptions']==='text_only'))); $mailcontent = mail_bo::get_mailcontent($mo,$uid,$partid,$mailbox,false,true,(!($GLOBALS['egw_info']['user']['preferences'][$sessionLocation]['saveAsOptions']==='text_only')));
// this one adds the mail itself (as message/rfc822 (.eml) file) to the app as additional attachment // this one adds the mail itself (as message/rfc822 (.eml) file) to the app as additional attachment
// this is done to have a simple archive functionality (ToDo: opening .eml in email module) // this is done to have a simple archive functionality (ToDo: opening .eml in email module)