Index: /trunk/prototype/modules/filters/interceptors/FilterMapping.php
===================================================================
--- /trunk/prototype/modules/filters/interceptors/FilterMapping.php	(revision 6348)
+++ /trunk/prototype/modules/filters/interceptors/FilterMapping.php	(revision 6363)
@@ -357,56 +357,100 @@
 	public function parseSieveScript( $script )
 	{
-		 $old_rule = strripos($script, "##PSEUDO script start");
-		
+		$old_rule = strripos($script, "##PSEUDO script start");
+		/* Tem regra antiga */
 		if($old_rule) {
 			$parsed_rule = $this->readOldScript($script);
 			$old_rules = array(); 
-			$j = 0;
+			$i_return = 0;
 			foreach ($parsed_rule['rule'] as $i => $value) {
-				
 				$array_rule = explode("&&", $parsed_rule['rule'][$i]);
+				
+				$action_type = array();
+				$action_parameter = array();
+				$criteria_value = array();
+				$criteria_operator = array();
+				$criteria_field = array();
+					
+				$i_criteria = 0;
+				$i_action = 0;
 
 				/* TO-DO: Ver as actions possíveis além de reject e fileinto */
 				switch($array_rule[6]) {
 					case 'reject':
-						$action_type      = 'reject';
-						$action_parameter = $array_rule[7];
+						$action_type[$i_action] = 'reject';
+						$action_parameter[$i_action] = $array_rule[7];
+						$i_action++;
 						break;
 					case 'folder':
-						$action_type      = 'fileinto';
-						$action_parameter = $array_rule[7];
-						break;
-				}
-
+						$action_type[$i_action] = 'fileinto';
+						$action_parameter[$i_action] = $array_rule[7];
+						$i_action++;
+						break;
+					case 'flagged':
+						$action_type[$i_action] = 'setflag';
+						$action_parameter[$i_action] = 'flagged';
+						$i_action++;
+						break;
+					case 'address': 
+						$action_type[$i_action] = 'redirect';
+						$action_parameter[$i_action] = $array_rule[7];
+						$i_action++;
+						break;
+					/* Somente para tratar casos em que a ação não é suportada */
+					default:	
+						$action_type[$i_action] = 'setflag';
+						$action_parameter[$i_action] = 'flagged';
+						$i_action++;
+						break;
+					// Recuperar o cyrus_delimiter para forçar um fileinto para INBOX/trash
+					//case 'discard':
+						//$action_type[$i_action] = 'fileinto';
+						//$action_parameter[$i_action] =;
+						//$i_action++;
+						//break;
+				}
 				if($array_rule[3] != "") {
-					$criteria_value = $array_rule[3];
-					$criteria_operator = '=';
-					$criteria_field = 'from';
+					$criteria_value[$i_criteria] = $array_rule[3];
+					$criteria_operator[$i_criteria] = '=';
+					$criteria_field[$i_criteria] = 'from';
+					$i_criteria++;
 				} 
-				else
-				{
-					$criteria_value = $array_rule[5];
-					$criteria_operator = '=';
-					$criteria_field = 'subject';
-				}
-
+				if($array_rule[4] != "") {
+					$criteria_value[$i_criteria] = $array_rule[4];
+					$criteria_operator[$i_criteria] = '=';
+					$criteria_field[$i_criteria] = 'to';
+					$i_criteria++;
+				} 
+				if($array_rule[5] != "") {
+					$criteria_value[$i_criteria] = $array_rule[5];
+					$criteria_operator[$i_criteria] = '=';
+					$criteria_field[$i_criteria] = 'subject';
+					$i_criteria++;
+				}
 				$old_retorno = array();
-				$old_retorno['isExact'] 				= true;
-				$old_retorno['name']					= 'regra_migrada_' . $array_rule[1];
-				$old_retorno['criteria'] 				= array();
-				$old_retorno['criteria'][0] 			= array();
-				$old_retorno['criteria'][0]['value']    = $criteria_value;
-				$old_retorno['criteria'][0]['operator'] = $criteria_operator;
-				$old_retorno['criteria'][0]['field']    = $criteria_field;
-				$old_retorno['actions']                 = array();
-				$old_retorno['actions'][0]              = array();
-				$old_retorno['actions'][0]['parameter'] = $action_parameter;
-				$old_retorno['actions'][0]['type']      = $action_type;
-				$old_retorno['enabled']                 = ($array_rule[2] == 'ENABLED') ? true: false;
-				$old_retorno['id']                      = 'regra_migrada_' . $array_rule[1];
-				$old_retorno['applyMessages']           = '';
-
-				$old_rules[$j] = $old_retorno;
-				$j++;
+				$old_retorno['isExact']  = true;
+				$old_retorno['name'] = 'regra_migrada_' . $array_rule[1];
+				
+				$old_retorno['criteria'] = array();				
+				foreach($criteria_value as $j => $value) {
+					$old_retorno['criteria'][$j] = array();
+					$old_retorno['criteria'][$j]['value'] = $criteria_value[$j];
+					$old_retorno['criteria'][$j]['operator'] = $criteria_operator[$j];
+					$old_retorno['criteria'][$j]['field'] = $criteria_field[$j];
+				}
+				
+				$old_retorno['actions'] = array();				
+				foreach($action_parameter as $j => $value) {
+					$old_retorno['actions'][$j] = array();
+					$old_retorno['actions'][$j]['parameter'] = $action_parameter[$j];
+					$old_retorno['actions'][$j]['type'] = $action_type[$j];
+				}
+				
+				$old_retorno['enabled'] = ($array_rule[2] == 'ENABLED') ? 'true' : 'false';
+				$old_retorno['id'] = 'Regra_migrada_' . $i_return;
+				$old_retorno['applyMessages']  = '';
+
+				$old_rules[$i_return] = $old_retorno;
+				$i_return++;
 			}			
 			return $old_rules;
Index: /trunk/prototype/modules/filters/filters.js
===================================================================
--- /trunk/prototype/modules/filters/filters.js	(revision 6348)
+++ /trunk/prototype/modules/filters/filters.js	(revision 6363)
@@ -170,5 +170,4 @@
 			actions.parent().find('[value="'+filter.actions[i].parameter+'"]').attr("selected", "selected");
     }
-    //isExact.val( filter.isExact != "false"? "and" : "or" );
 	isExact.filter('[value="'+(filter.isExact != "false"? "and" : "or")+'"]').attr("checked", "True");	
 }
@@ -225,5 +224,5 @@
 			if (type == 'fileintoTrash') {
 				type = 'fileinto';
-				the_parameter = 'INBOX/Trash';
+				the_parameter = 'INBOX' + cyrus_delimiter + 'Trash';
 			}
 			if (type == 'redirect') {
@@ -238,8 +237,5 @@
 		}),
 		enabled : true,
-		//applyMessages: allMessages? !$.isEmptyObject( selectedMessages ) ?
-		//keys( selectedMessages ) : allMessages : ""
 		applyMessages: apply_messages_ 
-		//applyMessages: ""
     };
   },
@@ -446,6 +442,4 @@
 
 function list_filters(html){
-
-
 	outOfficeVerify();
 	if(html){
@@ -723,6 +717,4 @@
 }
 
-
-
 function  init_filters(){
 	var html = DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {});
