Initial commit

This commit is contained in:
Christoph Haas 2017-04-04 15:28:10 +02:00
commit cdf612f0c5
2 changed files with 110 additions and 0 deletions

86
js/origrcv.js Normal file
View File

@ -0,0 +1,86 @@
Ext.namespace('Zarafa.plugins.origrcv');
/**
* @class Zarafa.plugins.origrcv.OrigRcvPlugin
* @extends Zarafa.core.Plugin
*/
Zarafa.plugins.origrcv.OrigRcvPlugin = Ext.extend(Zarafa.core.Plugin, {
/*
* Called after constructor.
* Registers insertion points.
* @protected
*/
initPlugin: function() {
Zarafa.plugins.origrcv.OrigRcvPlugin.superclass.initPlugin.apply(this, arguments);
// Insertion point which shows the original to header
this.registerInsertionPoint('previewpanel.toolbar.detaillinks', this.showOriginalReceiver, this);
},
/**
* Displays Original To: header information in the previewpanel
*
* @return {Object} a box which on record update displays to header
*/
showOriginalReceiver: function() {
return {
xtype: 'label',
style: 'width: 99%;',
plugins: ['zarafa.recordcomponentupdaterplugin'],
scope: this,
update: this.onMailDataOpen,
};
},
/**
* Function which displays information in the previewpanel.
*
* @param {Zarafa.core.data.IPMRecord} record record which is displayed
* @param {Boolean} contentReset force the component to perform a full update of the data.
*/
onMailDataOpen: function(record, resetContent) {
// Set label to empty value by default, to override previous S/MIME message text
this.setText("");
this.hide();
if (record.opened) {
var toRegex = /^To\s*:\s*(.*)$/igm; // parse "to" header
var headers = record.get('transport_message_headers');
var toMatches = toRegex.exec(headers);
if (toMatches.length == 2 && toMatches[1] != "") {
var addrListRegex = /\b[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,6}\b/ig; // split email address list
var emailAddresses = [];
var emailAddress;
while ((emailAddress = addrListRegex.exec(toMatches[1])) != null) {
if (emailAddresses.indexOf(emailAddress[0]) == -1) {
emailAddresses.push(emailAddress[0]);
}
}
// only display if receiver addresses differ
if (emailAddresses.length == 1 && !(emailAddresses[0] == record.get('display_to') || emailAddresses[0] == record.get('received_by_email_address'))) {
this.setText("Original To: " + emailAddresses[0]);
this.show();
} else if (emailAddresses.length > 1) {
var addressList = "";
for (var i = 0; i < emailAddresses.length; i++) {
if (i != 0) addressList += ", ";
addressList += emailAddresses[i];
}
this.setText("Original To: " + addressList);
this.show();
}
}
}
},
});
// PLUGIN ENTRY POINT
Zarafa.onReady(function() {
container.registerPlugin(new Zarafa.core.PluginMetaData({
name: 'origrcv',
displayName: _('Original Receiver Plugin'),
pluginConstructor: Zarafa.plugins.origrcv.OrigRcvPlugin
}));
});

24
manifest.xml Normal file
View File

@ -0,0 +1,24 @@
<?xml version="1.0"?>
<!DOCTYPE plugin SYSTEM "manifest.dtd">
<plugin version="2">
<info>
<version>0.0.1</version>
<name>origrcv</name>
<title>Original Receiver Plugin</title>
<author>Christoph Haas</author>
<authorURL>http://www.sprinternet.at</authorURL>
<description>Display original receiver address</description>
</info>
<components>
<component>
<files>
<client>
<clientfile load="release">js/origrcv.js</clientfile>
<clientfile load="debug">js/origrcv.js</clientfile>
<clientfile load="source">js/origrcv.js</clientfile>
</client>
</files>
</component>
</components>
</plugin>