Index: trunk/prototype/config/filter.ini
===================================================================
--- trunk/prototype/config/filter.ini	(revision 5862)
+++ trunk/prototype/config/filter.ini	(revision 6021)
@@ -20,9 +20,10 @@
 
 [after.create]
+makeId = modules/filters/interceptors/FilterMapping.php
 applySieveFilter = modules/filters/interceptors/FilterMapping.php
 
 
-;[after.update]
-;applySieveFilter = modules/filters/interceptors/FilterMapping.php
+[after.update]
+makeId = modules/filters/interceptors/FilterMapping.php
 
 
Index: trunk/prototype/modules/filters/interceptors/FilterMapping.php
===================================================================
--- trunk/prototype/modules/filters/interceptors/FilterMapping.php	(revision 6009)
+++ trunk/prototype/modules/filters/interceptors/FilterMapping.php	(revision 6021)
@@ -57,6 +57,24 @@
 class FilterMapping
 {
-	
 	var $service;
+	
+	/**
+	* MÃ©todo que cria o ID da regra que estÃ¡ sendo criada.
+	*
+	* @license    http://www.gnu.org/copyleft/gpl.html GPL
+	* @author     ConsÃ³rcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
+	* @sponsor    Caixa EconÃŽmica Federal
+	* @author     Airton Bordin Junior <airton@prognus.com.br>
+	* @author	  Gustavo Pereira dos Santos <gustavo@prognus.com.br>	
+	* @author	  Natan Fonseca <natan@prognus.com.br>	
+	* @param      <$uri> 
+	* @param      <$result> 
+	* @param      <$criteria> 
+	* @param      <$original> 
+	* @access     <public>
+	*/
+	public function makeId(&$uri , &$result , &$criteria , $original) {
+		$result['id'] = $uri['id'];
+	}
 	
 	
@@ -452,5 +470,4 @@
 		//if() 			
 		//{						
-			$result['id'] = $uri['id'];
 			$rule_apply = array(); 
 			
Index: trunk/prototype/modules/filters/filters.js
===================================================================
--- trunk/prototype/modules/filters/filters.js	(revision 5995)
+++ trunk/prototype/modules/filters/filters.js	(revision 6021)
@@ -4,7 +4,6 @@
 	var filters = DataLayer.get("filter");
 	var outoffice_active = false;
-	var outoffice = false;
+	outoffice = false;
 	for(var index in filters){
-		DataLayer.put( 'filter', filters[index].id, { enabled: (filters[index].enabled == "true" ? true: false)});
 		if(filters[index].id == "vacation")
 			outoffice = true;
@@ -15,4 +14,6 @@
 		}
 	}
+	if(!outoffice_active)
+		clean_msg();
 }
 
@@ -289,393 +290,4 @@
 var selectedMessages = {};
 var allMessages = false;
-//list_container = container.find(".rule-list-container");
-/*
-var raster = function( html ){
-    container = $('body.expressomail-module-container').append( html ).find(".expresso-window-container");
-	list_container = container.find(".rule-list-container");
-	details_container = container.find(".rule-details-container");
-	vacation_container = container.find(".vacation-details-container");
-	form = container.find("form");
-    criterias = details_container.find( 'fieldset input[name="criteriaType[]"]' );
-	actions = details_container.find( 'fieldset input[name="actionType[]"]' );
-	nameObj = details_container.find( 'input[name="name"]' );
-	isExact = details_container.find( 'input[name="isExact"]' );
-    formatter();
-    container = container.dialog({
-	    width:700,
-	    modal: true,
-	    closeOnEscape:true,
-	    close:function(event, ui) {
-		    event.stopPropagation();
-		    list_container.removeClass('hidden');
-		    details_container.addClass('hidden');
-		    vacation_container.addClass('hidden');
-	    },
-		open: function () {
-			$(".ui-dialog .ui-dialog-titlebar")
-			.append('<a href="#" class="ui-dialog-titlebar-minimize ui-corner-all" role="button"><span class="ui-icon ui-icon-minusthick">minimize</span></a>')
-			.find('.ui-dialog-titlebar-minimize').click(function() {
-				$(".ui-dialog-buttonpane, .ui-dialog-content").toggle();
-				$(".ui-icon-minusthick, .ui-icon-newwin").toggleClass('ui-icon-minusthick').toggleClass('ui-icon-newwin');
-			});
-		},
-	    autoOpen: false
-    });
-    details_container.accordion({autoHeight: false});
-    
-    DataLayer.render( BASE_PATH + 'api/templates/folderselect.ejs', 'folder:select', function( html ){
-	  details_container.find(".select-folderlist").append( html );
-    });
-
-
-    container.find(".button").button()
-    
-    .filter(".menu-filters > .button")
-
-    .click(function(){
-
-	container.dialog( 'close' );
-
-    })
-    
-    .filter(".cancel")
-    
-    .click(function(){
-
-	DataLayer.rollback( 'filter' );
-	return( false );
-
-    })
-    
-    .end().filter(".submit")
-    
-    .click(function(){
-
-	DataLayer.commit( 'filter' );
-	return( false );
-
-    });
-
-    details_container.find( ".menu-container" )
-
-	.find(".button.cancel").click(function(event){
-
-		details_container.accordion('activate',0);
-
-		showGridButton.removeClass('hidden');
-		grid.addClass('hidden').jqGrid('GridDestroy');
-	  
-		list_container.removeClass('hidden');
-		details_container.addClass('hidden');
-
-		return( false );
-
-	}).end()
-	.find(".button.submit").click(function(event){
-
-		$(this).submit();
-
-		details_container.accordion('activate',0);
-
-		showGridButton.removeClass('hidden');
-		grid.addClass('hidden').jqGrid('GridDestroy');
-
-		list_container.removeClass('hidden');
-		details_container.addClass('hidden');
-
-		return( false );
-
-	}).end()
-	.find(".button.back").click(function(event){
-
-		details_container.accordion('activate',0);
-
-		return( false );
-
-	}).end()
-	.find(".button.forth").click(function(event){
-
-		details_container.accordion('activate',1);
-
-		return( false );
-
-	}).end()
-
-    //$( ".expresso-window-container .rule-details-container" ).accordion();
-    // var removeURL = new RegExp("^*.#");
-
-    // ------------------------------------------------------------
-    // ------------------------------------------------------------
-
-    //jqgrid
-    .end().find(".fields-search-messages .button.search")
-
-    .click(function(){
-
-		  var rule = DataLayer.form( form );
-		  
-		  showGridButton = $(this).parent();
-
-		  var connect = rule.isExact ? "AND" : "OR";
-
-		  var filter = $.map( rule.criteria, function( criteria, i ){
-
-			  if( i === 0 )
-			      return {"0": criteria.field, "1": criteria.operator, "2": criteria.value};
-			  else
-			      return {"0": connect,  "1": criteria.field, "2": criteria.operator, "3": criteria.value};
-		  });
-
-		  $.ajax( {  
-			    url: DataLayer.basePath + 'folder/INBOX/message&' +  $.param( {"filter": filter} ),
-
-			    dataType: 'json',
-
-			    success: function(data){
-			      
-				  allMessages = data;
-
-				  grid = showGridButton.addClass('hidden')
-				  .siblings(".fields-search-messages-grid, .fields-search-messages-grid-pager")
-				  .removeClass('hidden').filter(".fields-search-messages-grid").jqGrid({
-
-					  url: DataLayer.basePath + 'folder/INBOX/message&' +  $.param( {"filter": [ "msgNumber", "IN", data ]} ),
-					  datatype: "json",
-					  mtype: 'GET',
-					  colNames:['#', ' ', 'De', 'Assunto', 'Data', 'Tamanho'],
-					  colModel:[
-						  {name:'msg_number',index:'msg_number', width:45, hidden:true, sortable:false},
-						  {name:'flags',index:'msg_number', width:40, sortable:false, formatter:flags2Class},
-						  {name:'from.name',index:'msg_number', width:130, sortable:false},
-						  {name:'subject',index:'subject', width:250, sortable:false},
-						  {name:'timestamp',index:'timestamp', width:65, align:"center", sortable:false, formatter:date2Time},
-						  {name:'size',index:'size', width:50, align:"right", sortable:false, formatter:bytes2Size}
-					  ],
-					  jsonReader : {
-						    root:"rows",
-						    page: "page",
-						    total: "total",
-						    records: "records",
-						    repeatitems: false,
-						    id: "0"
-					  },
-					  rowNum:10,
-					  rowList:[10,25,50],
-					  pager: '#fields-search-messages-grid-pager',
-					  sortname: 'id',
-					  viewrecords: true,
-					  sortorder: "desc",
-					  multiselect: true,
-					  autowidth: true,
-					  height:40,
-					  loadComplete: function(data) {
-		      //				// aplica o contador
-		      //				jQuery('.timable').each(function (i) {
-		      //					jQuery(this).countdown({
-		      //						since: new Date(parseInt(this.title)), 
-		      //						significant: 1,
-		      //						layout: 'h&aacute; {d<}{dn} {dl} {d>}{h<}{hn} {hl} {h>}{m<}{mn} {ml} {m>}{s<}{sn} {sl}{s>}', 
-		      //						description: ' atr&aacute;s'
-		      //					});
-		      //				});
-					  },
-					  onSelectRow: function (id, selected) {
-
-					      if( selected )
-						  selectedMessages[ id ] = true;
-					      else
-						  delete selectedMessages[ id ];
-
-					  },
-					  caption: 'Mensagens que atendem aos crit&eacute;rios'
-				  });
-			    }
-		  } );
-
-		  
-    });
-
-    vacation_container.find( ".menu-container" )
-	.find(".button.back").click(function(event){
-
-		list_container.removeClass('hidden');
-		vacation_container.addClass('hidden');
-
-		return( false );
-
-	}).end()
-	.find(".button.submit").click(function(event){
-
-		$(this).submit();
-	  
-		list_container.removeClass('hidden');
-		vacation_container.addClass('hidden');
-		return( false );
-	}); 
-
-}
-
-var reraster = function( html ){
-
-	//$(".rule-list-container").next().addClass("hidden");
-	
-	list_container.find( '.ui-widget' ).remove();
-
-	list_container.html( html ).find(".button").button();
-  
-	formatter();
-}
-
-var formatter = function(){
-
-    checkBoxes = container.find(".rule-list").selectable({
-		selecting: function(event, ui) {
-			$(ui.selecting).find(':checkbox').attr('checked', true);
-		},
-		unselecting: function(event, ui) {
-			$(ui.unselecting).find(':checkbox').attr('checked', false);
-		}
-    })
-    .find(':checkbox').change(function () {
-
-// 	if ($(this).attr("checked"))
-// 	    $(this).parents('.rule').addClass('ui-selected');
-// 	else
-	    $(this).parents('.rule').toggleClass('ui-selected');
-
-    });
-
-    list_container.children()
-
-    .filter( ".fields-add" )
-
-	.find(".button.add").click(function(){
-
-		list_container.addClass('hidden');
-		details_container.removeClass('hidden');
-		form.get(0).reset();
-
-		return( false );
-	})
-	.filter(".vacation").click(function(){
-
-		details_container.addClass('hidden');
-		vacation_container.removeClass('hidden');
-		form.get(0).reset();
-
-		return( false );
-
-	}).end().end()
-
-    .end().filter( ".fields-selected-itens" )
-
-    .find(".button.enable").click(function(){
-
-	    var values = [];
-      
-	    checkBoxes.filter(':checked').parents(".rule-list").find('.title').each(function(){
-
-		values[ values.length ] = { id: this.innerHTML, enabled: true };
-
-	    });
-
-	    DataLayer.put( 'filter', values );
-
-    }).end()
-
-    .find(".button.disable").click(function(){
-      
-	    var values = [];
-      
-	    checkBoxes.filter(':checked').parents(".rule-list").find('.title').each(function(){
-
-		values[ values.length ] = { id: this.innerHTML, enabled: false };
-
-	    });
-
-	    DataLayer.put( 'filter', values );
-
-    }).end()
-
-    .find(".button.delete").click(function(){
-      
-	    checkBoxes.filter(':checked').parents(".rule-list").find('.title').each(function(i, o){
-
-		 DataLayer.remove( 'filter', o.html() );
-
-	    });
-
-    }).end()
-    
-
-    .end().find( ".menu-control .button" ).filter(".update").button({
-		icons: {
-			primary: "ui-icon-pencil"
-		},
-		text: false
-	}).end()
-
-	.filter(".enable, .disable").click( function(event) {
-
-		var id = $(this).parents("li.rule").find('.title').html();
-
-		DataLayer.put( 'filter', id, { enabled: !$(this).is('.enable') } );
-	})
-
-	.filter(".enable").button({
-		icons: {
-			primary: "ui-icon-circle-check"
-		},
-		text: false
-	}).end()
-
-	.filter(".disable").button({
-		icons: {
-			primary: "ui-icon-circle-close"
-		},
-		text: false
-	}).end().end()
-	
-	.filter(".close").button({
-		icons: {
-			primary: "ui-icon-close"
-		},
-		text: false
-	}).click( function(event) {
-		$(event.target)
-		.parents("li.rule").find('.title')
-		.each( function(){
-
-		    DataLayer.remove( 'filter', $(this).html() );
-
-		}).end().remove();
-	}).end()
-	
-	.filter(".update").click(function(event){
-
-		var id = ( event.target.href || event.target.parentNode.href ).replace( new RegExp("^.*#"), "" );
-
-		var data = DataLayer.get( 'filter', id );
-
-		if( id === "vacation" )
-		{
-		    $('[name="vacation"]').val( data.actions[0].parameter );
-
-		    list_container.addClass('hidden');
-		    vacation_container.removeClass('hidden');
-		    return;
-		}
-
-		showDetails( data );
-
-		list_container.addClass('hidden');
-		details_container.removeClass('hidden');
-	}).end()
-	
-	.removeClass('ui-button-icon-only');
-};
-// ------------------------------------------------------------
-// ------------------------------------------------------------    
-*/ 
 
 function block_user_email(email) { 
@@ -717,23 +329,5 @@
 
 function list_filters(html){
-	/** TODO - Mudar quando API abstrair atualizações no cache */
-	DataLayer.remove('filter', false);
-	var filters = DataLayer.get("filter");
-	var outoffice_active = false;
-	var outoffice = false;
-	for(var index in filters){
-		DataLayer.put( 'filter', filters[index].id, { enabled: (filters[index].enabled == "true" ? true: false)});
-		if(filters[index].id == "vacation")
-			outoffice = true;
-		if(filters[index].id == "vacation" && filters[index].enabled == "true"){
-			write_msg(get_lang("Attention, you are in out of office mode."), true);	
-			outoffice_active = true;
-			break;
-		}
-	}
-	DataLayer.commit( 'filter' );
-	if(!outoffice_active){
-		clean_msg();
-	}
+	outOfficeVerify();
 	if(html){
 		if( ! $(".filters-windows").length )
@@ -852,5 +446,5 @@
 		text: false
 	}).click(function(){
-		var id = $(this).parents("li.rule").find('.id').val();
+		var id = $(this).parents("li.rule").find('.id').val();		
 		DataLayer.put( 'filter', id, { enabled: false  });
 		DataLayer.commit("filter", false,function(){
@@ -900,5 +494,5 @@
 	}).end().removeClass("ui-button-icon-only");
 	
-	$(".button.enable").click(function(){
+	$(".button.allenable").click(function(){
 		container.find('.rule-list').find('.rule').find('.select').find(':checked').parents('.rule').find('.title').each(function(i,o){
 			DataLayer.put( 'filter', o.innerHTML, { enabled: true  });
@@ -909,5 +503,5 @@
 	});
 	
-	$(".button.disable").click(function(){
+	$(".button.alldisable").click(function(){
 		container.find('.rule-list').find('.rule').find('.select').find(':checked').parents('.rule').find('.title').each(function(i,o){
 			DataLayer.put( 'filter', o.innerHTML, { enabled: false  });
@@ -920,5 +514,5 @@
 	
 	
-	$(".button.delete").click(function(){
+	$(".button.alldelete").click(function(){
 		$.Zebra_Dialog(get_lang("Are you sure to delete the filters?"),{
 			'type':     'question',
Index: trunk/prototype/modules/filters/filter-list.ejs
===================================================================
--- trunk/prototype/modules/filters/filter-list.ejs	(revision 5985)
+++ trunk/prototype/modules/filters/filter-list.ejs	(revision 6021)
@@ -48,6 +48,6 @@
 <fieldset class="fields-selected-itens ui-corner-all">
 	<legend>Selecionadas</legend>
-	<a href="#" class="button enable"  title="Habilitar regras selecionadas">Habilitar</a>
-	<a href="#" class="button disable" title="Desabilitar regras selecionadas">Desabilitar</a>
-	<a href="#" class="button delete"  title="Excluir regras selecionadas">Excluir</a>
+	<a href="#" class="button allenable"  title="Habilitar regras selecionadas">Habilitar</a>
+	<a href="#" class="button alldisable" title="Desabilitar regras selecionadas">Desabilitar</a>
+	<a href="#" class="button alldelete"  title="Excluir regras selecionadas">Excluir</a>
 </fieldset>
