mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-08 00:54:15 +01:00
Implement mail integration check entry for mail compose
This commit is contained in:
parent
ce9ba4e2bc
commit
662f9594ea
@ -179,7 +179,8 @@ class mail_compose
|
||||
'group' => $group,
|
||||
'checkbox' => true,
|
||||
'hint' => 'check to save as trackerentry on send',
|
||||
'onExecute' => 'javaScript:app.mail.compose_setToggle'
|
||||
'onExecute' => 'javaScript:app.mail.compose_setToggle',
|
||||
'mail_import' => Api\Hooks::single(array('location' => 'mail_import'),'tracker'),
|
||||
),
|
||||
'to_calendar' => array(
|
||||
'caption' => 'Calendar',
|
||||
@ -3155,6 +3156,7 @@ class mail_compose
|
||||
{
|
||||
foreach(array('to_infolog','to_tracker','to_calendar') as $app_key)
|
||||
{
|
||||
$entryid = $_formData['to_integrate_ids'][0][$app_key];
|
||||
if ($_formData[$app_key] == 'on')
|
||||
{
|
||||
$app_name = substr($app_key,3);
|
||||
@ -3166,11 +3168,7 @@ class mail_compose
|
||||
$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
|
||||
// and store the mail raw data as egw_data, in order to
|
||||
// be stored from registered app method later
|
||||
Framework::popup(Egw::link('/index.php', array(
|
||||
$target = array(
|
||||
'menuaction' => $hook['menuaction'],
|
||||
'egw_data' => Link::set_data(null,'mail_integration::integrate',array(
|
||||
$mailaddresses,
|
||||
@ -3181,7 +3179,12 @@ class mail_compose
|
||||
$eml,
|
||||
$_formData['serverID']),true),
|
||||
'app' => $app_name
|
||||
)),'_blank',$hook['popup']);
|
||||
);
|
||||
if ($entryid) $target['entry_id'] = $entryid;
|
||||
// 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
|
||||
Framework::popup(Egw::link('/index.php', $target),'_blank',$hook['popup']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
166
mail/js/app.js
166
mail/js/app.js
@ -2860,8 +2860,6 @@ app.classes.mail = AppJS.extend(
|
||||
var app = _action.id;
|
||||
var w_h = ['750','580']; // define a default wxh if there's no popup size registered
|
||||
|
||||
var add_as_new = true;
|
||||
|
||||
if (typeof _action.data != 'undefined' )
|
||||
{
|
||||
if (typeof _action.data.popup != 'undefined' && _action.data.popup) w_h = _action.data.popup.split('x');
|
||||
@ -2887,61 +2885,13 @@ app.classes.mail = AppJS.extend(
|
||||
|
||||
var url = window.egw_webserverUrl+ '/index.php?menuaction=mail.mail_integration.integrate&rowid=' + _elems[0].id + '&app='+app;
|
||||
|
||||
/**
|
||||
* Checks the application entry existance and offers user
|
||||
* to select desire app id to append mail content into it,
|
||||
* or add the mail content as a new app entry
|
||||
*
|
||||
* @param {string} _title select app entry title
|
||||
* @param {string} _appName app to be integrated
|
||||
* @param {string} _appCheckCallback registered mail_import hook method
|
||||
* for check app entry existance
|
||||
*/
|
||||
check_app_entry = function (_title, _appName, _appCheckCallback)
|
||||
if (mail_import_hook && typeof mail_import_hook.app_entry_method != 'undefined')
|
||||
{
|
||||
var data = egw.dataGetUIDdata(_elems[0].id);
|
||||
var subject = (data && typeof data.data != 'undefined')? data.data.subject : '';
|
||||
egw.json(_appCheckCallback, subject,function(_entryId){
|
||||
|
||||
// if there's no entry saved already
|
||||
// open dialog in order to select one
|
||||
if (!_entryId)
|
||||
{
|
||||
var buttons = [
|
||||
{text: 'Append', id: 'append', image: 'check', default:true},
|
||||
{text: 'Add as new', id: 'new', image: 'check'},
|
||||
{text: 'Cancel', id: 'cancel', image: 'check'}
|
||||
];
|
||||
et2_createWidget("dialog",
|
||||
{
|
||||
callback: function(_buttons, _value)
|
||||
{
|
||||
if (_buttons == 'cancel') return;
|
||||
if (_buttons == 'append' && _value)
|
||||
{
|
||||
url += '&entry_id=' + _value.id;
|
||||
}
|
||||
egw_openWindowCentered(url,'import_mail_'+_elems[0].id,w_h[0],w_h[1]);
|
||||
},
|
||||
title: egw.lang(_title),
|
||||
buttons: buttons||et2_dialog.BUTTONS_OK_CANCEL,
|
||||
value:{
|
||||
content:{
|
||||
appName:_appName // appName to search on its list later
|
||||
}},
|
||||
template: egw.webserverUrl+'/mail/templates/default/integration_to_entry_dialog.xet'
|
||||
},et2_dialog._create_parent('mail'));
|
||||
}
|
||||
else // there is an entry saved related to this mail's subject
|
||||
{
|
||||
egw_openWindowCentered(url,'import_mail_'+_elems[0].id,w_h[0],w_h[1]);
|
||||
}
|
||||
},this,true,this).sendRequest();
|
||||
};
|
||||
|
||||
if (mail_import_hook && typeof mail_import_hook.app_entry_method != 'undefined')
|
||||
{
|
||||
check_app_entry('Select '+ app + ' entry', app, mail_import_hook.app_entry_method);
|
||||
this.integrate_checkAppEntry('Select '+ app + ' entry', app, subject, url, mail_import_hook.app_entry_method, function (args){
|
||||
egw_openWindowCentered(args.url+ (args.entryid ?'&entry_id=' + args.entryid: ''),'import_mail_'+_elems[0].id,w_h[0],w_h[1]);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2950,6 +2900,60 @@ app.classes.mail = AppJS.extend(
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks the application entry existance and offers user
|
||||
* to select desire app id to append mail content into it,
|
||||
* or add the mail content as a new app entry
|
||||
*
|
||||
* @param {string} _title select app entry title
|
||||
* @param {string} _appName app to be integrated
|
||||
* @param {string} _subject
|
||||
* @param {string} _url
|
||||
* @param {string} _appCheckCallback registered mail_import hook method
|
||||
* @param {function} _execCallback function to get called on dialog actions
|
||||
*/
|
||||
integrate_checkAppEntry: function (_title, _appName, _subject ,_url, _appCheckCallback, _execCallback)
|
||||
{
|
||||
var subject = _subject || '';
|
||||
var execCallback = _execCallback;
|
||||
egw.json(_appCheckCallback, subject,function(_entryId){
|
||||
|
||||
// if there's no entry saved already
|
||||
// open dialog in order to select one
|
||||
if (!_entryId)
|
||||
{
|
||||
var buttons = [
|
||||
{text: 'Append', id: 'append', image: 'check', default:true},
|
||||
{text: 'Add as new', id: 'new', image: 'check'},
|
||||
{text: 'Cancel', id: 'cancel', image: 'check'}
|
||||
];
|
||||
et2_createWidget("dialog",
|
||||
{
|
||||
callback: function(_buttons, _value)
|
||||
{
|
||||
if (_buttons == 'cancel') return;
|
||||
if (_buttons == 'append' && _value)
|
||||
{
|
||||
_entryId = _value.id;
|
||||
}
|
||||
execCallback.call(this,{entryid:_entryId,url:_url});
|
||||
},
|
||||
title: egw.lang(_title),
|
||||
buttons: buttons||et2_dialog.BUTTONS_OK_CANCEL,
|
||||
value:{
|
||||
content:{
|
||||
appName:_appName // appName to search on its list later
|
||||
}},
|
||||
template: egw.webserverUrl+'/mail/templates/default/integration_to_entry_dialog.xet'
|
||||
},et2_dialog._create_parent('mail'));
|
||||
}
|
||||
else // there is an entry saved related to this mail's subject
|
||||
{
|
||||
execCallback.call(this,{entryid:_entryId,url:_url});
|
||||
}
|
||||
},this,true,this).sendRequest();
|
||||
},
|
||||
|
||||
/**
|
||||
* mail_getFormData
|
||||
*
|
||||
@ -4977,10 +4981,13 @@ app.classes.mail = AppJS.extend(
|
||||
/**
|
||||
* Set the relevant widget to toolbar actions and submit
|
||||
*
|
||||
* @param {type} _action toolbar action
|
||||
* @param {object|boolean} _action toolbar action or boolean value to stop extra call on
|
||||
* compose_integrated_submit
|
||||
*/
|
||||
compose_submitAction: function (_action)
|
||||
{
|
||||
if (this.compose_integrate_submit() && _action) return false;
|
||||
|
||||
if (this.mailvelope_editor)
|
||||
{
|
||||
var self = this;
|
||||
@ -5002,6 +5009,55 @@ app.classes.mail = AppJS.extend(
|
||||
this.et2._inst.submit(null,null,true);
|
||||
},
|
||||
|
||||
/**
|
||||
* This function runs before client submit (send) mail to server
|
||||
* and takes care of mail integration modules to popup entry selection
|
||||
* dialog to give user a choice to which entry of selected app the compose
|
||||
* should be integereated.
|
||||
*
|
||||
* @returns {Boolean} return true if to_tracker is checked otherwise false
|
||||
*/
|
||||
compose_integrate_submit: function (_integIndex)
|
||||
{
|
||||
if (_integIndex == false) return false;
|
||||
var index = _integIndex || 0;
|
||||
var integApps = ['to_tracker', 'to_infolog', 'to_calendar'];
|
||||
var subject = this.et2.getWidgetById('subject');
|
||||
var toolbar = this.et2.getWidgetById('composeToolbar');
|
||||
var to_integrate_ids = this.et2.getWidgetById('to_integrate_ids');
|
||||
var integWidget= {};
|
||||
var self = this;
|
||||
|
||||
integWidget = this.et2.getWidgetById(integApps[index]);
|
||||
if (toolbar.options.actions[integApps[index]] &&
|
||||
typeof toolbar.options.actions[integApps[index]]['mail_import'] != 'undefined' &&
|
||||
typeof toolbar.options.actions[integApps[index]]['mail_import']['app_entry_method'] != 'unefined')
|
||||
{
|
||||
var mail_import_hook = toolbar.options.actions[integApps[index]]['mail_import']['app_entry_method'];
|
||||
if (integWidget.get_value() == 'on')
|
||||
{
|
||||
this.integrate_checkAppEntry(egw.lang('Select %1 entry',integApps[index]), integApps[index].substr(3), subject.get_value(), '', mail_import_hook , function (args){
|
||||
var value = {};
|
||||
value[integApps[index]] = args.entryid;
|
||||
var oldValue = to_integrate_ids.get_value()[0];
|
||||
to_integrate_ids.set_value(jQuery.extend(value,oldValue));
|
||||
index = index<integApps.length? ++index:false;
|
||||
self.compose_integrate_submit(index);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(index<integApps.length)
|
||||
{
|
||||
this.compose_integrate_submit(++index);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.compose_submitAction(false);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the selected checkbox action
|
||||
*
|
||||
|
@ -12,6 +12,7 @@
|
||||
<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"/>
|
||||
<taglist id="to_integrate_ids"/>
|
||||
<menulist>
|
||||
<menupopup id="priority"/>
|
||||
</menulist>
|
||||
|
Loading…
Reference in New Issue
Block a user