Changeset 5601


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

Location:
trunk/prototype
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/prototype/api/datalayer.js

    r5592 r5601  
    745745                  DataLayer.move( concept, id, data[URI].id ); 
    746746                 
    747                 DataLayer.put( concept, id, data[URI], false ); 
     747                DataLayer.put( concept,  data[URI].id || id, data[URI], false ); 
    748748            } 
    749749             
     
    833833            if ( source === null ) return null; 
    834834 
    835             // All non-objects use value semantics and don't need explict copying. 
    836             if ( typeof source !== 'object' ) return source; 
     835            // All non-objects use value semantics and don't need explict copying.         
     836                if ( typeof source !== 'object' ) return source; 
    837837 
    838838            if( !depth || !(depth instanceof RecursionHelper) ) depth = new RecursionHelper(depth); 
     
    10851085              var newResult = []; 
    10861086             
    1087               for( var i = 0; i < result.length; i++ ) 
    1088                   newResult[i] = $.extend( {}, result[i] ); 
     1087              $.each( result, function( i, res ){ 
     1088                        newResult[ i ] = $.extend( {}, res ); 
     1089                  }); 
    10891090 
    10901091              this.put( concept, id, newResult, false ); 
  • trunk/prototype/modules/filters/filter-list.ejs

    r5539 r5601  
    77                <li class="rule <%= (data.rules[i].name=='vacation')?'vacation':'' %>" title="<%= data.rules[i].name %>"> 
    88                        <strong class="title <%= (data.rules[i].enabled)? 'enable':'disable' %>"><%= data.rules[i].name %></strong> 
     9                        <input type="hidden" class="id" value="<%= data.rules[i].id %>"> 
    910                        <dl class="rule-briefing"> 
    1011                                <dt>Critérios:</dt> 
  • trunk/prototype/modules/filters/filters.js

    r5598 r5601  
    185185 
    186186                }), 
    187                 enabled : "enabled", 
     187                enabled : true, 
    188188                applyMessages: allMessages? !$.isEmptyObject( selectedMessages ) ? 
    189189                keys( selectedMessages ) : allMessages : "" 
     
    676676        $(".ui-dialog-titlebar").after("<div class='dialog-head-buttonpane ui-dialog-buttonpane ui-widget-content ui-helper-clearfix' style='background-color: rgb(224, 238, 238); '><div class='ui-dialog-buttonset header-buttonpane'></div></div>"); 
    677677        $(".dialog-head-buttonpane").css("padding", "5px"). 
    678         find(".header-buttonpane").html("<a href='#' class='button add' title='Adicionar nova regra'>Nova regra</a><a href='#' class='button add vacation' title='Adicionar regra 'Fora do escritorio''>Fora do escritorio</a>").find(".button").button(); 
     678        find(".header-buttonpane").html("<a href='#' class='button add' title='Adicionar nova regra'>Nova regra</a><!--<a href='#' class='button add vacation' title='Adicionar regra 'Fora do escritorio''>Fora do escritorio</a>-->").find(".button").button(); 
    679679         
    680680        $(".ui-dialog-buttonpane.ui-widget-content").css("background-color", "#E0EEEE"); 
     
    752752        }).click(function(){ 
    753753                var id = $(this).parents("li.rule").find('.title').html(); 
    754                 DataLayer.put( 'filter', id, { enabled: "disable"  }); 
     754                DataLayer.put( 'filter', id, { enabled: false  }); 
    755755                DataLayer.commit("filter"); 
    756756                DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); 
     
    764764        }).click(function(){ 
    765765                var id = $(this).parents("li.rule").find('.title').html(); 
    766                 DataLayer.put( 'filter', id, { enabled: "enabled" }); 
     766                DataLayer.put( 'filter', id, { enabled: true }); 
    767767                DataLayer.commit("filter"); 
    768768                DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); 
  • 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.