@ -4345,14 +4345,23 @@ function rcube_webmail()
} ;
// checks the input fields before sending a message
this . check _compose _input = function ( cmd )
this . check _compose _input = function ( cmd , skip _recipients _checks )
{
// check input fields
var input _to = $ ( "[name='_to']" ) ,
var key , recipients , dialog ,
limit = this . env . max _disclosed _recipients ,
input _to = $ ( "[name='_to']" ) ,
input _cc = $ ( "[name='_cc']" ) ,
input _bcc = $ ( "[name='_bcc']" ) ,
input _from = $ ( "[name='_from']" ) ,
input _subject = $ ( "[name='_subject']" ) ;
input _subject = $ ( "[name='_subject']" ) ,
get _recipients = function ( fields ) {
fields = $ . map ( fields , function ( v ) {
v = $ . trim ( v . val ( ) ) ;
return v . length ? v : null ;
} ) ;
return fields . join ( ',' ) . replace ( /^[\s,;]+/ , '' ) . replace ( /[\s,;]+$/ , '' ) ;
} ;
// check sender (if have no identities)
if ( input _from . prop ( 'type' ) == 'text' && ! rcube _check _email ( input _from . val ( ) , true ) ) {
@ -4362,53 +4371,92 @@ function rcube_webmail()
}
// check for empty recipient
var recipients = input _to . val ( ) ? input _to . val ( ) : ( input _cc . val ( ) ? input _cc . val ( ) : input _bcc . val ( ) ) ;
if ( ! rcube_check _email ( recipients . replace ( /^\s+/ , '' ) . replace ( /[\s,;]+$/ , '' ) , true ) ) {
recipients = get _recipients ( [ input _to , input _cc , input _bcc ] ) ;
if ( ! skip_recipients _checks && ! rcube_check _email ( recipients , true ) ) {
alert ( this . get _label ( 'norecipientwarning' ) ) ;
input _to . focus ( ) ;
return false ;
}
// check if all files has been uploaded
for ( var key in this . env . attachments ) {
for ( key in this . env . attachments ) {
if ( typeof this . env . attachments [ key ] === 'object' && ! this . env . attachments [ key ] . complete ) {
alert ( this . get _label ( 'notuploadedwarning' ) ) ;
return false ;
}
}
// check disclosed recipients limit
if ( limit && ! skip _recipients _checks && ! this . env . disclosed _recipients _warned
&& rcube _check _email ( recipients = get _recipients ( [ input _to , input _cc ] ) , true , true ) > limit
) {
var save _func = function ( move _to _bcc ) {
if ( move _to _bcc ) {
var bcc = input _bcc . val ( ) ;
input _bcc . val ( ( bcc ? ( bcc + ', ' ) : '' ) + recipients ) . change ( ) ;
input _to . val ( '' ) . change ( ) ;
input _cc . val ( '' ) . change ( ) ;
}
dialog . dialog ( 'close' ) ;
ref . check _compose _input ( cmd , true ) ;
} ;
dialog = this . show _popup _dialog (
this . get _label ( 'disclosedrecipwarning' ) ,
this . get _label ( 'disclosedreciptitle' ) ,
[ {
text : this . get _label ( 'sendmessage' ) ,
click : function ( ) { save _func ( false ) ; } ,
'class' : 'mainaction'
} , {
text : this . get _label ( 'bccinstead' ) ,
click : function ( ) { save _func ( true ) ; }
} , {
text : this . get _label ( 'cancel' ) ,
click : function ( ) { dialog . dialog ( 'close' ) ; }
} ] ,
{ dialogClass : 'warning' }
) ;
this . env . disclosed _recipients _warned = true ;
return false ;
}
// display localized warning for missing subject
if ( input _subject . val ( ) == '' ) {
var buttons = { } ,
myprompt = $ ( '<div class="prompt">' ) . html ( '<div class="message">' + this . get _label ( 'nosubjectwarning' ) + '</div>' )
. appendTo ( document . body ) ,
prompt _value = $ ( '<input>' ) . attr ( { type : 'text' , size : 30 } ) . val ( this . get _label ( 'nosubject' ) )
. appendTo ( myprompt ) ,
if ( ! this . env . nosubject _warned && input _subject . val ( ) == '' ) {
var prompt _value = $ ( '<input>' ) . attr ( { type : 'text' , size : 40 } ) ,
myprompt = $ ( '<div class="prompt">' )
. append ( $ ( '<div class="message">' ) . text ( this . get _label ( 'nosubjectwarning' ) ) )
. append ( prompt _value ) ,
save _func = function ( ) {
input _subject . val ( prompt _value . val ( ) ) ;
myprompt . dialog ( 'close' ) ;
dialog . dialog ( 'close' ) ;
ref . command ( cmd , { nocheck : true } ) ; // repeat command which triggered this
} ;
buttons [ this . get _label ( 'sendmessage' ) ] = function ( ) {
save _func ( $ ( this ) ) ;
} ;
buttons [ this . get _label ( 'cancel' ) ] = function ( ) {
input _subject . focus ( ) ;
$ ( this ) . dialog ( 'close' ) ;
} ;
myprompt . dialog ( {
modal : true ,
resizable : false ,
buttons : buttons ,
close : function ( event , ui ) { $ ( this ) . remove ( ) ; }
} ) ;
dialog = this . show _popup _dialog (
myprompt ,
this . get _label ( 'nosubjecttitle' ) ,
[ {
text : this . get _label ( 'sendmessage' ) ,
click : function ( ) { save _func ( ) ; } ,
'class' : 'mainaction'
} , {
text : this . get _label ( 'cancel' ) ,
click : function ( ) {
input _subject . focus ( ) ;
dialog . dialog ( 'close' ) ;
}
} ] ,
{ dialogClass : 'warning' }
) ;
prompt _value . select ( ) . keydown ( function ( e ) {
if ( e . which == 13 ) save _func ( ) ;
} ) ;
this . env . nosubject _warned = true ;
return false ;
}