Add sieve rules to mail application

This commit is contained in:
Hadi Nategh 2013-07-25 15:35:44 +00:00
parent 36eae09fe0
commit 3c23bd0dfb
4 changed files with 1302 additions and 98 deletions

View File

@ -689,6 +689,7 @@ class mail_hooks
'admin' => False,
'default'=> 'text',
),
'add_popup' => '600x425',
);
if (!$GLOBALS['egw_info']['apps']['stylite']) unset($settingsArray['attachVCardAtCompose']);
return $settingsArray;
@ -734,7 +735,7 @@ class mail_hooks
$mailPreferences =& $mail_bo->mailPreferences;
$file['Preferences'] = egw::link('/index.php','menuaction=preferences.preferences_settings.index&appname=' . $appname);
/*
if($mailPreferences->userDefinedAccounts) {
$linkData = array
(
@ -751,12 +752,12 @@ class mail_hooks
if($icServer->enableSieve) {
if(empty($mailPreferences->preferences['prefpreventeditfilterrules']) || $mailPreferences->preferences['prefpreventeditfilterrules'] == 0)
$file['filter rules'] = egw::link('/index.php', 'menuaction=mail.uisieve.listRules');
$file['filter rules'] = egw::link('/index.php', 'menuaction=mail.mail_sieve.index');
if(empty($mailPreferences->preferences['prefpreventabsentnotice']) || $mailPreferences->preferences['prefpreventabsentnotice'] == 0)
$file['vacation notice'] = egw::link('/index.php','menuaction=mail.uisieve.editVacation');
$file['vacation notice'] = egw::link('/index.php','menuaction=mail.mail_sieve.editVacation');
}
}
*/
//Do not modify below this line
display_section($appname,$title,$file);
}
@ -878,7 +879,7 @@ class mail_hooks
*/
display_sidebox($appname,$menu_title,$file);
unset($file);
/*
$menu_title = lang('Sieve');
if (is_object($preferences)) $icServer = $preferences->getIncomingServer($profileID);
if(($icServer instanceof defaultimap)) {
@ -886,14 +887,14 @@ class mail_hooks
{
$linkData = array
(
'menuaction' => 'mail.uisieve.listRules',
'menuaction' => 'mail.mail_sieve.index',
);
if(empty($preferences->preferences['prefpreventeditfilterrules']) || $preferences->preferences['prefpreventeditfilterrules'] == 0)
$file['filter rules'] = egw::link('/index.php',$linkData);
$linkData = array
(
'menuaction' => 'mail.uisieve.editVacation',
'menuaction' => 'mail.mail_sieve.editVacation',
);
if(empty($preferences->preferences['prefpreventabsentnotice']) || $preferences->preferences['prefpreventabsentnotice'] == 0)
{
@ -902,13 +903,13 @@ class mail_hooks
if((empty($preferences->preferences['prefpreventnotificationformailviaemail']) ||
$preferences->preferences['prefpreventnotificationformailviaemail'] == 0))
{
$file['email notification'] = egw::link('/index.php','menuaction=mail.uisieve.editEmailNotification'); //Added email notifications
$file['email notification'] = egw::link('/index.php','menuaction=mail.mail_sieve.editEmailNotification'); //Added email notifications
}
if (count($file)) display_sidebox($appname,$menu_title,$file);
unset($file);
}
}
*/
}
if ($GLOBALS['egw_info']['user']['apps']['admin'])

View File

@ -17,7 +17,7 @@ app.mail = AppJS.extend(
et2: null,
doStatus: null,
mail_doTimedRefresh: false,
mail_refreshTimeOut: 1000*60*3, // initial call
mail_queuedFolders: [],
mail_queuedFoldersIndex: 0,
@ -25,22 +25,22 @@ app.mail = AppJS.extend(
mail_selectedMails: [],
mail_currentlyFocussed: '',
mail_previewAreaActive: true, // we start with the area active
/**
* Initialize javascript for this application
*
*
* @memberOf app.mail
*/
init: function() {
this._super.apply(this,arguments);
window.register_app_refresh("mail", this.app_refresh);
this.mail_startTimerFolderStatusUpdate(this.mail_refreshTimeOut);
//inital call of refresh folderstatus
var self = this;
window.setTimeout(function() {self.mail_refreshFolderStatus.apply(self);},1000);
},
/**
* Destructor
*/
@ -50,7 +50,7 @@ app.mail = AppJS.extend(
// call parent
this._super.apply(this, arguments);
},
/**
* This function is called when the etemplate2 object is loaded
* and ready. If you must store a reference to the et2 object,
@ -76,7 +76,7 @@ app.mail = AppJS.extend(
/**
* mail_fetchCurrentlyFocussed - implementation to decide wich mail of all the selected ones is the current
*
*
* @param _selected array of the selected mails
* @param _reset bool - tell the function to reset the global vars used
*/
@ -111,7 +111,7 @@ app.mail = AppJS.extend(
/**
* mail_open - implementation of the open action
*
*
* @param _action
* @param _senders - the representation of the elements(s) the action is to be performed on
* @param _mode - you may pass the mode. if not given view is used (tryastext|tryashtml are supported)
@ -133,10 +133,10 @@ app.mail = AppJS.extend(
h.document.title = subject;
});
},
/**
* Open a single message in html mode
*
*
* @param _action
* @param _elems _elems[0].id is the row-id
*/
@ -147,7 +147,7 @@ app.mail = AppJS.extend(
/**
* Open a single message in plain text mode
*
*
* @param _action
* @param _elems _elems[0].id is the row-id
*/
@ -158,7 +158,7 @@ app.mail = AppJS.extend(
/**
* Compose, reply or forward a message
*
*
* @param _action _action.id is 'compose', 'composeasnew', 'reply', 'reply_all' or 'forward' (forward can be multiple messages)
* @param _elems _elems[0].id is the row-id
*/
@ -235,7 +235,7 @@ app.mail = AppJS.extend(
/**
* Compose, reply or forward a message
*
*
* @param _url url to open
* @param forwardByCompose boolean to decide about the method
*/
@ -297,7 +297,7 @@ app.mail = AppJS.extend(
/**
* mail_disablePreviewArea - implementation of the disablePreviewArea action
*
*
* @param _value
*/
mail_disablePreviewArea: function(_value) {
@ -317,7 +317,7 @@ app.mail = AppJS.extend(
{
if (this.mail_previewAreaActive) splitter.dock();
this.mail_previewAreaActive = false;
}
}
else
{
if (!this.mail_previewAreaActive) splitter.undock();
@ -327,7 +327,7 @@ app.mail = AppJS.extend(
/**
* mail_preview - implementation of the preview action
*
*
* @param nextmatch et2_nextmatch The widget whose row was selected
* @param selected Array Selected row IDs. May be empty if user unselected all rows.
*/
@ -375,7 +375,7 @@ app.mail = AppJS.extend(
var IframeHandle = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById('messageIFRAME');
IframeHandle.set_value('');
},
/**
* mail_startTimerFolderStatusUpdate, timer functions, if the counter changes for the current folder
* refresh the message list
@ -398,10 +398,10 @@ app.mail = AppJS.extend(
}, _refreshTimeOut);
}
},
/**
* mail_refreshFolderStatus, function to call to read the counters of a folder and apply them
*
*
* @param _nodeID
* @param mode
*/
@ -415,7 +415,7 @@ app.mail = AppJS.extend(
try
{
var tree_wdg = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById('nm[foldertree]');
var activeFolders = tree_wdg.getTreeNodeOpenItems(nodeToRefresh,mode2use);
//alert(activeFolders.join('#,#'));
this.mail_queueRefreshFolderList(activeFolders);
@ -425,8 +425,8 @@ app.mail = AppJS.extend(
this.mail_refreshMessageGrid();
} catch(e) { } // ignore the error; maybe the template is not loaded yet
},
/**
* Queues a refreshFolderList request for 1ms. Actually this will just execute the
* code after the calling script has finished.
@ -435,7 +435,7 @@ app.mail = AppJS.extend(
{
this.mail_queuedFolders.push(_folders);
this.mail_queuedFoldersIndex++;
// Copy idx onto the anonymous function scope
var idx = this.mail_queuedFoldersIndex;
var self = this;
@ -445,13 +445,13 @@ app.mail = AppJS.extend(
//var folders = mail_queuedFolders.join(",");
self.mail_queuedFoldersIndex = 0;
self.mail_queuedFolders = [];
var request = new egw_json_request('mail.mail_ui.ajax_setFolderStatus',[_folders]);
request.sendRequest();
}
}, 10);
},
/**
* mail_setFolderStatus, function to set the status for the visible folders
*/
@ -459,7 +459,7 @@ app.mail = AppJS.extend(
var ftree = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById('nm[foldertree]');
for (var i in _status) ftree.setLabel(i,_status[i]);//alert(i +'->'+_status[i]);
},
/**
* mail_setLeaf, function to set the id and description for the folder given by status key
* @param array _status status array with the required data (new id, desc, old desc)
@ -544,12 +544,12 @@ app.mail = AppJS.extend(
var nm = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById('nm');
nm.applyFilters(); // this should refresh the active folder
},
/**
* Refresh given application _targetapp display of entry _app _id, incl. outputting _msg
*
*
* Default implementation here only reloads window with it's current url with an added msg=_msg attached
*
*
* @param string _msg message (already translated) to show, eg. 'Entry deleted'
* @param string _app application name
* @param string|int _id=null id of entry to refresh
@ -570,7 +570,7 @@ app.mail = AppJS.extend(
if (_app=='mail')
{
//we may want to trigger some actions, like modifying the grid, disable preview and stuff
// TODO: more actions
}
if (bufferExists)
@ -578,7 +578,7 @@ app.mail = AppJS.extend(
this.doStatus = window.setInterval("app.mail.mail_setMsg(myMessageBuffer);", 10000);
}
},
/**
* mail_getMsg - gets the current Message
* @return string
@ -592,7 +592,7 @@ app.mail = AppJS.extend(
}
return "";
},
/**
* mail_setMsg - sets a Message, with the msg container, and controls if the container is enabled/disabled
* @param string myMsg - the message
@ -606,7 +606,7 @@ app.mail = AppJS.extend(
msg_wdg.set_disabled(myMsg.trim().length==0);
}
},
/**
* Delete mails
* takes in all arguments
@ -664,7 +664,7 @@ app.mail = AppJS.extend(
/**
* UnDelete mailMessages
*
*
* @param _messageList
*/
mail_undeleteMessages: function(_messageList) {
@ -682,7 +682,7 @@ app.mail = AppJS.extend(
}
*/
},
/**
* mail_emptyTrash
*/
@ -691,7 +691,7 @@ app.mail = AppJS.extend(
var request = new egw_json_request('mail.mail_ui.ajax_emptyTrash');
request.sendRequest();
},
/**
* mail_compressFolder
*/
@ -700,7 +700,7 @@ app.mail = AppJS.extend(
var request = new egw_json_request('mail.mail_ui.ajax_compressFolder');
request.sendRequest();
},
/**
* mail_changeProfile
* @param folder, the ID of the selected Node -> should be an integer
@ -711,10 +711,10 @@ app.mail = AppJS.extend(
var request = new egw_json_request('mail.mail_ui.ajax_changeProfile',[folder]);
request.sendRequest(false);
this.mail_refreshMessageGrid();
return true;
},
/**
* mail_changeFolder
* @param folder, the ID of the selected Node
@ -742,7 +742,7 @@ app.mail = AppJS.extend(
else
{
_widget.set_value('');
}
}
}
var nm = _widget.getRoot().getWidgetById('nm');
nm.activeFilters["selectedFolder"] = folder;
@ -767,10 +767,10 @@ app.mail = AppJS.extend(
this.mail_fetchCurrentlyFocussed(null,true);
this.mail_preview();
},
/**
* Flag mail as 'read', 'unread', 'flagged' or 'unflagged'
*
*
* @param _action _action.id is 'read', 'unread', 'flagged' or 'unflagged'
* @param _elems
*/
@ -781,10 +781,10 @@ app.mail = AppJS.extend(
//
this.mail_flagMessages(_action.id,msg);
},
/**
* Flag mail as 'read', 'unread', 'flagged' or 'unflagged'
*
*
* @param _action _action.id is 'read', 'unread', 'flagged' or 'unflagged'
* @param _elems
*/
@ -795,20 +795,20 @@ app.mail = AppJS.extend(
request.sendRequest(false);
this.mail_refreshMessageGrid();
},
/**
* display header lines, or source of mail, depending on the url given
*
*
* @param _url
*/
mail_displayHeaderLines: function(_url) {
// only used by right clickaction
egw_openWindowCentered(_url,'mail_display_headerLines','700','600',window.outerWidth/2,window.outerHeight/2);
},
/**
* View header of a message
*
*
* @param _action
* @param _elems _elems[0].id is the row-id
*/
@ -820,10 +820,10 @@ app.mail = AppJS.extend(
url += '&id='+_elems[0].id;
this.mail_displayHeaderLines(url);
},
/**
* View message source
*
*
* @param _action
* @param _elems _elems[0].id is the row-id
*/
@ -836,10 +836,10 @@ app.mail = AppJS.extend(
url += '&location=display';
this.mail_displayHeaderLines(url);
},
/**
* Save a message
*
*
* @param _action
* @param _elems _elems[0].id is the row-id
*/
@ -852,7 +852,7 @@ app.mail = AppJS.extend(
//window.open(url,'_blank','dependent=yes,width=100,height=100,scrollbars=yes,status=yes');
document.location = url;
},
/**
* User clicked an address (FROM, TO, etc)
*/
@ -860,10 +860,10 @@ app.mail = AppJS.extend(
{
console.log(this, arguments);
},
/**
* Save a message to filemanager
*
*
* @param _action
* @param _elems _elems[0].id is the row-id
*/
@ -883,12 +883,12 @@ app.mail = AppJS.extend(
//window.open(url,'_blank','dependent=yes,width=100,height=100,scrollbars=yes,status=yes')
//document.location = url;
egw_openWindowCentered(url,'vfs_save_message_'+_elems[0].id,'640','570',window.outerWidth/2,window.outerHeight/2);
},
/**
* Save message as InfoLog
*
*
* @param _action
* @param _elems _elems[0].id is the row-id
*/
@ -900,10 +900,10 @@ app.mail = AppJS.extend(
url += '&rowid='+_elems[0].id;
egw_openWindowCentered(url,'import_mail_'+_elems[0].id,_action.data.width,_action.data.height);
},
/**
* Save message as ticket
*
*
* @param _action _action.id is 'read', 'unread', 'flagged' or 'unflagged'
* @param _elems
*/
@ -915,11 +915,11 @@ app.mail = AppJS.extend(
url += '&rowid='+_elems[0].id;
egw_openWindowCentered(url,'import_tracker_'+_elems[0].id,_action.data.width,_action.data.height);
},
/**
* mail_getFormData
*
*
* @param _actionObjects, the senders
* @return structured array of message ids: array(msg=>message-ids)
*/
@ -929,7 +929,7 @@ app.mail = AppJS.extend(
{
messages['msg'] = [];
}
for (var i = 0; i < _actionObjects.length; i++)
{
if (_actionObjects[i].id.length>0)
@ -937,32 +937,32 @@ app.mail = AppJS.extend(
messages['msg'][i] = _actionObjects[i].id;
}
}
return messages;
},
/**
* mail_setRowClass
*
*
* @param _actionObjects, the senders
*/
mail_setRowClass: function(_actionObjects,_class) {
if (typeof _class == 'undefined') return false;
for (var i = 0; i < _actionObjects.length; i++)
for (var i = 0; i < _actionObjects.length; i++)
{
if (_actionObjects[i].id.length>0)
{
var dataElem = $j(_actionObjects[i].iface.getDOMNode());
dataElem.addClass(_class);
}
}
},
/**
* mail_removeRowClass
*
*
* @param _actionObjects, the senders, or a messages object
* @param _class, the class to be removed
*/
@ -971,13 +971,13 @@ app.mail = AppJS.extend(
if (typeof _actionObjects['msg'] == 'undefined')
{
for (var i = 0; i < _actionObjects.length; i++)
for (var i = 0; i < _actionObjects.length; i++)
{
if (_actionObjects[i].id.length>0)
{
var dataElem = $j(_actionObjects[i].iface.getDOMNode());
dataElem.removeClass(_class);
}
}
}
@ -985,17 +985,17 @@ app.mail = AppJS.extend(
{
var nm = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById('nm');
var aO = nm.controller._objectManager.selectedChildren;
for (var i = 0; i < _actionObjects['msg'].length; i++)
for (var i = 0; i < _actionObjects['msg'].length; i++)
{
for (var i = 0; i < aO.length; i++)
for (var i = 0; i < aO.length; i++)
{
if (aO[i].id==_actionObjects['msg'][i])
{
var dataElem = $j(aO[i].iface.getDOMNode());
dataElem.removeClass(_class);
}
}
}
}
}
},
@ -1003,7 +1003,7 @@ app.mail = AppJS.extend(
// Tree widget stubs
/**
* mail_dragStart - displays information while dragging
*
*
* @param action
* @param _senders - the representation of the elements dragged
* @return the ddhelper
@ -1014,7 +1014,7 @@ app.mail = AppJS.extend(
},
/**
* mail_move - implementation of the move action from drag n drop
*
*
* @param _action
* @param _senders - the representation of the elements dragged
* @param _target - the representation of the target
@ -1036,7 +1036,7 @@ app.mail = AppJS.extend(
},
/**
* mail_copy - implementation of the copy action from drag n drop
*
*
* @param _action
* @param _senders - the representation of the elements dragged
* @param _target - the representation of the target
@ -1055,7 +1055,7 @@ app.mail = AppJS.extend(
/**
* mail_AddFolder - implementation of the AddFolder action of right click options on the tree
*
*
* @param _action
* @param _senders - the representation of the tree leaf to be manipulated
*/
@ -1082,7 +1082,7 @@ app.mail = AppJS.extend(
/**
* mail_RenameFolder - implementation of the RenameFolder action of right click options on the tree
*
*
* @param _action
* @param _senders - the representation of the tree leaf to be manipulated
*/
@ -1109,7 +1109,7 @@ app.mail = AppJS.extend(
/**
* mail_DeleteFolder - implementation of the DeleteFolder action of right click options on the tree
*
*
* @param _action
* @param _senders - the representation of the tree leaf to be manipulated
*/
@ -1130,5 +1130,80 @@ app.mail = AppJS.extend(
var request = new egw_json_request('mail.mail_ui.ajax_deleteFolder',[_senders[0].iface.id]);
request.sendRequest(true);
}
}
},
/**
* action - handling actions on sieve rules
*
* @param _type - action name
* @param _selected - selected row from the sieve rule list
* @param _msg - messages
*/
action: function(_type, _selected)
{
var actionData ;
var that = this;
var typeId = _type.id;
var ruleID = ((_selected[0].id.split("_").pop()) - 1); // subtract the row id from 1 because the first row id is reserved by grid header
if (_type)
{
switch (_type.id)
{
case 'delete':
var callbackDeleteDialog = function (button_id)
{
if (button_id == et2_dialog.YES_BUTTON )
{
actionData = _type.parent.data.widget.getArrayMgr('content');
that._do_action(typeId, actionData['data'],ruleID);
}
}
var confirmDeleteDialog = et2_dialog.show_dialog(callbackDeleteDialog, egw.lang("Do you really want to DELETE this Rule"),egw.lang("Delete"), {},et2_dialog.BUTTONS_YES_NO_CANCEL, et2_dialog.WARNING_MESSAGE);
break;
case 'add' :
$linkData = "mail.mail_sieve.edit";
egw.open_link($linkData,'',"600x480");
break;
case 'edit' :
$linkData = "mail.mail_sieve.edit&ruleID="+ruleID;
egw.open_link($linkData,'',"600x480");
break;
case 'enable':
actionData = _type.parent.data.widget.getArrayMgr('content');
this._do_action(typeId,actionData['data'],ruleID);
//window.egw_refresh('refreshed',this.appname);
break;
case 'disable':
actionData = _type.parent.data.widget.getArrayMgr('content');
this._do_action(typeId,actionData['data'],ruleID);
break;
}
}
},
_do_action: function(_typeID, _data,_selectedID)
{
if (_typeID && _data)
{
var request = new egw_json_request('mail.mail_sieve.ajax_action', [_typeID,_selectedID]);
console.log(request);
request.sendRequest(true,this._callback_do_action,this);
}
},
sieve_refresh: function (_rows,_msg)
{
var grid = this.et2.getWidgetById('rg');
window.egw_refresh(_msg,this.appname);
if (grid)
{
grid.set_value(_rows);
}
},
});

1125
mail/js/app.js.mine Normal file

File diff suppressed because it is too large Load Diff

View File

@ -5,6 +5,7 @@
(separate multiple addresses by comma) mail en Separate multiple addresses by comma
(unknown sender) mail en Unknown sender
(with checkbox enforced) mail en with checkbox enforced
... mail en ...
1) keep drafted message (press ok) mail en 1) keep drafted message (press OK)
2) discard the message completely (press cancel) mail en 2) discard the message completely (press Cancel)
aborted mail en Aborted
@ -43,6 +44,7 @@ attach mail en Attach
attach users vcard at compose to every new mail mail en Attach user's VCard at compose to every new mail
attach vcard mail en Attach vCard
attachments mail en Attachments
attachments, ... mail en attachments, ...
authentication required mail en Authentication required
auto refresh folder list mail en Auto refresh folder list
available personal email-accounts/profiles mail en available personal EMail-Accounts/Profiles
@ -267,8 +269,10 @@ how often to check with the server for new mail mail en How often to check with
how should the available information on identities be displayed mail en How should the available information on identities be displayed
how to forward messages mail en How to forward messages
html mail en HTML
icons mail en Icons
icons and text mail en Icons and text
icons only mail en Icons only
id mail en ID
identifying name mail en Identifying name
identity mail en Identity
if mail en IF
@ -476,6 +480,7 @@ return to options page mail en Return to options page
right mail en Right
row order style mail en Row order style
rule mail en Rule
rule lists mail en Rule Lists
save mail en Save
save all mail en Save all
save as mail en Save as
@ -536,6 +541,7 @@ skipping previous mail en Skipping previous
small view mail en Small view
smtp settings admin en SMTP settings
sort order mail en Sort order
st. mail en St.
start new messages with mime type plain/text or html? mail en Start new messages with mime type plain/text or HTML?
start reply messages with mime type plain/text or html or try to use the displayed format (default)? mail en Start reply messages with mime type plain/text or html or try to use the displayed format?
stationery mail en Stationery
@ -572,7 +578,6 @@ to mail en To
to do mail en to do
to mail sent to mail en To mail sent to
to use a tls connection, you must be running a version of php 5.1.0 or higher. mail en To use a TLS connection, you must be running a version of PHP 5.1.0 or higher.
turn off horizontal line between signature and composed message (this is not according to RFC).\nIf you use templates, this option is only applied to the text part of the message. mail en Turn off horizontal line between signature and composed message (this is not according to RFC).\nIf you use templates, this option is only applied to the text part of the message.
translation preferences mail en Translation preferences
translation server mail en Translation server
trash mail en Trash
@ -581,6 +586,7 @@ trash folder mail en Trash folder
trust servers seen / unseen info mail en Trust server's SEEN / UNSEEN info
trust the server when retrieving the folder status. if you select no, we will search for the unseen messages and count them ourselves mail en Trust the server when retrieving the folder status. if you select no, we will search for the UNSEEN messages and count them ourselves
trying to recover from session data mail en Trying to recover from session data
turn off horizontal line between signature and composed message (this is not according to rfc).\nif you use templates, this option is only applied to the text part of the message. mail en Turn off horizontal line between signature and composed message (this is not according to RFC).\nIf you use templates, this option is only applied to the text part of the message.
type mail en Type
undelete mail en Undelete
unexpected response from server to authenticate command. mail en Unexpected response from server to AUTHENTICATE command.
@ -631,9 +637,6 @@ what to do when you delete a message mail en What to do when you delete a messag
what to do when you send a message mail en What to do when you send a message
what to do with html email mail en What to do with HTML email
when deleting messages mail en When deleting messages
when displaying messages in a popup, re-use the same popup for all or open a new popup for each
message mail en When displaying messages in a popup, re-use the same popup for all or open a new popup for each
message
when saving messages as item of a different app mail en When saving messages as item of a different app
when sending messages mail en When sending messages
which folders (additional to the sent folder) should be displayed using the sent folder view schema mail en Which folders in addition to the Sent folder should be displayed using the Sent Folder View Schema