Ignore:
Timestamp:
03/01/12 14:51:37 (12 years ago)
Author:
airton
Message:

Ticket #2088 - Melhorias no editor de regras de filtro de mensagens do Expresso - Pequenas correcoes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/prototype/modules/filters/interceptors/FilterMapping.php

    r5539 r5601  
    8181                foreach( $rules as $name => $data ) 
    8282                { 
    83                         //if( $data['enabled'] ) 
    84                                 //continue; 
     83                        if( !$data['enabled'] ) 
     84                                continue; 
    8585 
    8686                        $criteria = $data['criteria']; 
     
    121121                                                $require_vacation = true; 
    122122                                                $vacation = true; 
    123                                                 $script_match = "vacation"; 
    124                                                 break; 
     123                                                //$script_match = "vacation"; 
     124                                                continue; 
    125125                                        default: 
    126126                                                $script_criteria .= "header :"; 
     
    191191                                                $require_vacation = true; 
    192192                                                $action[$k]['parameter'] = "\"" . $action[$k]['parameter'] . "\""; 
    193                                                 $script_action = " :subject \"Fora do Escritório\" " . $action[$k]['parameter'] . ";"; 
     193                                                $vacation_action = " :subject \"Fora do Escritório\" " . $action[$k]['parameter'] . ";"; 
    194194                                                $vacation = true; 
    195                                                 break; 
     195                                                continue; 
    196196                                        case 'setflag': 
    197197                                                $require_flag = true; 
     
    201201                                                break; 
    202202                                } 
    203                                 if ($vacation == false) $script_action .= $action[$k]['type'] . " \"" . $action[$k]['parameter'] . "\";\r\n "; 
     203                                /*if ($vacation == false)*/ $script_action .= $action[$k]['type'] . " \"" . $action[$k]['parameter'] . "\";\r\n "; 
    204204                        } 
    205205 
    206                         if ($vacation == false) $script_action .= "}"; 
     206                        /*if ($vacation == false)*/ $script_action .= "}"; 
    207207 
    208208                        $script_rules .= $script_match . $script_criteria . $script_action . "\r\n"; 
     
    224224                } 
    225225 
     226                if( $vacation ) 
     227                { 
     228                  $script_rules .= "vacation" . $vacation_action . "\r\n"; 
     229                } 
     230 
    226231                $json_data = json_encode($rules); 
    227232                 
     
    313318        public function applySieveFilter( &$uri , &$result , &$criteria , $original  ) 
    314319        { 
     320                 $result['id'] = $uri['id']; 
     321 
    315322                 if( $original['properties']['applyMessages'] ) 
    316323                 { 
    317                           $filter = Controller::read($uri); 
    318                            
    319                           $proc = array(); 
    320                           $proc['keep'] = false; 
    321                            
    322                           foreach ($filter['actions'] as $v){ 
    323                                   if($v['type'] == 'keep') 
    324                                           $proc['keep'] = true; 
    325                                   else{ 
    326                                           $proc['type'] = $v['type']; 
    327                                           $proc['parameter'] = $v['parameter']; 
    328                                   } 
    329                           } 
    330  
    331                   $imap = Controller::service( 'Imap' ); 
    332                           $imap->apliSieveFilter($original['properties']['applyMessages'] , $proc );  
    333                           return $result; 
     324                      $filter = Controller::read($uri); 
     325 
     326                      $proc = array(); 
     327                      $proc['keep'] = false; 
     328                       
     329                      foreach ($filter['actions'] as $v){ 
     330                              if($v['type'] == 'keep') 
     331                                      $proc['keep'] = true; 
     332                              else{ 
     333                                      $proc['type'] = $v['type']; 
     334                                      $proc['parameter'] = $v['parameter']; 
     335                              } 
     336                      } 
     337 
     338                      $imap = Controller::service( 'Imap' ); 
     339                      $imap->apliSieveFilter($original['properties']['applyMessages'] , $proc );  
     340                      return $result; 
    334341                  } 
    335342        } 
     
    373380        */ 
    374381        public function setRule( &$uri , &$params , &$criteria , $original  ) 
    375         {                
    376           if( !$this->rules ) 
     382        { 
     383            if( !$this->rules ) 
    377384                $this->rules = $this->getRules(); 
    378          
    379       $params['id'] = isset($params['id']) ? $params['id'] : $params['name']; 
    380       $update = false; 
    381  
    382       foreach( $this->rules as $i => $rule ) 
    383                   if( $update = ($rule['id'] === $params['id']) ) 
    384                   { 
    385                           $this->rules[$i] = $params; 
    386                           break; 
    387                   } 
    388  
    389       if( !$update ) 
    390                 $this->rules[] = $params; 
    391  
    392       $content = $this->formatSieveScript( $this->rules ); 
    393            
    394           $params = array( 'name' => $this->service->config['user'], 
    395                        'content' => $content, 
    396                        'active' => true ); 
     385 
     386            $uri['id'] = $params['id'] = isset($params['id']) ? $params['id'] : urlencode($params['name']); 
     387 
     388            $i = 0; 
     389 
     390            for( ;$this->rules[$i] && $this->rules[$i]['id'] !== $params['id']; $i++ ); 
     391 
     392            $this->rules[$i] = $params; 
     393 
     394            $params = array( 'name' => $this->service->config['user'], 
     395                             'content' => $this->formatSieveScript( $this->rules ), 
     396                             'active' => true ); 
    397397        } 
    398398 
     
    414414        public function deleteRule( &$uri, &$params, &$criteria, $original ) 
    415415        { 
    416                 if( !$this->rules ) 
    417                   $this->rules = $this->getRules(); 
    418  
     416                if( !$this->rules ) {    
     417                        $this->rules = $this->getRules(); 
     418                }          
    419419                $params['id'] = $uri['id']; 
    420420 
    421421                $update = false; 
     422                 
     423                $rules = array(); 
    422424 
    423425                foreach( $this->rules as $i => $rule ) 
    424                         if( $rule['id'] === $uri['id'] ) 
    425                                 unset( $this->rules[$i] ); 
    426  
     426                        if( $rule['id'] !== $uri['id'] ) 
     427                                $rules[] = $this->rules[$i]; 
     428 
     429                $this->rules = $rules; 
     430                 
    427431                $uri['id'] = ''; 
    428432 
     
    433437                $URI = Controller::URI( $uri['concept'], $this->service->config['user'] ); 
    434438                $this->service->update( $URI, $params ); 
    435  
     439         
    436440                return( false ); 
    437441        } 
Note: See TracChangeset for help on using the changeset viewer.