Ignore:
Timestamp:
07/08/10 17:52:20 (14 years ago)
Author:
amuller
Message:

Ticket #1135 - Aplicando alterações do branches 2.0 no branches 2.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/expressoMail1_2/js/filter.js

    r1546 r3018  
    1111        function cfilter(){ 
    1212 
     13                this.criticalError = false; 
    1314                this.mode_in   = ""; 
    1415                this.rulest              = new Array; 
     
    4142 
    4243         
    43         cfilter.prototype.load_rules = function() 
     44        cfilter.prototype.load_rules = function(posHandler, param) 
    4445        { 
    4546                var _this = this; 
    4647                var cont1 = parseInt(0); 
    4748                var cont2 = parseInt(0); 
    48                                  
     49         
    4950                if( _this.rulest.length == 0 ) 
    5051                { 
    5152                        var handler_sieve = function(data) 
    5253                        { 
     54                                if (data.toString().indexOf('Error:') == 0)  
     55                                { 
     56                                        _this.criticalError = true; 
     57                                        alert(get_lang('The filters service is out of service, try again later...')); 
     58                                } 
     59                                else 
     60                                try{ 
    5361                                if(data.rule.length > 0){ 
    5462                                        for(var i=0 ; i < data.rule.length; i++) 
     
    6472                                _this.out_officeR = _this.out_officeR ? trim(_this.out_officeR.toString().replace("\n","")) : ""; 
    6573                                if(data.mode.length > 0){_this.mode_in = data.mode[0];} 
     74                                } 
     75                                catch(e){ 
     76                                        _this.criticalError = true; 
     77                                        alert(get_lang('The filters service is out of service, try again later...')); 
     78                                } 
     79                                if (typeof(posHandler) == 'function')   
     80                                        posHandler(param);   
    6681                        } 
    6782                        if(Element('form_status') != null) 
     
    381396                this.reload_rules(); 
    382397        } 
    383          
    384         cfilter.prototype.new_rule = function(email){ 
    385  
    386                 if(this.email_deny.length > 0){ 
    387                         for(var i=0 ; i < this.email_deny.length; i++){ 
    388                                 if(this.email_deny[i] == email){ 
    389                                         alert(get_lang("Sender blocked")+"!"); 
    390                                         return false; 
    391                                 } 
    392                         } 
    393                 } 
    394  
    395                 // Verifica Email 
    396                 var emailReg = /^[a-z][a-z-_0-9\.]+@[a-z-_=>0-9\.]+\.[a-z]{2,3}$/i 
    397         if(!emailReg.test(email)){ 
    398                         alert(get_lang("Inform a valid e-mail!")); 
    399                         return false; 
    400                 } 
    401  
    402                 this.load_rules(); 
    403                 if(confirm(get_lang("Do you want to block this e-mail?"))){ 
    404                         new_r = "&&ENABLED&&" + email + "&&&&&&discard&&&&0&&&&&&0"; 
    405 //                      setTimeout("filter.e_newrule('" + new_r + "')",2000);            
    406                         if (filter.e_newrule(new_r)){ 
    407                                 this.email_deny.push(email); 
    408                                 write_msg(get_lang("The sender was blocked"));                                                   
    409                         }else 
    410                                 write_msg(get_lang("You have reached the maximum number of rules")); 
    411                 } 
    412         } 
    413          
     398 
     399cfilter.prototype.new_rule = function(email){ 
     400 
     401        var createFilter = function (param){  
     402                if (filter.criticalError){  
     403                        alert(get_lang('The filters service is out of service, try again later...'));  
     404                        return false;  
     405                }  
     406                if(filter.rulest.length > 0){  
     407                        var blockedReg = new RegExp('#rule&&[0-9]+&&ENABLED&&'+param+'&&&&&&discard&&&&0&&&&&&0');  
     408                        for(var i=0 ; i < filter.rulest.length; i++){  
     409                                if(blockedReg.test(filter.rulest[i])){  
     410                                        alert(get_lang("Sender blocked")+"!");  
     411                                        return false;  
     412                                }  
     413                        }  
     414                }                         
     415                if(confirm(get_lang("Do you want to block this e-mail?"))){  
     416                        new_r = "&&ENABLED&&" + param + "&&&&&&discard&&&&0&&&&&&0";  
     417                        //setTimeout("filter.e_newrule('" + new_r + "')",2000);           
     418                        if (filter.e_newrule(new_r)){  
     419                                filter.email_deny.push(new_r);  
     420                                write_msg(get_lang("The sender was blocked"));                                                    
     421                        }else  
     422                                write_msg(get_lang("You have reached the maximum number of rules"));  
     423                }  
     424        };  
     425        if ( filter.rulest.length > 0 )  
     426                createFilter(email);  
     427        else  
     428                this.load_rules( createFilter, email );  
     429} 
     430 
    414431        cfilter.prototype.e_newrule = function(nw_rule) 
    415432        { 
     
    747764                var args   = "$this.ScriptS.rec_rules"; 
    748765                var params = "arfilter="+aux_rul; 
    749                 cExecute(args,h_filter,params); 
     766                if(!_this.criticalError) 
     767                        cExecute(args,h_filter,params); 
    750768        } 
    751769 
Note: See TracChangeset for help on using the changeset viewer.