Changeset 6363 for trunk


Ignore:
Timestamp:
05/31/12 15:25:39 (12 years ago)
Author:
airton
Message:

Ticket #2819 - Inconsistencia na migracao dos filtros antigos para a nova funcionalidade de filtros de mensagens

Location:
trunk/prototype/modules/filters
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/prototype/modules/filters/filters.js

    r6348 r6363  
    170170                        actions.parent().find('[value="'+filter.actions[i].parameter+'"]').attr("selected", "selected"); 
    171171    } 
    172     //isExact.val( filter.isExact != "false"? "and" : "or" ); 
    173172        isExact.filter('[value="'+(filter.isExact != "false"? "and" : "or")+'"]').attr("checked", "True");       
    174173} 
     
    225224                        if (type == 'fileintoTrash') { 
    226225                                type = 'fileinto'; 
    227                                 the_parameter = 'INBOX/Trash'; 
     226                                the_parameter = 'INBOX' + cyrus_delimiter + 'Trash'; 
    228227                        } 
    229228                        if (type == 'redirect') { 
     
    238237                }), 
    239238                enabled : true, 
    240                 //applyMessages: allMessages? !$.isEmptyObject( selectedMessages ) ? 
    241                 //keys( selectedMessages ) : allMessages : "" 
    242239                applyMessages: apply_messages_  
    243                 //applyMessages: "" 
    244240    }; 
    245241  }, 
     
    446442 
    447443function list_filters(html){ 
    448  
    449  
    450444        outOfficeVerify(); 
    451445        if(html){ 
     
    723717} 
    724718 
    725  
    726  
    727719function  init_filters(){ 
    728720        var html = DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {}); 
  • trunk/prototype/modules/filters/interceptors/FilterMapping.php

    r6348 r6363  
    357357        public function parseSieveScript( $script ) 
    358358        { 
    359                  $old_rule = strripos($script, "##PSEUDO script start"); 
    360                  
     359                $old_rule = strripos($script, "##PSEUDO script start"); 
     360                /* Tem regra antiga */ 
    361361                if($old_rule) { 
    362362                        $parsed_rule = $this->readOldScript($script); 
    363363                        $old_rules = array();  
    364                         $j = 0; 
     364                        $i_return = 0; 
    365365                        foreach ($parsed_rule['rule'] as $i => $value) { 
    366                                  
    367366                                $array_rule = explode("&&", $parsed_rule['rule'][$i]); 
     367                                 
     368                                $action_type = array(); 
     369                                $action_parameter = array(); 
     370                                $criteria_value = array(); 
     371                                $criteria_operator = array(); 
     372                                $criteria_field = array(); 
     373                                         
     374                                $i_criteria = 0; 
     375                                $i_action = 0; 
    368376 
    369377                                /* TO-DO: Ver as actions possíveis além de reject e fileinto */ 
    370378                                switch($array_rule[6]) { 
    371379                                        case 'reject': 
    372                                                 $action_type      = 'reject'; 
    373                                                 $action_parameter = $array_rule[7]; 
     380                                                $action_type[$i_action] = 'reject'; 
     381                                                $action_parameter[$i_action] = $array_rule[7]; 
     382                                                $i_action++; 
    374383                                                break; 
    375384                                        case 'folder': 
    376                                                 $action_type      = 'fileinto'; 
    377                                                 $action_parameter = $array_rule[7]; 
    378                                                 break; 
    379                                 } 
    380  
     385                                                $action_type[$i_action] = 'fileinto'; 
     386                                                $action_parameter[$i_action] = $array_rule[7]; 
     387                                                $i_action++; 
     388                                                break; 
     389                                        case 'flagged': 
     390                                                $action_type[$i_action] = 'setflag'; 
     391                                                $action_parameter[$i_action] = 'flagged'; 
     392                                                $i_action++; 
     393                                                break; 
     394                                        case 'address':  
     395                                                $action_type[$i_action] = 'redirect'; 
     396                                                $action_parameter[$i_action] = $array_rule[7]; 
     397                                                $i_action++; 
     398                                                break; 
     399                                        /* Somente para tratar casos em que a ação não é suportada */ 
     400                                        default:         
     401                                                $action_type[$i_action] = 'setflag'; 
     402                                                $action_parameter[$i_action] = 'flagged'; 
     403                                                $i_action++; 
     404                                                break; 
     405                                        // Recuperar o cyrus_delimiter para forçar um fileinto para INBOX/trash 
     406                                        //case 'discard': 
     407                                                //$action_type[$i_action] = 'fileinto'; 
     408                                                //$action_parameter[$i_action] =; 
     409                                                //$i_action++; 
     410                                                //break; 
     411                                } 
    381412                                if($array_rule[3] != "") { 
    382                                         $criteria_value = $array_rule[3]; 
    383                                         $criteria_operator = '='; 
    384                                         $criteria_field = 'from'; 
     413                                        $criteria_value[$i_criteria] = $array_rule[3]; 
     414                                        $criteria_operator[$i_criteria] = '='; 
     415                                        $criteria_field[$i_criteria] = 'from'; 
     416                                        $i_criteria++; 
    385417                                }  
    386                                 else 
    387                                 { 
    388                                         $criteria_value = $array_rule[5]; 
    389                                         $criteria_operator = '='; 
    390                                         $criteria_field = 'subject'; 
    391                                 } 
    392  
     418                                if($array_rule[4] != "") { 
     419                                        $criteria_value[$i_criteria] = $array_rule[4]; 
     420                                        $criteria_operator[$i_criteria] = '='; 
     421                                        $criteria_field[$i_criteria] = 'to'; 
     422                                        $i_criteria++; 
     423                                }  
     424                                if($array_rule[5] != "") { 
     425                                        $criteria_value[$i_criteria] = $array_rule[5]; 
     426                                        $criteria_operator[$i_criteria] = '='; 
     427                                        $criteria_field[$i_criteria] = 'subject'; 
     428                                        $i_criteria++; 
     429                                } 
    393430                                $old_retorno = array(); 
    394                                 $old_retorno['isExact']                                 = true; 
    395                                 $old_retorno['name']                                    = 'regra_migrada_' . $array_rule[1]; 
    396                                 $old_retorno['criteria']                                = array(); 
    397                                 $old_retorno['criteria'][0]                     = array(); 
    398                                 $old_retorno['criteria'][0]['value']    = $criteria_value; 
    399                                 $old_retorno['criteria'][0]['operator'] = $criteria_operator; 
    400                                 $old_retorno['criteria'][0]['field']    = $criteria_field; 
    401                                 $old_retorno['actions']                 = array(); 
    402                                 $old_retorno['actions'][0]              = array(); 
    403                                 $old_retorno['actions'][0]['parameter'] = $action_parameter; 
    404                                 $old_retorno['actions'][0]['type']      = $action_type; 
    405                                 $old_retorno['enabled']                 = ($array_rule[2] == 'ENABLED') ? true: false; 
    406                                 $old_retorno['id']                      = 'regra_migrada_' . $array_rule[1]; 
    407                                 $old_retorno['applyMessages']           = ''; 
    408  
    409                                 $old_rules[$j] = $old_retorno; 
    410                                 $j++; 
     431                                $old_retorno['isExact']  = true; 
     432                                $old_retorno['name'] = 'regra_migrada_' . $array_rule[1]; 
     433                                 
     434                                $old_retorno['criteria'] = array();                              
     435                                foreach($criteria_value as $j => $value) { 
     436                                        $old_retorno['criteria'][$j] = array(); 
     437                                        $old_retorno['criteria'][$j]['value'] = $criteria_value[$j]; 
     438                                        $old_retorno['criteria'][$j]['operator'] = $criteria_operator[$j]; 
     439                                        $old_retorno['criteria'][$j]['field'] = $criteria_field[$j]; 
     440                                } 
     441                                 
     442                                $old_retorno['actions'] = array();                               
     443                                foreach($action_parameter as $j => $value) { 
     444                                        $old_retorno['actions'][$j] = array(); 
     445                                        $old_retorno['actions'][$j]['parameter'] = $action_parameter[$j]; 
     446                                        $old_retorno['actions'][$j]['type'] = $action_type[$j]; 
     447                                } 
     448                                 
     449                                $old_retorno['enabled'] = ($array_rule[2] == 'ENABLED') ? 'true' : 'false'; 
     450                                $old_retorno['id'] = 'Regra_migrada_' . $i_return; 
     451                                $old_retorno['applyMessages']  = ''; 
     452 
     453                                $old_rules[$i_return] = $old_retorno; 
     454                                $i_return++; 
    411455                        }                        
    412456                        return $old_rules; 
Note: See TracChangeset for help on using the changeset viewer.