Changeset 564


Ignore:
Timestamp:
01/05/09 17:20:41 (15 years ago)
Author:
niltonneto
Message:

resolve #381

Location:
trunk/expressoMail1_2
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/expressoMail1_2/inc/class.ScriptS.inc.php

    r330 r564  
    1313        var $rules;                                             // Regras do sieve; 
    1414        var $errstr;                                    // Erros retornados; 
    15         var $size;                                              // var tamanho; 
    16         var $so;                                                // para verificar se a regra foi criada por outro tipo serviço de filtros; 
     15        var $size;                                              // Tamanho; 
     16        var $so;                                                // Verifica se a regra foi criada por outro tipo serviço de filtros; 
    1717        var $continuebit; 
    1818        var $sizebit; 
     
    2222        var $newrules = array(); 
    2323        var $newout; 
     24        var $teste; 
     25        var $EmailVoip; 
     26        var $EmailExpresso; 
    2427         
    2528        function ScriptS(){ 
     
    4245        $this->keepbit          = 8; 
    4346        $this->regexbit         = 128; 
     47         
     48        $this->EmailVoip = trim($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['voip_email_redirect']); 
     49        $this->EmailExpresso = trim($_SESSION['phpgw_info']['expressomail']['user']['email']); 
    4450         
    4551        } 
     
    189195                        return "Ok"; 
    190196                }else{ 
    191                         return "Problemas na criação do arquivo!"; 
     197                        return "Problemas na criação do arquivo!\n" . $this->teste; 
    192198                } 
    193199        } 
    194200 
    195         function convert_specialchar($input){ 
    196                   $special_char = false; 
    197                   for ( $i = 0; $i < strlen($input); $i++ ) 
    198                       if ( preg_match('/[ÁáÉéÍíÓóÚúÀàÈèÌìÒòÙùÇçÃãÕõÂâÊêÔô®©§ªºÐ¹²³°¢¿Æ£µøæß«»Ø÷±¬]/', $input[$i]) ) 
    199                       { 
    200                           $special_char = true; 
    201                           $input = preg_replace('/'.$input[$i].'/', '=' . bin2hex($input[$i]), $input); 
    202                       } 
    203                        
    204            if ( $special_char ) 
    205                    { 
    206                    /*  When using arrays with pattern and replacement, the keys are processed in the order they appear in the array. See preg_replace in php.net/preg_replace */ 
     201    function convert_specialchar($input) 
     202    { 
     203      $special_char = false; 
     204          for ( $i = 0; $i < strlen($input); $i++ ) 
     205          { 
     206              if ( preg_match('/[ÁáÉéÍíÓóÚúÀàÈèÌìÒòÙùüÇçÃãÕõÂâÊêÔô®©§ªºÐ¹²³°¢¿Æ£µøæß«»Ø÷±¬]/', $input[$i]) ) 
     207              { 
     208                  $special_char = true; 
     209                  $input = preg_replace('/'.$input[$i].'/', '=' . bin2hex($input[$i]), $input); 
     210              } 
     211          }    
     212       
     213      if ( $special_char ) 
     214          { 
     215                   /* * 
     216                    * When using arrays with pattern and replacement,  
     217                    * the keys are processed in the order they appear in the array.  
     218                    * See preg_replace in php.net/preg_replace  
     219                    * */ 
    207220                   $patterns[0] = '/=c3/i'; 
    208221                   $patterns[1] = '/ /'; 
     
    210223                   $replacements[0] = '_'; 
    211224                   $input = preg_replace($patterns, $replacements, $input); 
    212                    } 
    213                 //   if (($input{0}) && (!eregi('^[a-zA-Z0-9=\-@&\.#\$!?%:\+_<>\(\)\"\ ]+$',$input))) 
    214                 //              return false;    
    215                 //      else 
    216                         return($input); 
    217         } 
     225           } 
     226        
     227       return($input); 
     228    } 
    218229 
    219230        // Grava a nova regra; 
     
    227238                $regexused = 0; 
    228239                $rejectused = 0; 
     240                $notify = 0; 
    229241                $newscriptbody = ""; 
    230242        $continue = 1; 
     243        $tmpSubject = ""; 
    231244         
    232245                // Recebe os valores das regras; 
     
    237250          $rule['from']              = $this->convert_specialchar($tmp1[3]); 
    238251          $rule['to']            = $this->convert_specialchar($tmp1[4]); 
    239                   $rule['subject'] = $this->convert_specialchar($tmp1[5]); 
     252                  $tmpSubject                    = $tmp1[5]; 
     253                  $rule['subject']               = $this->convert_specialchar($tmp1[5]); 
    240254          $rule['action']            = $tmp1[6]; 
    241255                  $rule['action_arg']    = utf8_encode(preg_replace("/\\r\\n/","\r\n",$tmp1[7])); 
     
    337351                if (!$rule['unconditional']) $newruletext .= ") {\n\t"; 
    338352         
    339                 if (preg_match("/folder/i",$rule['action'])) { 
     353                if (preg_match("/folder/i",$rule['action'])) 
     354                { 
    340355                    $newruletext .= "fileinto \"" . $rule['action_arg'] . "\";"; 
    341356                } 
    342                 if (preg_match("/reject/i",$rule['action'])) { 
     357                 
     358                if (preg_match("/reject/i",$rule['action'])) 
     359                { 
    343360                    $newruletext .= "reject text: \n" . $rule['action_arg'] . "\n.\n;"; 
    344361                    $rejectused = 1; 
    345362                } 
    346                 if (preg_match("/address/i",$rule['action'])) { 
     363                 
     364                if (preg_match("/address/i",$rule['action'])) 
     365                { 
    347366                    $newruletext .= "redirect \"" . $rule['action_arg'] . "\";"; 
    348367                } 
     368                 
     369                if (preg_match("/notify/i",$rule['action'])) 
     370                { 
     371                                $newruletext .= "notify :method \"mailto\" :options [\"".$this->EmailVoip ."\"]:" . 
     372                                                                "message \"<expressovoip><from>". $this->EmailExpresso."</from>". 
     373                                                                "<br/><Subject>".utf8_encode($tmpSubject)."</Subject></expressovoip>\";"; 
     374                                $notify = 1;                                                     
     375                } 
     376                 
    349377                if (preg_match("/discard/i",$rule['action'])) { 
    350378                    $newruletext .= "discard;"; 
     
    362390              } 
    363391                }// Fim do Foreach; 
    364                  
     392                $this->teste = $newscriptbody;           
    365393                // Para a regras fora do escritorio; 
    366394        unset($tmp); 
     
    389417            if ($activerules) { 
    390418                $newscripthead .= "require [\"fileinto\""; 
     419                 
     420                if($notify){ 
     421                        $newscripthead .= ",\"notify\"";                         
     422                } 
    391423                if($regexused){ 
    392424                        $newscripthead .= ",\"regex\""; 
     
    405437            } 
    406438                 
    407                 //preg_replace("/[\\n\\r]/","", $p);             
    408                  
    409    
    410439            // Cria o rodapé do arquivo; 
    411440            $newscriptfoot  = ""; 
  • trunk/expressoMail1_2/index.php

    r537 r564  
    4242        $voip_enabled = false; 
    4343        $voip_groups = array(); 
     44         
    4445        if($GLOBALS['phpgw_info']['server']['voip_groups']) { 
     46                $emailVoip = false; 
    4547                foreach(explode(",",$GLOBALS['phpgw_info']['server']['voip_groups']) as $i => $voip_group){ 
    4648                        $a_voip = explode(";",$voip_group);                      
     
    5052                        if(array_search($group['account_name'],$voip_groups) !== FALSE){                  
    5153                                $voip_enabled = true; 
     54                                $emailVoip = $GLOBALS['phpgw_info']['server']['voip_email_redirect']; 
    5255                                break; 
    5356                        } 
     
    7073        $_SESSION['phpgw_info']['expressomail']['user']['email'] = $GLOBALS['phpgw']->preferences->values['email']; 
    7174         
     75         
    7276        $_SESSION['phpgw_info']['user']['preferences']['expressoMail'] = array( 
    7377                        'voip_enabled'                                          => $voip_enabled, 
     78                        'voip_email_redirect'                           => $emailVoip, 
    7479                        'outoffice'                                                     => $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['outoffice'], 
    7580                        'telephone_number'                                      => $GLOBALS['phpgw_info']['user']['telephonenumber'], 
     
    9398                 
    9499        ); 
    95          
     100 
    96101        $template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); 
    97102        $template->set_var("txt_loading",lang("Loading")); 
  • trunk/expressoMail1_2/js/filter.js

    r377 r564  
    1 function charCounter(form) 
    2 { 
    3         if (form.value.length >= 300) { 
    4                 alert(get_lang("You have exceeded the number of allowed characters")); 
    5                 return false; 
    6         } 
    7  
    8 } 
     1 
     2        function charCounter(form) 
     3        { 
     4                if (form.value.length >= 300) 
     5                { 
     6                        alert(get_lang("You have exceeded the number of allowed characters")); 
     7                        return false; 
     8                } 
     9        } 
    910 
    1011        function cfilter(){ 
     
    1213                this.mode_in   = ""; 
    1314                this.rulest              = new Array; 
     15                this.rulesVoip   = new Array; 
    1416                this.out_officeR = ""; 
    1517                this.out_officeF = false; 
     
    3739                 
    3840        } 
    39          
    40         cfilter.prototype.load_rules = function(){ 
     41 
     42         
     43        cfilter.prototype.load_rules = function() 
     44        { 
    4145                var _this = this; 
    42                 if(_this.rulest.length == 0){ 
    43                         var handler_sieve = function(data){ 
     46                var cont1 = parseInt(0); 
     47                var cont2 = parseInt(0); 
     48                                 
     49                if( _this.rulest.length == 0 ) 
     50                { 
     51                        var handler_sieve = function(data) 
     52                        { 
    4453                                if(data.rule.length > 0){ 
    45                                         for(var i=0 ; i < data.rule.length; i++){ 
    46                                                 _this.rulest[_this.rulest.length] = data.rule[i]; 
     54                                        for(var i=0 ; i < data.rule.length; i++) 
     55                                        { 
     56                                                var fields = data.rule[i].split("&&"); 
     57                                                if( fields[6] == 'notify' && fields[7] == preferences.voip_email_redirect ) 
     58                                                        _this.rulesVoip[cont1++] = data.rule[i]; 
     59                                                else 
     60                                                        _this.rulest[cont2++] = data.rule[i]; 
    4761                                        } 
    4862                                } 
     
    7387        } 
    7488         
    75         cfilter.prototype.form_r = function(pos){ 
     89        cfilter.prototype.form_r = function(pos,type) 
     90        { 
    7691                Element('form_body').innerHTML = ""; 
    7792                Element('form_body').innerHTML = this.forms_(); 
    78                 Element('div_rule').style.display = "";  
    79                 this.ac_form = "old_rule"; 
    80                 this.ind = pos; 
    81                 this.r_rules_form(pos); 
    82         } 
    83          
    84         cfilter.prototype.get_email = function(){ 
     93                this.ind = pos;          
     94                 
     95                if( type === 'voip') 
     96                { 
     97                        this.ac_form = "old_voip"; 
     98                        Element('div_voipFilter').style.display = ""; 
     99                        this.r_rules_form(pos, type);    
     100                } 
     101                else 
     102                { 
     103                        this.ac_form = "old_rule"; 
     104                        Element('div_rule').style.display = "";  
     105                        this.r_rules_form(pos, type); 
     106                } 
     107        } 
     108         
     109        cfilter.prototype.get_email = function() 
     110        { 
    85111                var _this = this; 
    86                 var handler_get_email = function(data){ 
     112                var handler_get_email = function(data) 
     113                { 
    87114                        _this.email_ld = data ? data : ""; 
    88115                } 
     
    90117        } 
    91118         
    92         cfilter.prototype.sel_boxes = function(){ 
     119        cfilter.prototype.sel_boxes = function() 
     120        { 
    93121                var nm_folders = tree_folders.getNodesList(cyrus_delimiter); 
    94122                if(document.getElementById("select_mailboxes") != null){ 
     
    100128                                } 
    101129                        } 
    102                         for(var i=0; i < nm_folders.length; i++){ 
    103                                 if(nm_folders[i].id != "root"){ 
     130                        for(var i=0; i < nm_folders.length; i++) 
     131                        { 
     132                                if(nm_folders[i].id != "root") 
     133                                { 
    104134                                        var opt = new Option(nm_folders[i].caption,nm_folders[i].id,false,true); 
    105135                                        sel_nm[sel_nm.length] = opt; 
     
    125155        } 
    126156 
    127         cfilter.prototype.r_rules_form = function(ind){ 
     157        cfilter.prototype.r_rules_form = function(ind, type) 
     158        { 
     159                var fields = new Array; 
     160                var _this = this; 
    128161                 
    129162                // hide buttons 
    130163                Element('form_buttons').style.display = 'none'; 
    131  
    132                 this.sel_boxes(); 
    133                 var aux = new Array; 
    134                 var _this = this; 
    135                 if(this.rulest.length == 0){ 
    136                         return false; 
    137                 } 
    138                 aux = _this.rulest[ind].split("&&"); 
    139                 document.getElementById("field1").value = aux[3]; 
    140                 document.getElementById("field2").value = aux[4]; 
    141                 document.getElementById("field3").value = aux[5]; 
    142                 document.getElementById("field4").value = aux[11];                               
    143                  
    144                 switch(aux[6]){ 
    145                         case "folder": 
    146                                 document.getElementById("radio1").checked  = true; 
    147                                 var name_mb = aux[7]; 
    148                                 var sel_mb = document.getElementById("select_mailboxes"); 
    149                                 for(var i=0; i < sel_mb.options.length; i++){if((sel_mb.options[i].value) ==  name_mb){sel_mb.options[i].selected = true;}} 
    150                                 break; 
    151                         case "address": 
    152                                 document.getElementById("radio2").checked   = true; 
    153                                 document.getElementById("field5").value         = aux[7]; 
    154                                 break; 
    155                         case "reject": 
    156                                  document.getElementById("radio3").checked  = true; 
    157                                  var text0 = aux[7].split("\\n");                                        
    158                                  for(var i=0; i < text0.length; i++){document.getElementById("field6").value += text0[i] + "\n";} 
    159                                  break; 
    160                         case "discard": 
    161                                 document.getElementById("radio4").checked       = true; 
    162                                 break; 
    163                 } 
    164                 var mark_values = this.values[aux[8]].split(","); 
    165                 for(var i=0; i < mark_values.length; i++){ 
    166                         if( mark_values[i] == "checkBox1" || mark_values[i] == "checkBox2"){ 
    167                                 document.getElementById(mark_values[i]).checked = true; 
    168                         } 
    169                         if( mark_values[i] == "select_size=1" || mark_values[i] == "select_rules=1"){ 
    170                                 var mark_val = mark_values[i].split("="); 
    171                                 document.getElementById(mark_val[0]).options[mark_val[1]].selected = true; 
     164                 
     165                if( type === 'voip') 
     166                { 
     167                        fields = _this.rulesVoip[ind].split("&&"); 
     168                        document.getElementById("field9").value = fields[5];                     
     169                } 
     170                else 
     171                { 
     172                        this.sel_boxes(); 
     173                        if(this.rulest.length == 0){ 
     174                                return false; 
     175                        } 
     176                        fields = _this.rulest[ind].split("&&"); 
     177                        document.getElementById("field1").value = fields[3]; 
     178                        document.getElementById("field2").value = fields[4]; 
     179                        document.getElementById("field3").value = fields[5]; 
     180                        document.getElementById("field4").value = fields[11];                            
     181                         
     182                        switch(fields[6]){ 
     183                                case "folder": 
     184                                        document.getElementById("radio1").checked  = true; 
     185                                        var name_mb = fields[7]; 
     186                                        var sel_mb = document.getElementById("select_mailboxes"); 
     187                                        for(var i=0; i < sel_mb.options.length; i++){if((sel_mb.options[i].value) ==  name_mb){sel_mb.options[i].selected = true;}} 
     188                                        break; 
     189                                case "address": 
     190                                        document.getElementById("radio2").checked   = true; 
     191                                        document.getElementById("field5").value         = fields[7]; 
     192                                        break; 
     193                                case "reject": 
     194                                         document.getElementById("radio3").checked  = true; 
     195                                         var text0 = fields[7].split("\\n");                                     
     196                                         for(var i=0; i < text0.length; i++){document.getElementById("field6").value += text0[i] + "\n";} 
     197                                         break; 
     198                                case "discard": 
     199                                        document.getElementById("radio4").checked       = true; 
     200                                        break; 
     201                        } 
     202                        var mark_values = this.values[fields[8]].split(","); 
     203                        for(var i=0; i < mark_values.length; i++){ 
     204                                if( mark_values[i] == "checkBox1" || mark_values[i] == "checkBox2"){ 
     205                                        document.getElementById(mark_values[i]).checked = true; 
     206                                } 
     207                                if( mark_values[i] == "select_size=1" || mark_values[i] == "select_rules=1"){ 
     208                                        var mark_val = mark_values[i].split("="); 
     209                                        document.getElementById(mark_val[0]).options[mark_val[1]].selected = true; 
     210                                } 
    172211                        } 
    173212                } 
     
    224263         * quando a caixa de seleção para manter o e-mail na caixa de entrada do usuário for selecionada 
    225264         */ 
    226         cfilter.prototype.disable_radio3 =  function(){ 
    227  
     265        cfilter.prototype.disable_radio3 =  function() 
     266        { 
    228267                radio3 = Element('radio3'); 
    229268                field6 = Element('field6'); 
    230269                cb2 = Element('checkBox2'); 
    231270 
    232                 if (cb2.checked){ 
     271                if (cb2.checked) 
     272                { 
    233273                        radio3.disabled = true; 
    234274                        field6.disabled = true; 
    235275 
    236                         if (radio3.checked){ 
     276                        if (radio3.checked) 
     277                        { 
    237278                                radio3.checked = false; 
    238279                        } 
    239280                } 
    240                 else{ 
     281                else 
     282                { 
    241283                        radio3.disabled = false; 
    242284                        field6.disabled = false; 
     
    245287        } 
    246288 
    247         cfilter.prototype.forms_ = function(){ 
    248                         var form   = ""; 
    249                         form       = "<div id='div_rule' style='display:none'><table id='table_rule' border='0' cellpading='0' cellspacing='0' width='100%'>"+ 
    250                                                  "<tr><td colspan='2'><input type='checkBox' id='checkBox1' name='checkb'>"+get_lang('Also check message against next rule') + "</td></tr>"+ 
    251                                                  "<tr><td colspan='2'><input type='checkBox' id='checkBox2' onclick='filter.disable_radio3();' name='checkb'>"+get_lang('Keep a copy of the message at your Inbox')+ "</td><tr>"+ 
    252                                                  "<tr><td colspan='2'><hr size='1' width='100%'></td></tr><tr>"+ 
    253                                                  "<td rowspan='4' width='20%'>"+get_lang('Coincident')+"<br><select id='select_rules' name='select_rules'>"+ 
    254                                                  "<option value='0'>"+get_lang("with all")+"</option><option value='1'>"+get_lang("with some")+"</option>"+ 
    255                                                  "</select></td><td>"+get_lang('The field \"%1\" of the message it contains',get_lang('From'))+".: <input type='text' id='field1' name='field1' size='35' maxlength='200'></td>"+ 
    256                                                  "</tr><tr><td>"+get_lang('The field \"%1\" of the message it contains', get_lang('To'))+".: <input type='text' id='field2' name='field2' size='35' maxlength='200'></td>"+ 
    257                                                  "</tr><tr><td>"+get_lang('The field \"%1\" of the message it contains', get_lang('Subject'))+".: <input type='text' id='field3' name='field3' size='35' maxlength='200'></td>"+ 
    258                                                  "</tr><tr><td>"+get_lang('The size of the message is')+".: &nbsp<select id='select_size' name='select_size'>"+ 
    259                                                  "<option value='0'>"+get_lang("Less than")+"</option><option value='1'>"+get_lang("Greater than")+"</option>"+                                           
    260                                                  "</select>&nbsp;<input type='text' id='field4' name='field4' size='8' maxlength='8'> Kb</td>"+ 
    261                                                  "</tr><tr><td colspan='2'><hr size='1' width='100%'></td></tr>"+ 
    262                                                  "</table><table id='table_rule1' border='0' cellpading='0' cellspacing='0' width='100%'>"+ 
    263                                                  "<tr><td width='50%'><input type='radio' id='radio1' name='radio' value='folder'>"+get_lang('Store at')+".:</td>"+ 
    264                                                  "<td width='50%'><select id='select_mailboxes' name='select_mailboxes'></select></td>"+ 
    265                                                  "</tr><tr><td width='50%'><input type='radio' id='radio2' name='radio' value='address'>"+get_lang('Forward to the address')+".:</td>"+ 
    266                                                  "<td width='50%'><input type='text' id='field5' name='field5' size='35' maxlength='70'></td>"+ 
    267                                                  "</tr><tr><td width='50%'><input type='radio' id='radio3' name='radio' value='reject'>"+get_lang('Send a rejection message')+".:</td>"+ 
    268                                                  "<td width='50%'><textarea id='field6' onkeypress='return charCounter(this);' name='field6' rows='3' cols='25'></textarea></td>"+ 
    269                                                  "</tr><tr><td colspan='2'><input type='radio' id='radio4' name='radio' value='discard'>"+get_lang('Erase the message')+"</td>"+ 
    270                                                  "</tr></table></div><div id='div_vacation' style='display:none'>"+ 
    271                                                  "<table id='table_vacation' border='0' cellpading='0' cellspacing='0' width='100%'>"+ 
    272                                                  "<tr><td colspan='3'><br><b>"+get_lang('out office')+"</b></td></tr>"+ 
    273                                                  //"<tr><td colspan='3'><br>"+get_lang('Subject')+".: <input type='text' id='field7' name='field7' size='35' maxlength='200'/></td></tr>"+ 
    274                                                  "<tr><td colspan='3'><br>"+get_lang('With the following message')+".:</td>"+ 
    275                                                  "</tr><tr><td colspan='3'><textarea id='field8' onkeypress='return charCounter(this);' rows='8' cols='50'></textarea></td></tr></table></div>"+ 
    276                                                  "<span align='right'><input type='button' value="+get_lang("Back")+" onclick='filter.form_m()'></span>"+ 
    277                                                  "<span align='right'><input type='button' value="+get_lang("Save")+" onclick='filter.saved_rules()'></span>";                                            
     289        cfilter.prototype.forms_ = function() 
     290        { 
     291                         var form = ""; 
     292                                 form = "<div id='div_rule' style='display:none'><table id='table_rule' border='0' cellpading='0' cellspacing='0' width='100%'>"+ 
     293                                                "<tr><td colspan='2'><input type='checkBox' id='checkBox1' name='checkb'>"+get_lang('Also check message against next rule') + "</td></tr>"+ 
     294                                                "<tr><td colspan='2'><input type='checkBox' id='checkBox2' onclick='filter.disable_radio3();' name='checkb'>"+get_lang('Keep a copy of the message at your Inbox')+ "</td><tr>"+ 
     295                                                "<tr><td colspan='2'><hr size='1' width='100%'></td></tr><tr>"+ 
     296                                                "<td rowspan='4' width='20%'>"+get_lang('Coincident')+"<br><select id='select_rules' name='select_rules'>"+ 
     297                                                "<option value='0'>"+get_lang("with all")+"</option><option value='1'>"+get_lang("with some")+"</option>"+ 
     298                                                "</select></td><td>"+get_lang('The field \"%1\" of the message it contains',get_lang('From'))+".: <input type='text' id='field1' name='field1' size='35' maxlength='200'></td>"+ 
     299                                                "</tr><tr><td>"+get_lang('The field \"%1\" of the message it contains', get_lang('To'))+".: <input type='text' id='field2' name='field2' size='35' maxlength='200'></td>"+ 
     300                                                "</tr><tr><td>"+get_lang('The field \"%1\" of the message it contains', get_lang('Subject'))+".: <input type='text' id='field3' name='field3' size='35' maxlength='200'></td>"+ 
     301                                                "</tr><tr><td>"+get_lang('The size of the message is')+".: &nbsp<select id='select_size' name='select_size'>"+ 
     302                                                "<option value='0'>"+get_lang("Less than")+"</option><option value='1'>"+get_lang("Greater than")+"</option>"+                                            
     303                                                "</select>&nbsp;<input type='text' id='field4' name='field4' size='8' maxlength='8'> Kb</td>"+ 
     304                                                "</tr><tr><td colspan='2'><hr size='1' width='100%'></td></tr>"+ 
     305                                                "</table><table id='table_rule1' border='0' cellpading='0' cellspacing='0' width='100%'>"+ 
     306                                                "<tr><td width='50%'><input type='radio' id='radio1' name='radio' value='folder'>"+get_lang('Store at')+".:</td>"+ 
     307                                                "<td width='50%'><select id='select_mailboxes' name='select_mailboxes'></select></td>"+ 
     308                                                "</tr><tr><td width='50%'><input type='radio' id='radio2' name='radio' value='address'>"+get_lang('Forward to the address')+".:</td>"+ 
     309                                                "<td width='50%'><input type='text' id='field5' name='field5' size='35' maxlength='70'></td>"+ 
     310                                                "</tr><tr><td width='50%'><input type='radio' id='radio3' name='radio' value='reject'>"+get_lang('Send a rejection message')+".:</td>"+ 
     311                                                "<td width='50%'><textarea id='field6' onkeypress='return charCounter(this);' name='field6' rows='3' cols='25'></textarea></td>"+ 
     312                                                "</tr><tr><td colspan='2'><input type='radio' id='radio4' name='radio' value='discard'>"+get_lang('Erase the message')+"</td>"+ 
     313                                                "</tr></table></div><div id='div_vacation' style='display:none'>"+ 
     314                                                "<table id='table_vacation' border='0' cellpading='0' cellspacing='0' width='100%'>"+ 
     315                                                "<tr><td colspan='3'><br><b>"+get_lang('out office')+"</b></td></tr>"+ 
     316                                                //"<tr><td colspan='3'><br>"+get_lang('Subject')+".: <input type='text' id='field7' name='field7' size='35' maxlength='200'/></td></tr>"+ 
     317                                                "<tr><td colspan='3'><br>"+get_lang('With the following message')+".:</td>"+ 
     318                                                "</tr><tr><td colspan='3'><textarea id='field8' onkeypress='return charCounter(this);' rows='8' cols='50'></textarea></td></tr></table></div>" + 
     319                                                "<div id='div_voipFilter' style='display:none'>" + 
     320                                                "<br/><table id='table_voipFilter'>" + 
     321                                                "<tr><td>"+get_lang("Type the subject of the message for receiving a phone warning")+" .:"+ 
     322                                                "</td></tr><tr><td><input type='text' id='field9' size='50' maxlength='200'>" + 
     323                                                "</td></tr><br/></table></div>" + 
     324                                                "<span align='right'><input type='button' value="+get_lang("Back")+" onclick='filter.form_m()'></span>"+ 
     325                                                "<span align='right'><input type='button' value="+get_lang("Save")+" onclick='filter.saved_rules()'></span>"; 
    278326                return form; 
    279327        } 
     
    314362                        } 
    315363                } 
     364 
     365                // Voip 
     366                if(Element("voip_rule_0") != null){ 
     367                        for(var i=0; i < this.rulesVoip.length; i++){ 
     368                                if(Element("voip_rule_"+i).checked){ 
     369                                        var aux_rul = this.rulesVoip[i].split("&&"); 
     370                                        if(aux_rul[2] != param){ 
     371                                                aux_rul[2] = param;                                      
     372                                                var rl = ""; 
     373                                                for(var j=0; j < aux_rul.length; j++){ 
     374                                                        rl += aux_rul[j] + "&&"; 
     375                                                } 
     376                                                rl = rl.substr(0,(rl.length - 2)); 
     377                                                this.rulesVoip[i] = rl;                                  
     378                                        } 
     379                                } 
     380                        } 
     381                } 
     382                 
    316383                this.reload_rules(); 
    317384        } 
     
    347414        } 
    348415         
    349         cfilter.prototype.e_newrule = function(nw_rule){ 
     416        cfilter.prototype.e_newrule = function(nw_rule) 
     417        { 
    350418 
    351419                var new_rl = ""; 
     
    399467                        } 
    400468                } 
     469                 
     470                // Voip 
     471                if(Element("voip_rule_0") != null){ 
     472                        for(var i=0; i < _this.rulesVoip.length; i++){ 
     473                                if(Element("voip_rule_"+i).checked){_this.rulesVoip[i] = "delete";} 
     474                        } 
     475                        for(var i=0; i < _this.rulesVoip.length; i++){ 
     476                                if(_this.rulesVoip[i] == "delete"){_this.rulesVoip.splice(i,1);i--;} 
     477                        } 
     478                } 
     479         
     480                if(_this.rulesVoip.length > 0){ 
     481                        var cont = parseInt(1); 
     482                        for(var i=0; i < _this.rulesVoip.length ; i++){ 
     483                                var n_rulest = _this.rulesVoip[i].split("&&"); 
     484                                n_rulest[1] = cont; 
     485                                cont = cont + parseInt(2); 
     486                                var aux = ""; 
     487                                for(var j=0; j < n_rulest.length; j++){aux += n_rulest[j] + "&&";} 
     488                                aux = aux.substr(0,(aux.length - 2)); 
     489                                _this.rulesVoip[i] = aux; 
     490                        } 
     491                }  
     492 
    401493                _this.reload_rules(); 
    402494        } 
    403495         
    404         cfilter.prototype.reload_rules = function(){ 
     496        cfilter.prototype.reload_rules = function() 
     497        { 
    405498                this.saved_all(); 
    406499                Element('form_body').innerHTML = ""; 
    407500                this.load_rules(); 
    408                  
    409                 if(this.out_officeF){ 
     501 
     502                if(this.out_officeF) 
     503                { 
    410504                        write_msg(get_lang("Attention, you are in out of office mode."), true); 
    411                 }else { 
     505                }else{ 
    412506                        clean_msg(); 
    413507                        this.out_officeF = false; 
     
    422516                var n_rule = ""; 
    423517 
    424                 if(form[1] == "rule"){ 
     518                if(form[1] == "rule") 
     519                { 
    425520                        mount_rule = "#rule&&"; 
    426                         if(form[0] == "new"){ 
     521                        if(form[0] == "new") 
     522                        { 
    427523                                n_rule = "1&&"; 
    428                                 if(this.rulest.length > 0){ 
     524                                if(this.rulest.length > 0) 
     525                                { 
    429526                                        aux = this.rulest[this.rulest.length - parseInt(1)].split("&&"); 
    430527                                        n_rule = (parseInt(aux[1]) + parseInt(2)) + "&&"; 
    431528                                } 
    432529                                mount_rule += n_rule + "ENABLED&&"; 
    433                         }else{ 
     530                        } 
     531                        else 
     532                        { 
    434533                                n_rule = this.rulest[this.ind].split("&&"); 
    435534                                mount_rule += n_rule[1] + "&&"; 
     
    503602                        } 
    504603                        if(form[0] == "new") 
     604                        { 
    505605                                this.rulest[this.rulest.length] = mount_rule; 
     606                        } 
    506607                        else 
    507608                                this.rulest[this.ind] = mount_rule; 
    508                 }else{ 
     609                } 
     610                else if(form[1] == "out") 
     611                { 
    509612                        mount_rule = ""; 
    510613                        var fld_emails = this.email_ld; // Get first email of list! 
     
    522625                        this.out_officeR = mount_rule; 
    523626                } 
     627                else if(form[1] == "voip") 
     628                { 
     629                        if( Element("field9").value != "" && LTrim(Element("field9").value) != "" ) 
     630                        { 
     631                                mount_rule = "#rule&&"; 
     632                                if(form[0] == "new") 
     633                                { 
     634                                        n_rule = "1&&"; 
     635                                        if( this.rulesVoip.length > 0 ) 
     636                                        { 
     637                                                aux = this.rulesVoip[this.rulesVoip.length - parseInt(1)].split("&&"); 
     638                                                n_rule = (parseInt(aux[1]) + parseInt(2)) + "&&"; 
     639                                        } 
     640                                        mount_rule += n_rule + "ENABLED&&"; 
     641                                } 
     642                                else 
     643                                { 
     644                                        n_rule = this.rulesVoip[this.ind].split("&&"); 
     645                                        mount_rule += n_rule[1] + "&&"; 
     646                                        mount_rule += n_rule[2] + "&&"; 
     647                                } 
     648 
     649                                if ( Element("field9").value.indexOf("#") >= 0 ) 
     650                                { 
     651                                        alert(get_lang('Caracter "#" is not allowed!')); 
     652                                        return false; 
     653                                } 
     654                                 
     655                                mount_rule = mount_rule + "&&&&" + Element("field9").value + "&&notify&&" + preferences.voip_email_redirect + "&&8&&&&&&0"; 
     656 
     657                                if( form[0] == "new" ) 
     658                                { 
     659                                        this.rulesVoip[this.rulesVoip.length] = mount_rule; 
     660                                } 
     661                                else 
     662                                { 
     663                                        this.rulesVoip[this.ind] = mount_rule; 
     664                                } 
     665                        } 
     666                        else 
     667                        { 
     668                                alert( 'CAMPOS EM BRANCO !!' ); 
     669                                return false; 
     670                        } 
     671                } 
     672                 
    524673                Element('form_buttons').style.display = ''; 
    525674                this.reload_rules(); 
    526675        } 
    527676 
    528         cfilter.prototype.close_frm= function(){ 
     677        cfilter.prototype.close_frm= function() 
     678        { 
    529679                filters.filter_Sh['window_ffilter_ccform'].close(); 
    530680        } 
    531681         
    532         cfilter.prototype.saved_all = function(){ 
     682        cfilter.prototype.saved_all = function() 
     683        { 
    533684                var aux_rul = ""; 
    534685                var _this = this; 
    535                 if(_this.rulest.length > 0){ 
    536                         for(var i=0; i < _this.rulest.length; i++){ 
    537                                 var aux = _this.rulest[i].split("&&");                           
     686                var cont = 0; 
     687                 
     688                // Regras Gerais 
     689                if(_this.rulest.length > 0) 
     690                { 
     691                        for(var i=0; i < _this.rulest.length; i++) 
     692                        { 
     693                                var fieldsNormal = _this.rulest[i].split("&&");                          
    538694                                aux_rul += "_begin_##"; 
    539                                 for(var j=0 ; j < aux.length; j++){ 
    540                                         if( (j +1) > aux.length){aux_rul += url_encode(aux[j]);} 
    541                                         else{aux_rul += url_encode(aux[j]) + "##";} 
     695                                for(var j=0 ; j < fieldsNormal.length; j++) 
     696                                { 
     697                                        aux_rul += url_encode(fieldsNormal[j]) + "##"; 
     698                                        cont = parseInt(fieldsNormal[1]);                                        
    542699                                }        
    543700                                aux_rul += "_end_\n"; 
    544701                        } 
    545702                } 
    546                 if(_this.out_officeR.length > 0){ 
     703         
     704                // Voip 
     705                if(_this.rulesVoip.length > 0) 
     706                { 
     707                        for(var i=0; i < _this.rulesVoip.length; i++) 
     708                        { 
     709                                var fieldsVoip = _this.rulesVoip[i].split("&&"); 
     710                                aux_rul += "_begin_##"; 
     711                                for(var j=0 ; j < fieldsVoip.length; j++) 
     712                                { 
     713                                        if(j == 1) 
     714                                        { 
     715                                                if( cont == 0 ) 
     716                                                        cont = parseInt(1); 
     717                                                else 
     718                                                        cont = parseInt(cont) + parseInt(2); 
     719                                                aux_rul += cont; 
     720                                                aux_rul += "##"; 
     721                                        } 
     722                                        else 
     723                                                aux_rul += url_encode(fieldsVoip[j]) + "##"; 
     724                                } 
     725                                aux_rul += "_end_\n"; 
     726                        } 
     727                } 
     728                 
     729                // Fora do Escritório 
     730                if(_this.out_officeR.length > 0) 
     731                { 
    547732                                var aux = _this.out_officeR.split("&&");                                 
    548733                                aux_rul += "_begin_##"; 
    549                                 for(var j=0 ; j < aux.length; j++){ 
    550                                         if( (j +1) > aux.length){aux_rul += url_encode(aux[j]);} 
    551                                         else{aux_rul += url_encode(aux[j]) + "##";} 
     734                                for(var j=0 ; j < aux.length; j++) 
     735                                { 
     736                                        aux_rul += url_encode(aux[j]) + "##";                                    
    552737                                }        
    553738                                aux_rul += "_end_\n"; 
    554                                 _this.out_officeF = (aux[4].replace("\n","") == "off") ? false : true; 
     739                                _this.out_officeF = (aux[4].replace("\n","") === "off") ? false : true; 
    555740                                //Save outoffice in prefs: 
    556741                                connector.loadScript("preferences"); 
    557742                                prefe.save("outoffice", _this.out_officeF); 
    558743                } 
    559                 var h_filter = function(data){ 
     744                 
     745                var h_filter = function(data) 
     746                { 
    560747                        if(data != "Ok"){alert("Erro : \n" + data);} 
    561748                } 
  • trunk/expressoMail1_2/js/filters.js

    r246 r564  
    1414                this.for_email_img = new Image(); 
    1515                this.for_email_img.src = 'templates/default/images/filtro/answered.gif'; 
     16                this.telephone_voip = new Image(); 
     17                this.telephone_voip.src = 'templates/default/images/filtro/telephone_voip.jpg'; 
    1618        }                
    1719 
     
    3032                var form_cont = document.createElement("SPAN"); 
    3133                form_cont.id = "form_status"; 
    32                 form_cont.style.display = "";                    
     34                form_cont.style.display = "block";                       
    3335                form_cont.style.position = "absolute"; 
    3436                form_cont.style.top = "10px"; 
     
    8183                Element('form_status').innerHTML = ""; 
    8284                var list = ""; 
     85         
    8386                // rules 
    8487                if(filter.rulest.length == 0){ 
    85                         list = "<img id='set_rules_img' src='"+this.grp_close_img.src+"' border='0'>&nbsp;<span><b>"+get_lang('list of the filters') + " - ( " + filter.rulest.length + " ) </b></span> - " + "<a href='javascript:filters.n_rule()'>" + get_lang("new rule") + "</a>";          
     88                        list = "<img id='set_rules_img' src='" + this.grp_close_img.src + "' border='0' />&nbsp;<span><b>"+get_lang('list of the filters') + " - ( " + filter.rulest.length + " ) </b></span> - " + "<a href='javascript:filters.n_rule()'>" + get_lang("new rule") + "</a>";            
    8689                }else{ 
    87                         if (filter.rulest.length < rules_limit ) //Limit of rules 
    88                                 list = "<img id='set_rules_img' src='"+this.grp_open_img.src+"' onclick=filters.hidden(\"set_rules\") border='0'>&nbsp;<span><b>"+get_lang('list of the filters') + " - ( " + filter.rulest.length + " ) </b></span> - " + "<a href='javascript:filters.n_rule()'>" + get_lang("new rule") + "</a>"; 
     90                        if ( filter.rulest.length < rules_limit ) //Limit of rules 
     91                                list = "<img id='set_rules_img' src='" + this.grp_open_img.src + "' onclick='visibleRulesFalse(\"set_rules\");' border='0' />&nbsp;<span><b>"+get_lang('list of the filters') + " - ( " + filter.rulest.length + " ) </b></span> - " + "<a href='javascript:filters.n_rule();'>" + get_lang("new rule") + "</a>"; 
    8992                        else 
    90                                 list = "<img id='set_rules_img' src='"+this.grp_open_img.src+"' onclick=filters.hidden(\"set_rules\") border='0'>&nbsp;<span><b>"+get_lang('list of the filters') + " - ( " + filter.rulest.length + " ) </b></span> - " + get_lang("You have reached the maximum number of rules"); 
    91                                  
     93                                list = "<img id='set_rules_img' src='" + this.grp_open_img.src + "' onclick='visibleRulesFalse(\"set_rules\");' border='0' />&nbsp;<span><b>"+get_lang('list of the filters') + " - ( " + filter.rulest.length + " ) </b></span> - " + get_lang("You have reached the maximum number of rules"); 
     94                         
    9295                        list += "<div id='set_rules'>"; 
    93                         for(var i=0; i < filter.rulest.length; i++){ 
    94                                 list += "<input id=rule_"+i+" type='checkBox'>&nbsp;<img src='"+this.filter_img.src+"' width='16' height='16' border='0'>&nbsp;" + get_lang("Rule")+" : " + parseInt(i+1) + " -- " + this.vl_rule(filter.rulest[i],i) + "<br>"; 
     96                         
     97                        for(var i= 0; i < filter.rulest.length; i++) 
     98                        { 
     99                                list += "<input id=rule_"+i+" type='checkBox'>&nbsp;<img src='"+this.filter_img.src+"' width='16' height='16' border='0' />&nbsp;" + get_lang("Rule")+" : " + parseInt(i+1) + " -- " + this.vl_rule(filter.rulest[i],i,'') + "<br>"; 
    95100                        } 
    96                 } 
    97                 list += "</div><br>"; 
     101                        list += "</div>";                        
     102                } 
     103                 
     104                list += "<br/>"; 
     105                 
    98106                // out office 
    99107                if(!filter.out_officeR){ 
    100                         list += "<img id='set_out_img' src='"+this.grp_close_img.src+"' border='0'>&nbsp;"; 
     108                        list += "<img id='set_out_img' src='"+this.grp_close_img.src+"' border='0' />&nbsp;"; 
    101109                        list += "<span><b>"+get_lang('out office') + " - ( 0 ) </b></span> " + "<a href='javascript:filters.n_out_office()'>" + get_lang("new rule") + "</a>";                   
    102110                }else{ 
    103                         list += "<img id='set_out_img' src='"+this.grp_open_img.src+"' onclick=filters.hidden(\"set_out\") border='0'>&nbsp;"; 
     111                        list += "<img id='set_out_img' src='"+this.grp_open_img.src+"' onclick='visibleRulesFalse(\"set_out\");' border='0' />&nbsp;"; 
    104112                        list += "<span><b>"+get_lang('out office') + " - ( 1 )</b></span>"; 
    105113                        list += "<div id='set_out'>"; 
     
    108116                        list += "</div>"; 
    109117                } 
     118                list += "<br/>"; 
     119         
     120                // Voip 
     121                if(preferences.voip_email_redirect) 
     122                { 
     123                        if( filter.rulesVoip.length == 0) 
     124                        { 
     125                                list += "<img id='voip_rule_img' src='"+this.grp_close_img.src+"' border='0' />&nbsp;<span><b>" + get_lang('Phone Warnings List') + " - ( " + filter.rulesVoip.length + " ) </b></span> - " + "<a href='javascript:filters.n_voipFilter();'>" + get_lang("new rule") + "</a>";           
     126                        } 
     127                        else 
     128                        { 
     129                                if ( filter.rulest.length < rules_limit ) //Limit of rules 
     130                                        list += "<img id='voip_rule_img' src='"+this.grp_open_img.src+"' onclick='visibleRulesFalse(\"voip_rule\");' border='0'/>&nbsp;<span><b>" + get_lang('Phone Warnings List') + " - ( " + filter.rulesVoip.length + " ) </b></span> - " + "<a href='javascript:filters.n_voipFilter()'>" + get_lang("new rule") + "</a>"; 
     131                                else 
     132                                        list += "<img id='voip_rule_img' src='"+this.grp_open_img.src+"' onclick='visibleRulesFalse(\"voip_rule\");' border='0'/>&nbsp;<span><b>" + get_lang('Phone Warnings List') + " - ( " + filter.rulesVoip.length + " ) </b></span> - " + get_lang("You have reached the maximum number of rules"); 
     133                                         
     134                                list += "<div id='voip_rule'>"; 
     135                                for(var i= 0; i < filter.rulesVoip.length; i++) 
     136                                { 
     137                                        list += "<input id='voip_rule_"+i+"' type='checkBox'>&nbsp;<img src='"+this.telephone_voip.src+"' width='16' height='16' border='0'/>&nbsp;" + get_lang("Rule")+" : " + parseInt(i+1) + " -- " + this.vl_rule(filter.rulesVoip[i],i,'voip') + "<br>"; 
     138                                } 
     139                                list += "</div>"; 
     140                        } 
     141                } 
     142 
    110143                Element("form_body").innerHTML = list; 
    111144        } 
    112145         
    113         cfilterSh.prototype.vl_rule = function(rule,pos){ 
    114                 var aux = rule.split("&&"); 
    115                 return " <a href='javascript:void(0)' onclick=filter.form_r('"+pos+"')><b>" + get_lang("Status") + " : </b>" + "<font color='red'>" + get_lang(aux[2]) + "</font>" + " - <b>" + get_lang("E-mail rule") + ":</b> " + aux[3] + " - <b>" + get_lang("Action") + ":</b> " + aux[6] + "</a>"; 
     146        cfilterSh.prototype.vl_rule = function(rule,pos,type) 
     147        { 
     148                var fields = rule.split("&&"); 
     149                if(type == 'voip') 
     150                        return " <a href='javascript:void(0)' onclick=filter.form_r('"+pos+"','voip')><b>" + get_lang("Status") + " : </b>" + "<font color='red'>" + get_lang(fields[2]) + "</font>" + " - " + fields[3] + " <b>" + get_lang("Subject") + ":</b> " + fields[5] + "</a>"; 
     151                else 
     152                        return " <a href='javascript:void(0)' onclick=filter.form_r('"+pos+"','')><b>" + get_lang("Status") + " : </b>" + "<font color='red'>" + get_lang(fields[2]) + "</font>" + " - <b>" + get_lang("E-mail rule") + ":</b> " + fields[3] + " - <b>" + get_lang("Action") + ":</b> " + fields[6] + "</a>"; 
    116153        } 
    117154         
     
    121158        } 
    122159         
    123         cfilterSh.prototype.n_rule = function(){ 
     160        cfilterSh.prototype.n_rule = function() 
     161        { 
    124162                Element('form_body').innerHTML = ""; 
    125163                Element('form_body').innerHTML = filter.forms_();        
    126                 Element('div_rule').style.display = ""; 
     164                Element('div_rule').style.display = "block"; 
    127165                filter.ac_form = "new_rule"; 
    128166                Element('form_buttons').style.display = 'none'; 
     
    131169        } 
    132170 
    133         cfilterSh.prototype.n_out_office = function(){ 
     171        cfilterSh.prototype.n_out_office = function() 
     172        { 
    134173                Element('form_body').innerHTML = ""; 
    135174                Element('form_body').innerHTML = filter.forms_();        
    136                 Element('div_vacation').style.display = "";                      
     175                Element('div_vacation').style.display = "block";                         
    137176                Element('form_buttons').style.display = 'none'; 
    138177                filter.ac_form = "new_out";      
    139                 } 
    140  
    141         cfilterSh.prototype.hidden = function(el){ 
    142                 var _this = this; 
     178        } 
     179 
     180        cfilterSh.prototype.n_voipFilter = function() 
     181        { 
     182                Element('form_body').innerHTML = ""; 
     183                Element('form_body').innerHTML = filter.forms_(); 
     184                Element('div_voipFilter').style.display = "block";       
     185                Element('form_buttons').style.display = 'none'; 
     186                filter.ac_form = "new_voip"; 
     187        } 
     188 
     189        function visibleRulesFalse(el) 
     190        { 
    143191                Element(el).style.display = "none"; 
    144                 Element(el+"_img").src = _this.grp_close_img.src; 
    145                 Element(el+"_img").onclick = function(){filters.un_hidden(el);} 
    146         } 
    147  
    148         cfilterSh.prototype.un_hidden = function(el){ 
    149                 var _this = this; 
     192                Element(el+"_img").src = filters.grp_close_img.src; 
     193                Element(el+"_img").onclick = function(){visibleRulesTrue(el);}; 
     194        } 
     195 
     196        function visibleRulesTrue(el) 
     197        { 
    150198                Element(el).style.display = ""; 
    151                 Element(el+"_img").src = _this.grp_open_img.src; 
    152                 Element(el+"_img").onclick = function(){filters.hidden(el);} 
    153         } 
    154  
    155         cfilterSh.prototype.showWindow = function (div){ 
     199                Element(el+"_img").src = filters.grp_open_img.src; 
     200                Element(el+"_img").onclick = function(){visibleRulesFalse(el);}; 
     201        } 
     202 
     203        cfilterSh.prototype.showWindow = function (div) 
     204        { 
    156205                if(! this.filter_Sh[div.id]) { 
    157206                        div.style.width = "680px"; 
Note: See TracChangeset for help on using the changeset viewer.