2013-02-12 18:48:04 +01:00
/ * *
* mail - static javaScript functions
*
* @ link http : //www.egroupware.org
2013-10-24 09:15:48 +02:00
* @ author Stylite AG [ info @ stylite . de ]
* @ copyright ( c ) 2013 by Stylite AG < info - AT - stylite . de >
2013-02-12 18:48:04 +01:00
* @ package mail
* @ license http : //opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @ version $Id$
* /
2013-10-07 18:53:13 +02:00
/ * *
* UI for mail
2013-10-09 18:44:03 +02:00
*
2013-10-07 18:53:13 +02:00
* @ augments AppJS
* /
2013-04-13 12:30:07 +02:00
app . mail = AppJS . extend (
2013-02-19 17:30:59 +01:00
{
2013-04-13 12:30:07 +02:00
appname : 'mail' ,
2013-08-21 12:47:20 +02:00
2013-06-12 13:50:30 +02:00
/ * *
* et2 widget container
* /
et2 : null ,
2013-04-13 12:30:07 +02:00
doStatus : null ,
mail _doTimedRefresh : false ,
2013-07-25 17:35:44 +02:00
2013-04-13 12:30:07 +02:00
mail _refreshTimeOut : 1000 * 60 * 3 , // initial call
mail _queuedFolders : [ ] ,
mail _queuedFoldersIndex : 0 ,
2013-05-21 10:46:54 +02:00
mail _selectedMails : [ ] ,
mail _currentlyFocussed : '' ,
2013-05-29 14:34:33 +02:00
mail _previewAreaActive : true , // we start with the area active
2013-07-25 17:35:44 +02:00
2013-08-21 12:47:20 +02:00
nm _index : 'nm' , // nm nome of index
2013-09-23 10:33:30 +02:00
mail _fileSelectorWindow : null ,
2013-10-05 18:36:20 +02:00
mail _isMainWindow : true ,
2013-08-21 12:47:20 +02:00
2013-04-13 12:30:07 +02:00
/ * *
* Initialize javascript for this application
2013-07-25 17:35:44 +02:00
*
2013-10-09 16:35:03 +02:00
* @ memberOf mail
2013-04-13 12:30:07 +02:00
* /
init : function ( ) {
this . _super . apply ( this , arguments ) ;
window . register _app _refresh ( "mail" , this . app _refresh ) ;
} ,
2013-07-25 17:35:44 +02:00
2013-06-12 13:50:30 +02:00
/ * *
* Destructor
* /
destroy : function ( )
{
delete this . et2 ;
2013-10-09 18:44:03 +02:00
delete this . et2 _obj ;
2013-06-12 13:50:30 +02:00
// call parent
this . _super . apply ( this , arguments ) ;
} ,
2013-07-25 17:35:44 +02:00
2013-06-12 13:50:30 +02:00
/ * *
* This function is called when the etemplate2 object is loaded
* and ready . If you must store a reference to the et2 object ,
* make sure to clean it up in destroy ( ) .
*
* @ param et2 etemplate2 Newly ready object
* /
et2 _ready : function ( et2 )
{
2013-09-02 17:15:35 +02:00
// call parent; somehow this function is called more often. (twice on a display and compose) why?
2013-06-12 13:50:30 +02:00
this . _super . apply ( this , arguments ) ;
2013-08-09 19:47:53 +02:00
this . et2 _obj = et2 ;
2013-06-12 13:50:30 +02:00
this . et2 = et2 . widgetContainer ;
var isMainView = false ;
2013-06-17 16:25:20 +02:00
var isDisplay = false ;
2013-10-14 15:30:04 +02:00
var isCompose = false ;
2013-06-17 16:25:20 +02:00
for ( var t in et2 . templates )
{
2013-09-02 17:15:35 +02:00
//alert(t); // as we iterate through this more than once, ... we separate trigger and action
switch ( t ) {
case 'mail.index' :
2013-10-05 18:36:20 +02:00
this . mail _isMainWindow = isMainView = true ;
2013-09-02 17:15:35 +02:00
break ;
case 'mail.display' :
2013-10-05 18:36:20 +02:00
this . mail _isMainWindow = false ;
2013-09-02 17:15:35 +02:00
isDisplay = true ;
break ;
2013-10-01 13:29:54 +02:00
case 'mail.compose' :
2013-10-05 18:36:20 +02:00
this . mail _isMainWindow = false ;
2013-10-14 15:30:04 +02:00
isCompose = true ;
2013-09-02 17:15:35 +02:00
}
2013-06-17 16:25:20 +02:00
}
2013-09-02 17:15:35 +02:00
//alert('action about to go down');
2013-10-08 16:23:46 +02:00
if ( isMainView )
{
this . mail _disablePreviewArea ( true ) ;
this . mail _startTimerFolderStatusUpdate ( this . mail _refreshTimeOut ) ;
//inital call of refresh folderstatus
var self = this ;
window . setTimeout ( function ( ) { self . mail _refreshFolderStatus . apply ( self ) ; } , 1000 ) ;
}
2013-09-02 17:15:35 +02:00
if ( isDisplay )
{
2013-10-18 11:58:25 +02:00
var subject = this . et2 . getWidgetById ( 'mail_displaysubject' ) ;
var body = this . et2 . getWidgetById ( 'mail_displaybody' ) ;
2013-09-02 17:15:35 +02:00
body . node . parentNode . style . top = subject . node . offsetTop + 40 + 'px' ;
2013-10-05 16:15:29 +02:00
var app _registry = egw . link _get _registry ( 'mail' ) ; //this.appname);
2013-09-05 16:52:11 +02:00
//console.log(app_registry);
2013-10-01 13:29:54 +02:00
w = 870 ;
2013-09-05 16:52:11 +02:00
if ( typeof app _registry [ 'view' ] != 'undefined' && typeof app _registry [ 'view_popup' ] != 'undefined' )
{
var w _h = app _registry [ 'view_popup' ] . split ( 'x' ) ;
if ( w _h [ 1 ] == 'egw_getWindowOuterHeight()' ) w _h [ 1 ] = ( screen . availHeight > egw _getWindowOuterHeight ( ) ? screen . availHeight : egw _getWindowOuterHeight ( ) ) ;
}
2013-10-01 13:29:54 +02:00
//alert('resizing to'+(w_h[0]?w_h[0]:870)+','+(w_h[1]?w_h[1]:egw_getWindowOuterHeight()));
window . resizeTo ( ( w _h [ 0 ] ? w _h [ 0 ] : 870 ) , ( w _h [ 1 ] ? w _h [ 1 ] : ( screen . availHeight > egw _getWindowOuterHeight ( ) ? screen . availHeight : egw _getWindowOuterHeight ( ) ) ) ) ;
2013-09-02 17:15:35 +02:00
}
2013-10-14 15:30:04 +02:00
if ( isCompose )
{
var app _registry = egw . link _get _registry ( 'mail' ) ; //this.appname);
//console.log(app_registry);
w = 870 ;
if ( typeof app _registry [ 'edit' ] != 'undefined' && typeof app _registry [ 'edit_popup' ] != 'undefined' )
{
var w _h = app _registry [ 'edit_popup' ] . split ( 'x' ) ;
if ( w _h [ 1 ] == 'egw_getWindowOuterHeight()' ) w _h [ 1 ] = ( screen . availHeight > egw _getWindowOuterHeight ( ) ? screen . availHeight : egw _getWindowOuterHeight ( ) ) ;
}
//alert('resizing to'+(w_h[0]?w_h[0]:870)+','+(w_h[1]?w_h[1]:egw_getWindowOuterHeight()));
window . resizeTo ( ( w _h [ 0 ] ? w _h [ 0 ] : 870 ) , ( w _h [ 1 ] ? w _h [ 1 ] : ( screen . availHeight > egw _getWindowOuterHeight ( ) ? screen . availHeight : egw _getWindowOuterHeight ( ) ) ) ) ;
}
2013-10-16 13:22:53 +02:00
//Vacation By_date filter
if ( typeof et2 . templates [ 'mail.sieve.vacation' ] != 'undefined' )
{
this . vacationFilterStatusChange ( ) ;
}
2013-06-12 13:50:30 +02:00
} ,
2013-05-21 10:46:54 +02:00
/ * *
* mail _fetchCurrentlyFocussed - implementation to decide wich mail of all the selected ones is the current
2013-07-25 17:35:44 +02:00
*
2013-05-21 10:46:54 +02:00
* @ param _selected array of the selected mails
* @ param _reset bool - tell the function to reset the global vars used
* /
mail _fetchCurrentlyFocussed : function ( _selected , _reset ) {
//console.log("mail_fetchCurrentlyFocussed",_selected, _reset);
// reinitialize the buffer-info on selected mails
if ( _reset == true || typeof _selected == 'undefined' )
{
2013-05-21 14:02:58 +02:00
if ( _reset == true )
{
2013-10-18 11:58:25 +02:00
//var nm = this.et2.getWidgetById(nm_index);
2013-06-04 17:29:53 +02:00
//if (this.mail_currentlyFocussed!='') nm.refresh([this.mail_currentlyFocussed],'delete');//egw.dataDeleteUID(this.mail_currentlyFocussed);
2013-05-21 14:02:58 +02:00
if ( this . mail _currentlyFocussed != '' ) egw . dataDeleteUID ( this . mail _currentlyFocussed ) ;
for ( var k = 0 ; k < this . mail _selectedMails . length ; k ++ ) egw . dataDeleteUID ( this . mail _selectedMails [ k ] ) ;
2013-06-04 17:29:53 +02:00
//nm.refresh(this.mail_selectedMails,'delete');
2013-05-21 14:02:58 +02:00
}
2013-05-21 10:46:54 +02:00
this . mail _selectedMails = [ ] ;
this . mail _currentlyFocussed = '' ;
return '' ;
}
for ( var k = 0 ; k < _selected . length ; k ++ )
{
if ( jQuery . inArray ( _selected [ k ] , this . mail _selectedMails ) == - 1 )
{
this . mail _currentlyFocussed = _selected [ k ] ;
break ;
}
}
this . mail _selectedMails = _selected ;
return this . mail _currentlyFocussed ;
} ,
2013-04-13 12:30:07 +02:00
/ * *
* mail _open - implementation of the open action
2013-07-25 17:35:44 +02:00
*
2013-04-13 12:30:07 +02:00
* @ param _action
* @ param _senders - the representation of the elements ( s ) the action is to be performed on
2013-07-20 09:23:55 +02:00
* @ param _mode - you may pass the mode . if not given view is used ( tryastext | tryashtml are supported )
2013-04-13 12:30:07 +02:00
* /
2013-07-20 09:23:55 +02:00
mail _open : function ( _action , _senders , _mode ) {
2013-07-17 14:01:01 +02:00
//console.log("mail_open",_action, _senders);
2013-10-05 11:03:51 +02:00
if ( typeof _senders == 'undefined' )
{
if ( this . et2 . getArrayMgr ( "content" ) . getEntry ( 'mail_id' ) )
{
var _senders = [ ] ;
_senders . push ( { id : this . et2 . getArrayMgr ( "content" ) . getEntry ( 'mail_id' ) || '' } ) ;
}
2013-10-14 15:30:04 +02:00
if ( typeof _senders == 'undefined' && this . mail _isMainWindow )
{
if ( this . mail _currentlyFocussed )
{
var _senders = [ ] ;
_senders . push ( { id : this . mail _currentlyFocussed } ) ;
}
}
2013-10-05 11:03:51 +02:00
}
2013-04-13 12:30:07 +02:00
var _id = _senders [ 0 ] . id ;
2013-05-21 10:46:54 +02:00
// reinitialize the buffer-info on selected mails
2013-07-20 09:23:55 +02:00
if ( ! ( _mode == 'tryastext' || _mode == 'tryashtml' || _mode == 'view' ) ) _mode = 'view' ;
2013-05-21 10:46:54 +02:00
this . mail _selectedMails = [ ] ;
this . mail _selectedMails . push ( _id ) ;
this . mail _currentlyFocussed = _id ;
2013-04-13 12:30:07 +02:00
var dataElem = egw . dataGetUIDdata ( _id ) ;
var subject = dataElem . data . subject ;
2013-06-05 16:24:56 +02:00
//alert('Open Message:'+_id+' '+subject);
2013-07-20 09:23:55 +02:00
var h = egw ( ) . open ( _id , 'mail' , 'view' , _mode + '=' + _id . replace ( /=/g , "_" ) ) ;
2013-07-17 14:01:01 +02:00
egw ( h ) . ready ( function ( ) {
h . document . title = subject ;
} ) ;
2013-04-13 12:30:07 +02:00
} ,
2013-07-25 17:35:44 +02:00
2013-05-13 16:42:42 +02:00
/ * *
* Open a single message in html mode
2013-07-25 17:35:44 +02:00
*
2013-05-13 16:42:42 +02:00
* @ param _action
* @ param _elems _elems [ 0 ] . id is the row - id
* /
mail _openAsHtml : function ( _action , _elems )
{
2013-07-20 09:23:55 +02:00
this . mail _open ( _action , _elems , 'tryashtml' ) ;
2013-05-13 16:42:42 +02:00
} ,
/ * *
* Open a single message in plain text mode
2013-07-25 17:35:44 +02:00
*
2013-05-13 16:42:42 +02:00
* @ param _action
* @ param _elems _elems [ 0 ] . id is the row - id
* /
mail _openAsText : function ( _action , _elems )
{
2013-07-20 09:23:55 +02:00
this . mail _open ( _action , _elems , 'tryastext' ) ;
} ,
/ * *
* Compose , reply or forward a message
2013-07-25 17:35:44 +02:00
*
2013-10-07 12:12:18 +02:00
* @ function
* @ memberOf mail
2013-07-20 09:23:55 +02:00
* @ 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
* /
mail _compose : function ( _action , _elems )
{
2013-10-05 11:03:51 +02:00
if ( typeof _elems == 'undefined' )
{
//console.log(this.et2.getArrayMgr('content').data,this.et2.getArrayMgr("content").getEntry('mail_id'));
2013-10-07 12:12:18 +02:00
if ( this . et2 && this . et2 . getArrayMgr ( "content" ) . getEntry ( 'mail_id' ) )
2013-10-05 11:03:51 +02:00
{
var _elems = [ ] ;
_elems . push ( { id : this . et2 . getArrayMgr ( "content" ) . getEntry ( 'mail_id' ) || '' } ) ;
}
2013-10-14 15:30:04 +02:00
if ( typeof _elems == 'undefined' && this . mail _isMainWindow )
{
if ( this . mail _currentlyFocussed )
{
var _elems = [ ] ;
_elems . push ( { id : this . mail _currentlyFocussed } ) ;
}
}
2013-10-05 11:03:51 +02:00
}
console . log ( _action , _elems ) ;
2013-10-04 19:45:33 +02:00
// Extra info passed to egw.open()
var settings = {
// 'Source' Mail UID
id : '' ,
// How to pull data from the Mail IDs for the compose
from : ''
} ;
2013-10-09 18:44:03 +02:00
2013-10-05 11:03:51 +02:00
// We only handle one for everything but forward
settings . id = ( typeof _elems == 'undefined' ? '' : _elems [ 0 ] . id ) ;
2013-10-09 18:44:03 +02:00
2013-10-04 19:45:33 +02:00
switch ( _action . id )
2013-05-13 16:42:42 +02:00
{
2013-10-04 19:45:33 +02:00
case 'compose' :
if ( _elems . length == 1 )
{
2013-10-05 11:03:51 +02:00
//mail_parentRefreshListRowStyle(settings.id,settings.id);
2013-10-04 19:45:33 +02:00
}
else
{
return this . mail _compose ( 'forward' , _elems ) ;
}
break ;
case 'forward' :
case 'forwardinline' :
case 'forwardasattach' :
2013-10-08 16:23:46 +02:00
if ( _elems . length > 1 || _action . id == 'forwardasattach' )
2013-10-04 19:45:33 +02:00
{
2013-10-07 12:12:18 +02:00
var url = 'menuaction=mail.mail_compose.compose' ;
2013-10-04 19:45:33 +02:00
return this . mail _openComposeWindow ( url , _action . id == 'forwardasattach' , _elems ) ;
}
else
{
settings . from = 'forward' ;
settings . mode = 'forwardinline' ;
}
break ;
default :
// No further client side processing needed for these
settings . from = _action . id ;
2013-07-20 09:23:55 +02:00
}
2013-10-07 17:28:49 +02:00
var compose _list = egw . getOpenWindows ( "mail" , /^compose_/ ) ;
var window _name = 'compose_' + compose _list . length + '_' + ( settings . from || '' ) + '_' + settings . id ;
2013-10-07 12:12:18 +02:00
return egw ( ) . open ( '' , 'mail' , 'add' , settings , window _name , 'mail' ) ;
2013-10-04 19:45:33 +02:00
} ,
2013-10-09 18:44:03 +02:00
2013-10-07 12:12:18 +02:00
/ * *
* Set content into a compose window
2013-10-09 18:44:03 +02:00
*
2013-10-07 12:12:18 +02:00
* @ function
* @ memberOf mail
2013-10-09 18:44:03 +02:00
*
2013-10-07 12:12:18 +02:00
* @ param { String } window _name The name of an open content window .
* @ param content Data to set into the window ' s fields
* @ param content . to Addresses to add to the to line
* @ param content . cc Addresses to add to the CC line
* @ param content . bcc Addresses to add to the BCC line
2013-10-09 18:44:03 +02:00
*
2013-10-07 12:12:18 +02:00
* @ return { boolean } Success
* /
setCompose : function ( window _name , content )
{
// Get window
var compose = window . open ( '' , window _name ) ;
if ( ! compose || compose . closed ) return false ;
2013-10-09 18:44:03 +02:00
2013-10-07 12:12:18 +02:00
// Get etemplate of popup
var compose _et2 = compose . etemplate2 . getByApplication ( 'mail' ) ;
if ( ! compose _et2 || compose _et2 . length != 1 || ! compose _et2 [ 0 ] . widgetContainer )
{
return false ;
}
2013-10-09 18:44:03 +02:00
2013-10-07 12:12:18 +02:00
// Set each field provided
var success = true ;
for ( var field in content )
{
try
{
var widget = compose _et2 [ 0 ] . widgetContainer . getWidgetById ( field ) ;
2013-10-09 18:44:03 +02:00
2013-10-07 12:12:18 +02:00
// Merge array values, replace strings
var value = widget . getValue ( ) || content [ field ] ;
if ( jQuery . isArray ( value ) )
{
if ( jQuery . isArray ( content [ field ] ) )
{
value . concat ( content [ field ] ) ;
}
else
{
value . push ( content [ field ] ) ;
}
}
widget . set _value ( value ) ;
}
catch ( e )
{
egw . log ( "error" , "Unable to set field %s to '%s' in window '%s'" , field , content [ field ] , window _name ) ;
success = false ;
continue ;
}
}
return success ;
} ,
2013-08-21 12:47:20 +02:00
2013-07-20 09:23:55 +02:00
/ * *
* Compose , reply or forward a message
2013-07-25 17:35:44 +02:00
*
2013-07-20 09:23:55 +02:00
* @ param _url url to open
* @ param forwardByCompose boolean to decide about the method
* /
mail _openComposeWindow : function ( _url , forwardByCompose , _elems ) {
var Check = true ;
var alreadyAsked = false ;
var _messageList ;
var sMessageList = '' ;
// check if mailgrid exists, before accessing it
var cbAllVisibleMessages ;
2013-10-08 16:23:46 +02:00
var cbAllMessages = false ;
2013-07-20 09:23:55 +02:00
if ( typeof forwardByCompose == 'undefined' ) forwardByCompose = true ;
if ( forwardByCompose == false )
{
cbAllMessages = cbAllVisibleMessages = Check = false ;
}
if ( typeof prefAskForMultipleForward == 'undefined' ) prefAskForMultipleForward = egw . preference ( 'prefaskformultipleforward' , 'mail' ) ;
if ( cbAllMessages == true || cbAllVisibleMessages == true )
{
2013-10-07 18:53:13 +02:00
Check = confirm ( this . egw . lang ( 'multiple forward of all mesages' ) ) ;
2013-07-20 09:23:55 +02:00
alreadyAsked = true ;
}
if ( ( cbAllMessages == true || cbAllVisibleMessages == true ) && Check == true )
{
//_messageList = 'all'; // all is not supported by now, only visibly selected messages are chosen
_messageList = this . mail _getFormData ( _elems ) ;
}
else
{
if ( Check == true ) _messageList = this . mail _getFormData ( _elems ) ;
}
if ( typeof _messageList != 'undefined' )
{
for ( var i in _messageList [ 'msg' ] ) {
//alert('eigenschaft:'+_messageList['msg'][i]);
sMessageList = sMessageList + _messageList [ 'msg' ] [ i ] + ',' ;
//sMessageList.concat(',');
}
}
if ( prefAskForMultipleForward == 1 && Check == true && alreadyAsked == false && sMessageList . length > 0 && _messageList [ 'msg' ] . length > 1 )
{
2013-10-07 18:53:13 +02:00
askme = this . egw . lang ( 'multipleforward' ) ;
2013-07-20 09:23:55 +02:00
//if (cbAllMessages == true || cbAllVisibleMessages == true) askme = egw_appWindow('felamimail').lang_confirm_all_messages; // not supported
Check = confirm ( askme ) ;
}
//alert("Check:"+Check+" MessageList:"+sMessageList+"#");
if ( Check != true ) sMessageList = '' ; // deny the appending off selected messages to new compose -> reset the sMessageList
if ( Check == true || sMessageList == '' )
{
if ( sMessageList . length > 0 ) {
2013-10-08 16:23:46 +02:00
sMessageList = 'AsForward&from=forward&mode=asattach&reply_id=' + sMessageList . substring ( 0 , sMessageList . length - 1 ) ;
2013-07-20 09:23:55 +02:00
}
//alert(sMessageList);
2013-10-04 19:45:33 +02:00
egw _openWindowCentered ( window . egw _webserverUrl + '/index.php?' + _url + sMessageList , 'compose' , 870 , egw _getWindowOuterHeight ( ) ) ;
2013-05-13 16:42:42 +02:00
}
2013-07-20 09:23:55 +02:00
//ToDo: reset message selection
2013-05-13 16:42:42 +02:00
} ,
2013-05-27 15:48:55 +02:00
/ * *
* mail _disablePreviewArea - implementation of the disablePreviewArea action
2013-07-25 17:35:44 +02:00
*
2013-05-27 15:48:55 +02:00
* @ param _value
* /
mail _disablePreviewArea : function ( _value ) {
2013-10-18 11:58:25 +02:00
var splitter = this . et2 . getWidgetById ( 'mailSplitter' ) ;
2013-06-12 13:50:30 +02:00
if ( typeof splitter == 'undefined' || splitter == null ) return ;
2013-05-29 14:34:33 +02:00
var splitterDN = splitter . getDOMNode ( ) ;
// check if DOM Node has class that contains docked; then we assume the bar docked, whatever our class var states
for ( var i = 0 ; i < splitterDN . childNodes [ 1 ] . classList . length ; i ++ ) if ( splitterDN . childNodes [ 1 ] . classList [ i ] . search ( /docked/ ) >= 0 ) this . mail _previewAreaActive = false ;
2013-05-29 16:19:49 +02:00
//if this.mail_previewAreaActive but clientHeight of childNode is 0, assume this.mail_previewAreaActive incorrect
2013-06-12 13:50:30 +02:00
if ( this . mail _previewAreaActive && splitterDN . childNodes . length > 2 && splitterDN . childNodes [ 2 ] . clientHeight < 15 ) this . mail _previewAreaActive = false ;
2013-10-18 11:58:25 +02:00
//this.et2.getWidgetById('mailPreviewHeadersFrom').set_disabled(_value);
//this.et2.getWidgetById('mailPreviewHeadersTo').set_disabled(_value);
//this.et2.getWidgetById('mailPreviewHeadersDate').set_disabled(_value);
//this.et2.getWidgetById('mailPreviewHeadersSubject').set_disabled(_value);
this . et2 . getWidgetById ( 'mailPreview' ) . set _disabled ( _value ) ;
2013-05-27 15:48:55 +02:00
if ( _value == true )
{
2013-05-29 14:34:33 +02:00
if ( this . mail _previewAreaActive ) splitter . dock ( ) ;
this . mail _previewAreaActive = false ;
2013-07-25 17:35:44 +02:00
}
2013-05-27 15:48:55 +02:00
else
{
2013-05-29 14:34:33 +02:00
if ( ! this . mail _previewAreaActive ) splitter . undock ( ) ;
this . mail _previewAreaActive = true ;
2013-05-27 15:48:55 +02:00
}
} ,
2013-04-13 12:30:07 +02:00
/ * *
* mail _preview - implementation of the preview action
2013-07-25 17:35:44 +02:00
*
2013-04-13 12:30:07 +02:00
* @ param nextmatch et2 _nextmatch The widget whose row was selected
* @ param selected Array Selected row IDs . May be empty if user unselected all rows .
* /
2013-10-09 16:35:03 +02:00
mail _preview : function ( selected , nextmatch ) {
2013-07-17 14:01:01 +02:00
//console.log("mail_preview",nextmatch, selected);
2013-04-13 12:30:07 +02:00
// Empty values, just in case selected is empty (user cleared selection)
var dataElem = { data : { subject : "" , fromaddress : "" , toaddress : "" , date : "" , subject : "" } } ;
2013-06-04 17:29:53 +02:00
if ( typeof selected != 'undefined' && selected . length == 1 )
2013-02-19 17:30:59 +01:00
{
2013-05-21 10:46:54 +02:00
var _id = this . mail _fetchCurrentlyFocussed ( selected ) ;
2013-04-13 12:30:07 +02:00
dataElem = egw . dataGetUIDdata ( _id ) ;
2013-02-19 17:30:59 +01:00
}
2013-10-01 13:29:54 +02:00
//get_class does not exist yet
2013-10-18 11:58:25 +02:00
//var pAAClass = this.et2.getWidgetById('previewAttachmentArea').get_class();
2013-10-01 13:29:54 +02:00
//console.log(pAAClass);
2013-10-18 11:58:25 +02:00
if ( this . et2 . getWidgetById ( 'previewAttachmentArea' ) )
2013-10-05 18:36:20 +02:00
{
2013-10-18 11:58:25 +02:00
this . et2 . getWidgetById ( 'previewAttachmentArea' ) . set _class ( 'previewAttachmentArea' ) ;
2013-10-05 18:36:20 +02:00
}
else
{
return ;
}
2013-05-21 14:02:58 +02:00
if ( typeof selected == 'undefined' || selected . length == 0 || selected . length > 1 || typeof dataElem == 'undefined' )
2013-04-13 12:30:07 +02:00
{
2013-05-21 10:46:54 +02:00
this . mail _fetchCurrentlyFocussed ( ) ;
2013-04-30 16:16:52 +02:00
var subject = "" ;
2013-10-18 11:58:25 +02:00
this . et2 . getWidgetById ( 'previewFromAddress' ) . set _value ( "" ) ;
this . et2 . getWidgetById ( 'previewToAddress' ) . set _value ( "" ) ;
this . et2 . getWidgetById ( 'previewDate' ) . set _value ( "" ) ;
this . et2 . getWidgetById ( 'previewSubject' ) . set _value ( "" ) ;
2013-10-21 11:25:34 +02:00
this . et2 . getWidgetById ( 'previewAttachmentArea' ) . set _value ( { content : [ ] } ) ;
2013-10-18 11:58:25 +02:00
this . et2 . getWidgetById ( 'previewAttachmentArea' ) . set _class ( 'previewAttachmentArea noContent mail_DisplayNone' ) ;
var IframeHandle = this . et2 . getWidgetById ( 'messageIFRAME' ) ;
2013-04-30 16:16:52 +02:00
IframeHandle . set _src ( egw . link ( '/index.php' , { menuaction : 'mail.mail_ui.loadEmailBody' , _messageID : "" } ) ) ;
2013-05-27 15:48:55 +02:00
this . mail _disablePreviewArea ( true ) ;
2013-04-13 12:30:07 +02:00
return ;
}
2013-04-30 16:16:52 +02:00
//console.log("mail_preview",dataElem);
2013-05-21 10:46:54 +02:00
this . mail _selectedMails . push ( _id ) ;
2013-04-13 12:30:07 +02:00
var subject = dataElem . data . subject ;
2013-05-27 15:48:55 +02:00
this . mail _disablePreviewArea ( false ) ;
2013-10-18 11:58:25 +02:00
this . et2 . getWidgetById ( 'previewFromAddress' ) . set _value ( dataElem . data . fromaddress ) ;
this . et2 . getWidgetById ( 'previewToAddress' ) . set _value ( dataElem . data . toaddress ) ;
this . et2 . getWidgetById ( 'previewDate' ) . set _value ( dataElem . data . date ) ;
this . et2 . getWidgetById ( 'previewSubject' ) . set _value ( subject ) ;
if ( dataElem . data . attachmentsBlock . length < 1 )
{
this . et2 . getWidgetById ( 'previewAttachmentArea' ) . set _class ( 'previewAttachmentArea noContent mail_DisplayNone' ) ;
}
else
{
2013-10-21 11:25:34 +02:00
this . et2 . getWidgetById ( 'previewAttachmentArea' ) . set _value ( { content : dataElem . data . attachmentsBlock } ) ;
2013-10-18 11:58:25 +02:00
}
this . et2 . getWidgetById ( 'toolbar' ) . set _actions ( JSON . parse ( dataElem . data . toolbaractions ) ) ;
var IframeHandle = this . et2 . getWidgetById ( 'messageIFRAME' ) ;
2013-10-01 13:29:54 +02:00
//console.log(IframeHandle);
2013-04-13 12:30:07 +02:00
IframeHandle . set _src ( egw . link ( '/index.php' , { menuaction : 'mail.mail_ui.loadEmailBody' , _messageID : _id } ) ) ;
2013-06-05 12:41:38 +02:00
var messages = { } ;
messages [ 'msg' ] = [ _id ] ;
this . mail _removeRowClass ( messages , 'unseen' ) ;
2013-04-13 12:30:07 +02:00
// var request = new egw_json_request('mail.mail_ui.ajax_loadEmailBody',[_id]);
// request.sendRequest(false);
} ,
2013-05-27 15:48:55 +02:00
2013-04-13 12:30:07 +02:00
mail _setMailBody : function ( content ) {
2013-07-17 14:01:01 +02:00
//console.log('mail_setMailBody',content);
2013-10-18 11:58:25 +02:00
var IframeHandle = this . et2 . getWidgetById ( 'messageIFRAME' ) ;
2013-04-13 12:30:07 +02:00
IframeHandle . set _value ( '' ) ;
} ,
2013-07-25 17:35:44 +02:00
2013-04-13 12:30:07 +02:00
/ * *
* mail _startTimerFolderStatusUpdate , timer functions , if the counter changes for the current folder
* refresh the message list
* @ param timeout
* /
mail _startTimerFolderStatusUpdate : function ( _refreshTimeOut ) {
if ( typeof _refreshTimeOut == 'undefined' )
{
var minutes = egw . preference ( 'refreshTime' , 'mail' ) ;
this . mail _refreshTimeOut = _refreshTimeOut = 1000 * 60 * ( minutes ? minutes : 3 ) ; // either the prefs or 3 Minutes
}
if ( this . mail _refreshTimeOut > _refreshTimeOut ) _refreshTimeOut = this . mail _refreshTimeOut ;
if ( this . mail _doTimedRefresh ) {
window . clearTimeout ( this . mail _doTimedRefresh ) ;
}
if ( _refreshTimeOut > 9999 ) { //we do not set _refreshTimeOut's less than 10 seconds
var self = this ;
this . mail _doTimedRefresh = window . setInterval ( function ( ) {
self . mail _refreshFolderStatus . apply ( self ) ;
} , _refreshTimeOut ) ;
}
} ,
2013-07-25 17:35:44 +02:00
2013-04-13 12:30:07 +02:00
/ * *
* mail _refreshFolderStatus , function to call to read the counters of a folder and apply them
2013-07-25 17:35:44 +02:00
*
2013-04-13 12:30:07 +02:00
* @ param _nodeID
* @ param mode
* /
mail _refreshFolderStatus : function ( _nodeID , mode ) {
var nodeToRefresh = 0 ;
var mode2use = "none" ;
if ( _nodeID ) nodeToRefresh = _nodeID ;
if ( mode ) {
if ( mode == "forced" ) { mode2use = mode ; }
}
try
{
2013-10-18 11:58:25 +02:00
var tree _wdg = this . et2 . getWidgetById ( this . nm _index + '[foldertree]' ) ;
2013-07-25 17:35:44 +02:00
2013-04-13 12:30:07 +02:00
var activeFolders = tree _wdg . getTreeNodeOpenItems ( nodeToRefresh , mode2use ) ;
//alert(activeFolders.join('#,#'));
this . mail _queueRefreshFolderList ( activeFolders ) ;
2013-10-18 11:58:25 +02:00
this . mail _refreshQuotaDisplay ( ) ;
2013-06-04 17:29:53 +02:00
// maybe to use the mode forced as trigger for grid reload and using the grids own autorefresh
// would solve the refresh issue more accurately
//if (mode == "forced") this.mail_refreshMessageGrid();
2013-04-13 12:30:07 +02:00
this . mail _refreshMessageGrid ( ) ;
} catch ( e ) { } // ignore the error; maybe the template is not loaded yet
} ,
2013-07-25 17:35:44 +02:00
2013-10-18 11:58:25 +02:00
/ * *
* mail _refreshQuotaDisplay , function to call to read the quota for the active server
*
* /
mail _refreshQuotaDisplay : function ( _server )
{
egw . json ( 'mail.mail_ui.ajax_refreshQuotaDisplay' , [ _server ] )
. sendRequest ( true ) ;
} ,
/ * *
* mail _setQuotaDisplay , function to call to read the quota for the active server
*
* /
mail _setQuotaDisplay : function ( _data )
{
//this.et2 should do the same as etemplate2.getByApplication('mail')[0].widgetContainer
var quotabox = this . et2 . getWidgetById ( this . nm _index + '[quotainpercent]' ) ;
//console.log(_data,quotabox);
//try to set it via set_value and set label
this . et2 . getWidgetById ( this . nm _index + '[quotainpercent]' ) . set _class ( _data . data . quotaclass ) ;
this . et2 . getWidgetById ( this . nm _index + '[quotainpercent]' ) . set _value ( _data . data . quotainpercent ) ;
this . et2 . getWidgetById ( this . nm _index + '[quotainpercent]' ) . set _label ( _data . data . quota ) ;
} ,
2013-07-25 17:35:44 +02:00
2013-04-13 12:30:07 +02:00
/ * *
* Queues a refreshFolderList request for 1 ms . Actually this will just execute the
* code after the calling script has finished .
* /
mail _queueRefreshFolderList : function ( _folders )
2013-02-13 15:02:02 +01:00
{
2013-04-13 12:30:07 +02:00
this . mail _queuedFolders . push ( _folders ) ;
this . mail _queuedFoldersIndex ++ ;
2013-07-25 17:35:44 +02:00
2013-04-13 12:30:07 +02:00
// Copy idx onto the anonymous function scope
var idx = this . mail _queuedFoldersIndex ;
var self = this ;
window . setTimeout ( function ( ) {
if ( idx == self . mail _queuedFoldersIndex )
{
//var folders = mail_queuedFolders.join(",");
self . mail _queuedFoldersIndex = 0 ;
self . mail _queuedFolders = [ ] ;
2013-07-25 17:35:44 +02:00
2013-09-10 22:41:18 +02:00
egw . json ( 'mail.mail_ui.ajax_setFolderStatus' , [ _folders ] )
. sendRequest ( true ) ;
2013-04-13 12:30:07 +02:00
}
} , 10 ) ;
} ,
2013-07-25 17:35:44 +02:00
2013-04-13 12:30:07 +02:00
/ * *
* mail _setFolderStatus , function to set the status for the visible folders
* /
mail _setFolderStatus : function ( _status ) {
2013-10-18 11:58:25 +02:00
var ftree = this . et2 . getWidgetById ( this . nm _index + '[foldertree]' ) ;
2013-04-13 12:30:07 +02:00
for ( var i in _status ) ftree . setLabel ( i , _status [ i ] ) ; //alert(i +'->'+_status[i]);
} ,
2013-07-25 17:35:44 +02:00
2013-04-29 16:56:33 +02:00
/ * *
* mail _setLeaf , function to set the id and description for the folder given by status key
2013-05-07 10:26:17 +02:00
* @ param array _status status array with the required data ( new id , desc , old desc )
* key is the original id of the leaf to change
* multiple sets can be passed to mail _setLeaf
2013-04-29 16:56:33 +02:00
* /
mail _setLeaf : function ( _status ) {
//console.log('mail_setLeaf',_status);
2013-10-18 11:58:25 +02:00
var ftree = this . et2 . getWidgetById ( this . nm _index + '[foldertree]' ) ;
2013-05-07 10:26:17 +02:00
var selectedNode = ftree . getSelectedNode ( ) ;
2013-04-29 16:56:33 +02:00
for ( var i in _status )
{
2013-05-10 09:24:27 +02:00
// if olddesc is undefined or #skip# then skip the message, as we process subfolders
2013-10-07 18:53:13 +02:00
if ( typeof _status [ i ] [ 'olddesc' ] !== 'undefined' && _status [ i ] [ 'olddesc' ] !== '#skip-user-interaction-message#' ) app . mail . app _refresh ( this . egw . lang ( "Renamed Folder %1 to %2" , _status [ i ] [ 'olddesc' ] , _status [ i ] [ 'desc' ] , 'mail' ) ) ;
2013-04-29 16:56:33 +02:00
ftree . renameItem ( i , _status [ i ] [ 'id' ] , _status [ i ] [ 'desc' ] ) ;
//alert(i +'->'+_status[i]['id']+'+'+_status[i]['desc']);
2013-05-07 10:26:17 +02:00
if ( _status [ i ] [ 'id' ] == selectedNode . id )
{
2013-10-18 11:58:25 +02:00
var nm = this . et2 . getWidgetById ( this . nm _index ) ;
2013-05-07 10:26:17 +02:00
nm . activeFilters [ "selectedFolder" ] = _status [ i ] [ 'id' ] ;
nm . applyFilters ( ) ;
}
2013-04-29 16:56:33 +02:00
}
} ,
2013-05-13 16:42:42 +02:00
/ * *
* mail _removeLeaf , function to remove the leaf represented by the given ID
* @ param array _status status array with the required data ( KEY id , VALUE desc )
* key is the id of the leaf to delete
* multiple sets can be passed to mail _deleteLeaf
* /
2013-05-21 10:46:54 +02:00
mail _removeLeaf : function ( _status ) {
2013-07-17 14:01:01 +02:00
//console.log('mail_removeLeaf',_status);
2013-10-18 11:58:25 +02:00
var ftree = this . et2 . getWidgetById ( this . nm _index + '[foldertree]' ) ;
2013-05-13 16:42:42 +02:00
var selectedNode = ftree . getSelectedNode ( ) ;
for ( var i in _status )
{
// if olddesc is undefined or #skip# then skip the message, as we process subfolders
2013-10-07 18:53:13 +02:00
if ( typeof _status [ i ] !== 'undefined' && _status [ i ] !== '#skip-user-interaction-message#' ) app . mail . app _refresh ( this . egw . lang ( "Removed Folder %1 " , _status [ i ] , 'mail' ) ) ;
2013-05-13 16:42:42 +02:00
ftree . deleteItem ( i , ( selectedNode . id == i ) ) ;
var selectedNodeAfter = ftree . getSelectedNode ( ) ;
//alert(i +'->'+_status[i]['id']+'+'+_status[i]['desc']);
if ( selectedNodeAfter . id != selectedNode . id && selectedNode . id == i )
{
2013-10-18 11:58:25 +02:00
var nm = this . et2 . getWidgetById ( this . nm _index ) ;
2013-05-13 16:42:42 +02:00
nm . activeFilters [ "selectedFolder" ] = selectedNodeAfter . id ;
nm . applyFilters ( ) ;
}
}
} ,
2013-05-21 10:46:54 +02:00
/ * *
* mail _reloadNode , function to reload the leaf represented by the given ID
* @ param array _status status array with the required data ( KEY id , VALUE desc )
* key is the id of the leaf to delete
* multiple sets can be passed to mail _deleteLeaf
* /
mail _reloadNode : function ( _status ) {
2013-07-17 14:01:01 +02:00
//console.log('mail_reloadNode',_status);
2013-10-18 11:58:25 +02:00
var ftree = this . et2 . getWidgetById ( this . nm _index + '[foldertree]' ) ;
2013-05-21 10:46:54 +02:00
var selectedNode = ftree . getSelectedNode ( ) ;
for ( var i in _status )
{
// if olddesc is undefined or #skip# then skip the message, as we process subfolders
2013-10-07 18:53:13 +02:00
if ( typeof _status [ i ] !== 'undefined' && _status [ i ] !== '#skip-user-interaction-message#' ) app . mail . app _refresh ( this . egw . lang ( "Reloaded Folder %1 " , _status [ i ] , 'mail' ) ) ;
2013-05-21 10:46:54 +02:00
ftree . refreshItem ( i ) ;
var selectedNodeAfter = ftree . getSelectedNode ( ) ;
//alert(i +'->'+_status[i]['id']+'+'+_status[i]['desc']);
if ( selectedNodeAfter . id != selectedNode . id && selectedNode . id == i )
{
2013-10-18 11:58:25 +02:00
var nm = this . et2 . getWidgetById ( this . nm _index ) ;
2013-05-21 10:46:54 +02:00
nm . activeFilters [ "selectedFolder" ] = selectedNodeAfter . id ;
nm . applyFilters ( ) ;
}
}
} ,
2013-04-13 12:30:07 +02:00
/ * *
* mail _refreshMessageGrid , function to call to reread ofthe current folder
* /
2013-10-05 11:03:51 +02:00
mail _refreshMessageGrid : function ( _isPopup ) {
if ( typeof _isPopup == 'undefined' ) _isPopup = false ;
var nm ;
2013-10-14 15:30:04 +02:00
if ( _isPopup && ! this . mail _isMainWindow )
2013-10-05 11:03:51 +02:00
{
nm = window . opener . etemplate2 . getByApplication ( 'mail' ) [ 0 ] . widgetContainer . getWidgetById ( this . nm _index ) ;
}
else
{
2013-10-18 11:58:25 +02:00
nm = this . et2 . getWidgetById ( this . nm _index ) ;
2013-10-05 11:03:51 +02:00
}
2013-04-13 12:30:07 +02:00
nm . applyFilters ( ) ; // this should refresh the active folder
} ,
2013-07-25 17:35:44 +02:00
2013-04-13 12:30:07 +02:00
/ * *
* Refresh given application _targetapp display of entry _app _id , incl . outputting _msg
2013-07-25 17:35:44 +02:00
*
2013-04-13 12:30:07 +02:00
* Default implementation here only reloads window with it ' s current url with an added msg = _msg attached
2013-07-25 17:35:44 +02:00
*
2013-04-13 12:30:07 +02:00
* @ 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
* @ param string _type = null either 'edit' , 'delete' , 'add' or null
* /
app _refresh : function ( _msg , _app , _id , _type )
2013-04-09 10:53:25 +02:00
{
2013-04-13 12:30:07 +02:00
var bufferExists = false ;
window . clearInterval ( app . mail . doStatus ) ; // whatever message was up to be activated
//alert("app_refresh(\'"+_msg+"\',\'"+_app+"\',\'"+_id+"\',\'"+_type+"\')");
//myCurrentMsg = mail_getMsg();
//if (myCurrentMsg.length) {
// clear message after some time
myMessageBuffer = "" ; //myCurrentMsg;
bufferExists = true ;
//}
2013-10-05 18:36:20 +02:00
//app.mail.mail_setMsg('<span style="font-weight: bold;">' +_msg+ '</span>');
egw _message ( _msg , _type ) ;
app . mail . mail _setMsg ( '' ) ; //without that applyFilters is not refreshing the index page
2013-04-13 12:30:07 +02:00
if ( _app == 'mail' )
{
//we may want to trigger some actions, like modifying the grid, disable preview and stuff
2013-07-25 17:35:44 +02:00
2013-04-13 12:30:07 +02:00
// TODO: more actions
}
if ( bufferExists )
{
2013-10-05 18:36:20 +02:00
//this.doStatus = window.setInterval("app.mail.mail_setMsg(myMessageBuffer);", 10000);
2013-04-13 12:30:07 +02:00
}
} ,
2013-07-25 17:35:44 +02:00
2013-04-13 12:30:07 +02:00
/ * *
* mail _getMsg - gets the current Message
* @ return string
* /
mail _getMsg : function ( )
2013-02-13 15:02:02 +01:00
{
2013-10-18 11:58:25 +02:00
var msg _wdg = this . et2 . getWidgetById ( 'msg' ) ;
2013-04-13 12:30:07 +02:00
if ( msg _wdg )
{
return msg _wdg . valueOf ( ) . htmlNode [ 0 ] . innerHTML ;
}
return "" ;
} ,
2013-07-25 17:35:44 +02:00
2013-04-13 12:30:07 +02:00
/ * *
* mail _setMsg - sets a Message , with the msg container , and controls if the container is enabled / disabled
* @ param string myMsg - the message
* /
mail _setMsg : function ( myMsg )
2013-02-13 15:02:02 +01:00
{
2013-10-18 11:58:25 +02:00
var msg _wdg = this . et2 . getWidgetById ( 'msg' ) ;
2013-04-13 12:30:07 +02:00
if ( msg _wdg )
{
msg _wdg . set _value ( myMsg ) ;
msg _wdg . set _disabled ( myMsg . trim ( ) . length == 0 ) ;
2013-02-28 10:28:08 +01:00
}
2013-04-13 12:30:07 +02:00
} ,
2013-07-25 17:35:44 +02:00
2013-04-13 12:30:07 +02:00
/ * *
* Delete mails
* takes in all arguments
* @ param _action
* @ param _elems
* /
mail _delete : function ( _action , _elems )
2013-02-13 15:02:02 +01:00
{
2013-10-05 18:36:20 +02:00
var calledFromPopup = false ;
if ( typeof _elems == 'undefined' )
{
calledFromPopup = true ;
if ( this . et2 . getArrayMgr ( "content" ) . getEntry ( 'mail_id' ) )
{
var _elems = [ ] ;
_elems . push ( { id : this . et2 . getArrayMgr ( "content" ) . getEntry ( 'mail_id' ) || '' } ) ;
}
2013-10-14 15:30:04 +02:00
if ( typeof _elems == 'undefined' && this . mail _isMainWindow )
{
if ( this . mail _currentlyFocussed )
{
var _elems = [ ] ;
_elems . push ( { id : this . mail _currentlyFocussed } ) ;
}
}
2013-10-05 18:36:20 +02:00
}
2013-04-13 12:30:07 +02:00
var msg = this . mail _getFormData ( _elems ) ;
//alert(_action.id+','+ msg);
2013-10-07 18:53:13 +02:00
app . mail . app _refresh ( this . egw . lang ( 'delete messages' ) , 'mail' ) ;
2013-10-05 18:36:20 +02:00
if ( ! calledFromPopup ) this . mail _setRowClass ( _elems , 'deleted' ) ;
this . mail _deleteMessages ( msg , 'no' , calledFromPopup ) ;
if ( calledFromPopup && this . mail _isMainWindow == false ) window . close ( ) ;
2013-05-27 15:48:55 +02:00
} ,
/ * *
* Delete mails - actually calls the backend function for deletion
* takes in all arguments
* @ param _msg - message list
* @ param _action - optional action
* /
2013-10-05 18:36:20 +02:00
mail _deleteMessages : function ( _msg , _action , _calledFromPopup )
2013-05-27 15:48:55 +02:00
{
2013-10-07 18:53:13 +02:00
app . mail . app _refresh ( this . egw . lang ( 'delete messages' ) , 'mail' ) ;
2013-09-10 22:41:18 +02:00
egw . json ( 'mail.mail_ui.ajax_deleteMessages' , [ _msg , ( typeof _action == 'undefined' ? 'no' : _action ) ] )
. sendRequest ( ) ;
2013-05-27 15:48:55 +02:00
for ( var i = 0 ; i < _msg [ 'msg' ] . length ; i ++ ) egw . dataDeleteUID ( _msg [ 'msg' ] [ i ] ) ;
2013-10-05 18:36:20 +02:00
this . mail _refreshMessageGrid ( _calledFromPopup ) ;
2013-05-21 10:46:54 +02:00
this . mail _preview ( ) ;
2013-04-13 12:30:07 +02:00
} ,
2013-05-27 15:48:55 +02:00
/ * *
* retry to Delete mails
* @ param responseObject - >
* reason - reason to report
* messageList
* /
mail _retryForcedDelete : function ( responseObject )
{
var reason = responseObject [ 'response' ] ;
var messageList = responseObject [ 'messageList' ] ;
Check = confirm ( reason ) ;
if ( Check == true )
{
this . mail _deleteMessages ( messageList , 'remove_immediately' ) ;
}
else
{
2013-10-07 18:53:13 +02:00
app . mail . app _refresh ( this . egw . lang ( 'canceled deletion due to userinteraction' ) , 'mail' ) ;
2013-05-27 15:48:55 +02:00
this . mail _removeRowClass ( messageList , 'deleted' ) ;
}
this . mail _refreshMessageGrid ( ) ;
this . mail _preview ( ) ;
} ,
2013-04-13 12:30:07 +02:00
/ * *
* UnDelete mailMessages
2013-07-25 17:35:44 +02:00
*
2013-04-13 12:30:07 +02:00
* @ param _messageList
* /
mail _undeleteMessages : function ( _messageList ) {
// setting class of row, the old style
/ *
for ( var i = 0 ; i < _messageList [ 'msg' ] . length ; i ++ ) {
_id = _messageList [ 'msg' ] [ i ] ;
var dataElem = egw _appWindow ( 'felamimail' ) . mailGrid . dataRoot . getElementById ( _id ) ;
if ( dataElem )
{
//dataElem.clearData();
//dataElem.addClass('deleted');
dataElem . removeClass ( 'deleted' ) ;
}
}
* /
} ,
2013-07-25 17:35:44 +02:00
2013-04-13 12:30:07 +02:00
/ * *
* mail _emptyTrash
* /
mail _emptyTrash : function ( ) {
2013-10-07 18:53:13 +02:00
app . mail . app _refresh ( this . egw . lang ( 'empty trash' ) , 'mail' ) ;
2013-09-10 22:41:18 +02:00
egw . json ( 'mail.mail_ui.ajax_emptyTrash' )
. sendRequest ( true ) ;
2013-04-13 12:30:07 +02:00
} ,
2013-07-25 17:35:44 +02:00
2013-04-13 12:30:07 +02:00
/ * *
* mail _compressFolder
* /
mail _compressFolder : function ( ) {
2013-10-07 18:53:13 +02:00
app . mail . app _refresh ( this . egw . lang ( 'compress folder' ) , 'mail' ) ;
2013-09-10 22:41:18 +02:00
egw . json ( 'mail.mail_ui.ajax_compressFolder' )
. sendRequest ( true ) ;
2013-04-13 12:30:07 +02:00
} ,
2013-07-25 17:35:44 +02:00
2013-04-13 12:30:07 +02:00
/ * *
* mail _changeProfile
* @ param folder , the ID of the selected Node - > should be an integer
* @ param _widget , handle to the tree widget
* /
mail _changeProfile : function ( folder , _widget ) {
// alert(folder);
2013-09-10 22:41:18 +02:00
egw . json ( 'mail.mail_ui.ajax_changeProfile' , [ folder ] )
. sendRequest ( ) ;
2013-04-13 12:30:07 +02:00
this . mail _refreshMessageGrid ( ) ;
2013-07-25 17:35:44 +02:00
2013-04-13 12:30:07 +02:00
return true ;
} ,
2013-07-25 17:35:44 +02:00
2013-04-13 12:30:07 +02:00
/ * *
* mail _changeFolder
* @ param folder , the ID of the selected Node
* @ param _widget , handle to the tree widget
* /
mail _changeFolder : function ( folder , _widget ) {
//alert('change Folder called:'+folder);
2013-10-18 11:58:25 +02:00
var server = folder . split ( '::' ) ;
2013-10-07 18:53:13 +02:00
app . mail . app _refresh ( this . egw . lang ( 'change folder' ) + '...' , 'mail' ) ;
2013-04-13 12:30:07 +02:00
var img = _widget . getSelectedNode ( ) . images [ 0 ] ; // fetch first image
if ( ! ( img . search ( eval ( '/' + 'NoSelect' + '/' ) ) < 0 ) || ! ( img . search ( eval ( '/' + 'thunderbird' + '/' ) ) < 0 ) )
2013-02-20 12:31:57 +01:00
{
2013-04-13 12:30:07 +02:00
if ( ! ( img . search ( eval ( '/' + 'thunderbird' + '/' ) ) < 0 ) )
{
rv = this . mail _changeProfile ( folder , _widget ) ;
if ( rv )
{
return rv ;
}
}
if ( _widget . event _args . length == 2 )
2013-02-20 12:31:57 +01:00
{
2013-04-13 12:30:07 +02:00
folder = _widget . event _args [ 1 ] ;
_widget . set _value ( folder ) ;
2013-02-20 12:31:57 +01:00
}
2013-04-13 12:30:07 +02:00
else
{
_widget . set _value ( '' ) ;
2013-07-25 17:35:44 +02:00
}
2013-02-20 12:31:57 +01:00
}
2013-08-21 12:47:20 +02:00
var nm = _widget . getRoot ( ) . getWidgetById ( this . nm _index ) ;
2013-04-13 12:30:07 +02:00
nm . activeFilters [ "selectedFolder" ] = folder ;
2013-05-28 16:10:17 +02:00
//nm.applyFilters();// its done in refrefreshMessageGrid
2013-04-13 12:30:07 +02:00
var msg = _widget . getRoot ( ) . getWidgetById ( 'msg' ) ;
if ( msg )
2013-02-13 15:02:02 +01:00
{
2013-04-13 12:30:07 +02:00
window . clearInterval ( this . doStatus ) ;
displayname = _widget . getSelectedLabel ( ) ;
inBraket = displayname . search ( /\(/ ) ;
if ( inBraket != - 1 )
{
outBraket = displayname . search ( /\)/ ) ;
2013-10-05 18:36:20 +02:00
if ( outBraket != - 1 )
{
displayname = displayname . replace ( /\((.*?)\)/ , "" ) ;
displayname = displayname . replace ( /<b>/ , "" ) ;
displayname = displayname . replace ( /<\/b>/ , "" ) ;
}
2013-04-13 12:30:07 +02:00
}
2013-10-07 18:53:13 +02:00
myMsg = ( displayname ? displayname : folder ) + ' ' + this . egw . lang ( 'selected' ) ;
2013-04-13 12:30:07 +02:00
app . mail . app _refresh ( myMsg , 'mail' ) ;
2013-02-13 15:02:02 +01:00
}
2013-05-28 16:10:17 +02:00
//mail_refreshMessageGrid();// its done in refreshFolderStatus already
2013-04-13 12:30:07 +02:00
this . mail _refreshFolderStatus ( folder , 'forced' ) ;
2013-10-18 11:58:25 +02:00
this . mail _refreshQuotaDisplay ( server [ 0 ] ) ;
2013-04-13 12:30:07 +02:00
this . mail _startTimerFolderStatusUpdate ( this . mail _refreshTimeOut ) ;
2013-05-21 14:02:58 +02:00
this . mail _fetchCurrentlyFocussed ( null , true ) ;
2013-05-21 10:46:54 +02:00
this . mail _preview ( ) ;
2013-04-13 12:30:07 +02:00
} ,
2013-07-25 17:35:44 +02:00
2013-04-13 12:30:07 +02:00
/ * *
* Flag mail as 'read' , 'unread' , 'flagged' or 'unflagged'
2013-07-25 17:35:44 +02:00
*
2013-04-13 12:30:07 +02:00
* @ param _action _action . id is 'read' , 'unread' , 'flagged' or 'unflagged'
* @ param _elems
* /
mail _flag : function ( _action , _elems )
2013-02-13 15:02:02 +01:00
{
2013-10-05 11:03:51 +02:00
var do _nmactions = true ;
var msg ;
if ( typeof _elems == 'undefined' )
{
do _nmactions = false ; //indicates that this action is probably a popup?
if ( this . et2 . getArrayMgr ( "content" ) . getEntry ( 'mail_id' ) )
{
msg = { } ;
msg [ 'msg' ] = [ this . et2 . getArrayMgr ( 'content' ) . getEntry ( 'mail_id' ) || '' ] ;
}
2013-10-14 15:30:04 +02:00
if ( typeof _elems == 'undefined' && this . mail _isMainWindow )
{
if ( this . mail _currentlyFocussed )
{
msg = { } ;
msg [ 'msg' ] = [ this . mail _currentlyFocussed ] ;
}
}
2013-10-05 11:03:51 +02:00
}
2013-04-13 12:30:07 +02:00
//alert(_action.id+' - '+_elems[0].id);
2013-10-04 11:33:44 +02:00
//console.log(_action, _elems);
2013-10-05 11:03:51 +02:00
if ( do _nmactions )
{
msg = this . mail _getFormData ( _elems ) ;
if ( _action . id . substring ( 0 , 2 ) == 'un' ) {
this . mail _removeRowClass ( _elems , _action . id . substring ( 2 ) ) ;
}
else
{
this . mail _removeRowClass ( _elems , 'un' + _action . id ) ;
}
this . mail _setRowClass ( _elems , _action . id ) ;
2013-10-04 11:33:44 +02:00
}
else
{
2013-10-05 11:03:51 +02:00
//mail_parentRefreshListRowStyle(msg,_action.id);
2013-10-04 11:33:44 +02:00
}
2013-10-05 11:03:51 +02:00
this . mail _flagMessages ( _action . id , msg , ( do _nmactions ? false : true ) ) ;
2013-04-13 12:30:07 +02:00
} ,
2013-07-25 17:35:44 +02:00
2013-04-13 12:30:07 +02:00
/ * *
* Flag mail as 'read' , 'unread' , 'flagged' or 'unflagged'
2013-07-25 17:35:44 +02:00
*
2013-04-13 12:30:07 +02:00
* @ param _action _action . id is 'read' , 'unread' , 'flagged' or 'unflagged'
* @ param _elems
* /
2013-10-05 11:03:51 +02:00
mail _flagMessages : function ( _flag , _elems , _isPopup )
2013-02-19 17:30:59 +01:00
{
2013-10-05 11:03:51 +02:00
console . log ( _flag , _elems ) ;
2013-10-07 18:53:13 +02:00
app . mail . app _refresh ( this . egw . lang ( 'flag messages' ) , 'mail' ) ;
2013-09-10 22:41:18 +02:00
egw . json ( 'mail.mail_ui.ajax_flagMessages' , [ _flag , _elems ] )
. sendRequest ( ) ;
2013-10-05 11:03:51 +02:00
this . mail _refreshMessageGrid ( _isPopup ) ;
2013-04-13 12:30:07 +02:00
} ,
2013-07-25 17:35:44 +02:00
2013-04-13 12:30:07 +02:00
/ * *
* display header lines , or source of mail , depending on the url given
2013-07-25 17:35:44 +02:00
*
2013-04-13 12:30:07 +02:00
* @ param _url
* /
mail _displayHeaderLines : function ( _url ) {
// only used by right clickaction
2013-10-01 13:29:54 +02:00
egw _openWindowCentered ( _url , 'mail_display_headerLines' , '870' , '600' , window . outerWidth / 2 , window . outerHeight / 2 ) ;
2013-04-13 12:30:07 +02:00
} ,
2013-07-25 17:35:44 +02:00
2013-04-13 12:30:07 +02:00
/ * *
* View header of a message
2013-07-25 17:35:44 +02:00
*
2013-04-13 12:30:07 +02:00
* @ param _action
* @ param _elems _elems [ 0 ] . id is the row - id
* /
mail _header : function ( _action , _elems )
{
2013-10-05 11:03:51 +02:00
if ( typeof _elems == 'undefined' )
{
if ( this . et2 . getArrayMgr ( "content" ) . getEntry ( 'mail_id' ) )
{
var _elems = [ ] ;
_elems . push ( { id : this . et2 . getArrayMgr ( "content" ) . getEntry ( 'mail_id' ) || '' } ) ;
}
2013-10-14 15:30:04 +02:00
if ( typeof _elems == 'undefined' && this . mail _isMainWindow )
{
if ( this . mail _currentlyFocussed )
{
var _elems = [ ] ;
_elems . push ( { id : this . mail _currentlyFocussed } ) ;
}
}
2013-10-05 11:03:51 +02:00
}
2013-04-13 12:30:07 +02:00
//alert('mail_header('+_elems[0].id+')');
var url = window . egw _webserverUrl + '/index.php?' ;
url += 'menuaction=mail.mail_ui.displayHeader' ; // todo compose for Draft folder
url += '&id=' + _elems [ 0 ] . id ;
this . mail _displayHeaderLines ( url ) ;
} ,
2013-07-25 17:35:44 +02:00
2013-04-13 12:30:07 +02:00
/ * *
* View message source
2013-07-25 17:35:44 +02:00
*
2013-04-13 12:30:07 +02:00
* @ param _action
* @ param _elems _elems [ 0 ] . id is the row - id
* /
mail _mailsource : function ( _action , _elems )
{
2013-10-05 11:03:51 +02:00
if ( typeof _elems == 'undefined' )
{
if ( this . et2 . getArrayMgr ( "content" ) . getEntry ( 'mail_id' ) )
{
var _elems = [ ] ;
_elems . push ( { id : this . et2 . getArrayMgr ( "content" ) . getEntry ( 'mail_id' ) || '' } ) ;
}
2013-10-14 15:30:04 +02:00
if ( typeof _elems == 'undefined' && this . mail _isMainWindow )
{
if ( this . mail _currentlyFocussed )
{
var _elems = [ ] ;
_elems . push ( { id : this . mail _currentlyFocussed } ) ;
}
}
2013-10-05 11:03:51 +02:00
}
2013-04-13 12:30:07 +02:00
//alert('mail_mailsource('+_elems[0].id+')');
var url = window . egw _webserverUrl + '/index.php?' ;
url += 'menuaction=mail.mail_ui.saveMessage' ; // todo compose for Draft folder
url += '&id=' + _elems [ 0 ] . id ;
url += '&location=display' ;
this . mail _displayHeaderLines ( url ) ;
} ,
2013-07-25 17:35:44 +02:00
2013-04-13 12:30:07 +02:00
/ * *
* Save a message
2013-07-25 17:35:44 +02:00
*
2013-04-13 12:30:07 +02:00
* @ param _action
* @ param _elems _elems [ 0 ] . id is the row - id
* /
mail _save : function ( _action , _elems )
{
2013-10-05 11:03:51 +02:00
if ( typeof _elems == 'undefined' )
{
if ( this . et2 . getArrayMgr ( "content" ) . getEntry ( 'mail_id' ) )
{
var _elems = [ ] ;
_elems . push ( { id : this . et2 . getArrayMgr ( "content" ) . getEntry ( 'mail_id' ) || '' } ) ;
}
2013-10-14 15:30:04 +02:00
if ( typeof _elems == 'undefined' && this . mail _isMainWindow )
{
if ( this . mail _currentlyFocussed )
{
var _elems = [ ] ;
_elems . push ( { id : this . mail _currentlyFocussed } ) ;
}
}
2013-10-05 11:03:51 +02:00
}
2013-04-13 12:30:07 +02:00
//alert('mail_save('+_elems[0].id+')');
var url = window . egw _webserverUrl + '/index.php?' ;
url += 'menuaction=mail.mail_ui.saveMessage' ; // todo compose for Draft folder
url += '&id=' + _elems [ 0 ] . id ;
//window.open(url,'_blank','dependent=yes,width=100,height=100,scrollbars=yes,status=yes');
document . location = url ;
} ,
2013-07-25 17:35:44 +02:00
2013-07-19 17:13:01 +02:00
/ * *
* User clicked an address ( FROM , TO , etc )
2013-10-16 13:22:53 +02:00
*
2013-10-09 19:29:36 +02:00
* @ param object tag _info with values for attributes id , label , title , ...
* @ param et2 _taglist widget
2013-07-19 17:13:01 +02:00
* /
2013-10-09 19:29:36 +02:00
address _click : function ( tag _info , widget )
2013-07-19 17:13:01 +02:00
{
console . log ( this , arguments ) ;
} ,
2013-07-25 17:35:44 +02:00
2013-10-16 13:25:46 +02:00
/ * *
*
* /
displayAttachment : function ( tag _info , widget )
{
//console.log(this, arguments, widget);
2013-10-21 15:07:32 +02:00
var mailid ;
var attgrid ;
if ( this . mail _isMainWindow )
{
mailid = this . mail _currentlyFocussed ; //this.et2.getArrayMgr("content").getEntry('mail_id');
var p = widget . getParent ( ) ;
var cont = p . getArrayMgr ( "content" ) . data ;
attgrid = cont [ widget . id . replace ( /\[filename\]/ , '' ) ] ;
}
else
{
mailid = this . et2 . getArrayMgr ( "content" ) . getEntry ( 'mail_id' ) ;
attgrid = this . et2 . getArrayMgr ( "content" ) . getEntry ( 'mail_displayattachments' ) [ widget . id . replace ( /\[filename\]/ , '' ) ] ;
}
2013-10-16 13:25:46 +02:00
//console.log(mailid,attgrid.partID,attgrid.filename,attgrid.mimetype);
var url = window . egw _webserverUrl + '/index.php?' ;
var width ;
var height ;
var windowName = 'mail' ;
switch ( attgrid . type . toUpperCase ( ) )
{
case 'MESSAGE/RFC822' :
url += 'menuaction=mail.mail_ui.displayMessage' ; // todo compose for Draft folder
url += '&id=' + mailid ;
url += '&part=' + attgrid . partID ;
url += '&is_winmail=' + attgrid . winmailFlag ;
windowName = windowName + 'displayMessage_' + mailid + '_' + attgrid . partID ;
width = 870 ;
height = egw _getWindowOuterHeight ( ) ;
break ;
case 'IMAGE/JPEG' :
case 'IMAGE/PNG' :
case 'IMAGE/GIF' :
case 'IMAGE/BMP' :
case 'APPLICATION/PDF' :
case 'TEXT/PLAIN' :
case 'TEXT/HTML' :
case 'TEXT/DIRECTORY' :
/ *
$sfxMimeType = $value [ 'mimeType' ] ;
$buff = explode ( '.' , $value [ 'name' ] ) ;
$suffix = '' ;
if ( is _array ( $buff ) ) $suffix = array _pop ( $buff ) ; // take the last extension to check with ext2mime
if ( ! empty ( $suffix ) ) $sfxMimeType = mime _magic : : ext2mime ( $suffix ) ;
if ( strtoupper ( $sfxMimeType ) == 'TEXT/VCARD' || strtoupper ( $sfxMimeType ) == 'TEXT/X-VCARD' )
{
$attachments [ $key ] [ 'mimeType' ] = $sfxMimeType ;
$value [ 'mimeType' ] = strtoupper ( $sfxMimeType ) ;
}
* /
case 'TEXT/X-VCARD' :
case 'TEXT/VCARD' :
case 'TEXT/CALENDAR' :
case 'TEXT/X-VCALENDAR' :
url += 'menuaction=mail.mail_ui.getAttachment' ; // todo compose for Draft folder
url += '&id=' + mailid ;
url += '&part=' + attgrid . partID ;
url += '&is_winmail=' + attgrid . winmailFlag ;
windowName = windowName + 'displayAttachment_' + mailid + '_' + attgrid . partID ;
var reg = '800x600' ;
var reg2 ;
// handle calendar/vcard
if ( attgrid . type . toUpperCase ( ) == 'TEXT/CALENDAR' )
{
windowName = 'maildisplayEvent_' + mailid + '_' + attgrid . partID ;
reg2 = egw . link _get _registry ( 'calendar' ) ;
if ( typeof app _registry [ 'view' ] != 'undefined' && typeof app _registry [ 'view_popup' ] != 'undefined' )
{
reg = app _registry [ 'view_popup' ] ;
}
}
if ( attgrid . type . toUpperCase ( ) == 'TEXT/X-VCARD' || attgrid . type . toUpperCase ( ) == 'TEXT/VCARD' )
{
windowName = 'maildisplayContact_' + mailid + '_' + attgrid . partID ;
reg2 = egw . link _get _registry ( 'addressbook' ) ;
if ( typeof app _registry [ 'add' ] != 'undefined' && typeof app _registry [ 'add_popup' ] != 'undefined' )
{
reg = app _registry [ 'add_popup' ] ;
}
}
var w _h = reg . split ( 'x' ) ;
width = w _h [ 0 ] ;
height = w _h [ 1 ] ;
break ;
default :
url += 'menuaction=mail.mail_ui.getAttachment' ; // todo compose for Draft folder
url += '&id=' + mailid ;
url += '&part=' + attgrid . partID ;
url += '&is_winmail=' + attgrid . winmailFlag ;
windowName = windowName + 'displayAttachment_' + mailid + '_' + attgrid . partID ;
width = 870 ;
height = 600 ;
//document.location = url;
//return;
}
egw _openWindowCentered ( url , windowName , width , height ) ;
} ,
saveAttachment : function ( tag _info , widget )
{
//console.log(this, arguments);
2013-10-21 15:07:32 +02:00
var mailid ;
var attgrid ;
if ( this . mail _isMainWindow )
{
mailid = this . mail _currentlyFocussed ; //this.et2.getArrayMgr("content").getEntry('mail_id');
var p = widget . getParent ( ) ;
var cont = p . getArrayMgr ( "content" ) . data ;
attgrid = cont [ widget . id . replace ( /\[save\]/ , '' ) ] ;
}
else
{
mailid = this . et2 . getArrayMgr ( "content" ) . getEntry ( 'mail_id' ) ;
attgrid = this . et2 . getArrayMgr ( "content" ) . getEntry ( 'mail_displayattachments' ) [ widget . id . replace ( /\[save\]/ , '' ) ] ;
}
2013-10-16 13:25:46 +02:00
//console.log(mailid,attgrid.partID,attgrid.filename,attgrid.mimetype);
var url = window . egw _webserverUrl + '/index.php?' ;
var width ;
var height ;
var windowName = 'mail' ;
url += 'menuaction=mail.mail_ui.getAttachment' ; // todo compose for Draft folder
url += '&mode=save' ;
url += '&id=' + mailid ;
url += '&part=' + attgrid . partID ;
url += '&is_winmail=' + attgrid . winmailFlag ;
document . location = url ;
} ,
saveAttachmentToVFS : function ( tag _info , widget )
{
//console.log(this, arguments);
2013-10-21 15:07:32 +02:00
var mailid ;
var attgrid ;
if ( this . mail _isMainWindow )
{
mailid = this . mail _currentlyFocussed ; //this.et2.getArrayMgr("content").getEntry('mail_id');
var p = widget . getParent ( ) ;
var cont = p . getArrayMgr ( "content" ) . data ;
attgrid = cont [ widget . id . replace ( /\[saveAsVFS\]/ , '' ) ] ;
}
else
{
mailid = this . et2 . getArrayMgr ( "content" ) . getEntry ( 'mail_id' ) ;
attgrid = this . et2 . getArrayMgr ( "content" ) . getEntry ( 'mail_displayattachments' ) [ widget . id . replace ( /\[saveAsVFS\]/ , '' ) ] ;
}
2013-10-16 13:25:46 +02:00
//console.log(mailid,attgrid.partID,attgrid.filename,attgrid.mimetype);
var url = window . egw _webserverUrl + '/index.php?' ;
var width = 640 ;
var height = 570 ;
var windowName = 'mail' ;
url += 'menuaction=filemanager.filemanager_select.select' ; // todo compose for Draft folder
url += '&mode=saveas' ;
url += '&id=' + mailid + '::' + attgrid . partID + '::' + attgrid . winmailFlag ;
url += '&name=' + attgrid . filename ;
url += '&type=' + attgrid . type . toLowerCase ( ) ;
url += '&method=mail.mail_ui.vfsSaveAttachment' ;
url += '&label=' + egw . lang ( 'Save' ) ;
egw _openWindowCentered ( url , windowName , width , height ) ;
} ,
saveAllAttachmentsToVFS : function ( tag _info , widget )
{
2013-10-21 15:07:32 +02:00
var mailid ;
var attgrid ;
if ( this . mail _isMainWindow )
{
mailid = this . mail _currentlyFocussed ; //this.et2.getArrayMgr("content").getEntry('mail_id');
var p = widget . getParent ( ) ;
attgrid = p . getArrayMgr ( "content" ) . data ;
}
else
{
mailid = this . et2 . getArrayMgr ( "content" ) . getEntry ( 'mail_id' ) ;
attgrid = this . et2 . getArrayMgr ( "content" ) . getEntry ( 'mail_displayattachments' ) ;
}
2013-10-16 13:25:46 +02:00
console . log ( mailid , attgrid ) ;
var url = window . egw _webserverUrl + '/index.php?' ;
var width = 640 ;
var height = 570 ;
var windowName = 'mail' ;
url += 'menuaction=filemanager.filemanager_select.select' ; // todo compose for Draft folder
url += '&mode=select-dir' ;
url += '&method=mail.mail_ui.vfsSaveAttachment' ;
url += '&label=' + egw . lang ( 'Save all' ) ;
for ( i = 0 ; i < attgrid . length ; i ++ )
{
if ( attgrid [ i ] != null ) url += '&id[' + i + ']=' + mailid + '::' + attgrid [ i ] . partID + '::' + attgrid [ i ] . winmailFlag + '::' + attgrid [ i ] . filename ;
}
egw _openWindowCentered ( url , windowName , width , height ) ;
} ,
2013-04-13 12:30:07 +02:00
/ * *
* Save a message to filemanager
2013-07-25 17:35:44 +02:00
*
2013-04-13 12:30:07 +02:00
* @ param _action
* @ param _elems _elems [ 0 ] . id is the row - id
* /
mail _save2fm : function ( _action , _elems )
{
2013-10-05 11:03:51 +02:00
if ( typeof _elems == 'undefined' )
{
if ( this . et2 . getArrayMgr ( "content" ) . getEntry ( 'mail_id' ) )
{
var _elems = [ ] ;
_elems . push ( { id : this . et2 . getArrayMgr ( "content" ) . getEntry ( 'mail_id' ) || '' } ) ;
}
2013-10-14 15:30:04 +02:00
if ( typeof _elems == 'undefined' && this . mail _isMainWindow )
{
if ( this . mail _currentlyFocussed )
{
var _elems = [ ] ;
_elems . push ( { id : this . mail _currentlyFocussed } ) ;
}
}
2013-10-05 11:03:51 +02:00
}
2013-04-13 12:30:07 +02:00
var _id = _elems [ 0 ] . id ;
var dataElem = egw . dataGetUIDdata ( _id ) ;
var url = window . egw _webserverUrl + '/index.php?' ;
url += 'menuaction=filemanager.filemanager_select.select' ; // todo compose for Draft folder
url += '&mode=saveas' ;
var filename = dataElem . data . subject . replace ( /[\f\n\t\v/\\:*#?<>\|]/g , "_" ) ;
url += '&name=' + encodeURIComponent ( filename + '.eml' ) ;
url += '&mime=message' + encodeURIComponent ( '/' ) + 'rfc822' ;
url += '&method=mail.mail_ui.vfsSaveMessage'
url += '&id=' + _elems [ 0 ] . id ;
url += '&label=Save' ;
//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 ) ;
2013-07-25 17:35:44 +02:00
2013-04-13 12:30:07 +02:00
} ,
2013-07-25 17:35:44 +02:00
2013-04-13 12:30:07 +02:00
/ * *
* Save message as InfoLog
2013-07-25 17:35:44 +02:00
*
2013-04-13 12:30:07 +02:00
* @ param _action
* @ param _elems _elems [ 0 ] . id is the row - id
* /
mail _infolog : function ( _action , _elems )
2013-02-19 17:30:59 +01:00
{
2013-10-05 11:03:51 +02:00
if ( typeof _elems == 'undefined' )
{
if ( this . et2 . getArrayMgr ( "content" ) . getEntry ( 'mail_id' ) )
{
var _elems = [ ] ;
_elems . push ( { id : this . et2 . getArrayMgr ( "content" ) . getEntry ( 'mail_id' ) || '' } ) ;
}
2013-10-14 15:30:04 +02:00
if ( typeof _elems == 'undefined' && this . mail _isMainWindow )
{
if ( this . mail _currentlyFocussed )
{
var _elems = [ ] ;
_elems . push ( { id : this . mail _currentlyFocussed } ) ;
}
}
if ( typeof _action . data . width == 'undefined' && typeof _action . data . height == 'undefined' && ! ( typeof _action . data . event == 'undefined' && typeof _action . data . event . popup == 'undefined' ) )
{
if ( _action . data . event . popup )
{
var app _registry = _action . data . event . popup ;
}
else
{
var app _registry = egw . link _get _registry ( 'infolog' ) ; //this.appname);
}
//console.log(app_registry);
if ( typeof app _registry [ 'edit' ] != 'undefined' && typeof app _registry [ 'edit_popup' ] != 'undefined' )
{
var w _h = app _registry [ 'edit_popup' ] . split ( 'x' ) ;
}
}
2013-10-05 11:03:51 +02:00
}
2013-04-13 12:30:07 +02:00
//alert('mail_infolog('+_elems[0].id+')');return;
2013-10-16 13:25:46 +02:00
//console.log(_action, _elems);
2013-04-13 12:30:07 +02:00
var url = window . egw _webserverUrl + '/index.php?' ;
url += 'menuaction=infolog.infolog_ui.import_mail' ; // todo compose for Draft folder
url += '&rowid=' + _elems [ 0 ] . id ;
2013-10-14 15:30:04 +02:00
egw _openWindowCentered ( url , 'import_mail_' + _elems [ 0 ] . id , ( _action . data . width ? _action . data . width : w _h [ 0 ] ) , ( _action . data . height ? _action . data . height : w _h [ 1 ] ) ) ;
2013-04-13 12:30:07 +02:00
} ,
2013-07-25 17:35:44 +02:00
2013-04-13 12:30:07 +02:00
/ * *
* Save message as ticket
2013-07-25 17:35:44 +02:00
*
2013-04-13 12:30:07 +02:00
* @ param _action _action . id is 'read' , 'unread' , 'flagged' or 'unflagged'
* @ param _elems
* /
mail _tracker : function ( _action , _elems )
{
2013-10-05 11:03:51 +02:00
if ( typeof _elems == 'undefined' )
{
if ( this . et2 . getArrayMgr ( "content" ) . getEntry ( 'mail_id' ) )
{
var _elems = [ ] ;
_elems . push ( { id : this . et2 . getArrayMgr ( "content" ) . getEntry ( 'mail_id' ) || '' } ) ;
}
2013-10-14 15:30:04 +02:00
if ( typeof _elems == 'undefined' && this . mail _isMainWindow )
{
if ( this . mail _currentlyFocussed )
{
var _elems = [ ] ;
_elems . push ( { id : this . mail _currentlyFocussed } ) ;
}
}
if ( typeof _action . data . width == 'undefined' && typeof _action . data . height == 'undefined' && ! ( typeof _action . data . event == 'undefined' && typeof _action . data . event . popup == 'undefined' ) )
{
if ( _action . data . event . popup )
{
var app _registry = _action . data . event . popup ;
}
else
{
var app _registry = egw . link _get _registry ( 'infolog' ) ; //this.appname);
}
//console.log(app_registry);
if ( typeof app _registry [ 'edit' ] != 'undefined' && typeof app _registry [ 'edit_popup' ] != 'undefined' )
{
var w _h = app _registry [ 'edit_popup' ] . split ( 'x' ) ;
}
}
2013-10-05 11:03:51 +02:00
}
2013-04-13 12:30:07 +02:00
//alert('mail_tracker('+_elems[0].id+')');
var url = window . egw _webserverUrl + '/index.php?' ;
url += 'menuaction=tracker.tracker_ui.import_mail' ; // todo compose for Draft folder
url += '&rowid=' + _elems [ 0 ] . id ;
2013-10-14 15:30:04 +02:00
egw _openWindowCentered ( url , 'import_tracker_' + _elems [ 0 ] . id , ( _action . data . width ? _action . data . width : w _h [ 0 ] ) , ( _action . data . height ? _action . data . height : w _h [ 1 ] ) ) ;
2013-04-13 12:30:07 +02:00
} ,
2013-07-25 17:35:44 +02:00
2013-04-13 12:30:07 +02:00
/ * *
* mail _getFormData
2013-07-25 17:35:44 +02:00
*
2013-04-13 12:30:07 +02:00
* @ param _actionObjects , the senders
* @ return structured array of message ids : array ( msg => message - ids )
* /
mail _getFormData : function ( _actionObjects ) {
var messages = { } ;
if ( _actionObjects . length > 0 )
2013-02-19 17:30:59 +01:00
{
2013-04-13 12:30:07 +02:00
messages [ 'msg' ] = [ ] ;
2013-02-19 17:30:59 +01:00
}
2013-07-25 17:35:44 +02:00
2013-04-30 16:16:52 +02:00
for ( var i = 0 ; i < _actionObjects . length ; i ++ )
2013-02-28 10:28:08 +01:00
{
2013-04-13 12:30:07 +02:00
if ( _actionObjects [ i ] . id . length > 0 )
{
messages [ 'msg' ] [ i ] = _actionObjects [ i ] . id ;
}
2013-02-28 10:28:08 +01:00
}
2013-07-25 17:35:44 +02:00
2013-04-13 12:30:07 +02:00
return messages ;
} ,
2013-07-25 17:35:44 +02:00
2013-04-13 12:30:07 +02:00
/ * *
* mail _setRowClass
2013-07-25 17:35:44 +02:00
*
2013-04-13 12:30:07 +02:00
* @ param _actionObjects , the senders
* /
mail _setRowClass : function ( _actionObjects , _class ) {
if ( typeof _class == 'undefined' ) return false ;
2013-07-25 17:35:44 +02:00
for ( var i = 0 ; i < _actionObjects . length ; i ++ )
2013-04-13 12:30:07 +02:00
{
if ( _actionObjects [ i ] . id . length > 0 )
{
var dataElem = $j ( _actionObjects [ i ] . iface . getDOMNode ( ) ) ;
dataElem . addClass ( _class ) ;
2013-07-25 17:35:44 +02:00
2013-04-13 12:30:07 +02:00
}
}
} ,
2013-07-25 17:35:44 +02:00
2013-05-27 15:48:55 +02:00
/ * *
* mail _removeRowClass
2013-07-25 17:35:44 +02:00
*
2013-05-27 15:48:55 +02:00
* @ param _actionObjects , the senders , or a messages object
* @ param _class , the class to be removed
* /
mail _removeRowClass : function ( _actionObjects , _class ) {
if ( typeof _class == 'undefined' ) return false ;
if ( typeof _actionObjects [ 'msg' ] == 'undefined' )
{
2013-07-25 17:35:44 +02:00
for ( var i = 0 ; i < _actionObjects . length ; i ++ )
2013-05-27 15:48:55 +02:00
{
if ( _actionObjects [ i ] . id . length > 0 )
{
var dataElem = $j ( _actionObjects [ i ] . iface . getDOMNode ( ) ) ;
dataElem . removeClass ( _class ) ;
2013-07-25 17:35:44 +02:00
2013-05-27 15:48:55 +02:00
}
}
}
else
{
2013-10-18 11:58:25 +02:00
var nm = this . et2 . getWidgetById ( this . nm _index ) ;
2013-05-27 15:48:55 +02:00
var aO = nm . controller . _objectManager . selectedChildren ;
2013-07-25 17:35:44 +02:00
for ( var i = 0 ; i < _actionObjects [ 'msg' ] . length ; i ++ )
2013-05-27 15:48:55 +02:00
{
2013-07-25 17:35:44 +02:00
for ( var i = 0 ; i < aO . length ; i ++ )
2013-05-27 15:48:55 +02:00
{
if ( aO [ i ] . id == _actionObjects [ 'msg' ] [ i ] )
{
var dataElem = $j ( aO [ i ] . iface . getDOMNode ( ) ) ;
dataElem . removeClass ( _class ) ;
2013-07-25 17:35:44 +02:00
2013-05-27 15:48:55 +02:00
}
2013-07-25 17:35:44 +02:00
}
2013-05-27 15:48:55 +02:00
}
}
} ,
2013-04-13 12:30:07 +02:00
// Tree widget stubs
/ * *
* mail _dragStart - displays information while dragging
2013-07-25 17:35:44 +02:00
*
2013-04-13 12:30:07 +02:00
* @ param action
* @ param _senders - the representation of the elements dragged
* @ return the ddhelper
* /
mail _dragStart : function ( action , _senders ) {
//console.log(action,_senders);
return $j ( "<div class=\"ddhelper\">" + _senders . length + " Mails selected </div>" ) ;
} ,
/ * *
* mail _move - implementation of the move action from drag n drop
2013-07-25 17:35:44 +02:00
*
2013-04-13 12:30:07 +02:00
* @ param _action
* @ param _senders - the representation of the elements dragged
* @ param _target - the representation of the target
* /
mail _move : function ( _action , _senders , _target ) {
//console.log(_action,_senders,_target);
var target = _action . id == 'drop_move_mail' ? _target . iface . id : _action . id . substr ( 5 ) ;
var messages = this . mail _getFormData ( _senders ) ;
//alert('mail_move('+messages.msg.join(',')+' --> '+target+')');
// TODO: Write move/copy function which cares about doing the same stuff
// as the "onNodeSelect" function!
2013-09-10 22:41:18 +02:00
egw . json ( 'mail.mail_ui.ajax_moveMessages' , [ target , messages ] )
. sendRequest ( ) ;
2013-10-18 11:58:25 +02:00
var nm = this . et2 . getWidgetById ( this . nm _index ) ;
2013-06-04 17:29:53 +02:00
this . mail _setRowClass ( _senders , 'deleted' ) ;
nm . refresh ( messages [ 'msg' ] , 'delete' )
//for (var i = 0; i < messages['msg'].length; i++) egw.dataDeleteUID(messages['msg'][i]);
2013-04-13 12:30:07 +02:00
this . mail _refreshMessageGrid ( ) ;
} ,
/ * *
* mail _copy - implementation of the copy action from drag n drop
2013-07-25 17:35:44 +02:00
*
2013-04-13 12:30:07 +02:00
* @ param _action
* @ param _senders - the representation of the elements dragged
* @ param _target - the representation of the target
* /
mail _copy : function ( _action , _senders , _target ) {
//console.log(_action,_senders,_target);
2013-04-29 16:56:33 +02:00
var target = _action . id == 'drop_copy_mail' ? _target . iface . id : _action . id . substr ( 5 ) ;
2013-04-13 12:30:07 +02:00
var messages = this . mail _getFormData ( _senders ) ;
//alert('mail_copy('+messages.msg.join(',')+' --> '+target+')');
// TODO: Write move/copy function which cares about doing the same stuff
// as the "onNodeSelect" function!
2013-09-10 22:41:18 +02:00
egw . json ( 'mail.mail_ui.ajax_copyMessages' , [ target , messages ] )
. sendRequest ( ) ;
2013-04-13 12:30:07 +02:00
this . mail _refreshMessageGrid ( ) ;
} ,
2013-05-21 10:46:54 +02:00
/ * *
* mail _AddFolder - implementation of the AddFolder action of right click options on the tree
2013-07-25 17:35:44 +02:00
*
2013-05-21 10:46:54 +02:00
* @ param _action
* @ param _senders - the representation of the tree leaf to be manipulated
* /
mail _AddFolder : function ( action , _senders ) {
//console.log(action,_senders);
//action.id == 'add'
//_senders.iface.id == target leaf / leaf to edit
2013-10-18 11:58:25 +02:00
var ftree = this . et2 . getWidgetById ( this . nm _index + '[foldertree]' ) ;
2013-05-21 10:46:54 +02:00
OldFolderName = ftree . getLabel ( _senders [ 0 ] . iface . id ) ;
if ( jQuery ( OldFolderName ) . text ( ) . length > 0 ) OldFolderName = jQuery ( OldFolderName ) . text ( ) ;
OldFolderName = OldFolderName . trim ( ) ;
OldFolderName = OldFolderName . replace ( /\([0-9]*\)/g , '' ) . trim ( ) ;
//console.log(OldFolderName);
2013-10-07 18:53:13 +02:00
NewFolderName = prompt ( this . egw . lang ( "Add a new Folder to %1:" , OldFolderName ) ) ;
2013-05-21 10:46:54 +02:00
if ( jQuery ( NewFolderName ) . text ( ) . length > 0 ) NewFolderName = jQuery ( NewFolderName ) . text ( ) ;
//alert(NewFolderName);
if ( NewFolderName && NewFolderName . length > 0 )
{
2013-10-07 18:53:13 +02:00
app . mail . app _refresh ( this . egw . lang ( "Adding Folder %1 to %2" , NewFolderName , OldFolderName , 'mail' ) ) ;
2013-09-10 22:41:18 +02:00
egw . json ( 'mail.mail_ui.ajax_addFolder' , [ _senders [ 0 ] . iface . id , NewFolderName ] )
. sendRequest ( true ) ;
2013-05-21 10:46:54 +02:00
}
} ,
2013-04-13 12:30:07 +02:00
/ * *
* mail _RenameFolder - implementation of the RenameFolder action of right click options on the tree
2013-07-25 17:35:44 +02:00
*
2013-04-13 12:30:07 +02:00
* @ param _action
* @ param _senders - the representation of the tree leaf to be manipulated
* /
mail _RenameFolder : function ( action , _senders ) {
//console.log(action,_senders);
//action.id == 'rename'
//_senders.iface.id == target leaf / leaf to edit
2013-10-18 11:58:25 +02:00
var ftree = this . et2 . getWidgetById ( this . nm _index + '[foldertree]' ) ;
2013-04-13 12:30:07 +02:00
OldFolderName = ftree . getLabel ( _senders [ 0 ] . iface . id ) ;
if ( jQuery ( OldFolderName ) . text ( ) . length > 0 ) OldFolderName = jQuery ( OldFolderName ) . text ( ) ;
OldFolderName = OldFolderName . trim ( ) ;
OldFolderName = OldFolderName . replace ( /\([0-9]*\)/g , '' ) . trim ( ) ;
//console.log(OldFolderName);
2013-10-07 18:53:13 +02:00
NewFolderName = prompt ( this . egw . lang ( "Rename Folder %1 to:" , OldFolderName ) ) ;
2013-04-13 12:30:07 +02:00
if ( jQuery ( NewFolderName ) . text ( ) . length > 0 ) NewFolderName = jQuery ( NewFolderName ) . text ( ) ;
//alert(NewFolderName);
if ( NewFolderName && NewFolderName . length > 0 )
{
2013-10-07 18:53:13 +02:00
app . mail . app _refresh ( this . egw . lang ( "Renaming Folder %1 to %2" , OldFolderName , NewFolderName , 'mail' ) ) ;
2013-09-10 22:41:18 +02:00
egw . json ( 'mail.mail_ui.ajax_renameFolder' , [ _senders [ 0 ] . iface . id , NewFolderName ] )
. sendRequest ( true ) ;
2013-04-13 12:30:07 +02:00
}
2013-05-13 16:42:42 +02:00
} ,
/ * *
* mail _DeleteFolder - implementation of the DeleteFolder action of right click options on the tree
2013-07-25 17:35:44 +02:00
*
2013-05-13 16:42:42 +02:00
* @ param _action
* @ param _senders - the representation of the tree leaf to be manipulated
* /
mail _DeleteFolder : function ( action , _senders ) {
//console.log(action,_senders);
//action.id == 'delete'
//_senders.iface.id == target leaf / leaf to edit
2013-10-18 11:58:25 +02:00
var ftree = this . et2 . getWidgetById ( this . nm _index + '[foldertree]' ) ;
2013-05-13 16:42:42 +02:00
OldFolderName = ftree . getLabel ( _senders [ 0 ] . iface . id ) ;
if ( jQuery ( OldFolderName ) . text ( ) . length > 0 ) OldFolderName = jQuery ( OldFolderName ) . text ( ) ;
OldFolderName = OldFolderName . trim ( ) ;
OldFolderName = OldFolderName . replace ( /\([0-9]*\)/g , '' ) . trim ( ) ;
//console.log(OldFolderName);
2013-10-07 18:53:13 +02:00
reallyDelete = confirm ( this . egw . lang ( "Do you really want to DELETE Folder %1 ? \r\nAll messages in the folder will be lost" , OldFolderName ) ) ;
2013-05-13 16:42:42 +02:00
if ( reallyDelete )
{
2013-10-07 18:53:13 +02:00
app . mail . app _refresh ( this . egw . lang ( "Deleting Folder %1" , OldFolderName , 'mail' ) ) ;
2013-09-10 22:41:18 +02:00
egw . json ( 'mail.mail_ui.ajax_deleteFolder' , [ _senders [ 0 ] . iface . id ] )
. sendRequest ( true ) ;
2013-05-13 16:42:42 +02:00
}
2013-07-25 17:35:44 +02:00
} ,
2013-09-02 17:15:35 +02:00
/ * *
* Send names of uploaded files ( again ) to server , to process them : either copy to vfs or ask overwrite / rename
2013-10-09 18:44:03 +02:00
*
2013-09-02 17:15:35 +02:00
* @ param _event
* @ param _file _count
* @ param { string } [ _path = current directory ] Where the file is uploaded to .
* /
uploadForImport : function ( _event , _file _count , _path )
{
2013-09-05 16:52:11 +02:00
//console.log(_event,_file_count,_path);
// path is probably not needed when uploading for file; maybe it is when from vfs
2013-09-02 17:15:35 +02:00
if ( typeof _path == 'undefined' )
{
//_path = this.get_path();
}
if ( _file _count && ! jQuery . isEmptyObject ( _event . data . getValue ( ) ) )
{
2013-09-05 16:52:11 +02:00
var widget = _event . data ;
//console.log(widget.getValue());
// var request = new egw_json_request('mail_ui::ajax_importMessage', ['upload', widget.getValue(), _path], this);
2013-09-02 17:15:35 +02:00
// widget.set_value('');
2013-09-05 16:52:11 +02:00
// request.sendRequest();//false, this._upload_callback, this);
2013-09-10 15:39:44 +02:00
this . et2 _obj . submit ( ) ;
}
} ,
/ * *
* Send names of uploaded files ( again ) to server , to process them : either copy to vfs or ask overwrite / rename
2013-10-09 18:44:03 +02:00
*
2013-09-10 15:39:44 +02:00
* @ param _event
* @ param _file _count
* @ param { string } [ _path = current directory ] Where the file is uploaded to .
* /
uploadForCompose : function ( _event , _file _count , _path )
{
//console.log(_event,_file_count,_path);
// path is probably not needed when uploading for file; maybe it is when from vfs
if ( typeof _path == 'undefined' )
{
//_path = this.get_path();
}
if ( _file _count && ! jQuery . isEmptyObject ( _event . data . getValue ( ) ) )
{
var widget = _event . data ;
//console.log(widget.getValue());
// var request = new egw_json_request('mail_ui::ajax_importMessage', ['upload', widget.getValue(), _path], this);
// widget.set_value('');
// request.sendRequest();//false, this._upload_callback, this);
2013-09-11 15:46:00 +02:00
this . et2 _obj . submit ( ) ;
2013-09-02 17:15:35 +02:00
}
} ,
2013-10-03 18:09:25 +02:00
vfsUploadForImport : function ( _egw , _widget , _window ) {
2013-10-04 13:17:45 +02:00
//console.log(_egw, _widget, _window);
2013-10-03 18:09:25 +02:00
if ( ! jQuery . isEmptyObject ( _widget . getValue ( ) ) )
{
this . et2 _obj . submit ( ) ;
}
} ,
2013-10-02 16:50:24 +02:00
vfsUploadForCompose : function ( _egw , _widget , _window )
{
2013-10-04 13:17:45 +02:00
//console.log(_egw, _widget, _window);
if ( ! jQuery . isEmptyObject ( _widget . getValue ( ) ) )
{
this . et2 _obj . submit ( ) ;
}
} ,
submitOnChange : function ( _egw , _widget , _window ) {
//console.log(_egw, _widget, _window);
2013-10-02 16:50:24 +02:00
if ( ! jQuery . isEmptyObject ( _widget . getValue ( ) ) )
{
this . et2 _obj . submit ( ) ;
}
} ,
saveAsDraft : function ( _egw , _widget , _window )
{
this . et2 _obj . submit ( ) ;
} ,
2013-10-07 17:02:35 +02:00
saveAsDraftAndPrint : function ( _egw , _widget , _window )
{
this . et2 _obj . submit ( ) ;
} ,
2013-10-16 13:22:53 +02:00
2013-10-18 16:04:04 +02:00
signature _open : function ( _egw , _widget )
{
var id = _widget [ 0 ] . id . replace ( /row_/ , '' ) ;
var siggrid = this . et2 . getArrayMgr ( "content" ) . getEntry ( 'sig' ) [ id ] ;
console . log ( _egw , _widget , siggrid , id ) ;
} ,
signature _delete : function ( _egw , _widget )
{
var id = _widget [ 0 ] . id . replace ( /row_/ , '' ) ;
var siggrid = this . et2 . getArrayMgr ( "content" ) . getEntry ( 'sig' ) [ id ] ;
2013-10-21 16:41:51 +02:00
console . log ( _egw , _widget , siggrid , id ) ;
2013-10-24 09:15:48 +02:00
egw . json ( 'mail.mail_signatures.ajax_deleteSignature' , [ siggrid . row _id ] )
. sendRequest ( ) ;
2013-10-21 16:41:51 +02:00
} ,
profile _open : function ( _egw , _widget )
{
var id = _widget [ 0 ] . id . replace ( /row_/ , '' ) ;
var accgrid = this . et2 . getArrayMgr ( "content" ) . getEntry ( 'acc' ) [ id ] ;
console . log ( _egw , _widget , accgrid , id ) ;
} ,
profile _delete : function ( _egw , _widget )
{
var id = _widget [ 0 ] . id . replace ( /row_/ , '' ) ;
var accgrid = this . et2 . getArrayMgr ( "content" ) . getEntry ( 'acc' ) [ id ] ;
console . log ( _egw , _widget , accgrid , id ) ;
2013-10-24 09:15:48 +02:00
egw . json ( 'mail.mail_uipreferences.ajax_deleteMailProfile' , [ accgrid . row _id ] )
. sendRequest ( ) ;
2013-10-18 16:04:04 +02:00
} ,
2013-10-09 19:29:36 +02:00
/ * *
* Focus handler for folder , address , reject textbox / taglist to automatic check associated radio button
* /
sieve _focus _radioBtn : function ( _ev , _widget )
2013-08-09 19:47:53 +02:00
{
2013-10-09 19:29:36 +02:00
_widget . getRoot ( ) . getWidgetById ( 'action' ) . set _value ( _widget . id . replace ( /^action_([^_]+)_text$/ , '$1' ) ) ;
2013-08-09 19:47:53 +02:00
} ,
2013-10-09 19:29:36 +02:00
2013-08-09 19:47:53 +02:00
/ * *
*
* /
sieve _vac _all _aliases : function ( )
{
var addr = this . et2 . getWidgetById ( 'addresses' ) ;
console . log ( 'say something' ) ;
addr . select _all ( ) ;
//addr.set_autocomplete_url('mail.mail_compose.ajax_searchAddress');
} ,
2013-10-16 13:22:53 +02:00
/ * *
* Disable / Enable date widgets on vacation seive rules form when status is "by_date"
*
* /
vacationFilterStatusChange : function ( )
{
var status = this . et2 . getWidgetById ( 'status' ) ;
var s _date = this . et2 . getWidgetById ( 'start_date' ) ;
var e _date = this . et2 . getWidgetById ( 'end_date' ) ;
var by _date _label = this . et2 . getWidgetById ( 'by_date_label' ) ;
if ( status && s _date && e _date && by _date _label )
{
s _date . set _disabled ( status . get _value ( ) != "by_date" ) ;
e _date . set _disabled ( status . get _value ( ) != "by_date" ) ;
by _date _label . set _disabled ( status . get _value ( ) != "by_date" ) ;
}
} ,
2013-07-25 17:35:44 +02:00
/ * *
* 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 ) ;
}
}
2013-10-07 18:53:13 +02:00
var confirmDeleteDialog = et2 _dialog . show _dialog ( callbackDeleteDialog , this . egw . lang ( "Do you really want to DELETE this Rule" ) , this . egw . lang ( "Delete" ) , { } , et2 _dialog . BUTTONS _YES _NO _CANCEL , et2 _dialog . WARNING _MESSAGE ) ;
2013-07-25 17:35:44 +02:00
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 ;
}
}
} ,
2013-08-09 19:47:53 +02:00
_do _action : function ( _typeID , _data , _selectedID , _msg )
2013-07-25 17:35:44 +02:00
{
if ( _typeID && _data )
{
2013-08-09 19:47:53 +02:00
var request = egw ( ) . json ( 'mail.mail_sieve.ajax_action' , [ _typeID , _selectedID , _msg ] , null , null , true ) ;
2013-07-25 17:35:44 +02:00
console . log ( request ) ;
2013-08-09 19:47:53 +02:00
request . sendRequest ( ) ;
2013-07-25 17:35:44 +02:00
}
} ,
2013-08-09 19:47:53 +02:00
sieve _egw _refresh : function ( _execid , _msg )
2013-07-25 17:35:44 +02:00
{
2013-08-09 19:47:53 +02:00
var request = egw ( ) . json ( 'mail.mail_sieve.ajax_sieve_egw_refresh' , [ this . et2 _obj . etemplate _exec _id , _msg ] , null , this . et2 _obj , true ) ;
console . log ( request ) ;
request . sendRequest ( ) ;
2013-07-25 17:35:44 +02:00
} ,
2013-08-09 19:47:53 +02:00
2013-04-09 10:53:25 +02:00
} ) ;