Index: /sandbox/2.4.1-1/prototype/modules/filters/filters.js
===================================================================
--- /sandbox/2.4.1-1/prototype/modules/filters/filters.js	(revision 6355)
+++ /sandbox/2.4.1-1/prototype/modules/filters/filters.js	(revision 6364)
@@ -376,4 +376,5 @@
 					$.Zebra_Dialog(get_lang("Lock User") + " " + email + " " + get_lang("removed"));
 					list_filters();
+					getFromAlertRules();
 				});
 				return true;
@@ -394,4 +395,5 @@
 			$.Zebra_Dialog(get_lang("User") + " " + email + " " + get_lang("blocked"));
 			list_filters();
+			getFromAlertRules();
 		});
 		
@@ -600,11 +602,12 @@
 						return;
 					DataLayer.commit( 'filter', false,function(data){
-					if(filters['alertMessage'] == "true"){
-						if(filters['alertMessage'] != $('.alertMessage').is(':checked').toString()){
-							/**RETIRA FLAG*/
-							removeMessagesFlag(filters['id']);
+						if(filters['alertMessage'] == "true"){
+							if(filters['alertMessage'] != $('.alertMessage').is(':checked').toString()){
+								/**RETIRA FLAG*/
+								removeMessagesFlag(filters['id']);
+							}
 						}
-					}
 						DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
+						getFromAlertRules();
 					});
 				}).end().filter('.button.search').click(function() {				
@@ -624,4 +627,5 @@
 					DataLayer.commit( 'filter', false,function(){
 						DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
+						getFromAlertRules();
 					});
 				});
@@ -642,4 +646,5 @@
 		DataLayer.commit("filter", false,function(){
 			DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
+			getFromAlertRules();
 		});
 	}).end()
@@ -655,4 +660,5 @@
 		DataLayer.commit("filter", false,function(){
 			DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
+			getFromAlertRules();
 		});
 	}).end()
@@ -681,4 +687,5 @@
 					DataLayer.commit("filter", false,function(){
 						DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
+						getFromAlertRules();
 					});
 				}else{
@@ -695,4 +702,5 @@
 		DataLayer.commit("filter", false, function(){
 			DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
+			getFromAlertRules();
 		});
 	});
@@ -706,4 +714,5 @@
 		DataLayer.commit("filter", false, function(){
 			DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
+			getFromAlertRules();
 		});
 	});
@@ -729,4 +738,5 @@
 					DataLayer.commit("filter", false,function(){
 						DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
+						getFromAlertRules();
 					});
 				}else{
@@ -761,4 +771,5 @@
 				DataLayer.commit( 'filter',false,function(){
 					DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
+					getFromAlertRules();
 				});
 			}).end().filter('.button.search').click(function() {				
@@ -782,4 +793,5 @@
 				DataLayer.commit( 'filter',false,function(){
 					DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
+					getFromAlertRules();
 				});
 			});
@@ -804,4 +816,5 @@
 	var folder = '';
 	var from = '';
+
 	for(var i=0; i < filters_c['actions'].length; i++){
 		if(filters_c['actions'][i].type == 'fileinto'){
@@ -809,9 +822,14 @@
 		}
 	}
-	for(var i=0; i < filters_c['criteria'].length; i++){
-		if(filters_c['criteria'][i].field == 'from'){
-			from = filters_c['criteria'][i].value;
-		}
-	}
-	cExecute ("$this.imap_functions.removeFlagMessagesFilter&folder="+folder+"&from="+from, function(){}); 
+	$.each(fromRules, function(index, value) {
+		if(value == folder){
+			for(var i=0; i < filters_c['criteria'].length; i++){
+				if(filters_c['criteria'][i].field == 'from'){
+					from = filters_c['criteria'][i].value;
+				}
+			}
+			cExecute ("$this.imap_functions.removeFlagMessagesFilter&folder="+folder+"&from="+from, function(){}); 
+			return false;
+		}
+	});
 }
Index: /sandbox/2.4.1-1/expressoMail1_2/inc/class.imap_functions.inc.php
===================================================================
--- /sandbox/2.4.1-1/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 6355)
+++ /sandbox/2.4.1-1/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 6364)
@@ -5337,21 +5337,48 @@
 	/**
 	* Remove a flag que caracteriza uma mensagem como alertada por Filtro por Remetente.
+	* se houver o parametro msg_number, então remove a flag de uma msg especifica
+	* se não houver o parametro msg_number, mas sim o from, então remove a flag de todas as msgs da pasta (parametro from), 
+	* e que o remetente for o from.
 	*/
 	function removeFlagMessagesFilter($params){
+		$message_number = $params['msg_number'];
 		$folder = $params['folder'];
-		$from = $params['from'];
-		if(isset($folder) && isset($from)){
-			$this->mbox = $this->open_mbox($folder);
-			$messages = imap_search($this->mbox, 'UNDELETED UNSEEN KEYWORD "$FilteredMessage"', SE_UID);
-		}
-		if(is_array($messages)){
-			foreach ($messages as $k => $m) {
-				$headers = imap_fetch_overview($this->mbox, $m, FT_UID);
-				if(strpos($headers[0]->from, $from) > 0){
-					imap_clearflag_full($this->mbox, $m, '$FilteredMessage', ST_UID);
-				}
-			}
-		}
-	}
+
+		if(isset($message_number)){
+			if(isset($folder)){
+				$message_number = explode(',', $message_number);
+						ob_start();
+print_r(var_export($message_number));
+
+$output = ob_get_clean();
+file_put_contents( "/tmp/marci.log", $output , FILE_APPEND);
+				$this->mbox = $this->open_mbox($folder);
+				foreach ($message_number as $k => $m) {						
+						imap_clearflag_full($this->mbox, $m, '$FilteredMessage', ST_UID);
+					}
+			}
+		}
+		else{
+			$from = $params['from'];
+									ob_start();
+print_r(var_export($from));
+
+$output = ob_get_clean();
+file_put_contents( "/tmp/marci.log", $output , FILE_APPEND);
+			if(isset($folder) && isset($from)){
+				$this->mbox = $this->open_mbox($folder);
+				$messages = imap_search($this->mbox, 'UNDELETED UNSEEN KEYWORD "$FilteredMessage"', SE_UID);
+			}
+			if(is_array($messages)){
+				foreach ($messages as $k => $m) {
+					$headers = imap_fetch_overview($this->mbox, $m, FT_UID);
+					if(strpos($headers[0]->from, $from) > 0){
+						imap_clearflag_full($this->mbox, $m, '$FilteredMessage', ST_UID);
+					}
+				}
+			}
+		}
+	}
+
 }
 ?>
Index: /sandbox/2.4.1-1/expressoMail1_2/js/main.js
===================================================================
--- /sandbox/2.4.1-1/expressoMail1_2/js/main.js	(revision 6354)
+++ /sandbox/2.4.1-1/expressoMail1_2/js/main.js	(revision 6364)
@@ -512,4 +512,5 @@
 
 function refresh(alert_new_msg){
+	getFromAlertRules();
 	var handler_refresh = function(data){
 		if(checkAlarmsFilter){
@@ -1091,5 +1092,11 @@
 			Element('tot_m').innerHTML = n_total_msg;
 		}
-		
+		// remove a flag $FilteredMessage da mensagem ao ser movida
+		$.each(fromRules, function(index, value) {
+			if(value == folder){
+				cExecute ("$this.imap_functions.removeFlagMessagesFilter&folder="+new_folder+"&msg_number="+msgs_number, function(){}); 
+				return false;
+			}
+		});
 		refresh();
 	}
@@ -2676,4 +2683,13 @@
 							set_msg_as_read(results_search_messages, false, true);
 						Element("check_box_message_" + msgs_to_set[i]).checked = false;
+						
+							// remove a flag $FilteredMessage da mensagem ao ser marcada como lida	
+		$.each(fromRules, function(index, value) {
+			if(value == folder){
+				cExecute ("$this.imap_functions.removeFlagMessagesFilter&folder="+folder+"&msg_number="+msgs_to_set, function(){}); 
+				return false;
+			}
+		});	
+						
 						break;
 					case "flagged":
@@ -2700,5 +2716,5 @@
 	else
 		folder = Element("input_folder_"+msgs_to_set+"_r").value;
-
+	
 	if (msgs_to_set)
 		cExecute ("$this.imap_functions.set_messages_flag&folder="+folder+"&msgs_to_set="+msgs_to_set+"&flag="+flag, handler_set_messages_flag);
Index: /sandbox/2.4.1-1/expressoMail1_2/js/messages_controller.js
===================================================================
--- /sandbox/2.4.1-1/expressoMail1_2/js/messages_controller.js	(revision 6088)
+++ /sandbox/2.4.1-1/expressoMail1_2/js/messages_controller.js	(revision 6364)
@@ -47,4 +47,13 @@
 		if (msgs_number == 'selected')
 			msgs_number = get_selected_messages();
+		
+		// remove a flag $FilteredMessage da mensagem ao excluí-la
+		$.each(fromRules, function(index, value) {
+			if(value == folder){
+				cExecute ("$this.imap_functions.removeFlagMessagesFilter&folder="+folder+"&msg_number="+msgs_number, function(){}); 	
+				return false;
+			}
+		});
+		
 		if(currentTab != 0 && currentTab.indexOf("search_")  >= 0){
 			var content_search = document.getElementById('content_id_'+currentTab);
Index: /sandbox/2.4.1-1/expressoMail1_2/js/draw_api.js
===================================================================
--- /sandbox/2.4.1-1/expressoMail1_2/js/draw_api.js	(revision 6245)
+++ /sandbox/2.4.1-1/expressoMail1_2/js/draw_api.js	(revision 6364)
@@ -1954,4 +1954,13 @@
 var msg_selected;
 function draw_message(info_msg, ID){
+	// remove a flag $FilteredMessage da mensagem ao ser lida
+	if(info_msg.Unseen == "U"){
+		$.each(fromRules, function(index, value) {
+			if(value == info_msg.msg_folder){
+				cExecute ("$this.imap_functions.removeFlagMessagesFilter&folder="+info_msg.msg_folder+"&msg_number="+info_msg.msg_number, function(){}); 
+				return false;
+			}
+		});
+	}
 	var content = document.getElementById('content_id_' + ID);
 
