Index: trunk/expressoAdmin1_2/inc/class.imap_functions.inc.php
===================================================================
--- trunk/expressoAdmin1_2/inc/class.imap_functions.inc.php	(revision 396)
+++ trunk/expressoAdmin1_2/inc/class.imap_functions.inc.php	(revision 414)
@@ -12,4 +12,8 @@
 	var $imap_server;
 	var $imap_port;
+    var $imap_trashfolder;
+    var $imap_sentfolder;
+    var $imap_draftsfolder;
+    var $imap_spamfolder;
 	
 	function imap_functions(){
@@ -18,4 +22,8 @@
 		$this->imap_server	= $_SESSION['phpgw_info']['expresso']['email_server']['imapServer'];
 		$this->imap_port	= $_SESSION['phpgw_info']['expresso']['email_server']['imapPort'];
+		$this->imap_trashfolder		= $_SESSION['phpgw_info']['expresso']['email_server']['imapDefaultTrashFolder'];
+		$this->imap_sentfolder		= $_SESSION['phpgw_info']['expresso']['email_server']['imapDefaultSentFolder'];
+		$this->imap_draftsfolder	= $_SESSION['phpgw_info']['expresso']['email_server']['imapDefaultDraftsFolder'];
+		$this->imap_spamfolder		= $_SESSION['phpgw_info']['expresso']['email_server']['imapDefaultSpamFolder'];
 		$this->imapDelimiter= $_SESSION['phpgw_info']['expresso']['email_server']['imapDelimiter'];
 		$this->imap 		= imap_open('{'.$this->imap_server.':'.$this->imap_port.'/novalidate-cert}', $this->imap_admin, $this->imap_passwd, OP_HALFOPEN);
@@ -28,34 +36,52 @@
 		{
 			$error = imap_errors();
-			$result['status'] = false;
-			$result['msg'] = 'Erro na funcao imap_function->create(INBOX): ' . $error[0];
-			return $result;
-		}
-		if (!imap_createmailbox($this->imap, '{'.$this->imap_server.'}' . "user" . $this->imapDelimiter . $uid . $this->imapDelimiter . "Enviados"))
-		{
-			$error = imap_errors();
-			$result['status'] = false;
-			$result['msg'] = 'Erro na funcao imap_function->create(Enviados): ' . $error[0];
-			return $result;
-		}
-		if (!imap_createmailbox($this->imap, '{'.$this->imap_server.'}' . "user" . $this->imapDelimiter . $uid . $this->imapDelimiter . "Rascunhos"))
-		{
-			$error = imap_errors();
-			$result['status'] = false;
-			$result['msg'] = 'Erro na funcao imap_function->create(Rascunho): ' . $error[0];
-			return $result;
-		}
-		if (!imap_createmailbox($this->imap, '{'.$this->imap_server.'}' . "user" . $this->imapDelimiter . $uid . $this->imapDelimiter . "Lixeira"))
-		{
-			$error = imap_errors();
-			$result['status'] = false;
-			$result['msg'] = 'Erro na funcao imap_function->create(Lixeira): ' . $error[0];
-			return $result;
-		}
+			if ($error[0] == 'Mailbox already exists')
+			{
+				$result['status'] = true;
+			}
+			else
+			{
+				$result['status'] = false;
+				$result['msg'] = $this->functions->lang('Error on function') . " imap_functions->create(INBOX) ($uid):" . $error[0];
+			}
+			return $result;
+		}
+		if ( (!empty($this->imap_sentfolder)) && (!imap_createmailbox($this->imap, '{'.$this->imap_server.'}' . "user" . $this->imapDelimiter . $uid . $this->imapDelimiter . $this->imap_sentfolder)) )
+		{
+			$error = imap_errors();
+			$result['status'] = false;
+			$result['msg'] = $this->functions->lang('Error on function') . " imap_functions->create(".$this->imap_sentfolder."):" . $error[0];
+			return $result;
+		}
+		if ( (!empty($this->imap_draftsfolder)) && (!imap_createmailbox($this->imap, '{'.$this->imap_server.'}' . "user" . $this->imapDelimiter . $uid . $this->imapDelimiter . $this->imap_draftsfolder)) )
+		{
+			$error = imap_errors();
+			$result['status'] = false;
+			$result['msg'] = $this->functions->lang('Error on function') . " imap_functions->create(".$this->imap_draftsfolder."):" . $error[0];
+			return $result;
+		}
+		if ( (!empty($this->imap_trashfolder)) && (!imap_createmailbox($this->imap, '{'.$this->imap_server.'}' . "user" . $this->imapDelimiter . $uid . $this->imapDelimiter . $this->imap_trashfolder)) )
+		{
+			$error = imap_errors();
+			$result['status'] = false;
+			$result['msg'] = $this->functions->lang('Error on function') . " imap_functions->create(".$this->imap_trashfolder."):" . $error[0];
+			return $result;
+		}
+		if (!empty($this->imap_sentfolder))
+		{
+		    if (!imap_createmailbox($this->imap, '{'.$this->imap_server.'}' . "user" . $this->imapDelimiter . $uid . $this->imapDelimiter . $this->imap_spamfolder))
+			{
+			    $error = imap_errors();
+			    $result['status'] = false;
+			    $result['msg'] = $this->functions->lang('Error on function') . " imap_functions->create(".$this->imap_spamfolder."):" . $error[0];
+			    return $result;
+			}
+		}
+
 		if (!imap_set_quota($this->imap,"user" . $this->imapDelimiter . $uid, ($mailquota*1024))) 
 		{
 			$error = imap_errors();
 			$result['status'] = false;
-			$result['msg'] = 'Erro na funcao imap_function->create(set_quota): ' . $error[0];
+			$result['msg'] = $this->functions->lang('Error on function') . " imap_functions->create(imap_set_quota):" . $error[0];
 			return $result;
 		}
@@ -100,5 +126,5 @@
 		{
 			$result['status'] = false;
-			$result['msg'] = "Erro na funcao imap_function->delete_user.\nRetorno do servidor: " . imap_last_error();
+			$result['msg'] = $this->functions->lang('Error on function') . " imap_functions->delete_user.\n" . $this->functions->lang('Server returns') . ': ' . imap_last_error();
 		}
 		
@@ -122,5 +148,5 @@
 		{
 			$result['status'] = false;
-			$result['msg'] = "Erro na funcao imap_function->rename_mailbox.\nRetorno do servidor: " . imap_last_error();
+			$result['msg'] = $this->functions->lang('Error on function') . " imap_functions->rename_mailbox.\n" . $this->functions->lang('Server returns') . ': ' . imap_last_error();
 		}
 		else
@@ -138,5 +164,5 @@
 		{
 			$result['status'] = false;
-			$result['msg'] = 'Você não tem acesso para executar esta operação.';
+			$result['msg'] = $this->functions->lang('You do not have access to clean an user inbox');
 			return $result;
 		}
@@ -159,5 +185,4 @@
 		if ($return_setacl)
 		{
-			//$mbox_stream = imap_open('{'.$this->imap_server.':'.$this->imap_port.$imap_options.'/user="'.$uid.'"}', $this->imap_admin, $this->imap_passwd);
 			$mbox_stream = imap_open('{'.$this->imap_server.':'.$this->imap_port.$imap_options .'}user'. $this->imapDelimiter . $uid, $this->imap_admin, $this->imap_passwd);
 			
@@ -180,11 +205,11 @@
 			{
 				$result['status'] = false;
-				$result['msg'] = "Nao foi possivel esvaziar a caixa postal do usuario:\n" . imap_last_error();
-			}
-		}
-		else
-		{
-			$result['status'] = false;
-			$result['msg'] = "Nao foi possivel modificar a acl do usuario:\n" . imap_last_error();
+				$result['msg'] = $this->functions->lang('It was not possible clean the users inbox') . ".\n" . $this->functions->lang('Server returns') . ': ' . imap_last_error();
+			}
+		}
+		else
+		{
+			$result['status'] = false;
+			$result['msg'] = $this->functions->lang('It was not possible to modify the users acl') . ".\n" . $this->functions->lang('Server returns') . ': ' . imap_last_error();
 		}
 		return $result;
