mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 06:30:59 +01:00
More WIP mail message integration:
- Make integrate function a static function - Implement infolog, tracker and calendar save as buttons in mail compose with open popup - Fix Date and Max_line_Chars in mail_integration
This commit is contained in:
parent
23000b1ff7
commit
c0097b3860
@ -864,7 +864,10 @@ END:VALARM';
|
||||
*/
|
||||
public static function mail_import($args)
|
||||
{
|
||||
return 'calendar.calendar_uiforms.mail_import';
|
||||
return array (
|
||||
'menuaction' => 'calendar.calendar_uiforms.mail_import',
|
||||
'popup' => egw_link::get_registry('calendar', 'edit_popup')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@ class calendar_uiforms extends calendar_ui
|
||||
'import' => true,
|
||||
'cat_acl' => true,
|
||||
'meeting' => true,
|
||||
'mail_import' => true,
|
||||
);
|
||||
|
||||
/**
|
||||
@ -2566,11 +2567,19 @@ class calendar_uiforms extends calendar_ui
|
||||
/**
|
||||
* imports a mail as Calendar
|
||||
*
|
||||
* @param array $mailContent mail content
|
||||
* @param array $mailContent = null mail content
|
||||
* @return array
|
||||
*/
|
||||
function mail_import($mailContent)
|
||||
function mail_import(array $mailContent=null)
|
||||
{
|
||||
// It would get called from compose as a popup with egw_data
|
||||
if (!is_array($mailContent) && ($_GET['egw_data']))
|
||||
{
|
||||
// get raw mail data
|
||||
egw_link::get_data ($_GET['egw_data']);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_array($mailContent))
|
||||
{
|
||||
|
||||
|
@ -566,6 +566,9 @@ class infolog_hooks
|
||||
*/
|
||||
public static function mail_import($args)
|
||||
{
|
||||
return 'infolog.infolog_ui.mail_import';
|
||||
return array (
|
||||
'menuaction' => 'infolog.infolog_ui.mail_import',
|
||||
'popup' => egw_link::get_registry('infolog', 'edit_popup')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ class infolog_ui
|
||||
'admin' => True,
|
||||
'hook_view' => True,
|
||||
'writeLangFile' => True,
|
||||
'mail_import' => True
|
||||
);
|
||||
/**
|
||||
* reference to the infolog preferences of the user
|
||||
@ -2487,12 +2488,20 @@ class infolog_ui
|
||||
/**
|
||||
* imports a mail as infolog
|
||||
*
|
||||
* @data string $_data registered hook data
|
||||
* @param array $mailContent = null content of mail
|
||||
* @return array
|
||||
*/
|
||||
function mail_import($mailContent)
|
||||
function mail_import(array $mailContent=null)
|
||||
{
|
||||
$this->edit($this->bo->import_mail($mailContent['addresses'],
|
||||
// It would get called from compose as a popup with egw_data
|
||||
if (!is_array($mailContent) && ($_GET['egw_data']))
|
||||
{
|
||||
// get the mail raw data
|
||||
egw_link::get_data ($_GET['egw_data']);
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->edit($this->bo->import_mail($mailContent['addresses'],
|
||||
$mailContent['subject'],
|
||||
$mailContent['message'],
|
||||
$mailContent['attachments'],
|
||||
|
@ -163,6 +163,14 @@ class mail_compose
|
||||
'hint' => 'check to save as trackerentry on send',
|
||||
'onExecute' => 'javaScript:app.mail.compose_setToggle'
|
||||
),
|
||||
'to_calendar' => array(
|
||||
'caption' => 'Calendar',
|
||||
'icon' => 'to_calendar',
|
||||
'group' => $group,
|
||||
'checkbox' => true,
|
||||
'hint' => 'check to save as calendar event on send',
|
||||
'onExecute' => 'javaScript:app.mail.compose_setToggle'
|
||||
),
|
||||
'disposition' => array(
|
||||
'caption' => 'Notification',
|
||||
'icon' => 'high',
|
||||
@ -3047,41 +3055,35 @@ class mail_compose
|
||||
if (is_array($this->sessionData['cc'])) $mailaddresses['cc'] = $this->sessionData['cc'];
|
||||
if (is_array($this->sessionData['bcc'])) $mailaddresses['bcc'] = $this->sessionData['bcc'];
|
||||
if (!empty($mailaddresses)) $mailaddresses['from'] = $GLOBALS['egw']->translation->decodeMailHeader($fromAddress);
|
||||
// attention: we dont return from infolog/tracker. You cannot check both. cleanups will be done there.
|
||||
if ($_formData['to_infolog'] == 'on') {
|
||||
$uiinfolog = new infolog_ui();
|
||||
$uiinfolog->import_mail(
|
||||
$mailaddresses,
|
||||
$this->sessionData['subject'],
|
||||
$this->convertHTMLToText($this->sessionData['body']),
|
||||
$this->sessionData['attachments'],
|
||||
false, // date
|
||||
$mail->getRaw()
|
||||
);
|
||||
}
|
||||
if ($_formData['to_tracker'] == 'on') {
|
||||
$uitracker = new tracker_ui();
|
||||
$uitracker->import_mail(
|
||||
$mailaddresses,
|
||||
$this->sessionData['subject'],
|
||||
$this->convertHTMLToText($this->sessionData['body']),
|
||||
$this->sessionData['attachments'],
|
||||
false, // date
|
||||
$mail->getRaw()
|
||||
);
|
||||
}
|
||||
/*
|
||||
if ($_formData['to_calendar'] == 'on') {
|
||||
$uical =& CreateObject('calendar.calendar_uiforms');
|
||||
$uical->import_mail(
|
||||
$mailaddresses,
|
||||
$this->sessionData['subject'],
|
||||
$this->convertHTMLToText($this->sessionData['body']),
|
||||
$this->sessionData['attachments']
|
||||
);
|
||||
}
|
||||
*/
|
||||
|
||||
if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' )
|
||||
{
|
||||
foreach(array('to_infolog','to_tracker','to_calendar') as $app_key)
|
||||
{
|
||||
if ($_formData[$app_key] == 'on')
|
||||
{
|
||||
$app_name = substr($app_key,3);
|
||||
// Get registered hook data of the app called for integration
|
||||
$hook = $GLOBALS['egw']->hooks->single(array('location'=> 'mail_import'),$app_name);
|
||||
|
||||
// Open the app called for integration in a popup
|
||||
// and store the mail raw data as egw_data, in order to
|
||||
// be stored from registered app method later
|
||||
egw_framework::popup(egw::link('/index.php', array(
|
||||
'menuaction' => $hook['menuaction'],
|
||||
'egw_data' => egw_link::set_data(null,'mail_integration::integrate',array(
|
||||
$app_name,
|
||||
$mailaddresses,
|
||||
$this->sessionData['subject'],
|
||||
$this->convertHTMLToText($this->sessionData['body']),
|
||||
$this->sessionData['attachments'],
|
||||
false, // date
|
||||
$mail->getRaw()),true)
|
||||
)),'_blank',$hook['popup']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(is_array($this->sessionData['attachments'])) {
|
||||
foreach($this->sessionData['attachments'] as $value) {
|
||||
|
@ -25,6 +25,13 @@ class mail_integration {
|
||||
'integrate' => true
|
||||
);
|
||||
|
||||
/**
|
||||
* Maximum number of line characters (-_+=~) allowed in a mail, to not stall the layout.
|
||||
* Longer lines / biger number of these chars are truncated to that max. number or chars.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const MAX_LINE_CHARS = 40;
|
||||
|
||||
/**
|
||||
* Gets requested mail information and sets them as data link
|
||||
@ -52,13 +59,17 @@ class mail_integration {
|
||||
* @param string $_rawMail
|
||||
* @throws egw_exception_assertion_failed
|
||||
*/
|
||||
function integrate ($_app='',$_to_emailAddress=false,$_subject=false,$_body=false,$_attachments=false,$_date=false,$_rawMail=null,$_icServerID=null)
|
||||
public static function integrate ($_app='',$_to_emailAddress=false,$_subject=false,$_body=false,$_attachments=false,$_date=false,$_rawMail=null,$_icServerID=null)
|
||||
{
|
||||
// App name which is called for integration
|
||||
$app = !empty($_GET['app'])? $_GET['app']:$_app;
|
||||
|
||||
// Set the date
|
||||
if (!$_date) $_date = $this->bo->user_time_now;
|
||||
if (!$_date)
|
||||
{
|
||||
$time = time();
|
||||
$_date = egw_time::server2user($time->now,'ts');
|
||||
}
|
||||
|
||||
// Integrate not yet saved mail
|
||||
if (empty($_GET['rowid']) && $_to_emailAddress && $app)
|
||||
@ -233,11 +244,11 @@ class mail_integration {
|
||||
);
|
||||
}
|
||||
|
||||
// shorten long (> $this->max_line_chars) lines of "line" chars (-_+=~) in mails
|
||||
// shorten long (> self::max_line_chars) lines of "line" chars (-_+=~) in mails
|
||||
$data_message = preg_replace_callback(
|
||||
'/[-_+=~\.]{'.$this->max_line_chars.',}/m',
|
||||
'/[-_+=~\.]{'.self::MAX_LINE_CHARS.',}/m',
|
||||
function($matches) {
|
||||
return substr($matches[0],0,$this->max_line_chars);
|
||||
return substr($matches[0],0,self::MAX_LINE_CHARS);
|
||||
},
|
||||
$mailcontent['message']
|
||||
);
|
||||
@ -258,10 +269,10 @@ class mail_integration {
|
||||
|
||||
|
||||
// Get the registered hook method of requested app for integration
|
||||
$menuaction = $GLOBALS['egw']->hooks->single(array('location' => 'mail_import'),$app);
|
||||
$hook = $GLOBALS['egw']->hooks->single(array('location' => 'mail_import'),$app);
|
||||
|
||||
// Execute import mail with provided content
|
||||
ExecMethod($menuaction,array (
|
||||
ExecMethod($hook['menuaction'],array (
|
||||
'addresses' => $data_addresses,
|
||||
'attachments' => $data_attachments,
|
||||
'message' => $data_message,
|
||||
|
@ -10,6 +10,7 @@
|
||||
<file class="mail-compose_fileselector" statustext="Select file to attach to message" multiple='true' progress='attachments' onFinish="app.mail.uploadForCompose" onStart="app.mail.composeUploadStart" id="uploadForCompose" drop_target ="mail-compose"/>
|
||||
<checkbox statustext="check to save as infolog on send" id="to_infolog" options="on,off"/>
|
||||
<checkbox statustext="check to save as trackerentry on send" id="to_tracker" options="on,off"/>
|
||||
<checkbox statustext="check to save as calendar event on send" id="to_calendar" options="on,off"/>
|
||||
<checkbox statustext="check to recieve a notification when the message is read (note: not all clients support this and/or the reciever may not authorize the notification)" id="disposition" options="on,off"/>
|
||||
<menulist>
|
||||
<menupopup id="priority"/>
|
||||
|
Loading…
Reference in New Issue
Block a user