Index: trunk/expressoMail1_2/preferences.php
===================================================================
--- trunk/expressoMail1_2/preferences.php	(revision 325)
+++ trunk/expressoMail1_2/preferences.php	(revision 339)
@@ -204,6 +204,13 @@
 	$_SESSION['phpgw_info']['expressomail']['email_server'] = $boemailadmin->getProfile($emailadmin_profile[0]['profileID']);
 	$_SESSION['phpgw_info']['expressomail']['user'] = $GLOBALS['phpgw_info']['user'];
-	$imap = CreateObject('expressoMail1_2.imap_functions');	
-	$save_in_folder_selected = $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['save_in_folder'];
+	$e_server = $_SESSION['phpgw_info']['expressomail']['email_server'];
+ 	$imap = CreateObject('expressoMail1_2.imap_functions');	
+	$save_in_folder_selected = $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['save_in_folder'];	
+	// Load Special Folders (Sent, Trash, Draft, Spam) from EmailAdmin (if exists, else get_lang)
+	$specialFolders = array ("Trash" => lang("Trash"), "Drafts" => lang("Drafts"), "Spam" => lang("Spam"), "Sent" => lang("Sent"));	
+	foreach ($specialFolders as $key => $value){
+		if($e_server['imapDefault'.$key.'Folder'])
+			$specialFolders[$key] = $e_server['imapDefault'.$key.'Folder'];
+	}        
 	// First access on ExpressoMail, load default preferences...
 	if(!$GLOBALS['phpgw_info']['user']['preferences']['expressoMail']) {
@@ -213,17 +220,28 @@
 		$GLOBALS['phpgw']->template->set_var('checked_use_signature','checked');
 		$GLOBALS['phpgw']->template->set_var('checked_mainscreen_showmail','checked');
-		$save_in_folder_selected = "INBOX".$_SESSION['phpgw_info']['expressomail']['email_server']['imapDelimiter']."Sent";
-	}
-	$o_folders = "<option value='-1' ".(!$save_in_folder_selected ? 'selected' : '' ).">".lang("Select on send")."</option>";
+		$save_in_folder_selected = "INBOX".$e_server['imapDelimiter'].$specialFolders["Sent"];
+	}
+	$o_folders = "<option value='-1' ".(!$save_in_folder_selected ? 'selected' : '' ).">".lang("Select on send")."</option>";	
+	
 	foreach($imap -> get_folders_list() as $id => $folder){
-		$folder['folder_name'] = $folder['folder_name'] == ('Inbox') ? lang($folder['folder_name']) : $folder['folder_name'];
-		$folder['folder_name'] = $folder['folder_name'] == ('Trash') ? lang($folder['folder_name']) : $folder['folder_name'];
-		$folder['folder_name'] = $folder['folder_name'] == ('Drafts') ? lang($folder['folder_name']) : $folder['folder_name'];
-		$folder['folder_name'] = $folder['folder_name'] == ('Sent') ? lang($folder['folder_name']) : $folder['folder_name'];
-		$folder['folder_name'] = $folder['folder_name'] == ('Spam') ? lang($folder['folder_name']) : $folder['folder_name'];
-		$o_folders.= "<option value='".$folder['folder_id']."' ".($save_in_folder_selected == $folder['folder_id'] ? 'selected' : '' ).">".$folder['folder_name']."</option>";		
-	$GLOBALS['phpgw']->template->set_var('value_save_in_folder',$o_folders);	
-	}
-
+		// Ignores numeric indexes and shared folders....
+		if(!is_numeric($id) || (strstr($folder['folder_id'],"user".$e_server['imapDelimiter'])))
+			continue;
+		// Translate INBOX (root folder)
+		elseif (strtolower($folder['folder_name']) == "inbox") 
+			$folder['folder_name'] = lang("Inbox");
+		// Translate Special Folders
+ 		elseif (($keyFolder = array_search($folder['folder_name'], $specialFolders)) !== false)
+ 			$folder['folder_name'] = lang($keyFolder);
+		// Identation for subfolders
+		$folder_id = explode($e_server['imapDelimiter'],$folder['folder_id']);		
+		$level = count($folder_id);
+		$ident = '';
+		for($i = 2; $level > 2 && $i < $level;$i++)
+			$ident .= ' - ';
+		$o_folders.= "<option value='".$folder['folder_id']."' ".($save_in_folder_selected == $folder['folder_id'] ? 'selected' : '' ).">".$ident.$folder['folder_name']."</option>";			
+	}
+
+	$GLOBALS['phpgw']->template->set_var('value_save_in_folder',$o_folders);
 	$GLOBALS['phpgw']->template->set_var('lang_save',lang('Save'));
 	$GLOBALS['phpgw']->template->set_var('lang_cancel',lang('Cancel'));
