Index: trunk/prototype/modules/filters/filters.js
===================================================================
--- trunk/prototype/modules/filters/filters.js	(revision 6443)
+++ trunk/prototype/modules/filters/filters.js	(revision 6452)
@@ -1,4 +1,4 @@
 /* Verifica se a regra fora de escritório está ativa */
-function outOfficeVerify() { 	
+function outOfficeVerify() {
 	DataLayer.remove('filter', false);
 	var filters = DataLayer.get("filter");
@@ -9,5 +9,5 @@
 			outoffice = true;
 		if(filters[index].id == "vacation" && filters[index].enabled == "true"){
-			write_msg(get_lang("Attention, you are in out of office mode."), true);	
+			write_msg(get_lang("Attention, you are in out of office mode."), true);
 			outoffice_active = true;
 			break;
@@ -52,5 +52,5 @@
 					error = true;
 					return;
-				}	
+				}
 			});
 			if(error){
@@ -62,5 +62,5 @@
 	var criteria_list = list_container.find('[name="criteriaValue[]"]');
 	var er_num = /^[0-9]+$/;
-	
+
 	if($(".sizeRule").val() != "" && er_num.test($(".sizeRule").val()) == false) {
 		$.Zebra_Dialog(get_lang("Size rule must be a number"),{
@@ -131,4 +131,6 @@
 date2Time = function (timestamp) {
 	var date = new Date();
+	if( typeof timestamp === "string" )
+	    timestamp = parseInt( timestamp, 10 );
 	if ((date.getTime() - timestamp) < (24*60*60*1000)) {
 		return '<span class="timable" title="'+timestamp+'"> </span>';
@@ -142,10 +144,10 @@
 
 keys = function( object ){
-  
+
   var array = [];
-  
+
   for( var key in object )
        array[ array.length ] = key;
-  
+
   return( array );
 
@@ -154,5 +156,5 @@
 /* Mostra os detalhes do filtro para edição */
 showDetails = function( filter ){
-  
+
     form.get(0).reset();
 
@@ -174,15 +176,15 @@
 		if(filter.actions[i].type == "redirect")
 			actions.siblings('[name="addressRedirect"]').val(filter.actions[i].parameter);
-		if(filter.actions[i].type == "reject")	
+		if(filter.actions[i].type == "reject")
 			actions.siblings('[name="messageReject"]').val(filter.actions[i].parameter);
 		if(filter.actions[i].type == "fileinto" || filter.actions[i].type == "setflag")
 			actions.parent().find('[value="'+filter.actions[i].parameter+'"]').attr("selected", "selected");
     }
-	isExact.filter('[value="'+(filter.isExact != "false"? "and" : "or")+'"]').attr("checked", "True");	
+	isExact.filter('[value="'+(filter.isExact != "false"? "and" : "or")+'"]').attr("checked", "True");
 }
 
 
 DataLayer.codec( "filter", "detail", {
-  
+
   decoder: function( form ){
       if( form.vacation )
@@ -198,13 +200,13 @@
 
 	var apply_messages_ = keys(selectedMessages);
-	
+
 	action = '';
-	
+
     return {
 		name: form.name ? form.name.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;') : nameObj.val().replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;'),
 		isExact: ( form.isExact === "and" ),
-		criteria: $.map( form.criteriaOperator || [], function( criteriaOperator, i ){	
+		criteria: $.map( form.criteriaOperator || [], function( criteriaOperator, i ){
 			return (!form.criteriaValue[i]) ? null:
-			{ 
+			{
 					value:  form.criteriaValue[i].replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;'),
 					operator: criteriaOperator,
@@ -214,7 +216,7 @@
 		actions: $.map( form.actionType || [], function( type, i ){
 			var the_parameter = form.actionParameter[i];
-			
+
 			!the_parameter ? the_parameter = form.actionParameter[i+1] : "";
-			if (type == 'fileinto') { 
+			if (type == 'fileinto') {
 				the_parameter = form.valueFileInto;
 			}
@@ -222,5 +224,5 @@
 				the_parameter = form.messageReject;
 			}
-			if (type == 'fileintoInbox') { 
+			if (type == 'fileintoInbox') {
 				if(!$('[value="fileintoInbox"]').parent().hasClass("hidden")){
 					type = 'fileinto';
@@ -237,5 +239,5 @@
 				the_parameter = form.addressRedirect;
 			}
-			if (type == 'setflag') { 
+			if (type == 'setflag') {
 				the_parameter = form.valueSetFlag;
 				action = form.valueSetFlag;
@@ -246,8 +248,8 @@
 		}),
 		enabled : true,
-		applyMessages: apply_messages_ 
+		applyMessages: apply_messages_
     };
   },
-  
+
   encoder: function( filters ){
 	var rules = [];
@@ -259,15 +261,15 @@
 
   }
-  
+
 });
 
 /* Codec do datalayer */
 DataLayer.codec( "folder", "select", {
-  
+
   decoder:function(){
-    
+
   },
   encoder:function( data ){
- 
+
       var tree1 = [], tree2 = [], tree3 = [];
 
@@ -294,5 +296,5 @@
 
       }
-      
+
       return {folders: [ tree1, tree2, tree3 ]};
 
@@ -310,5 +312,5 @@
 
 /* Bloqueio de usuários na tela de mensagem do ExpressoMail */
-function block_user_email(email) { 
+function block_user_email(email) {
 	delete selectedMessages;
 	var idd = urlencode(email);
@@ -330,11 +332,11 @@
 	}
 	if(confirm(get_lang("Want to block the user") + " " + email + "?")){
-		DataLayer.put( 'filter', idd, 
-					{ name: email, isExact: false, 
+		DataLayer.put( 'filter', idd,
+					{ name: email, isExact: false,
 						criteria:{ 0: {value: email, operator: "=", field: "from"} },
-						actions: { 0: {parameter: "INBOX" + cyrus_delimiter + "Spam", type: "fileinto"}}, 
-						enabled: true, 
+						actions: { 0: {parameter: "INBOX" + cyrus_delimiter + "Spam", type: "fileinto"}},
+						enabled: true,
 						id: email,
-						block: true 
+						block: true
 					});
 		DataLayer.commit("filter", false, function(){
@@ -342,5 +344,5 @@
 			list_filters();
 		});
-		
+
 	}
 }
@@ -348,5 +350,5 @@
 
 DataLayer.codec( 'message', 'jqGrid', {
- 
+
       encoder: function( data ){
 
@@ -378,38 +380,38 @@
 	for (i in criteria_)
 		if(criteria_[i] != "")
-		    criterias_.push( criterias_.length ?  {"0": "OR", "1": options[i], "2": criteria_value_[i], "3": criteria_[i]} : {"0": options[i], "1": criteria_value_[i], "2": criteria_[i]} ); 
+		    criterias_.push( criterias_.length ?  {"0": "OR", "1": options[i], "2": criteria_value_[i], "3": criteria_[i]} : {"0": options[i], "1": criteria_value_[i], "2": criteria_[i]} );
 
 	showGridButton = thiss.parent();
 
-	showGridButton.siblings("#filtergrid-container").block({  
-							message: '<div id="loading-content"><div class="image"></div></div>',  
-							css: {  
-								backgroundImage: 'url('+BASE_PATH+'modules/attach_message/images/loading.gif)',  
-								backgroundRepeat: 'no-repeat', 
-								backgroundPosition: 'center', 
-								backgroundColor: 'transparent', 
-								width: '32px', 
-								height: '32px', 
-								border:'none'  
-							}, 
-							overlayCSS: {  
-								backgroundColor: '#CCC',  
-								opacity:         0.5 
-							}  
+	showGridButton.siblings("#filtergrid-container").block({
+							message: '<div id="loading-content"><div class="image"></div></div>',
+							css: {
+								backgroundImage: 'url('+BASE_PATH+'modules/attach_message/images/loading.gif)',
+								backgroundRepeat: 'no-repeat',
+								backgroundPosition: 'center',
+								backgroundColor: 'transparent',
+								width: '32px',
+								height: '32px',
+								border:'none'
+							},
+							overlayCSS: {
+								backgroundColor: '#CCC',
+								opacity:         0.5
+							}
 						});
 
 	var data = DataLayer.get( 'message', { filter: criterias_, criteria: { properties: { context: { folder: 'INBOX' } } } }, true );
-	
+
 	DataLayer.register( 'criterias', 'message:jqGrid', function( crit ){
 
 		    crit.properties = { context: { folder: 'INBOX' } };
-		    
+
 		    return { filter: [ "msgNumber", "IN", data ], criteria: crit };
 	});
 
 	allMessages = data;
-	
-	if (typeof grid !== "undefined") { 
-		grid.jqGrid( 'setGridParam', { url: 'message:jqGrid', postData: data } ).trigger( 'reloadGrid' ); 
+
+	if (typeof grid !== "undefined") {
+		grid.jqGrid( 'setGridParam', { url: 'message:jqGrid', postData: data } ).trigger( 'reloadGrid' );
 		//return;
 	}
@@ -452,7 +454,7 @@
 	  //				jQuery('.timable').each(function (i) {
 	  //					jQuery(this).countdown({
-	  //						since: new Date(parseInt(this.title)), 
+	  //						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>}', 
+	  //						layout: 'h&aacute; {d<}{dn} {dl} {d>}{h<}{hn} {hl} {h>}{m<}{mn} {ml} {m>}{s<}{sn} {sl}{s>}',
 	  //						description: ' atr&aacute;s'
 	  //					});
@@ -460,5 +462,5 @@
 		},
 		onSelectRow: function (id, selected) {
-			if( selected ) 
+			if( selected )
 			{
 				selectedMessages[ id ] = true;
@@ -469,10 +471,10 @@
 			}
 		},
-		onSelectAll: function (id, selected) {					
+		onSelectAll: function (id, selected) {
 			for (i in id) {
 				if(selected)
 					selectedMessages[id[i]] = true;
 				else
-					delete selectedMessages[id[i]];	
+					delete selectedMessages[id[i]];
 			}
 		},
@@ -500,5 +502,5 @@
 		    event.stopPropagation();
 			if(list_container.find(".cancel").length)
-				list_container.find(".cancel").trigger('click');	
+				list_container.find(".cancel").trigger('click');
 			$(".dialog-head-buttonpane").hide();
 	    },
@@ -523,9 +525,9 @@
 	$(".dialog-head-buttonpane").css("padding", "5px").
 	find(".header-buttonpane").html("<a href='#' class='button add' title='"+get_lang("Add new rule")+"'>"+get_lang("New rule")+"</a>"+(!outoffice ? "<a href='#' class='button add vacation' title='"+get_lang("Add rule out of office")+"'>"+get_lang("Out of office")+"</a>" : "")).find(".button").button();
-	
+
 	$(".ui-dialog-buttonpane.ui-widget-content").css("background-color", "#E0EEEE");
 	var list = DataLayer.render( BASE_PATH + 'modules/filters/filter-list.ejs', DataLayer.get("filter:detail", true));
 	list_container.html(list).find(".button").button();
-	
+
 	list_container.find(".rule-list").selectable({
 		selecting: function(event, ui) {
@@ -536,5 +538,5 @@
 		}
 	});
-	
+
 	list_container.find( ".menu-control .button" ).filter(".update").button({
 		icons: {
@@ -549,5 +551,5 @@
 				filters = filters[i];
 				break;
-			}	
+			}
 		}
 		DataLayer.render( BASE_PATH + 'modules/filters/edit-filter.ejs', {folders : DataLayer.get("folder", true), delimiter: cyrus_delimiter},function(html){
@@ -578,6 +580,6 @@
 					else
 						return;
-					DataLayer.commit( 'filter', false,function(){						
-						if($('#gbox_fields-search-messages-grid').length > 0 && action != '') {	
+					DataLayer.commit( 'filter', false,function(){
+						if($('#gbox_fields-search-messages-grid').length > 0 && action != '') {
 							for (var index in selectedMessages) {
 								set_message_flag(index, action, false);
@@ -586,5 +588,5 @@
 						DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
 					});
-				}).end().filter('.button.search').click(function() {				
+				}).end().filter('.button.search').click(function() {
 					/* Valida se o usuário preencheu as informações */
 					if(valid_save())
@@ -614,5 +616,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(){
@@ -633,5 +635,5 @@
 		});
 	}).end()
-	
+
 	.filter(".close").button({
 		icons: {
@@ -661,5 +663,5 @@
 		});
 	}).end().removeClass("ui-button-icon-only");
-	
+
 	$(".button.allenable").click(function(){
 		container.find('.rule-list').find('.rule').find('.select').find(':checked').parents('.rule').find('.title').each(function(i,o){
@@ -670,5 +672,5 @@
 		});
 	});
-	
+
 	$(".button.alldisable").click(function(){
 		container.find('.rule-list').find('.rule').find('.select').find(':checked').parents('.rule').find('.title').each(function(i,o){
@@ -679,5 +681,5 @@
 		});
 	});
-	
+
 	$(".button.alldelete").click(function(){
 		$.Zebra_Dialog(get_lang("Are you sure to delete the filters?"),{
@@ -690,5 +692,5 @@
 					DataLayer.remove('filter', false);
 					DataLayer.get('filter');
-					container.find('.rule-list').find('.rule').find('.select').find(':checked').parents('.rule').find('.title').each(function(i,o){						
+					container.find('.rule-list').find('.rule').find('.select').find(':checked').parents('.rule').find('.title').each(function(i,o){
 						DataLayer.remove( 'filter', urlencode(o.innerHTML) );
 					});
@@ -702,7 +704,7 @@
 		});
 	});
-	
+
 	var aa = 0;
-	
+
 	list_container.parent().find(".button.add:first").click(function(){
 		list_container.parent().find(".dialog-head-buttonpane").addClass("hidden");
@@ -726,5 +728,5 @@
 					return;
 				DataLayer.commit( 'filter',false,function(){
-					if($('#gbox_fields-search-messages-grid').length > 0 && action != '') {	
+					if($('#gbox_fields-search-messages-grid').length > 0 && action != '') {
 						for (var index in selectedMessages) {
 							set_message_flag(index, action, false);
@@ -733,5 +735,5 @@
 					DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
 				});
-			}).end().filter('.button.search').click(function() {				
+			}).end().filter('.button.search').click(function() {
 				if(valid_save())
 					showGridMessages($(this));
@@ -742,5 +744,5 @@
 	});
 	list_container.parent().find(".button.add.vacation").click(function(){
-	
+
 		list_container.parent().find(".dialog-head-buttonpane").addClass("hidden");
 		DataLayer.render( BASE_PATH + 'modules/filters/edit-filter.ejs', {folders : DataLayer.get("folder", true), delimiter: cyrus_delimiter},function(html){
@@ -750,5 +752,5 @@
 			list_container.find(".button").button().filter(".back").click(function(){
 				DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
-			}).end().filter(".submit").click(function(){			
+			}).end().filter(".submit").click(function(){
 				if(list_container.find(".vacation-details-container .filter-textarea").val().length <= 0){
 						$.Zebra_Dialog(get_lang('Write a message'));
@@ -761,5 +763,5 @@
 				}
 			});
-		});	
+		});
 	});
 }
