Index: trunk/prototype/services/Sieve.php
===================================================================
--- trunk/prototype/services/Sieve.php	(revision 5341)
+++ trunk/prototype/services/Sieve.php	(revision 5539)
@@ -10,18 +10,21 @@
 	
     public function open( $config )
-    {
-	$this->config = $config;
-
-	if( PEAR::isError( $error = $this->connect( $config['host'] , $config['port'] , $config['options'] , $config['useTLS'] ) ) )
-	    return $error->toString();
-
-	if( PEAR::isError( $error = $this->login( $config['user'] , $config['password'] , $config['loginType'] ) ) )
-	    return $error->toString();
-
-	if( PEAR::isError( $error = $this->getError() ) )
-	    return $error->toString();
+    {	
+		$this->config = $config;
+			
+		if( PEAR::isError( $error = $this->connect( $config['host'] , $config['port'] , $config['options'] , $config['useTLS'] ) ) ) {
+			return $error->toString();
+		}
+		
+		if( PEAR::isError( $error = $this->login( $config['user'] , $config['password'] , $config['loginType'] ) ) ) {
+			return $error->toString();
+		}
+		
+		if( PEAR::isError( $error = $this->getError() ) ) {
+			return $error->toString();
+		}	
     }
 
-    public function find( $URI, $context, $justthese = false, $criteria = false )
+    public function find( $URI, $justthese = false, $criteria = false )
     {
 	$return = $this->listScripts();
@@ -34,10 +37,4 @@
 	foreach( $return as $i => $id )
 		$array_return[] = $this->read( array( 'id' => $id ) );
-
-// 	ob_start();
-//         print_r( $array_return );
-//         $output = ob_get_clean();
-//         file_put_contents( "/tmp/2.log",  $output , FILE_APPEND);
-
 	return $array_return;
     }
@@ -47,5 +44,5 @@
     public function read( $URI, $justthese = false )
     {
-	return array( 'name' => $URI['id'], 
+		return array( 'name' => $URI['id'], 
 		      'content' => $this->getScript( $URI['id'] ),
 		      'active' => ($this->getActive() === $URI['id']) );
@@ -53,9 +50,9 @@
 	
     public function create( $URI, $data )
-    {
-	if( $this->installScript( $data['name'], $data['content'], $data['active'] ) )
-	    return array('id' => $data['name']);
+    {	
+		if( $this->installScript( $data['name'], $data['content'], $data['active'] ) )
+			return array('id' => $data['name']);
 
-	return false;
+		return false;
     }
 
Index: trunk/prototype/modules/filters/filters.css
===================================================================
--- trunk/prototype/modules/filters/filters.css	(revision 5341)
+++ trunk/prototype/modules/filters/filters.css	(revision 5539)
@@ -31,6 +31,8 @@
 .rule-list .rule {
 	display: block;
-	margin: 0;
+	margin: 1px;
 	padding: 5px;
+	border : 1px solid #CCCCCC;
+	border-radius : 5px;
 /*	height: 18px;*/
 }
@@ -41,5 +43,5 @@
 
 .rule-list .rule .menu-control {
-	max-width:  125px;
+	max-width:  100px;
     float: right;
 	margin-top: -50px;
@@ -52,5 +54,5 @@
 	padding: 0;
 }
-.rule.vacation { background-color: #FBFAF3; }
+.rule.vacation { background-color: #F5F3BC; }
 .rule.vacation .title { font-style: italic; }
 
@@ -72,8 +74,12 @@
     margin: 5px;
     padding: 5px;
-    text-align: center;
     width: 250px;
 	border: 1px solid #AAA;
 }
+
+.expresso-window-container .filter-llist{    
+	border: 1px solid #AAA;
+}
+
 .expresso-window-container .fields-add { margin-right: 0;}
 
@@ -85,8 +91,4 @@
 }
 
-
-
-
-
 .filter-manager-window fieldset, .vacarion-details-container fieldset{ border: none; }
 .rule-details-container fieldset label.small { width: 100px; display: inline-block;}
@@ -95,6 +97,6 @@
 .rule-details-container fieldset.fields-isexact fieldset { border: none; }
 
-.rule-details-container fieldset.fields-replyto textarea { display: block; width: 350px; height: 50px; border: 1px solid #AAA; margin: 5px; }
-.vacation-details-container textarea { display: block; width: 350px; height: 100px; border: 1px solid #AAA; margin: 5px; }
+.rule-details-container fieldset.fields-replyto textarea { display: block; width : 100%; height: 50px; border: 1px solid #AAA; padding: 5px; margin: 5px; }
+.vacation-details-container textarea { display: block; width : 98.5%; height: 100px; border: 1px solid #AAA; padding: 5px; margin: 5px; }
 
 .filter-manager-window .message-tip-container { list-style: none; border:1px solid #E17009; background-color: #FBFAF3; padding: 5px; margin: 5px;}
@@ -116,4 +118,4 @@
 	font-size: 0.8em;
 }
-.rule .menu-control .ui-button.disable,.rule .menu-control .ui-button.enable, .rule .menu-control .ui-button.close  { top:5px; }
+.rule .menu-control .ui-button.disable,.rule .menu-control .ui-button.enable, .rule .menu-control .ui-button.update, .rule .menu-control .ui-button.close  { top:5px; }
 .filter-manager-window .ui-accordion-icons .ui-accordion-header a { padding-left: 2.2em; }
Index: trunk/prototype/modules/filters/interceptors/FilterMapping.php
===================================================================
--- trunk/prototype/modules/filters/interceptors/FilterMapping.php	(revision 5341)
+++ trunk/prototype/modules/filters/interceptors/FilterMapping.php	(revision 5539)
@@ -1,274 +1,485 @@
 <?php
-
+/**
+*
+* Copyright (C) 2011 ConsÃ³rcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
+*
+* This program is free software; you can redistribute it and/or modify it under
+* the terms of the GNU Affero General Public License version 3 as published by
+* the Free Software Foundation with the addition of the following permission
+* added to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED
+* WORK IN WHICH THE COPYRIGHT IS OWNED BY FUNAMBOL, FUNAMBOL DISCLAIMS THE
+* WARRANTY OF NON INFRINGEMENT  OF THIRD PARTY RIGHTS.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+* FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+* details.
+*
+* You should have received a copy of the GNU Affero General Public License
+* along with this program; if not, see www.gnu.org/licenses or write to
+* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+* MA 02110-1301 USA.
+*
+* This code is based on the OpenXchange Connector and on the Prognus pSync
+* Connector both developed by the community and licensed under the GPL
+* version 2 or above as published by the Free Software Foundation.
+*
+* You can contact Prognus Software Livre headquarters at Av. Tancredo Neves,
+* 6731, PTI, Bl. 05, Esp. 02, Sl. 10, Foz do IguaÃ§u - PR - Brasil or at
+* e-mail address prognus@prognus.com.br.
+*
+* DescriÃ§Ã£o rÃ¡pida do arquivo
+*
+* Arquivo responsÃ¡vel pela manipulaÃ§Ã£o dos filtros
+*
+* @package    filters
+* @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)
+* @version    1.0
+* @sponsor    Caixa EconÃŽmica Federal
+* @since      Arquivo disponibilizado na versÃ£o 2.4
+*/
+
+
+
+/**
+* Classe responsÃ¡vel pela manipulaÃ§Ã£o dos filtros.
+*
+*
+* @package    prototype
+* @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)
+* @author     Airton Bordin Junior
+* @author     Gustavo Pereira dos Santos
+* @version    1.0
+* @since      Classe disponibilizada na versÃ£o 2.4
+*/
 class FilterMapping
 {
-    public function formatSieveScript( $rules )
+	
+	var $service;
+	
+	
+	/**
+	* MÃ©todo que formata o Script de acordo com a sintaxe do Sieve.
+	*
+	* @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
+	* @author	  Gustavo Pereira dos Santos	
+	* @param      <Array> <$rules> <Array com as regras do usuÃ¡rio>
+	* @return     <Regra de acordo com a sintaxe do Sieve>
+	* @access     <public>
+	*/
+	public function formatSieveScript( $rules )
     {
-	$require_fileinto = $require_flag = $require_reject = $require_vacation = $require_body = $startswith = $endswith = false;
-
-	$script_rules = $script_header = "";
-
-	foreach( $rules as $name => $data )
+		$require_fileinto = $require_flag = $require_reject = $require_vacation = $require_body = $require_imapflag = $vacation = $startswith = $endswith = false;
+
+		$script_rules = $script_header = $script_criteria = "";
+		$i = 0;
+		foreach( $rules as $name => $data )
+		{
+			//if( $data['enabled'] )
+				//continue;
+
+			$criteria = $data['criteria'];
+			$action   = $data['actions'];
+			
+			($i >0) ? $script_match = 'els' : $script_match = '';
+			$data['isExact'] == 'false' ?  $script_match .= 'if anyof (' : $script_match .= 'if allof (';
+
+			for ($j=0; $j<count($criteria); $j++)
+			{					
+				switch($criteria[$j]['field']) {
+					case 'To':    
+					case 'to':    
+					case 'CC':
+					case 'Cc':
+						$criteria[$j]['field'] = "[\"To\", \"TO\", \"Cc\", \"CC\"]"; 
+						$script_criteria .= "address :";
+						break;
+					case 'from':
+						$criteria[$j]['field'] = "\"" . $criteria[$j]['field'] . "\"";
+						$script_criteria .= "address :";
+						break;
+					case 'size':	
+						$criteria[$j]['field'] = '';
+						$script_criteria .= "size :";
+						break;
+					case 'subject':
+						$criteria[$j]['field'] = "\"" . $criteria[$j]['field'] . "\"";
+						$criteria[$j]['value'] = "" . imap_8bit($criteria[$j]['value']) . "\", \"" . base64_encode($criteria[$j]['value']) . "";
+						$script_criteria .= "header :";
+						break;
+					case 'body':
+						$criteria[$j]['field'] = '';
+						$script_criteria .= "body :";
+						$require_body = true;
+						break;
+					case 'vacation':
+						$require_vacation = true;
+						$vacation = true;
+						$script_match = "vacation";
+						break;
+					default:
+						$script_criteria .= "header :";
+						break;
+				}
+				
+				switch ($criteria[$j]['operator']) {
+					case '>':
+						$criteria[$j]['operator'] = "over";
+						break;
+					case '<':
+						$criteria[$j]['operator'] = "under";
+						break;
+					case '=':
+						$criteria[$j]['operator'] = "is";
+						$criteria[$j]['value'] = "[\"" . $criteria[$j]['value'] . "\"]";
+						break;
+					case '*':
+						$criteria[$j]['operator'] = "contains";
+						$criteria[$j]['value'] = "[\"" . $criteria[$j]['value'] . "\"]";
+						break;						
+					case '^':
+						$criteria[$j]['operator'] = "matches";
+						$criteria[$j]['value'] = "[\"" . $criteria[$j]['value'] . "*\"]";
+						$startswith = true;
+						break;
+					case '$':
+						$criteria[$j]['operator'] = "matches";
+						$criteria[$j]['value'] = "[\"*" . $criteria[$j]['value'] . "\"]";
+						$endswith = true;
+						break;
+					/* 
+					   TO-DO:
+					   Arrrumar regra do "nÃ£o contÃ©m".
+					*/
+					case '!*':
+						$criteria[$j]['operator'] = "contains";
+						$criteria[$j]['value'] = "[\"" . $criteria[$j]['value'] . "\"]";
+						break;
+				}
+				
+				if ($criteria[$j]['field'] == "" || $criteria[$j]['field'] == "\"subject\"" || $startswith || $endswith)
+				{
+					$script_criteria .= $criteria[$j]['operator'] . " " . $criteria[$j]['field'] . " " . $criteria[$j]['value'] . ", "; 
+					$startswith = $endswith = false;
+				}
+				else
+					$script_criteria .= $criteria[$j]['operator'] . " " . $criteria[$j]['field'] . " " . $criteria[$j]['value'] . ", ";
+			}
+			$script_criteria = substr($script_criteria,0,-2);
+			if ($vacation == false) 
+				$script_criteria .= ")"; 
+			else 
+				$script_criteria = "";
+			$script_action = " {\r\n ";
+			for ($k=0; $k<count($action); $k++)
+			{
+				switch ($action[$k]['type']) {
+					case 'redirect':
+						break;
+					case 'reject':
+						$require_reject = true;
+						break;
+					case 'fileinto':
+						$require_fileinto = true;
+						break;
+					case 'vacation':
+						$require_vacation = true;
+						$action[$k]['parameter'] = "\"" . $action[$k]['parameter'] . "\"";
+						$script_action = " :subject \"Fora do EscritÃ³rio\" " . $action[$k]['parameter'] . ";";
+						$vacation = true;
+						break;
+					case 'setflag':
+						$require_flag = true;
+						$action[$k]['parameter'] = "\\\\" . $action[$k]['parameter'];
+						break;
+					case 'discard':
+						break;
+				}
+				if ($vacation == false) $script_action .= $action[$k]['type'] . " \"" . $action[$k]['parameter'] . "\";\r\n ";
+			}
+
+			if ($vacation == false) $script_action .= "}";
+
+			$script_rules .= $script_match . $script_criteria . $script_action . "\r\n";
+			$script_match = "";
+			$script_criteria = "";
+			$i++;
+		}
+
+		if($require_reject || $require_fileinto || $require_vacation || $require_body || $require_flag)
+		{
+			$script_header .= "require [";
+			$require_reject ? $script_header .= "\"reject\", " : ""; 
+			$require_fileinto ? $script_header .= "\"fileinto\", " : ""; 
+			$require_vacation? $script_header .= "\"vacation\", " : "";  
+			$require_flag ? $script_header .= "\"imapflags\", " : "";  
+			$require_body ? $script_header .= "\"body\", " : "";  /* tem que instalar as extensÃµes no Cyrus */
+			$script_header = substr($script_header,0,-2);
+			$script_header .= "];\r\n";
+		}
+
+		$json_data = json_encode($rules);
+		
+		$script_begin = "#Filtro gerado por Expresso Livre versÃ£o 2.4\r\n\r\n";
+
+		$content = $script_begin . $script_header . $script_rules . "\r\n\r\n#PseudoScript#" . "\r\n#" . $json_data;
+		
+		/* $content = "";  //fill script! */
+		return( $content );
+	}
+	
+
+	/**
+	* MÃ©todo que faz o parsing do Script Sieve, transformando em Array.
+	*
+	* @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
+	* @author	  Gustavo Pereira dos Santos	
+	* @param      <String> <$script> <Script Sieve com as regras do usuÃ¡rio>
+	* @return     <Regras do usuÃ¡rio em Array>
+	* @access     <public>
+	*/
+	public function parseSieveScript( $script )
 	{
-	    if( $data['enabled'] )
-		continue;
-
-	    $criteria = $data['criteria'];
-	    $action   = $data['actions'];
-	    $data['isExact'] ? $script_match = 'if allof (' : $script_match = 'if anyof (';
-
-	    for ($j=0; $j<count($criteria); $j++)
-	    {					
-		switch($criteria[$j]['field']) {
-		    case 'To':    /* Adicionar o TO e Cc tambÃ©m?! */
-		    case 'CC':
-			    $criteria[$j]['field'] = "[\"To\", \"TO\", \"Cc\", \"CC\"]"; 
-			    $script_criteria .= "address :";
-			    break;
-		    case 'size':	
-			    $criteria[$j]['field'] = '';
-			    $script_criteria .= "size :";
-			    break;
-		    case 'subject':
-			    $criteria[$j]['field'] = "\"" . $criteria[$j]['field'] . "\"";
-			    $criteria[$j]['value'] = "[\"" . imap_8bit($criteria[$j]['value']) . "\", \"" . base64_encode($criteria[$j]['value']) . "\"]";
-			    $script_criteria .= "header :";
-			    break;
-		    case 'body':
-			    $criteria[$j]['field'] = '';
-			    $criteria[$j]['value'] = "\"" . $criteria[$j]['value'] . "\"";
-			    $script_criteria .= "body :";
-			    $require_body = true;
-			    break;
-		    default:
-			    $criteria[$j]['field'] = "\"" . $criteria[$j]['field'] . "\"";
-			    $script_criteria .= "header :";
-			    break;
+		$pos = strripos($script, "#PseudoScript#");
+		$pseudo_script = substr( $script, $pos+17 );
+
+		$return = json_decode( $pseudo_script, true );
+
+		return $return;
+	}
+
+	var $rules = false;
+
+	/**
+	* Construtor da classe.
+	*
+	* @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
+	* @author	  Gustavo Pereira dos Santos	
+	* @access     <public>
+	*/
+	public function __construct()
+	{ 
+		$this->service = Controller::service("Sieve");
+	}
+
+	
+	/**
+	* MÃ©todo que recupera as regras do usuÃ¡rio.
+	*
+	* @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
+	* @author	  Gustavo Pereira dos Santos	
+	* @return     <Regras do usuÃ¡rio>
+	* @access     <public>
+	*/
+	public function getRules()
+	{
+		$this->rules = Controller::find( array( 'concept' => 'filter' ) );
+
+		if( !$this->rules ) {
+			$this->rules = array();
 		}
-		
-		switch ($criteria[$j]['operator']) {
-		    case '>':
-			    $criteria[$j]['operator'] = "over";
-			    break;
-		    case '<':
-			    $criteria[$j]['operator'] = "under";
-			    break;
-		    case '=':
-			    $criteria[$j]['operator'] = "is";
-			    break;
-		    case '*':
-			    $criteria[$j]['operator'] = "contains";
-			    break;						
-		    case '^':
-			    $criteria[$j]['operator'] = "matches";
-			    $criteria[$j]['value'] = "[\"" . $criteria[$j]['value'] . "*\"]";
-			    $startswith = true;
-			    break;
-		    case '$':
-			    $criteria[$j]['operator'] = "matches";
-			    $criteria[$j]['value'] = "[\"*" . $criteria[$j]['value'] . "*\"]";
-			    $endswith = true;
-			    break;
-		}
-		// if temporÃ¡rio, por favor! :D	
-		if ($criteria[$j]['field'] == "" || $criteria[$j]['field'] == "\"subject\"" || $startswith || $endswith)
-		{
-		    $script_criteria .= $criteria[$j]['operator'] . " " . $criteria[$j]['field'] . " " . $criteria[$j]['value'] . ", "; 
-		    $startswith = $endswith = false;
-		}
-		else
-		    $script_criteria .= $criteria[$j]['operator'] . " " . $criteria[$j]['field'] . " \"" . $criteria[$j]['value'] . "\", ";
-	    }
-	    $script_criteria = substr($script_criteria,0,-2);
-	    $script_criteria .= ")";
-	    $script_action = " {\r\n ";
-	    for ($k=0; $k<count($action); $k++)
-	    {
-		    switch ($action[$k]['type']) {
-			    case 'redirect':
-				    break;
-			    case 'reject':
-				    $require_reject = true;
-				    break;
-			    case 'fileinto':
-				    $require_fileinto = true;
-				    break;
-			    case 'vacation':
-				    $require_vacation = true;
-				    break;
-			    case 'setflag':
-				    $require_flag = true;
-				    break;
-			    case 'discard':
-				    break;
-		    }
-		    $script_action .= $action[$k]['type'] . " \"" . $action[$k]['parameter'] . "\";\r\n ";
-	    }
-
-	    $script_action .= "}";
-
-	    $script_rules .= $script_match . $script_criteria . $script_action . "\r\n";
-	}
-
-	// if temporÃ¡rio meu caro amigo
-	if($require_reject || $require_fileinto || $require_vacation || $require_body || $require_flag)
+		return( $this->rules );
+	}
+
+	
+	/**
+	* MÃ©todo que aplica o filtro para as mensagens do usuÃ¡rio.
+	*
+	* @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
+	* @author	  Gustavo Pereira dos Santos	
+	* @param      <$uri> 
+	* @param      <$result> 
+	* @param      <$criteria> 
+	* @param      <$original> 
+	* @access     <public>
+	*/
+	public function applySieveFilter( &$uri , &$result , &$criteria , $original  )
 	{
-		$script_header .= "require [";
-		$require_reject ? $script_header .= "\"reject\", " : ""; 
-		$require_fileinto ? $script_header .= "\"fileinto\", " : ""; 
-		$require_vacation? $script_header .= "\"vacation\", " : "";  
-		$require_flag ? $script_header .= "\"imapflags\", " : "";  
-		$require_body ? $script_header .= "\"body\", " : "";  /* tem que instalar o plugin no SIEVE */
-		$script_header = substr($script_header,0,-2);
-		$script_header .= "];\r\n";
-	}
-
-	$json_data = json_encode($rules);
-	
-	$script_begin = "#Filtro gerado por Expresso Livre versÃ£o 2.4 power\r\n\r\n";
-
-	$content = $script_begin . $script_header . $script_rules . "\r\n\r\n#PseudoScript#" . "\r\n#" . $json_data;
-
-	return( $content );
-    }
-   
-    public function parseSieveScript( $script )
-    {
-	$pos = strripos($script, "#PseudoScript#");
-	// Esse 17 hardcodificado Ã© temporÃ¡rio rapÃ¡! Ã o tamanho da palavra #PseudoScript## que vem antes do pseudoscript em si.
-	$pseudo_script = substr( $script, $pos+17 );
-
-	$return = json_decode( $pseudo_script, true );
-
-	return $return;
-
-// 		if( !$array_rules )
-// 		{
-// 		    require_once ROOTPATH.'/../expressoMail1_2/inc/class.ScriptS.inc.php';
-// 
-// 		    $rules = ScriptS::readScript( $script );
-// 
-// 		    foreach( $rules['rule'] as $i => $rule )
-// 		    {
-// 			$rule = ScriptS::parsePseudoScript( $rule );
-// 
-// 			ob_start();
-// 			print_r( var_export($rule) );
-// 			$output = ob_get_clean();
-// 			file_put_contents( '/tmp/2.log', file_get_contents( '/tmp/2.log' ) . $output );
-// 		    }
-// 	
-  }
-
-  var $rules = false;
-
-  public function __construct()
-  {
-      
-  }
-
-  public function getRules()
-  {
-      $this->rules = Controller::find( array( 'concept' => 'filter' ) );
-
-      if( !$this->rules ) 
-	  $this->rules = array();
-
-      return( $this->rules );
-  }
-
-  public function applySieveFilter( &$uri , &$result , &$criteria , $original , &$service ){
-     
-      if( $original['properties']['applyMessages'] )
-      {
-          $filter = Controller::read($uri);
-          
-          $proc = array();
-          $proc['keep'] = false;
-          
-          foreach ($filter['actions'] as $v){
-              if($v['type'] == 'keep')
-                  $proc['keep'] = true;
-              else{
-                  $proc['type'] = $v['type'];
-                  $proc['parameter'] = $v['parameter'];
-              }
-          }
-
-	  $imap = Controller::service( 'Imap' );
-          
-          $imap->apliSieveFilter($original['properties']['applyMessages'] , $proc );
-
-          return $result;
-      }
-  }
-
-  public function readUserScript( &$uri , &$params , &$criteria , $original, &$service )
-  {
-      $uri['id'] = $service->config['user'];
-  }
-
-  public function setRule( &$uri , &$params , &$criteria , $original , &$service )
-  {
-      if( !$this->rules )
-	  $this->rules = $this->getRules();
-
-      $params['id'] = $uri['id'];
-
+		 if( $original['properties']['applyMessages'] )
+		 {
+			  $filter = Controller::read($uri);
+			  
+			  $proc = array();
+			  $proc['keep'] = false;
+			  
+			  foreach ($filter['actions'] as $v){
+				  if($v['type'] == 'keep')
+					  $proc['keep'] = true;
+				  else{
+					  $proc['type'] = $v['type'];
+					  $proc['parameter'] = $v['parameter'];
+				  }
+			  }
+
+		  $imap = Controller::service( 'Imap' );
+			  $imap->apliSieveFilter($original['properties']['applyMessages'] , $proc ); 
+			  return $result;
+		  }
+	}
+
+	
+	/**
+	* MÃ©todo que lÃª o script do usuÃ¡rio.
+	*
+	* @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
+	* @author	  Gustavo Pereira dos Santos	
+	* @param      <$uri> 
+	* @param      <$result> 
+	* @param      <$criteria> 
+	* @param      <$original> 
+	* @return     <Script do usuÃ¡rio>
+	* @access     <public>
+	*/
+	public function readUserScript( &$uri , &$params , &$criteria , $original )
+	{  
+		$uri['id'] = $this->service->config['user'];
+	}
+  
+  
+	/**
+	* MÃ©todo que seta o script do usuÃ¡rio.
+	*
+	* @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
+	* @author	  Gustavo Pereira dos Santos	
+	* @param      <$uri> 
+	* @param      <$result> 
+	* @param      <$criteria> 
+	* @param      <$original> 
+	* @return     <Script do usuÃ¡rio>
+	* @access     <public>
+	*/
+	public function setRule( &$uri , &$params , &$criteria , $original  )
+	{		
+	  if( !$this->rules )
+		$this->rules = $this->getRules();
+	
+      $params['id'] = isset($params['id']) ? $params['id'] : $params['name'];
       $update = false;
 
       foreach( $this->rules as $i => $rule )
-	  if( $update = ($rule['id'] === $params['id']) )
-	  {
-	      $this->rules[$i] = $params;
-	      break;
-	  }
+		  if( $update = ($rule['id'] === $params['id']) )
+		  {
+			  $this->rules[$i] = $params;
+			  break;
+		  }
 
       if( !$update )
-	  $this->rules[] = $params;
+		$this->rules[] = $params;
 
       $content = $this->formatSieveScript( $this->rules );
-
-      $params = array( 'name' => $service->config['user'],
+	  
+	  $params = array( 'name' => $this->service->config['user'],
 		       'content' => $content,
                        'active' => true );
-  }
-
-  public function deleteRule( &$uri, &$params, &$criteria, $original, &$service )
-  {
-      if( !$this->rules )
-	  $this->rules = $this->getRules();
-
-      $params['id'] = $uri['id'];
-
-      $update = false;
-
-      foreach( $this->rules as $i => $rule )
-	  if( $rule['id'] === $uri['id'] )
-	      unset( $this->rules[$i] );
-
-      $uri['id'] = '';
-
-      $params = array( 'name' => $service->config['user'],
-		       'content' => $this->formatSieveScript( $this->rules ),
-		       'active' => true );
-
-      $URI = Controller::URI( $uri['concept'], $service->config['user'] );
-
-      $service->update( $URI, $params );
-  }
-
-  public function getSieveRule( &$uri , &$params , &$criteria , $original, &$service )
-  {
-      $script = $this->parseSieveScript( $params['content'] );
-
-      foreach( $script as $i => $rule )
-	  if( $rule['name'] === $original['id'] )
-	      return( $params = $rule );
-  }
-
-  public function listSieveRules( &$uri , &$params , &$criteria , $original , &$service )
-  {
-      return( $params = $this->parseSieveScript( $params[0]['content'] ) );
-  }
+	}
+
+	
+	/**
+	* MÃ©todo que deleta o script do usuÃ¡rio.
+	*
+	* @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
+	* @author	  Gustavo Pereira dos Santos	
+	* @param      <$uri> 
+	* @param      <$result> 
+	* @param      <$criteria> 
+	* @param      <$original> 
+	* @access     <public>
+	*/
+	public function deleteRule( &$uri, &$params, &$criteria, $original )
+	{
+		if( !$this->rules )
+		  $this->rules = $this->getRules();
+
+		$params['id'] = $uri['id'];
+
+		$update = false;
+
+		foreach( $this->rules as $i => $rule )
+			if( $rule['id'] === $uri['id'] )
+				unset( $this->rules[$i] );
+
+		$uri['id'] = '';
+
+		$params = array( 'name' => $this->service->config['user'],
+			   'content' => $this->formatSieveScript( $this->rules ),
+			   'active' => true );
+
+		$URI = Controller::URI( $uri['concept'], $this->service->config['user'] );
+		$this->service->update( $URI, $params );
+
+		return( false );
+	}
+
+	
+	/**
+	* MÃ©todo que pega o script do usuÃ¡rio.
+	*
+	* @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
+	* @author	  Gustavo Pereira dos Santos	
+	* @param      <$uri> 
+	* @param      <$result> 
+	* @param      <$criteria> 
+	* @param      <$original> 
+	* @return     <Script do usuÃ¡rio>
+	* @access     <public>
+	*/
+	public function getSieveRule( &$uri , &$params , &$criteria , $original )
+	{	  
+		$script = $this->parseSieveScript( $params['content'] );
+
+		foreach( $script as $i => $rule )
+			if( $rule['name'] === $original['id'] )
+				return( $params = $rule );
+	}
+
+	
+	/**
+	* MÃ©todo que lista as regras do usuÃ¡rio.
+	*
+	* @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
+	* @author	  Gustavo Pereira dos Santos	
+	* @param      <$uri> 
+	* @param      <$result> 
+	* @param      <$criteria> 
+	* @param      <$original> 
+	* @return     <Regras do usuÃ¡rio>
+	* @access     <public>
+	*/
+	public function listSieveRules( &$uri , &$params , &$criteria , $original  )
+	{		
+		$return = $params = $this->parseSieveScript( $params[0]['content'] ); 
+		return( $return );
+	}
 }
Index: trunk/prototype/modules/filters/filters.js
===================================================================
--- trunk/prototype/modules/filters/filters.js	(revision 5399)
+++ trunk/prototype/modules/filters/filters.js	(revision 5539)
@@ -60,5 +60,5 @@
 
     nameObj.val( filter.name );
-
+	nameObj.attr("disabled", "disabled");
     for( var i = 0; i < filter.criteria.length; i++ ){
 
@@ -69,12 +69,17 @@
     }
 
+	
     for( var i = 0; i < filter.actions.length; i++ ){
-
-	actions.filter( '[value="' + filter.actions[i].type + '"]' ).val( filter.actions[i].type )
-	.siblings( '[name="actionParameter[]"]' ).val( filter.actions[i].parameter );
-
+		actions.filter( '[value="' + filter.actions[i].type + '"]' ).attr("checked", "True");
+		actions.filter( '[value="' + filter.actions[i].type + '"]' ).val( filter.actions[i].type )
+		.siblings( '[name="actionParameter[]"]' ).val( filter.actions[i].parameter );
+		if(filter.actions[i].type == "redirect")
+			actions.siblings('[name="addressRedirect"]').val(filter.actions[i].parameter);
+		if(filter.actions[i].type == "reject")	
+			actions.siblings('[name="messageReject"]').val(filter.actions[i].parameter);
     }
   
-    isExact.val( filter.isExact ? "and" : "or" );
+    //isExact.val( filter.isExact != "false"? "and" : "or" );
+	isExact.filter('[value="'+(filter.isExact != "false"? "and" : "or")+'"]').attr("checked", "True");
 }
 
@@ -84,10 +89,9 @@
   
   decoder: function( form ){
-    
       if( form.vacation )
 	  return {
 
-		criteria: [{ value: "", operator: "*", field: "from" }],
-		actions: [{ parameter: form.vacation, type: "replyto" }],
+		criteria: [{ value: "vacation", operator: "", field: "vacation" }],
+		actions: [{ parameter: form.vacation, type: "vacation" }],
 		id: "vacation",
 		name: "vacation",
@@ -96,12 +100,10 @@
       }
 
-      return  {
-		id: form.name,
-		name: form.name,
+      var haha = {
+		//id: form.name,
+		name: form.name ? form.name : nameObj.val(),
 		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],
 				  operator: criteriaOperator,
@@ -110,19 +112,43 @@
 		}),
 		actions: $.map( form.actionType || [], function( type, i ){
-
+			var the_parameter = form.actionParameter[i];
+			
+			!the_parameter ? the_parameter = form.actionParameter[i+1] : "";
+			if (type == 'fileinto') { 
+				the_parameter = form.valueFileInto;
+			}
+			if (type == 'reject') {
+				the_parameter = form.messageReject;
+			}
+			if (type == 'fileintoInbox') { 
+				type = 'fileinto';
+				the_parameter = 'INBOX';
+			}
+			if (type == 'fileintoTrash') {
+				type = 'fileinto';
+				the_parameter = 'INBOX/Trash';
+			}
+			if (type == 'redirect') {
+				the_parameter = form.addressRedirect;
+			}
+			if (type == 'setflag') { 
+				the_parameter = form.valueSetFlag;
+			}
+			
 			return (!type) ? null:
-			      {parameter: form.actionParameter[i], type: type };
+			      {parameter: the_parameter, type: type };
 
 		}),
+		enabled : "enabled",
 		applyMessages: allMessages? !$.isEmptyObject( selectedMessages ) ?
-
-			       keys( selectedMessages ) : allMessages : ""
+		keys( selectedMessages ) : allMessages : ""
+		
       };
-
+	  return haha;
       //	'vacation' => ""
   },
   
   encoder: function( filters ){
-    
+	
 	var rules = [];
 
@@ -174,5 +200,5 @@
 
 });
-
+/*
 DataLayer.listen( "filter", function( status ){
  
@@ -180,5 +206,5 @@
 
 });
-
+*/
 
 
@@ -190,20 +216,18 @@
 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");
+	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"]' );
-  
+	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,
@@ -226,5 +250,4 @@
 	    autoOpen: false
     });
-    
     details_container.accordion({autoHeight: false});
     
@@ -260,5 +283,4 @@
 
     });
-    
     details_container.find( ".menu-container" )
 
@@ -399,5 +421,4 @@
 		  
     });
-    
     vacation_container.find( ".menu-container" )
 	.find(".button.back").click(function(event){
@@ -416,14 +437,16 @@
 		vacation_container.addClass('hidden');
 		return( false );
-	});    
+	}); 
 }
 
 var reraster = function( html ){
 
-  list_container.find( '.ui-widget' ).remove();
-
-  list_container.html( html ).find(".button").button();
-  
-  formatter();
+	//$(".rule-list-container").next().addClass("hidden");
+	
+	list_container.find( '.ui-widget' ).remove();
+
+	list_container.html( html ).find(".button").button();
+  
+	formatter();
 }
 
@@ -431,11 +454,10 @@
 
     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);
-	}
+		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 () {
@@ -511,5 +533,10 @@
     
 
-    .end().find( ".menu-control .button" )
+    .end().find( ".menu-control .button" ).filter(".update").button({
+		icons: {
+			primary: "ui-icon-pencil"
+		},
+		text: false
+	}).end()
 
 	.filter(".enable, .disable").click( function(event) {
@@ -573,5 +600,190 @@
 };
 
-DataLayer.render( BASE_PATH + 'modules/filters/filters.ejs', 'filter:detail', raster, true );
+//DataLayer.render(BASE_PATH + 'modules/filters/filters.ejs', {}, 'filter:detail', reraster, true);
+//var vamo_ver = DataLayer.render(BASE_PATH + 'modules/filters/filters.ejs', {});
+//raster(vamo_ver);
+var v = DataLayer.render( BASE_PATH + 'modules/filters/filters.ejs', {});
+raster(v);
+		details_container.accordion('activate',0);
+
+		showGridButton.removeClass('hidden');
+		grid.addClass('hidden').jqGrid('GridDestroy');
+	  
+		list_container.removeClass('hidden');
+		details_container.addClass('hidden');
+		
+DataLayer.render( BASE_PATH + 'modules/filters/filter-list.ejs', 'filter:detail', reraster );
+//var v = DataLayer.get("filter:detail");
 // ------------------------------------------------------------
-// ------------------------------------------------------------     
+// ------------------------------------------------------------    
+*/ 
+function list_filters(html){
+	if(html){
+		if( ! $(".filters-windows").length )
+			container = $('body.expressomail-module-container').append("<div class='filters-windows'></div>").find(".filters-windows").html( html ).find(".expresso-window-container");
+		list_container = $('body.expressomail-module-container').find(".rule-list-container");
+	}
+	list_container = $(".expresso-window-filters").dialog({
+	    width:700,
+	    modal: true,
+		resizable: false,
+	    closeOnEscape:true,
+	    close:function(event, ui) {
+		    event.stopPropagation();
+			if($(".cancel").length)
+				$(".cancel").trigger('click');
+		    //DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
+	    },
+		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,
+		buttons: [{
+			text : "Fechar",
+			click : function() {
+				$( this ).dialog( "close" );
+			}
+		}]
+    });
+	$(".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>");
+	$(".dialog-head-buttonpane").css("padding", "5px").
+	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();
+	
+	$(".ui-dialog-buttonpane.ui-widget-content").css("background-color", "#E0EEEE");
+	var zu = DataLayer.render( BASE_PATH + 'modules/filters/filter-list.ejs', DataLayer.get("filter:detail", true));
+//	DataLayer.render( BASE_PATH + 'modules/filters/filter-list.ejs', 'filter:detail',function(html){
+		list_container.html(zu).find(".button").button();
+		
+		list_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);
+			}
+		});
+		
+		$( ".menu-control .button" ).filter(".update").button({
+			icons: {
+				primary: "ui-icon-pencil"
+			},
+			text: false
+		}).click(function(){
+			var id = $(this).parents("li.rule").find('.title').html();
+			var filters = DataLayer.get( 'filter', true);
+			for(var i =0; i < filters.length; i++){
+				if(filters[i].id == id){
+					filters = filters[i];
+					break;
+				}	
+			}
+			
+			DataLayer.render( BASE_PATH + 'modules/filters/edit-filter.ejs', {},function(html){
+				var details_container = $(".expresso-window-filters").html(html);
+				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"]' );
+				showDetails(filters);
+				var accord = $(".rule-details-container").accordion({autoHeight: false});
+				$(".button").button().filter(".forth").click(function(){
+					accord.accordion('activate',1);
+				}).end().filter(".back").click(function(){
+					accord.accordion('activate',0);
+				}).end().filter(".cancel").click(function(){
+					DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
+				}).end().filter(".submit").click(function(){
+					if(nameObj)
+						nameObj.attr("disabled", "false");
+					$(this).submit();
+					DataLayer.commit( 'filter' );
+					DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
+				});
+			});
+		}).end()
+		.filter(".enable").button({
+			icons: {
+				primary: "ui-icon-circle-check"
+			},
+			text: false
+		}).click(function(){
+			var id = $(this).parents("li.rule").find('.title').html();
+			DataLayer.put( 'filter', id, { enabled: "disable"  });
+			DataLayer.commit("filter");
+			DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
+		}).end()
+
+		.filter(".disable").button({
+			icons: {
+				primary: "ui-icon-circle-close"
+			},
+			text: false
+		}).click(function(){
+			var id = $(this).parents("li.rule").find('.title').html();
+			DataLayer.put( 'filter', id, { enabled: "enabled" });
+			DataLayer.commit("filter");
+			DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
+		}).end()
+		
+		.filter(".close").button({
+			icons: {
+				primary: "ui-icon-close"
+			},
+			text: false
+		}).click(function(){
+			$(event.target)
+			.parents("li.rule").find('.title')
+			.each( function(){
+				DataLayer.remove( 'filter', $(this).html() );
+			});
+			DataLayer.commit("filter");
+			DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
+		}).end().removeClass("ui-button-icon-only");
+		
+		$(".button.add:first").click(function(){
+			$(".dialog-head-buttonpane").addClass("hidden");
+			DataLayer.render( BASE_PATH + 'modules/filters/edit-filter.ejs', {},function(html){
+				$(".expresso-window-filters").html(html);
+				var accord = $(".rule-details-container").accordion({autoHeight: false});
+				$(".button").button().filter(".forth").click(function(){
+					accord.accordion('activate',1);
+				}).end().filter(".back").click(function(){
+					accord.accordion('activate',0);
+				}).end().filter(".cancel").click(function(){
+					DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
+				}).end().filter(".submit").click(function(){
+					$(this).submit();
+					DataLayer.commit( 'filter' );
+					DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
+				});
+				//$(".rule-edit-container").html(html);
+			});	
+		});
+		$(".button.add.vacation").click(function(){
+			$(".dialog-head-buttonpane").addClass("hidden");
+			DataLayer.render( BASE_PATH + 'modules/filters/edit-filter.ejs', {},function(html){
+				$(".expresso-window-filters").html(html);
+				$(".vacation-details-container").removeClass("hidden");
+				$(".rule-details-container").addClass("hidden");
+				$(".button").button().filter(".back").click(function(){
+					DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
+				}).end().filter(".submit").click(function(){
+					$(this).submit();
+					DataLayer.commit( 'filter' );
+					DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
+				});
+				//$('[name="vacation"]').elastic().unbind('blur');
+				//$(".back").click(function(){
+				//$(".rule-edit-container").html(html);
+			});	
+		});
+//	});
+}
+
+DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
Index: trunk/prototype/modules/filters/init.ejs
===================================================================
--- trunk/prototype/modules/filters/init.ejs	(revision 5539)
+++ trunk/prototype/modules/filters/init.ejs	(revision 5539)
@@ -0,0 +1,7 @@
+<link rel="stylesheet" href="../prototype/modules/filters/filters.css" type="text/css" />
+
+<div class="expresso-window-filters expresso-window-container filter-manager-window" title="Filtros">
+	<div class="expresso-window-container filter-manager-window rule-list-container" title="Listagem"></div>
+	<div class="expresso-window-container filter-manager-window rule-edit-container" title="Regras de classificação de mensagem"></div>
+</div>
+
Index: trunk/prototype/modules/filters/edit-filter.ejs
===================================================================
--- trunk/prototype/modules/filters/edit-filter.ejs	(revision 5539)
+++ trunk/prototype/modules/filters/edit-filter.ejs	(revision 5539)
@@ -0,0 +1,162 @@
+<form action="filter:detail" method="POST">
+	<div class="rule-details-container">
+		<h3><a href="#">Critérios</a></h3>
+		<div>
+			<fieldset>
+				<label class="small">Nome da regra</label>
+				<input type="text" name="name" />
+			</fieldset>
+			<fieldset>
+				<label class="small">Remetente</label>
+				<select name="criteriaOperator[]">
+					<option value="=">é igual à</option>
+					<option value="*">contém a frase</option>
+					<option value="!*">não contém a frase</option>
+					<option value="^">começa com</option>
+					<option value="$">termina com</option>
+
+				</select>
+				<input type="text" name="criteriaValue[]" />
+				<input type="hidden" name="criteriaType[]" value="to"/>
+			</fieldset>
+			<fieldset>
+				<label class="small">Destinatário</label>
+				<select name="criteriaOperator[]">
+					<option value="=">é igual à</option>
+					<option value="*">contém a frase</option>
+					<option value="!*">não contém a frase</option>
+					<option value="^">começa com</option>
+					<option value="$">termina com</option>
+				</select>
+				<input type="text" name="criteriaValue[]" />
+				<input type="hidden" name="criteriaType[]" value="from"/>
+			</fieldset>
+			<fieldset>
+				<label class="small">Assunto</label>
+				<select name="criteriaOperator[]">
+					<option value="=">é igual à</option>
+					<option value="*">contém a frase</option>
+					<option value="!*">não contém a frase</option>
+					<option value="^">começa com</option>
+					<option value="$">termina com</option>
+
+				</select>
+				<input type="text" name="criteriaValue[]" />
+				<input type="hidden" name="criteriaType[]" value="subject"/>
+			</fieldset>
+			<fieldset>
+				<label class="small">Mensagem</label>
+				<select name="criteriaOperator[]">
+					<option value="=">é igual à</option>
+					<option value="*">contém a frase</option>
+					<option value="!*">não contém a frase</option>
+					<option value="^">começa com</option>
+					<option value="$">termina com</option>
+				</select>
+				<input type="text" name="criteriaValue[]" />
+				<input type="hidden" name="criteriaType[]" value="body"/>
+			</fieldset>
+			<fieldset>
+				<label class="small">Tamanho</label>
+				<select name="criteriaOperator[]">
+					<option value=">">é menor que</option>
+					<option value="<">é maior que</option>
+				</select>
+				<input type="text" name="criteriaValue[]" />
+				<input type="hidden" name="criteriaType[]" value="size"/>
+			</fieldset>
+			<!--
+			<fieldset>
+				<input type="checkbox" value="hasAttachment" name="hasAttachment" />
+				<label>A mensagem possui anexo</label>
+			</fieldset>
+			-->
+			<fieldset class="fields-isexact">
+				<fieldset>
+					<input type="radio" name="isExact" value="and"/>
+					<label>Atender a todos os critérios</label>
+				</fieldset>
+				<fieldset>
+					<input type="radio" name="isExact" value="or"/>
+					<label>Atender a qualquer um dos critérios</label>
+				</fieldset>
+			</fieldset>
+			<div class="menu-container">
+				<a class="button cancel" href="#">Cancelar</a>
+				<a class="button forth" href="#">Prosseguir &raquo;</a>
+			</div>
+		</div>
+		<h3><a href="#">Ações</a></h3>
+		<div>
+			<ul class="message-tip-container">
+				<li class="message-tip">Ações a serem executadas sobre as mensagens que atenderem aos critérios	especificados acima.</li>
+				<li class="message-tip">Estas ações serão aplicadas somente às novas mensagens que chegarem.</li>
+			</ul>
+			<fieldset class="select-folderlist">
+				<input type="radio" name="actionType[]" value="fileinto" />
+				<label>Arquivar na pasta</label>
+				<select name="valueFileInto">
+					<option value="INBOX">Caixa de entrada</option>
+					<option value="INBOX/Sent">Enviados</option>
+				</select>
+				<!-- <input type="text" name="actionParameter[]" /> --> 
+			</fieldset>
+			<fieldset>
+				<input type="radio" name="actionType[]" value="redirect" />
+				<label>Encaminhar para o endereço</label>
+				<input type="text" name="addressRedirect" />
+			</fieldset>
+			<fieldset>
+				<input type="radio" name="actionType[]" value="setflag" />
+				<label>Marcar como</label>
+				<select name="valueSetFlag">
+					<option value="flagged">Importante</option>
+					<option value="seen">Lida</option>
+				</select>
+				<!-- <input type="text" name="actionParameter[]" /> -->
+			</fieldset>
+			<fieldset>
+				<input type="radio" name="actionType[]" value="fileintoTrash" />
+				<label>Mover para a Lixeira</label>
+				<input type="hidden" name="actionParameter[]" value="Trash"/>
+			</fieldset>
+			<fieldset class="fields-replyto">
+				<input type="radio" name="actionType[]" value="reject"/>
+				<label>Responder com uma mensagem automaticamente</label>
+				<textarea name="messageReject"></textarea>
+			</fieldset>
+			<fieldset>
+				<input type="checkbox" name="actionType[]" value="fileintoInbox"/>
+				<label>Manter uma cópia na caixa de entrada</label>
+				<input type="hidden" name="actionParameter[]" value="INBOX"/>
+			</fieldset>
+			<!--
+			<fieldset class="fields-search-messages">
+				<label>Clique no botão "Buscar" para verificar se existem mensagens na sua Caixa de Entrada que 
+				atendem aos critérios especificados anteriormente.</label>
+				<span class="button search">Buscar na caixa de entrada</span>
+			</fieldset>
+			<table class="hidden fields-search-messages-grid" id="fields-search-messages-grid"><tr><td/></tr></table>
+			<div class="hidden fields-search-messages-grid-pager" id="fields-search-messages-grid-pager"></div>
+			-->
+			<div class="menu-container">	
+				<a class="button back"   href="#" >&laquo; Anterior</a>
+				<a class="button cancel" href="#">Cancelar</a>
+				<a class="button submit" href="#">Salvar</a>
+			</div>
+		</div>
+	</div>
+	<div class="vacation-details-container hidden">
+		<fieldset>
+			<label>Digite uma mensagem de resposta:</label>
+			<ul class="message-tip-container">
+				<li class="message-tip">Todas as mensagens serão respondidas automaticamente com a mensagem indicada.</li>
+			</ul>
+			<textarea class="filter-textarea" name="vacation"></textarea>
+		</fieldset>
+			<div class="menu-container">	
+			      <a class="button back"   href="#" title="Cancela e retorna á tela anterior">&laquo; Anterior</a>
+			      <a class="button submit" href="#" title="Salva e retorna á tela anterior">Salvar</a>
+			</div>
+	</div>
+</form>
Index: trunk/prototype/modules/filters/filter-list.ejs
===================================================================
--- trunk/prototype/modules/filters/filter-list.ejs	(revision 5341)
+++ trunk/prototype/modules/filters/filter-list.ejs	(revision 5539)
@@ -1,7 +1,7 @@
 <ul class="rule-list">
 <%
-	data.rules = data.rules || [];
+	data.rules = (data.rules || []);
+	for (var i=0; i<data.rules.length; i++) {
 
-	for (var i=0; i<data.rules.length; i++) {
 %>
 		<li class="rule <%= (data.rules[i].name=='vacation')?'vacation':'' %>" title="<%= data.rules[i].name %>">
@@ -20,5 +20,4 @@
 					</ul>
 				</dd>
-
 				<dt>AÃ§Ãµes:</dt>
 				<dd class="rule-briefing-action">
@@ -35,5 +34,5 @@
 			</dl>
 			<ul class="menu-control">
-				<li><a href="#<%= data.rules[i].name %>" class="button update" title="Alterar regra '<%= data.rules[i].name %>'">Alterar</a></li>
+				<li><a href="#<%= data.rules[i].name %>" class="button update" title="Alterar regra '<%= data.rules[i].name %>'"></a></li>
 				<li><a href="#<%= data.rules[i].name %>" class="button enable<%= (data.rules[i].enabled)? '': ' hidden' %>" title="Habilitar regra"></a></li>
 				<li><a href="#<%= data.rules[i].name %>" class="button disable<%= (data.rules[i].enabled)? ' hidden': '' %>" title="Desabilitar regra"></a></li>
@@ -46,12 +45,5 @@
 %>
 </ul>
-<ul class="message-tip-container no-saved hidden">
-	<li class="message-tip">VocÃª possui aÃ§Ãµes nÃ£o salvas. Para efetivÃ¡-las clique no botÃ£o "Concluir" abaixo.</li>
-</ul>
-<fieldset class="fields-add ui-corner-all">
-	<legend>Adicionar</legend>
-	<a href="#" class="button add" title="Adicionar nova regra">Nova regra</a>
-	<a href="#" class="button add vacation" title="Adicionar regra 'Fora do escritÃ³rio'">Fora do escritÃ³rio</a>
-</fieldset>
+<!--
 <fieldset class="fields-selected-itens ui-corner-all">
 	<legend>Selecionadas</legend>
@@ -60,2 +52,3 @@
 	<a href="#" class="button delete"  title="Excluir regras selecionadas">Excluir</a>
 </fieldset>
+-->
Index: trunk/prototype/api/datalayer.js
===================================================================
--- trunk/prototype/api/datalayer.js	(revision 5531)
+++ trunk/prototype/api/datalayer.js	(revision 5539)
@@ -89,5 +89,5 @@
     var $this = $(this), action = $this.attr('action'), res = false,
     
-    method = $this.attr( 'method' ),
+    method = $this.attr( 'method' ) || 'POST',
     
     fileInputs = $this.find('input[type="file"]');
Index: trunk/prototype/api/controller.php
===================================================================
--- trunk/prototype/api/controller.php	(revision 5514)
+++ trunk/prototype/api/controller.php	(revision 5539)
@@ -422,5 +422,5 @@
 		foreach( $interceptors[ $eventType ] as $intercept => $interceptor )
 		{
-		    $return = $interceptor->$intercept( $params['URI'], $params['properties'], $params['criteria'], $original/*, $params['service']*/ );
+		    $return = $interceptor->$intercept( $params['URI'], $params['properties'], $params['criteria'], $original /*, $params['service'] */);
 
 		    if( $return === false )
@@ -560,5 +560,5 @@
 		    $TX['rollback'] = !!!$params['properties'];
 
-		    if( $params['properties'] && isset($params['properties']['id']) )
+		    if( $params['properties'] && is_array($params['properties']) && isset($params['properties']['id']) )
 			$TX['id'] = $params['properties']['id'];
 
@@ -639,5 +639,5 @@
 		$result = Controller::call( $method, $URI, $data, false, false, true );
 
-		if( !is_bool( $result ) && !is_string( $result ) && isset( $result['id'] ) )
+		if( is_array( $result ) && isset( $result['id'] ) )
 		      $URI['id'] = $result['id'];
 
