Index: /sandbox/2.5.0-expresso1/prototype/modules/mail/js/foldertree.js
===================================================================
--- /sandbox/2.5.0-expresso1/prototype/modules/mail/js/foldertree.js	(revision 7220)
+++ /sandbox/2.5.0-expresso1/prototype/modules/mail/js/foldertree.js	(revision 7261)
@@ -566,4 +566,6 @@
 
                     var name_box = $(this).parents("li:first").attr("id");
+
+
                     var name_folder = name_box.split(cyrus_delimiter)[name_box.split(cyrus_delimiter).length-1];
 
@@ -571,10 +573,41 @@
                         if(!data){
                             write_msg(get_lang('Error compressing messages (ZIP). Contact the administrator.'))
-                        }else if(data["empty_folder"]){
+                        }else if(data["empty_folder"] || data == "empty_folder"){
                             write_msg(get_lang("The selected folder is empty."));
                         }else
                           download_attachments(null, null, data, null,null, name_folder +'.zip');
                     }
-                    cExecute("$this.exporteml.export_all",hand_export,"folder="+name_box);  
+                    if($(this).parents("li:first").find("input[type=hidden]:first").val() == "localFolder"){                        
+                          expresso_mail_archive.listMessages(name_box.split("_")[2]);
+                          var msgsArchive = expresso_mail_archive.messageslisted;
+                        
+                          var array = new Array();
+
+                          for(var i =0; i < msgsArchive.length; i++){
+                            eachMsg = {
+                                    'ContentType' : msgsArchive[i].ContentType,
+                                    'from' : { 'email' : msgsArchive[i].from.email, 'full' : msgsArchive[i].from.full, 'name' : msgsArchive[i].from.name},
+                                    'msg_sample' : msgsArchive[i].msg_sample,
+                                    'subject' : msgsArchive[i].subject,
+                                    'to' : { 'email' : msgsArchive[i].to.email, 'full' : msgsArchive[i].to.full, 'name' : msgsArchive[i].to.name},
+                                    'toaddress2' : msgsArchive[i].toaddress2,
+                                    'msg_number' : msgsArchive[i].msg_number,
+                                    'date' : new Date(msgsArchive[i].timestamp).toString()  
+                            };
+                            array.push(eachMsg);
+
+                          }
+
+                            $.ajax({
+                              type: "POST",
+                              url: "controller.php?action=$this.exporteml.export_all_byLocalFolder",
+                              data: { folder: name_box, type: "msg_local", messages : array}
+                              }).done(function(msg) {
+                                hand_export(msg.split('"')[1]);
+                              });
+                    } else {
+                        alert(1);
+                          cExecute("$this.exporteml.export_all",hand_export,"folder="+name_box);  
+                    }
                     write_msg(get_lang('You must wait while the messages will be exported...'));        
                 });
Index: /sandbox/2.5.0-expresso1/expressoMail1_2/inc/class.exporteml.inc.php
===================================================================
--- /sandbox/2.5.0-expresso1/expressoMail1_2/inc/class.exporteml.inc.php	(revision 7157)
+++ /sandbox/2.5.0-expresso1/expressoMail1_2/inc/class.exporteml.inc.php	(revision 7261)
@@ -56,4 +56,19 @@
 	// Rommel Cysne (rommel.cysne@serpro.gov.br)
 	// em 17/12/2008.
+
+    function createFileEml_by_localFolder($sEMLData, $tempDir, $file){ 
+
+        $file = "{$file}.eml";
+
+        $f = fopen($tempDir.'/'.$file,"w");
+        if(!$f)
+            return False;
+
+        fputs($f,$sEMLData);
+        fclose($f);
+        
+        return $file;
+    }
+
 	function createFileEml($sEMLData, $tempDir, $id, $subject=false, $i=false)
     {
@@ -67,5 +82,5 @@
  
 			//$subject = preg_replace('/\//', '\'', $subject);
-			$from = "áàâãäéèêëíìîïóòôõöúùûüç?\"!@#$%š&*()-=+Ž`[]{}~^,<>;:/?\\|¹²³£¢¬§ªº° .ÁÀÂÃÄÉÈÊËÍÌÎÏÓÒÔÕÖÚÙÛÜÇ";
+			$from = "Ã¡Ã Ã¢Ã£Ã€Ã©ÃšÃªÃ«Ã­Ã¬Ã®Ã¯Ã³Ã²ÃŽÃµÃ¶ÃºÃ¹Ã»ÃŒÃ§?\"!@#$%Âš&*()-=+ÂŽ`[]{}~^,<>;:/?\\|Â¹Â²Â³Â£Â¢Â¬Â§ÂªÂºÂ° .ÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃ";
 			$to =   "aaaaaeeeeiiiiooooouuuuc______________________________________________AAAAAEEEEIIIIOOOOOUUUUC";
 			$subject = strtr($subject,$from,$to);
@@ -78,5 +93,5 @@
 
 			if($subject && $i){
-				$from = "áàâãäéèêëíìîïóòôõöúùûüç?\"!@#$%š&*()-=+Ž`[]{}~^,<>;:/?\\|¹²³£¢¬§ªº° .ÁÀÂÃÄÉÈÊËÍÌÎÏÓÒÔÕÖÚÙÛÜÇ";
+				$from = "Ã¡Ã Ã¢Ã£Ã€Ã©ÃšÃªÃ«Ã­Ã¬Ã®Ã¯Ã³Ã²ÃŽÃµÃ¶ÃºÃ¹Ã»ÃŒÃ§?\"!@#$%Âš&*()-=+ÂŽ`[]{}~^,<>;:/?\\|Â¹Â²Â³Â£Â¢Â¬Â§ÂªÂºÂ° .ÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃ";
 				$to =   "aaaaaeeeeiiiiooooouuuuc______________________________________________AAAAAEEEEIIIIOOOOOUUUUC";
 				$subject = strtr($subject,$from,$to);
@@ -84,5 +99,5 @@
 				$subject = preg_replace('/[^a-zA-Z0-9_]/i', '_', $subject); 
 
-				// é necessário que a sessão faça parte do nome do arquivo para que o mesmo não venha vazio o.O 
+				// Ã© necessÃ¡rio que a sessÃ£o faÃ§a parte do nome do arquivo para que o mesmo nÃ£o venha vazio o.O 
 				$file = $subject."_".$i."_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].".eml";  
 			} else{
@@ -101,7 +116,7 @@
     } 
 
-	function createFileZip($files, $tempDir){		
+	function createFileZip($files, $tempDir){	
+
 		$tmp_zip_filename = "email_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].".zip";
-		
                 if (!empty($files))
                 {
@@ -119,6 +134,9 @@
                     }
                 }
-                
-		$command = "cd " . escapeshellarg($tempDir) . " && nice zip -m9 " . escapeshellarg($tmp_zip_filename) . " " .  $files;
+
+
+$command = "cd " . escapeshellarg($tempDir) . " && nice zip -m9 " . escapeshellarg($tmp_zip_filename) . " " .  $files;
+
+
 		if(!exec($command)) {
 			$command = "cd " .  escapeshellarg($tempDir) . " && rm ".$files." ". escapeshellarg($tmp_zip_filename);
@@ -126,11 +144,63 @@
 			return null;
 		}
-		
+
 		return $tmp_zip_filename;
 				
 	}
 
-	function export_all($params){
-		
+function export_all_byLocalFolder($params){
+        $error = false;
+
+        if(empty($params['messages'])){
+            $file["empty_folder"] = true;
+        } else {
+            foreach($params['messages'] as $eachMsg){
+               $header = "";
+               $body = "";
+               $tempDir = $this->tempDir;
+
+               $this->get_header_byLocalFolder($eachMsg, $header);
+               $this->get_body_byLocalFolder($eachMsg, $body);
+               $sEMLData    = $this->parseEml($header, $body);
+               $fileName   = $this->createFileEml_by_localFolder($sEMLData, $tempDir,$eachMsg['msg_number']);
+
+               if(!$fileName){
+                   $error = true;
+                   break;
+               } else 
+                   $fileNames .= "\"".$fileName."\" ";
+            }
+
+            $nameFileZip = 'False';         
+            if($fileNames && !$error) {         
+                $nameFileZip = $this->createFileZip($fileNames, $tempDir);
+                ($nameFileZip) ? ($file = $tempDir.'/'.$nameFileZip) : ($file = false);
+            } else 
+                $file = false;
+        }
+       
+       return $file;
+
+}
+
+function get_header_byLocalFolder($eachMsg, &$header){
+    $header = <<<header
+        MIME-Version: 1.0
+        Content-Type: text/html; charset=ISO-8859-1
+        Content-Transfer-Encoding: quoted-printable
+        From: "{$eachMsg['from']['name']}" <{$eachMsg['from']['email']}>
+        To: {$eachMsg['to']['email']}
+        Subject: {$eachMsg['subject']}
+        Message-Id: {$eachMsg['msg_number']}
+        Date: {$eachMsg['date']}
+header;
+}
+
+function get_body_byLocalFolder($eachMsg, &$body){
+    $body = $eachMsg['msg_sample']['body'];
+}
+
+function export_all($params){
+
 		$this->folder = $params['folder'];
 		$this->folder = mb_convert_encoding($this->folder, "UTF7-IMAP","UTF-8");
@@ -140,8 +210,11 @@
 		
 		$msgs = imap_search($this->mbox_stream,"ALL",SE_UID);
+
 		if($msgs){
 			foreach($msgs as $nMsgs){
-				$header	 	= $this-> getHeader($nMsgs);									
-				$body		= $this-> getBody($nMsgs);			
+
+				$header	 	= $this-> getHeader($nMsgs);								 
+				$body		= $this-> getBody($nMsgs);		
+
 				$sEMLData 	= $this -> parseEml($header, $body);
 				$fileName 	= $this -> CreateFileEml($sEMLData, $tempDir,$nMsgs);
@@ -182,5 +255,5 @@
 	// Funcao alterada para que, quando houver  
 	// apenas um arquivo a ser exportado, 
-	// não seja criado em zip 
+	// nÃ£o seja criado em zip 
 	//
 	// Funcao altarada para exportar uma ou
@@ -481,5 +554,5 @@
 	
 	/* Airton
-	 * Fazendo o port de um método necessário para o funcionamento do arquivamento local
+	 * Fazendo o port de um mÃ©todo necessÃ¡rio para o funcionamento do arquivamento local
 	 */
 	//MAILARCHIVER 
@@ -509,5 +582,5 @@
 	} 
 	/*Airton 
-	 * Fim do método portado
+	 * Fim do mÃ©todo portado
 	 */ 
 	
@@ -553,10 +626,10 @@
 	function remove_accents($string) {
 		/*
-			$array1 = array("á", "à", "â", "ã", "ä", "é", "è", "ê", "ë", "í", "ì", "î", "ï", "ó", "ò", "ô", "õ", "ö", "ú", "ù", "û", "ü", "ç" , "?", "\"", "!", "@", "#", "$", "%", "š", "&", "*", "(", ")", "-", "=", "+", "Ž", "`", "[", "]", "{", "}", "~", "^", ",", "<", ">", ";", ":", "/", "?", "\\", "|", "¹", "²", "³", "£", "¢", "¬", "§", "ª", "º", "°", "Á", "À", "Â", "Ã", "Ä", "É", "È", "Ê", "Ë", "Í", "Ì", "Î", "Ï", "Ó", "Ò", "Ô", "Õ", "Ö", "Ú", "Ù", "Û", "Ü", "Ç");
+			$array1 = array("Ã¡", "Ã ", "Ã¢", "Ã£", "Ã€", "Ã©", "Ãš", "Ãª", "Ã«", "Ã­", "Ã¬", "Ã®", "Ã¯", "Ã³", "Ã²", "ÃŽ", "Ãµ", "Ã¶", "Ãº", "Ã¹", "Ã»", "ÃŒ", "Ã§" , "?", "\"", "!", "@", "#", "$", "%", "Âš", "&", "*", "(", ")", "-", "=", "+", "ÂŽ", "`", "[", "]", "{", "}", "~", "^", ",", "<", ">", ";", ":", "/", "?", "\\", "|", "Â¹", "Â²", "Â³", "Â£", "Â¢", "Â¬", "Â§", "Âª", "Âº", "Â°", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã");
 			$array2 = array("a", "a", "a", "a", "a", "e", "e", "e", "e", "i", "i", "i", "i", "o", "o", "o", "o", "o", "u", "u", "u", "u", "c" , "" , ""  , "" , "" , "" , "" , "" , "" , "" , "" , "" , "" , "" , "" , "" , "" , "" , "" , "" , "" , "" , "" , "" , "" , "" ,  "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "A", "A", "A", "A", "A", "E", "E", "E", "E", "I", "I", "I", "I", "O", "O", "O", "O", "O", "U", "U", "U", "U", "C");
 		  	return str_replace( $array1, $array2, $string );
 		*/
 		return strtr($string,
-			"áàâãäéèêëíìîïóòôõöúùûüç?\"'!@#$%š&*()-=+Ž`[]{}~^,<>;:/?\\|¹²³£¢¬§ªº°ÁÀÂÃÄÉÈÊËÍÌÎÏÓÒÔÕÖÚÙÛÜÇ",
+			"Ã¡Ã Ã¢Ã£Ã€Ã©ÃšÃªÃ«Ã­Ã¬Ã®Ã¯Ã³Ã²ÃŽÃµÃ¶ÃºÃ¹Ã»ÃŒÃ§?\"'!@#$%Âš&*()-=+ÂŽ`[]{}~^,<>;:/?\\|Â¹Â²Â³Â£Â¢Â¬Â§ÂªÂºÂ°ÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃ",
 			"aaaaaeeeeiiiiooooouuuuc___________________________________________AAAAAEEEEIIIIOOOOOUUUUC");
         }
Index: /sandbox/2.5.0-expresso1/expressoMail1_2/js/mail_archiver.js
===================================================================
--- /sandbox/2.5.0-expresso1/expressoMail1_2/js/mail_archiver.js	(revision 7248)
+++ /sandbox/2.5.0-expresso1/expressoMail1_2/js/mail_archiver.js	(revision 7261)
@@ -1391,10 +1391,15 @@
 //ONLINE messages_proxy.prototype.messages_list = function(folder,msg_range_begin,emails_per_page,sort_box_type,search_box_type,sort_box_reverse,preview_msg_subject,preview_msg_tip,call_back,tree_name) {
 //sys call = proxy_mensagens.messages_list(current_folder,1,preferences.max_email_per_page,sort,search,sort_box_reverse,preferences.preview_msg_subject,preferences.preview_msg_tip,handler_draw_box);
-MailArchiver.prototype.listMessages = function(){
+MailArchiver.prototype.listMessages = function(folderId){
     try{
         connector.showProgressBar();
         var getcurrent = get_current_folder();       
         //tree_folders.getNodeById(get_current_folder())._select();
-        var folderid = this.currentfolder; //getcurrent.substr(6,getcurrent.length);
+        var folderid;
+        if(typeof(folderId) != "undefined"){
+            folderid = folderId;
+        } else {
+            folderid = this.currentfolder;    
+        }
         var objfolder = new Object();
         objfolder.folder = folderid;        
