More improvemnts and new folderstructure

This commit is contained in:
2015-04-30 22:11:52 +02:00
parent 27e2886de8
commit b11f487816
24 changed files with 2 additions and 812 deletions

202
js/EmailTrackingPlugin.js Executable file
View File

@@ -0,0 +1,202 @@
Ext.namespace('Zarafa.plugins.emailtracking');
/**
* @class Zarafa.plugins.emailtracking.EmailTrackingPlugin
* @extends Zarafa.core.Plugin
*/
Zarafa.plugins.emailtracking.EmailTrackingPlugin = Ext.extend(Zarafa.core.Plugin, {
/*
* Called after constructor.
* Registers insertion points.
* @protected
*/
initPlugin : function()
{
Zarafa.plugins.emailtracking.EmailTrackingPlugin.superclass.initPlugin.apply(this, arguments);
// Tracking button in mailcreatecontentpanel
this.registerInsertionPoint('context.mail.mailcreatecontentpanel.toolbar.options', this.showTrackButton, this);
// Insertion point which shows the read status
this.registerInsertionPoint('previewpanel.toolbar.detaillinks', this.showTrackingInfo, this);
Zarafa.core.data.SharedComponentType.addProperty('plugin.emailtracking.ui.trackinginfopanel');
},
/**
* Displays Tracking information in the previewpanel
*
* @return {Object} a box which on record update displays Tracking information
*/
showTrackingInfo : function()
{
return {
xtype: 'button',
style: 'margin-top: 4px; border: 2px solid red;',
plugins : [ 'zarafa.recordcomponentupdaterplugin' ],
autoEl: {
tag: 'div',
ref: 'trackingInfoBox'
},
scope : this,
update : this.onTrackingInfo,
handler : this.onTrackingButton
};
},
/**
* Handler for the button which is displayed when a encrypted / signed message is openend
* When an encrypted message is opened, we will send a request to unlock the certificate.
* When an signed email is openend, we will show a popup with extra information about the signed message
*/
onTrackingButton: function(button, config)
{
var user = container.getUser();
container.getRequest().singleRequest(
'plugintrackingmodule',
'gettrackinglog',
{
'trackingid' : button.record.get("trackingcode"),
'user' : user.getSMTPAddress()
},
new Zarafa.plugins.emailtracking.data.ResponseHandler({
successCallback : this.onTrackingLogLoaded
})
);
},
onTrackingLogLoaded: function(response) {
if(response.status) {
Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType['plugin.emailtracking.ui.trackinginfopanel'], response, {
manager: Ext.WindowMgr
});
} else {
container.getNotifier().notify('info.saved', _('Error'), "No tracking log available!");
}
},
/**
* Function which displays information in the previewpanel.
* In the case of a encrypted message, we either show a button to unlock the certificate
* or shows the message that the message has been decrypted.
* If the message is signed we display information depending on the state of the verification.
*
* @param {Zarafa.core.data.IPMRecord} record record which is displayed
* @param {Boolean} contentReset force the component to perform a full update of the data.
*/
onTrackingInfo : function(record, resetContent) {
// Set button.record for use in onSmimeButton
this.record = record;
var infoBox = this.getEl();
// Set smimeBox to empty value by default, to override previous S/MIME message text
infoBox.update("");
if (this.record.opened) {
// get the tracking code from the body
var body = this.record.getBody(true);
var trackingRegex = /(?:^|.*)track.php\?img=(.*?)(?:\"|\s|$)/g;
var match = trackingRegex.exec(body);
if(match) {
infoBox.update("This message is getting tracked (" + match[1] + ")");
infoBox.show();
this.record.set("trackingcode", match[1]);
}
} else {
infoBox.hide();
}
},
/**
* Create button which adds some tracking specials to the mail content.
*
* @return {Config} creates a button for tracking email
*/
showTrackButton : function()
{
return {
xtype : 'button',
text : _('Track'),
tooltip: {
title: _('Track message'),
text: _('Track this message and get detailed information about the current status.')
},
iconCls : 'icon_tracking_off',
handler : this.onTrackButton,
scope : this
};
},
/**
* Handler for the sign button, when clicked it checks if the private certificate exists.
* If we have signing already set and click it again, we unset it.
* If we already set have encryption set, we set a special message_class for both sign+ecnrypt.
*
*
* @param {Ext.button} button
* @param {Object} config
*/
onTrackButton : function(button, config)
{
var owner = button.ownerCt;
var record = owner.record;
var doTrack = button.iconCls === "icon_tracking_on" ? false : true;
if(record && doTrack) {
button.setIconClass('icon_tracking_on');
record.set('message_class', 'IPM.Note.Tracking');
record.set('entryid', record.entryid);
} else {
record.set('message_class', 'IPM.Note');
button.setIconClass('icon_tracking_off');
}
owner.dialog.saveRecord();
},
/*
* Bid for the type of shared component
* and the given record.
* This will bid on calendar.dialogs.importevents
* @param {Zarafa.core.data.SharedComponentType} type Type of component a context can bid for.
* @param {Zarafa.mail.dialogs.MailCreateContentPanel} owner Optionally passed panel
* @return {Number} The bid for the shared component
*/
bidSharedComponent : function(type, record) {
var bid = -1;
switch(type) {
case Zarafa.core.data.SharedComponentType['plugin.emailtracking.ui.trackinginfopanel']:
bid = 1;
break;
}
return bid;
},
/**
* Will return the reference to the shared component.
* Based on the type of component requested a component is returned.
* @param {Zarafa.core.data.SharedComponentType} type Type of component a context can bid for.
* @param {Zarafa.mail.dialogs.MailCreateContentPanel} owner Optionally passed panel
* @return {Ext.Component} Component
*/
getSharedComponent : function(type, record) {
var component;
switch(type) {
case Zarafa.core.data.SharedComponentType['plugin.emailtracking.ui.trackinginfopanel']:
component = Zarafa.plugins.emailtracking.ui.TrackingInfoPanel;
break;
}
return component;
}
});
Zarafa.onReady(function() {
container.registerPlugin(new Zarafa.core.PluginMetaData({
name : 'emailtracking',
displayName : _('Tracking Plugin'),
pluginConstructor : Zarafa.plugins.emailtracking.EmailTrackingPlugin
}));
});

25
js/data/ResponseHandler.js Executable file
View File

@@ -0,0 +1,25 @@
Ext.namespace('Zarafa.plugins.emailtracking.data');
/**
* @class Zarafa.plugins.emailtracking.data.ResponseHandler
* @extends Zarafa.core.data.AbstractResponseHandler
*
* Emailtracking specific response handler.
*/
Zarafa.plugins.emailtracking.data.ResponseHandler = Ext.extend(Zarafa.core.data.AbstractResponseHandler, {
/**
* @cfg {Function} successCallback The function which
* will be called after success request.
*/
successCallback : null,
/**
* @param {Object} response Object contained the response data.
*/
doGettrackinglog : function(response) {
this.successCallback(response);
}
});
Ext.reg('emailtracking.responsehandler', Zarafa.plugins.emailtracking.data.ResponseHandler);

116
js/ui/TrackingInfoPanel.js Executable file
View File

@@ -0,0 +1,116 @@
Ext.namespace('Zarafa.plugins.emailtracking.ui');
/**
* @class Zarafa.plugins.emailtracking.ui.TrackingInfoPanel
* @extends Zarafa.core.ui.ContentPanel
*
* Show the tracking table.
* @xtype emailtracking.trackinginfopanel
*/
Zarafa.plugins.emailtracking.ui.TrackingInfoPanel = Ext.extend(Zarafa.core.ui.ContentPanel, {
/**
* @var object The server response
*/
record : null,
store: null,
/**
* @constructor
* @param config Configuration structure
*/
constructor : function(config) {
config = config || {};
// fill the store
// create the data store
this.store = new Ext.data.ArrayStore({
fields: [
{name: 'ip'},
{name: 'timestamp', type: 'date'},
{name: 'referrer'},
{name: 'client'},
{name: 'tracking_type'}
]
});
var data = [];
var internals = container.getSettingsModel().get('zarafa/v1/plugins/emailtracking/internals');
Ext.each(config.record.log, function(rec) {
// hide entries from the own system (only external tracking will be possible!)
if(internals || (rec.referrer != window.location.href)) {
data.push([rec.ip_addr, rec.timestamp, rec.referrer, rec.client, rec.tracking_type]);
}
});
this.store.loadData(data);
Ext.applyIf(config, {
layout : 'fit',
title : _('Tracking information'),
closeOnSave : true,
width : 340,
height : 300,
//Add panel
items : [{
xtype: "grid",
style: 'margin-top:20px;',
store: this.store,
columns: [
{
header : 'IP Address',
width : 75,
sortable : true,
dataIndex: 'ip'
},
{
id : "timestamp",
header : 'Date',
width : 75,
sortable : true,
renderer : Ext.util.Format.dateRenderer('m/d/Y H:m:s'),
dataIndex: 'timestamp'
},
{
header : 'Referrer',
width : 150,
hidden : true,
sortable : true,
dataIndex: 'referrer'
},
{
header : 'Client',
width : 150,
hidden : true,
sortable : true,
dataIndex: 'client'
},
{
header : 'Type',
width : 60,
hidden : true,
sortable : true,
dataIndex: 'tracking_type'
}
],
viewConfig: {
forceFit: true
},
sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
frame: true
},{
xtype: 'button',
text: _('Close'),
handler: this.close,
scope: this
}]
});
Zarafa.plugins.emailtracking.ui.TrackingInfoPanel.superclass.constructor.call(this, config);
}
});
Ext.reg('emailtracking.trackinginfopanel' ,Zarafa.plugins.emailtracking.ui.TrackingInfoPanel);