Index: trunk/expressoMail1_2/setup/phpgw_en.lang
===================================================================
--- trunk/expressoMail1_2/setup/phpgw_en.lang	(revision 1622)
+++ trunk/expressoMail1_2/setup/phpgw_en.lang	(revision 1747)
@@ -82,4 +82,5 @@
 Do you want to block this e-mail?	expressoMail1_2	en	Do you want to block this e-mail?
 Do you want to log the sent messages?	admin	en	Do you want to log the sent messages?
+Do you want to show common name instead of UID?	expressoMail1_2	en	Do you want to show common name instead of UID?
 Do you want to use the spam filter?	admin	en	Do you want to use the spam filter?
 Do you wish to exclude the folder 	expressoMail1_2	en	Do you wish to exclude the folder 
Index: trunk/expressoMail1_2/inc/class.imap_functions.inc.php
===================================================================
--- trunk/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 1740)
+++ trunk/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 1747)
@@ -1499,5 +1499,5 @@
 				$result[$i]['folder_name'] = array_pop($tmp_folder_parent);
 				$result[$i]['folder_name'] = $result[$i]['folder_name'] == 'INBOX' ? 'Inbox' : $result[$i]['folder_name'];
-				if (substr($folder_id,0,4) == 'user' && is_numeric($result[$i]['folder_name']))	{
+				if ($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['uid2cn'] && substr($folder_id,0,4) == 'user')	{
 					//$this->ldap = new ldap_functions();
 					if ($cn = $this->ldap->uid2cn($result[$i]['folder_name'])){
@@ -2232,11 +2232,14 @@
         }
         //Este bloco tem a finalidade de transformar o CPF das pastas compartilhadas em common name
-        if (substr($new_folder_name,0,4) == 'user'){
-        	$this->ldap = new ldap_functions();
-        	$tmp_folder_name = explode($this->imap_delimiter, $new_folder_name);
-			$return['new_folder_name'] = array_pop($tmp_folder_name);
-			if (is_numeric($return['new_folder_name']))
-				if( $cn = $this->ldap->uid2cn($return['new_folder_name']))
-					$return['new_folder_name'] = $cn;
+        if ($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['uid2cn']){
+            if (substr($new_folder_name,0,4) == 'user'){
+                $this->ldap = new ldap_functions();
+                $tmp_folder_name = explode($this->imap_delimiter, $new_folder_name);
+                $return['new_folder_name'] = array_pop($tmp_folder_name);
+                if( $cn = $this->ldap->uid2cn($return['new_folder_name']))
+                {
+                    $return['new_folder_name'] = $cn;
+                }
+            }
         }
 
@@ -3085,7 +3088,7 @@
                     $filter = $this->remove_accents($filter);
                     //Este bloco tem a finalidade de transformar o login (quando numerico) das pastas compartilhadas em common name
-                    $folder_name = explode($this->imap_delimiter,$name_box);
-                    if (is_numeric($folder_name[1]))
+                    if ($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['uid2cn'] && substr($name_box,0,4) == 'user')
                     {
+                        $folder_name = explode($this->imap_delimiter,$name_box);
                         $this->ldap = new ldap_functions();
                         if ($cn = $this->ldap->uid2cn($folder_name[1]))
@@ -3093,6 +3096,10 @@
                             $folder_name[1] = $cn;
                         }
+                        $folder_name = implode($this->imap_delimiter,$folder_name);
                     }
-                    $folder_name = implode($this->imap_delimiter,$folder_name);
+                    else
+                    {
+                        $folder_name = mb_convert_encoding(utf8_decode($name_box), "UTF7-IMAP", "ISO_8859-1" );
+                    }
 
                     if(!is_resource($mbox_stream))
Index: trunk/expressoMail1_2/inc/hook_settings.inc.php
===================================================================
--- trunk/expressoMail1_2/inc/hook_settings.inc.php	(revision 1611)
+++ trunk/expressoMail1_2/inc/hook_settings.inc.php	(revision 1747)
@@ -61,4 +61,7 @@
 }');
 //}
+$default = false;
+create_check_box('Do you want to show common name instead of UID?','uid2cn',$default,
+	'Do you want to show common name instead of UID?');
 
 $default = array(
Index: trunk/expressoMail1_2/js/search.js
===================================================================
--- trunk/expressoMail1_2/js/search.js	(revision 1631)
+++ trunk/expressoMail1_2/js/search.js	(revision 1747)
@@ -482,4 +482,8 @@
 					
 					var td1  = get_lang(td1).substr(get_lang(td1).length-1) == "*"?td1:get_lang(td1);
+                                        if ((tmp = translatedFolders.get(td1)))
+                                        {
+                                            td1 = tmp;
+                                        }
 
 					if(proxy_mensagens.is_local_folder(td1)) {
Index: trunk/expressoMail1_2/js/local_messages.js
===================================================================
--- trunk/expressoMail1_2/js/local_messages.js	(revision 1666)
+++ trunk/expressoMail1_2/js/local_messages.js	(revision 1747)
@@ -779,5 +779,5 @@
 		}
 		sql += ") and (";
-		for (var z=0;z<friendly_filters.length-1;z++) {
+		for (var z=0;z<friendly_filters.length;z++) {
                     if (z != 0) {
                         if (sFilter.indexOf('ALL') != -1)
@@ -808,5 +808,5 @@
 		while(rs.isValidRow()) {
                     var header = connector.unserialize(rs.field(0));
-                    retorno+="##"+"local_"+rs.field(1)+"--"+"local_"+rs.field(1)+"--"+header["from"]["name"]+"--"+header["subject"]+"--"+header["udate"]+"--"+this.aux_convert_size(rs.field(3))+"--"+header["Unseen"]+header["Recent"]+header["Flagged"]+header["Draft"]+"--"+rs.field(2)+"##";
+                    retorno+="##"+"local_"+rs.field(1)+"--"+header["from"]["name"]+"--"+header["subject"]+"--"+header["udate"]+"--"+this.aux_convert_size(rs.field(3))+"--"+header["Unseen"]+header["Recent"]+header["Flagged"]+header["Draft"]+"--"+rs.field(2)+"##";
                     rs.next();
 		}
Index: trunk/expressoMail1_2/js/draw_api.js
===================================================================
--- trunk/expressoMail1_2/js/draw_api.js	(revision 1723)
+++ trunk/expressoMail1_2/js/draw_api.js	(revision 1747)
@@ -19,6 +19,42 @@
 var currentTab,numBox = 0; // Open Tab and num of mailboxes opened at context
 
+// Objeto Map, talvez o ideal fosse adicionar este objeto à Api do egroupware, e carregá-lo
+// aqui no expressoMail.
+function Map()
+{
+    this.keys = new Array();
+    this.values = new Array();
+}
+
+Map.prototype.add = function(key, value)
+{
+    this.keys.push(key);
+    this.values.push(value);
+}
+
+Map.prototype.get = function(key)
+{
+    result = new Array();
+    for (i = 0; i < this.keys.length; i++)
+    {
+        if (this.keys[i] == key)
+        {
+            result.push(this.values[i]);
+        }
+    }
+
+    if (result.length == 0)
+    {
+        return null;
+    }
+
+    return result;
+}
+
+var translatedFolders = new Map();
+
 function draw_tree_folders(folders){
 	// Check if the tree folders alredy exist.
+        translatedFolders = new Map();
 	if (Element('dftree_tree_folders')){
 		if (!expresso_offline) {
@@ -162,4 +198,9 @@
 					
 					if (!tree_folders.getNodeById('user')){
+                                                tmpFolderId = folders[i].folder_id.split(cyrus_delimiter).pop();
+                                                if (tmpFolderId != folders[i].folder_name)
+                                                {
+                                                    translatedFolders.add(tmpFolderId, folders[i].folder_name);
+                                                }
 						var n_root_shared_folders = new dNode({id:'user', caption:get_lang("Shared folders"), plusSign:true}); 
 						tree_folders.add(n_root_shared_folders,'root');
