Implement mail integration to an existing ticket

This commit is contained in:
Hadi Nategh 2015-04-20 14:31:21 +00:00
parent 495d6d3599
commit 53363be626
6 changed files with 91 additions and 9 deletions

View File

@ -50,6 +50,7 @@ class mail_integration {
* 'message' => string,
* 'date' => string,
* 'subject' => string,
* 'entry_id => string // Id of the app entry which mail content will append to
* )
*
* @param string $_to_emailAddress
@ -66,6 +67,9 @@ class mail_integration {
// App name which is called for integration
$app = isset($GLOBALS['egw_info']['user']['apps'][$_GET['app']])? $_GET['app'] : null;
// preset app entry id, selected by user from app_entry_dialog
$app_entry_id = $_GET['entry_id'];
// Set the date
if (!$_date)
{
@ -276,7 +280,8 @@ class mail_integration {
'attachments' => $data_attachments,
'message' => $data_message,
'date' => $mailcontent['date'],
'subject' => $mailcontent['subject']
'subject' => $mailcontent['subject'],
'entry_id' => $app_entry_id
));
}
}

View File

@ -1249,6 +1249,7 @@ class mail_ui
'icon' => 'tracker/navbar',
'onExecute' => 'javaScript:app.mail.mail_integrate',
'popup' => egw_link::get_registry('tracker', 'add_popup'),
'mail_import' => $GLOBALS['egw']->hooks->single(array('location' => 'mail_import'),'tracker'),
'allowOnMultiple' => false,
),
'calendar' => array(

View File

@ -2624,14 +2624,14 @@ app.classes.mail = AppJS.extend(
mail_integrate: function(_action, _elems)
{
var app = _action.id;
var w_h = ['750','580']; // define a default wxh if there's no popup size registered
if (typeof _action.data != 'undefined' && typeof _action.data.popup != 'undefined')
var add_as_new = true;
if (typeof _action.data != 'undefined' )
{
w_h = _action.data.popup.split('x');
}
else // define a default wxh if there's no popup size registered
{
var w_h = ['750','580'];
if (typeof _action.data.popup != 'undefined') w_h = _action.data.popup.split('x');
if (typeof _action.data.mail_import != 'undefined') var mail_import_hook = _action.data.mail_import;
}
if (typeof _elems == 'undefined' || _elems.length==0)
@ -2650,8 +2650,70 @@ app.classes.mail = AppJS.extend(
}
}
}
var url = window.egw_webserverUrl+ '/index.php?menuaction=mail.mail_integration.integrate&rowid=' + _elems[0].id + '&app='+app;
egw_openWindowCentered(url,'import_mail_'+_elems[0].id,w_h[0],w_h[1]);
/**
* 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)
{
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);
}
else
{
egw_openWindowCentered(url,'import_mail_'+_elems[0].id,w_h[0],w_h[1]);
}
},
/**

View File

@ -370,6 +370,7 @@ saving of message %1 failed. destination folder %2 does not exist. mail de Speic
saving of message %1 succeeded. check folder %2. mail de Speichern der Nachricht %1 war erfolgreich. Prüfen Sie den Ziel Ordner %2
saving the rule failed: mail de Speichern der Regel ist fehlgeschlagen:
select all mail de Alle Auswählen
select an existing entry in order to append mail content to it mail de Bestehendes Ticket auswählen, zu dem die Mail als Kommentar hinzugefügt werden soll.
select file to attach to message mail de Wählen Sie die Dateien aus, die Sie an diese Nachricht anhängen möchten.
select file to import into folder mail de Wählen Sie ein E-Mail als Datei aus, damit Sie in ein Ordner importiert werden kann.
select file(s) from vfs mail de Dateien aus dem EGroupware Dateimanager anhängen.

View File

@ -370,6 +370,7 @@ saving of message %1 failed. destination folder %2 does not exist. mail en Savin
saving of message %1 succeeded. check folder %2. mail en Saving of message %1 succeeded. Check Folder %2.
saving the rule failed: mail en Saving the rule failed:
select all mail en Select all
select an existing entry in order to append mail content to it mail en Select an existing entry in order to append mail content to it
select file to attach to message mail en Select file to attach to message
select file to import into folder mail en Select file to import into Folder
select file(s) from vfs mail en Select file(s) from VFS

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE overlay PUBLIC "-//Stylite AG//eTemplate 2//EN" "http://www.egroupware.org/etemplate2.dtd">
<!-- $Id$ -->
<overlay>
<template id="mail.integration_to_entry_dialog" template="" lang="" group="0" version="1.9.001">
<vbox width="100%">
<description value="Select an existing entry in order to append mail content to it"/>
<description/>
<link-entry id="id" only_app="@appName" class="et2_fullWidth"/>
</vbox>
</template>
</overlay>