Index: /sandbox/2.4.2-expresso2/prototype/modules/mail/js/foldertree.js
===================================================================
--- /sandbox/2.4.2-expresso2/prototype/modules/mail/js/foldertree.js	(revision 6875)
+++ /sandbox/2.4.2-expresso2/prototype/modules/mail/js/foldertree.js	(revision 6888)
@@ -318,6 +318,7 @@
 				if(shared.valid){
 					shared.head = folder_.parent().attr('id').split(cyrus_delimiter).length == 2 ?  true : false;
-					var teste = folder_.parent().attr('id').split(cyrus_delimiter);
-					var acls = shared_acls[teste[0]+cyrus_delimiter+teste[1]];
+					var folder_name_parts = folder_.parent().attr('id').split(cyrus_delimiter);
+					var acls = shared_acls[folder_name_parts[0]+cyrus_delimiter+folder_name_parts[1]];
+
 				}
 
@@ -353,5 +354,10 @@
 									type : "POST",
 									data : "current="+folder_id+"&rename="+new_name,
-									success : function(){
+									success : function(data){
+										data = connector.unserialize(data)[1];
+										if(data == "Permission denied"){
+											$(".folders-loading").removeClass("folders-loading");
+											return write_msg(get_lang("Permission denied"));
+										}
 										write_msg(get_lang("The folder was successfully rename"));
 										cExecute("$this.imap_functions.get_folders_list&onload=true", update_menu);
@@ -402,4 +408,7 @@
 											$(".folders-loading").removeClass("folders-loading");
 											return write_msg(get_lang("Mailbox does not exist"));
+										}else if(data.substring(data.indexOf("Permission"), data.length) == "Permission denied"){
+											$(".folders-loading").removeClass("folders-loading");
+											return write_msg(get_lang("Permission denied"));
 										}
 										write_msg(get_lang("The folder %1 was successfully removed", folder_name));
@@ -466,4 +475,20 @@
 						draw_new_tree_folder();
 					});
+				}).end().find(".float-menu-export").click(function(){
+					//proxy_mensagens.export_all_messages($(this).parents("li:first").attr("id"))
+
+					var name_box = $(this).parents("li:first").attr("id");
+					var name_folder = name_box.split(cyrus_delimiter)[name_box.split(cyrus_delimiter).length-1];
+
+					var hand_export = function(data){
+						if(!data){
+							write_msg(get_lang('Error compressing messages (ZIP). Contact the administrator.'))
+						}else if(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);	
+					write_msg(get_lang('You must wait while the messages will be exported...'));		
 				});
 				//FUNÇÃO DO eventNU FLUTUANTE NOVA PASTA < END
Index: /sandbox/2.4.2-expresso2/prototype/modules/mail/templates/float_folder_menu.ejs
===================================================================
--- /sandbox/2.4.2-expresso2/prototype/modules/mail/templates/float_folder_menu.ejs	(revision 6875)
+++ /sandbox/2.4.2-expresso2/prototype/modules/mail/templates/float_folder_menu.ejs	(revision 6888)
@@ -23,5 +23,7 @@
 		else if(data.name_folder == spamfolder){%>
 			<span class="ui-icon ui-icon-trash float-menu-clean floating-default" onclick="empty_spam_imap();" title="Limpar Pasta"></span>  
+			
 		<%}%>
+
 	<%}else{ %>
 	<%	if(parseInt(data.acl.create)){%>
@@ -35,4 +37,11 @@
 			<span class="ui-icon ui-icon-close float-menu-remove floating-default" title="Excluir Pasta"></span>
 		<%}%>
+		<%if(data.name_folder == trashfolder && parseInt(data.acl.delete)){%>
+			<span class="ui-icon ui-icon-trash float-menu-clean floating-default" onclick="empty_trash_imap(true, $(this));" title="Limpar Pasta"></span>  
+		<%}else if(data.name_folder == spamfolder && parseInt(data.acl.delete)){%>
+			<span class="ui-icon ui-icon-trash float-menu-clean floating-default" onclick="empty_spam_imap(true, $(this));" title="Limpar Pasta"></span>  
+		<%}%>
 	<%}%>
+
+	<span class="ui-icon ui-icon-arrowthickstop-1-n float-menu-export floating-default" title="Exportar Mensagens da Pasta"></span>  
  </span>
Index: /sandbox/2.4.2-expresso2/expressoMail1_2/inc/class.imap_functions.inc.php
===================================================================
--- /sandbox/2.4.2-expresso2/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 6846)
+++ /sandbox/2.4.2-expresso2/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 6888)
@@ -3903,7 +3903,8 @@
 	function empty_folder($params)
 	{
-		$folder = 'INBOX' . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server'][$params['clean_folder']];
+		$folder = (isset($params['shared']) ? $params['shared'] : 'INBOX') . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server'][$params['clean_folder']];
 		$mbox_stream = $this->open_mbox($folder);
 		$return = imap_delete($mbox_stream,'1:*');
+		$return = imap_errors();
 		if($mbox_stream)
 			imap_close($mbox_stream, CL_EXPUNGE);
Index: /sandbox/2.4.2-expresso2/expressoMail1_2/js/main.js
===================================================================
--- /sandbox/2.4.2-expresso2/expressoMail1_2/js/main.js	(revision 6875)
+++ /sandbox/2.4.2-expresso2/expressoMail1_2/js/main.js	(revision 6888)
@@ -3499,5 +3499,10 @@
 }
 
-function empty_trash_imap(){
+function empty_trash_imap(shared, button){
+	if(shared){
+		var folder_part = $(button).parents("li:first").attr("id").split(cyrus_delimiter);
+		var folder = folder_part[0]+cyrus_delimiter+folder_part[1];
+	}
+
 	var handler_empty_trash = function(data){
 		Element('chk_box_select_all_messages').checked = false;
@@ -3510,4 +3515,9 @@
 		draw_tree_labels();
 		if (data){
+			if(typeof(data) == "object"){
+				if(data[1] == "Permission denied"){
+					return write_msg(get_lang("Permission denied"));
+				}
+			}
 			write_msg(get_lang('Your Trash folder was empty.'));
 			if (get_current_folder() == mount_url_folder(["INBOX",special_folders["Trash"]])){
@@ -3529,5 +3539,5 @@
 		'onClose':  function(caption) {
 			if(caption == get_lang("Yes")){
-				cExecute ("$this.imap_functions.empty_folder&clean_folder="+"imapDefaultTrashFolder", handler_empty_trash);
+				cExecute ("$this.imap_functions.empty_folder&clean_folder="+"imapDefaultTrashFolder"+(shared ? "&shared="+folder : ""), handler_empty_trash);
 			}
 		}
@@ -3535,5 +3545,9 @@
 }
 
-function empty_spam_imap(){
+function empty_spam_imap(shared, button){
+	if(shared){
+		var folder_part = $(button).parents("li:first").attr("id").split(cyrus_delimiter);
+		var folder = folder_part[0]+cyrus_delimiter+folder_part[1];
+	}
 	var handler_empty_spam = function(data){
 		Element('chk_box_select_all_messages').checked = false;
@@ -3549,6 +3563,15 @@
 		draw_tree_labels();
 		update_quota(get_current_folder());
-		if (data)
-			write_msg(get_lang('Your Spam folder was empty.'));
+		if (data){
+			if(typeof(data) == "object"){
+				if(data[1] == "Permission denied"){
+					return write_msg(get_lang("Permission denied"));
+				}else{
+					write_msg(get_lang('Your Spam folder was empty.'));		
+				}
+			}else{
+				write_msg(get_lang('Your Spam folder was empty.'));	
+			}
+		}
 		else
 			write_msg(get_lang('ERROR emptying your Spam folder.'));
@@ -3562,5 +3585,5 @@
 		'onClose':  function(caption) {
 			if(caption == get_lang("Yes")){
-				cExecute ("$this.imap_functions.empty_folder&clean_folder="+"imapDefaultSpamFolder", handler_empty_spam);
+				cExecute ("$this.imap_functions.empty_folder&clean_folder="+"imapDefaultSpamFolder"+(shared ? "&shared="+folder : ""), handler_empty_spam);
 			}
 		}
@@ -4265,4 +4288,7 @@
 			if(data == "Mailbox already exists"){
 				write_msg(get_lang("Mailbox already exists"));
+			}else if(data.substring(data.indexOf("Permission"), data.length) == "Permission denied"){
+				$(".folders-loading").removeClass("folders-loading");
+				return write_msg(get_lang("Permission denied"));
 			}
 			cExecute("$this.imap_functions.get_folders_list&onload=true", update_menu);
