Index: branches/2.4/expressoMail1_2/inc/class.imap_functions.inc.php
===================================================================
--- branches/2.4/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 7180)
+++ branches/2.4/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 7228)
@@ -128,6 +128,7 @@
 		$result = true;
 		if(!imap_renamemailbox($mbox, '{'.$this->imap_server.":".$this->imap_port.$this->imap_options.'}'.$old_folder, '{'.$this->imap_server.":".$this->imap_port.$this->imap_options.'}'.$to_folder.$this->imap_delimiter.$new_folder[count($new_folder)-1])){
-			$result = false;
-		}
+			$result = imap_last_error();
+		}
+
 		imap_close($mbox); 
 		return $result;
@@ -1061,5 +1062,5 @@
 		$content = $this->html2txt($content);	
 		$content != "" ? $return['body'] = " - " . $content: $return['body'] = "";
-        $return['body'] = base64_encode(mb_convert_encoding(substr($return['body'], 0, 305),'UTF-8' , 'UTF-8,ISO-8859-1')); 
+                $return['body'] = base64_encode(mb_convert_encoding(substr($return['body'], 0, 305),'UTF-8' , 'UTF-8,ISO-8859-1'));
 		return $return;
 	}
@@ -1235,5 +1236,5 @@
 		$return['sender']['name'] = isset($sender[0]->personal) ? $this->decode_string($sender[0]->personal): '';
 		$return['sender']['email'] = $this->decode_string($sender[0]->mailbox . "@" . $sender[0]->host);
-		
+
 		if ($return['sender']['name'])
 		{
@@ -1256,6 +1257,6 @@
 				if (!empty($tmp->personal))
 				{
-					$personal_tmp = $this->formatMailObject($tmp); 
- 	                $return['toaddress2'] .= '"' . $personal_tmp['name'] . '"';
+					$personal_tmp = $this->formatMailObject($tmp);
+					$return['toaddress2'] .= '"' . $personal_tmp['name'] . '"';
 					$return['toaddress2'] .= " ";
 					$return['toaddress2'] .= "&lt;";
@@ -1288,6 +1289,6 @@
 				if (!empty($tmp_cc->personal))
 				{
-					$personal_tmp_cc = $this->formatMailObject($tmp_cc); 
- 	                $return['cc'] .= '"' . $personal_tmp_cc['name']. '"'; 
+					$personal_tmp_cc = $this->formatMailObject($tmp_cc);
+					$return['cc'] .= '"' . $personal_tmp_cc['name']. '"';
 					$return['cc'] .= " ";
 					$return['cc'] .= "&lt;";
@@ -1328,6 +1329,6 @@
 				if (!empty($tmp_bcc->personal))
 				{
-					$personal_tmp_bcc = $this->formatMailObject($tmp_bcc); 
- 	                $return['bcc'] .= '"' . $personal_tmp_bcc['name'] . '"';
+					$personal_tmp_bcc = $this->formatMailObject($tmp_bcc);
+					$return['bcc'] .= '"' . $personal_tmp_bcc['name'] . '"';
 					$return['bcc'] .= " ";
 					$return['bcc'] .= "&lt;";
@@ -1355,29 +1356,38 @@
 		$reply_to = $header->reply_to;
 		$return['reply_to'] = "";
+		
 		if (is_object($reply_to[0]))
 		{
 			if ($return['from']['email'] != ($reply_to[0]->mailbox."@".$reply_to[0]->host))
 			{
-				if (!empty($reply_to[0]->personal))
+				foreach ($reply_to as $tmp_reply_to)
 				{
-					$personal_reply_to = $this->formatMailObject($tmp_reply_to);
-					if(!empty($personal_reply_to[0]->text)) {
-						$return['reply_to'] .= '"' . $personal_reply_to['name']. '"';
+					if (!empty($tmp_reply_to->personal))
+					{
+						$personal_tmp_reply_to = $this->formatMailObject($tmp_reply_to);
+						$return['reply_to'] .= '"' . $personal_tmp_reply_to['name'] . '"';
 						$return['reply_to'] .= " ";
 						$return['reply_to'] .= "&lt;";
-						$return['reply_to'] .= $personal_reply_to['email'];
+						$return['reply_to'] .= $personal_tmp_reply_to['email'];
 						$return['reply_to'] .= "&gt;";
+						$return['reply_to'] .= ", ";
 					}
-					else {
-						$return['reply_to'] .= $reply_to[0]->mailbox . "@" . $reply_to[0]->host;
+					else
+					{
+						if (isset($tmp_reply_to->host) && $tmp_reply_to->host != 'unspecified-domain')
+							$return['reply_to'] .= $tmp_reply_to->mailbox . "@" . $tmp_reply_to->host;
+						else
+							$return['reply_to'] .= $tmp_reply_to->mailbox;
+						$return['reply_to'] .= ", ";
 					}
 				}
-				else
-				{
-					$return['reply_to'] .= $reply_to[0]->mailbox . "@" . $reply_to[0]->host;
-				}
-			}
-		}
-		$return['reply_to'] = $this->decode_string($return['reply_to']);
+				$return['reply_to'] = $this->del_last_two_caracters($return['reply_to']);
+			}
+		}
+		else
+		{
+			$return['reply_to'] = "";
+		}
+
 		$return['subject'] = ( isset($header->subject) && trim($header->subject) !== '' ) ?  self::decodeMimeString($header->subject) : $this->functions->getLang('(no subject)   ');
 
@@ -1398,5 +1408,5 @@
 		}  
 		$return['alarm'] = $alarm;
-	
+		
 		return $return;
 	}
@@ -1896,4 +1906,13 @@
             $body = str_ireplace('<o:p>&nbsp;</o:p>','<br />', $body);//Qubra de linha do MSO
             $body = preg_replace('/<(meta|base|link|html|\/html)[^>]*>/i', '', $body);
+
+
+			// Malicious Code Remove
+            $dirtyCodePattern = "/(<([\w]+[\w0-9]*)(.*)on(mouse(move|over|down|up)|load|blur|change|error|click|dblclick|focus|key(down|up|press)|select)([\n\ ]*)=([\n\ ]*)[\"'][^>\"']*[\"']([^>]*)>)(.*)(<\/\\2>)?/misU";
+            preg_match_all($dirtyCodePattern, $body, $rest, PREG_PATTERN_ORDER);
+            foreach ($rest[0] as $i => $val) {
+                if (!(preg_match("/javascript:window\.open\(\"([^'\"]*)\/index\.php\?menuaction=calendar\.uicalendar\.set_action\&cal_id=([^;'\"]+);?['\"]/i", $rest[1][$i]) && strtoupper($rest[4][$i]) == "CLICK" )) //Calendar events
+                    $body = str_replace($rest[1][$i], "<" . $rest[2][$i] . $rest[3][$i] . $rest[7][$i] . ">", $body);
+            }
             
 
@@ -1932,4 +1951,6 @@
             $body = str_ireplace('position:absolute;', '', $body);
             	
+            $body = str_ireplace('position:absolute;', '', $body);
+
             //Remoção de tags <span></span> para correção de erro no firefox
             //Comentado pois estes replaces geram erros no html da msg, não se pode garantir que o os </span></span> sejam realmente os fechamentos dos <span><span>.
@@ -2145,32 +2166,31 @@
 		$return['status'] = true;
 
-			//Este bloco tem a finalidade de averiguar as permissoes para pastas compartilhadas 
-	    if (substr($folder,0,4) == 'user'){ 
-	            $acl = $this->getacltouser($folder, isset($params['decoded'])); 
-	            /* 
-	             * l - lookup (mailbox is visible to LIST/LSUB commands, SUBSCRIBE mailbox) 
-                 * r - read (SELECT the mailbox, perform STATUS) 
-                 * s - keep seen/unseen information across sessions (set or clear \SEEN flag via STORE, also set \SEEN during APPEND/COPY/        FETCH BODY[...]) 
-                 * w - write (set or clear flags other than \SEEN and \DELETED via STORE, also set them during APPEND/COPY) 
-                 * i - insert (perform APPEND, COPY into mailbox) 
-                 * p - post (send mail to submission address for mailbox, not enforced by IMAP4 itself) 
-                 * k - create mailboxes (CREATE new sub-mailboxes in any implementation-defined hierarchy, parent mailbox for the new mailbox name in RENAME) 
-                 * x - delete mailbox (DELETE mailbox, old mailbox name in RENAME) 
-                 * t - delete messages (set or clear \DELETED flag via STORE, set \DELETED flag during APPEND/COPY) 
-                 * e - perform EXPUNGE and expunge as a part of CLOSE 
-                 * a - administer (perform SETACL/DELETEACL/GETACL/LISTRIGHTS) 
-                 * Os Atributos da ACL para pastas compartilhadas são definidos no arquivo sharemailbox.js, na função setaclfromuser 
-                 * Os Atributos da ACL para contas compartilhadas são definidos no arquivo shared_accounts.js, na função setaclfromuser  
-                 */ 
-	                    $acl_share_delete = (stripos($acl,'t') !== false && stripos($acl,'e') !== false); 
- 		 
- 		                if (!$acl_share_delete) {  
-	                            $return['status'] = false; 
-	                    } 
-	    } 
-	    
+		//Este bloco tem a finalidade de averiguar as permissoes para pastas compartilhadas
+        if (substr($folder,0,4) == 'user'){
+        	$acl = $this->getacltouser($folder, isset($params['decoded']));
+        	/*
+			* l - lookup (mailbox is visible to LIST/LSUB commands, SUBSCRIBE mailbox)
+			* r - read (SELECT the mailbox, perform STATUS)
+			* s - keep seen/unseen information across sessions (set or clear \SEEN flag via STORE, also set \SEEN during APPEND/COPY/        FETCH BODY[...])
+			* w - write (set or clear flags other than \SEEN and \DELETED via STORE, also set them during APPEND/COPY)
+			* i - insert (perform APPEND, COPY into mailbox)
+			* p - post (send mail to submission address for mailbox, not enforced by IMAP4 itself)
+			* k - create mailboxes (CREATE new sub-mailboxes in any implementation-defined hierarchy, parent mailbox for the new mailbox name in RENAME)
+			* x - delete mailbox (DELETE mailbox, old mailbox name in RENAME)
+			* t - delete messages (set or clear \DELETED flag via STORE, set \DELETED flag during APPEND/COPY)
+			* e - perform EXPUNGE and expunge as a part of CLOSE
+			* a - administer (perform SETACL/DELETEACL/GETACL/LISTRIGHTS)
+			* Atributos da ACL para pastas compartilhadas são definidos no arquivo sharemailbox.js, na função setaclfromuser
+			* Atributos da ACL para contas compartilhadas são definidos no arquivo shared_accounts.js, na função setaclfromuser
+			*/
+			$acl_share_delete = (stripos($acl,'t') !== false && stripos($acl,'e') !== false);
+
+			if (!$acl_share_delete) {
+				$return['status'] = false;
+			}
+        }
+
 		return $return;
 	}
-
 
 	function refresh($params)
@@ -2367,9 +2387,9 @@
 	    foreach ($return as $i => &$vv)
 	    {
-		if(!is_array($vv)) continue; 
- 		 
- 	    $vv['folder_id'] = mb_convert_encoding($vv['folder_id'],'ISO-8859-1','UTF7-IMAP');//DECODIFICA ID DAS PASTAS COM ACENTOS 
- 	    $vv['folder_name'] = mb_convert_encoding($vv['folder_name'],'ISO-8859-1','UTF7-IMAP');//DECODIFICA NOME DAS PASTAS COM ACENTOS 
- 	    $vv['folder_parent'] = mb_convert_encoding($vv['folder_parent'],'ISO-8859-1','UTF7-IMAP');//DECODIFICA NOME DAS PASTAS COM ACENTOS
+            if(!is_array($vv)) continue;
+
+            $vv['folder_id'] = mb_convert_encoding($vv['folder_id'],'ISO-8859-1','UTF7-IMAP');//DECODIFICA ID DAS PASTAS COM ACENTOS
+            $vv['folder_name'] = mb_convert_encoding($vv['folder_name'],'ISO-8859-1','UTF7-IMAP');//DECODIFICA NOME DAS PASTAS COM ACENTOS
+            $vv['folder_parent'] = mb_convert_encoding($vv['folder_parent'],'ISO-8859-1','UTF7-IMAP');//DECODIFICA NOME DAS PASTAS COM ACENTOS
 	    }
 
@@ -2412,9 +2432,55 @@
 			$decifrada = mb_convert_encoding('INBOX'.$this->imap_delimiter.'decifradas','UTF7-IMAP','ISO-8859-1'); //Ignorar esta pasta decifrada
 			$parent = ($nameCount > 1 && $nameArray[($nameCount - 2)] !== 'INBOX') ? implode($this->imap_delimiter, array_slice($nameArray, 0, ($nameCount - 1))): ''; //Pega folder pai
-			if($nameArray[0] === 'user')
-				$folders[$prefixShared.$this->imap_delimiter.$nameArray[1]][] = array('id' => $folderId , 'stream' => $v->name , 'attributes' => $v->attributes , 'name' => $nameArray[($nameCount-1)] , 'user' => $nameArray[1] ,'parent' => $parent);
-			else if( $folderId !== $decifrada) //Escapa pasta decifrada
-				$folders['INBOX'][strtolower($folderId)] =  array('id' => $folderId , 'stream' => $v->name , 'attributes' => $v->attributes ,'name' => $nameArray[($nameCount-1)] , 'parent' => $parent);
-		}
+
+			if($nameArray[0] === 'user'){
+
+				//variaveis utilizadas para definição das permissões das pastas compartilhadas
+				$acl_share_create = 0;
+				$acl_share_rename = 0;
+				$acl_share_delete = 0;
+
+				//recuperando as permissões (ACLs) aplicadas na pasta
+				$imap_getacl = imap_getacl($mboxStream, $folderId);
+
+				//Se existe ACLs aplicadas a respectiva pasta (para o usuario corrente)
+				if(isset($imap_getacl[ $this->username ])){
+					$aclImap = $imap_getacl[ $this->username ];
+
+					//A partir dos atributos da ACL definir permissões para cada ação (create, delete e rename):
+					//http://www.ietf.org/rfc/rfc4314.txt
+					$acl_share_create = (stripos($aclImap,'w') !== false && stripos($aclImap,'i') !== false && stripos($aclImap,'k') !== false) ? 1 : 0;
+					$acl_share_delete = (stripos($aclImap,'x') !== false && stripos($aclImap,'t') !== false && stripos($aclImap,'e') !== false) ? 1 : 0;
+
+					$acl_share_rename = ($acl_share_create && $acl_share_delete) ? 1 : 0;
+				}
+
+				$folders[$prefixShared.$this->imap_delimiter.$nameArray[1]][] = array(
+					'id' => $folderId , 
+					'stream' => $v->name , 
+					'attributes' => $v->attributes , 
+					'name' => $nameArray[($nameCount-1)] , 
+					'user' => $nameArray[1] ,
+					'parent' => $parent ,
+
+					//Acrescentando ACLs configuradas a cada pasta compartilhada
+					'acl_share' => array(
+					 	'create' => $acl_share_create,
+						'rename' => $acl_share_rename,
+						'delete' => $acl_share_delete
+					)
+				);
+
+ 			}	
+			else if( $folderId !== $decifrada){ //Escapa pasta decifrada
+				$folders['INBOX'][strtolower($folderId)] = array(
+					'id' => $folderId , 
+					'stream' => $v->name , 
+					'attributes' => $v->attributes ,
+					'name' => $nameArray[($nameCount-1)] , 
+					'parent' => $parent 
+				);
+			}
+		}
+
 		unset($folders_list); //destroy array de objetos desnecessarios
 		
@@ -2434,4 +2500,9 @@
 				$append['folder_hasChildren'] = (($vv['attributes'] == 32) && ($vv['name'] != 'INBOX')) ? 1 : 0;
 				$append['folder_parent'] = $vv['parent'];
+
+				//Preparando o array de retorno para conter as ACLs configuradas para cada pasta
+				if(isset($vv['acl_share'])){
+					$append['acl_share'] = $vv['acl_share'];
+				}
 				$return[] = $append;
 			}
@@ -2440,5 +2511,5 @@
 		$quotaInfo =  (!isset($params['noQuotaInfo'])) ? $this->get_quota( array('folder_id' => $currentFolder)) : false; //VERIFICA SE O USUARIO TEM COTA
 
-		return ( ( is_array($quotaInfo) ) ?  array_merge($return, $quotaInfo) : $return );        
+		return ( ( is_array($quotaInfo) ) ?  array_merge($return, $quotaInfo) : $return );
 	}
     
@@ -2460,5 +2531,5 @@
 			if(!imap_createmailbox($mbox_stream,"{".$imap_server."}".$namebox))
 			{
-				$result = implode("<br />\n", imap_errors());
+				$result = imap_last_error();
 			}
 		}else{
@@ -2471,5 +2542,5 @@
 				if(!imap_createmailbox($mbox_stream,"{".$imap_server."}$namebox"))
 				{
-					$result = implode("<br />\n", imap_errors());						
+					$result = imap_last_error();						
 				}
 				$child .=$this->imap_delimiter;
@@ -2513,5 +2584,5 @@
 		if(!imap_deletemailbox($mbox_stream,"{".$imap_server."}$namebox"))
 		{
-			$result = implode("<br />\n", imap_errors());
+			$result = imap_last_error();
 		}
 		/*
@@ -2536,5 +2607,5 @@
 		if(!imap_renamemailbox($mbox_stream,"{".$imap_server."}$namebox","{".$imap_server."}$new_box"))
 		{
-			$result = imap_errors();
+			$result = imap_last_error();
 		}
 		if($mbox_stream)
@@ -2593,8 +2664,8 @@
             }
 
-            /*Wraps the text dividing the emails as from ">,"*/ 
+            /*Wraps the text dividing the emails as from ">,"*/
             $toaddress = $db->getAddrs(preg_split('/>,/',preg_replace('/>,/', '>>,', $params['input_to'])));
- 	        $ccaddress = $db->getAddrs(preg_split('/>,/',preg_replace('/>,/', '>>,', $params['input_cc']))); 
- 	        $ccoaddress = $db->getAddrs(preg_split('/>,/',preg_replace('/>,/', '>>,', $params['input_cco']))); 
+            $ccaddress = $db->getAddrs(preg_split('/>,/',preg_replace('/>,/', '>>,', $params['input_cc'])));
+            $ccoaddress = $db->getAddrs(preg_split('/>,/',preg_replace('/>,/', '>>,', $params['input_cco'])));
 
             if ($toaddress["False"] || $ccaddress["False"] || $ccoaddress["False"]) {
@@ -2619,5 +2690,5 @@
             $ccoaddress = preg_replace('/\s+>/', '>', $ccoaddress);
 
-            $replytoaddress = $params['input_replyto'];
+            $replytoaddress = $params['input_reply_to'];
             $subject = $params['input_subject'];
             $return_receipt = $params['input_return_receipt'];
@@ -2625,5 +2696,5 @@
             $encrypt = $params['input_return_cripto'];
             $signed = $params['input_return_digital'];
-			
+
 			$params['attachments'] = mb_convert_encoding($params['attachments'], "UTF7-IMAP","UTF-8, ISO-8859-1, UTF7-IMAP");
             $message_attachments = $params['message_attachments'];
@@ -2804,4 +2875,6 @@
             else
                 $mailService->setFrom('"' . $_SESSION['phpgw_info']['expressomail']['user']['firstname'] . ' ' . $_SESSION['phpgw_info']['expressomail']['user']['lastname'] . '" <' . $_SESSION['phpgw_info']['expressomail']['user']['email'] . '>');
+            
+            $mailService->addHeaderField('Reply-To', $replytoaddress);
 
             $bol = $this->add_recipients('to', $toaddress, $mailService);
@@ -2950,9 +3023,10 @@
                 {
                     $value = json_decode($value, true);
-		    		    
+
                     switch ($value['type']) {
                         case 'imapPart':
                                 $att = $this->getForwardingAttachment(mb_convert_encoding($value['folder'] , 'ISO-8859-1' , 'UTF7-IMAP'),$value['uid'], $value['part']);
-                                if(strstr($body,'src="./inc/get_archive.php?msgFolder='.$value['folder'].'&msgNumber='.$value['uid'].'&indexPart='.$value['part'].'"') !== false)//Embeded IMG 
+
+                                if(strstr($body,'src="./inc/get_archive.php?msgFolder='.$value['folder'].'&msgNumber='.$value['uid'].'&indexPart='.$value['part'].'"') !== false)//Embeded IMG
                                 {    
                                     $body = str_ireplace('src="./inc/get_archive.php?msgFolder='.$value['folder'].'&msgNumber='.$value['uid'].'&indexPart='.$value['part'].'"' , 'src="'.$att['name'].'"', $body);
@@ -3168,6 +3242,6 @@
             $attachment = new attachment();
             $attachment->decodeConf['rfc_822bodies'] = $rfc_822bodies; //Forçar a não decodificação de mensagens em anexo.
-			            $folder = urldecode($folder); 
-			 	$attachment->setStructureFromMail($folder, $uid);
+			$folder = urldecode($folder);
+    		$attachment->setStructureFromMail($folder, $uid);
             
             if($info === true)
@@ -3414,25 +3488,25 @@
 
 		//Este bloco tem a finalidade de averiguar as permissoes para pastas compartilhadas
-		if (substr($folder,0,4) == 'user'){
-			$acl = $this->getacltouser($folder, isset($params['decoded']));
-
-			/*
-		   	 * l - lookup (mailbox is visible to LIST/LSUB commands, SUBSCRIBE mailbox) 
-             * r - read (SELECT the mailbox, perform STATUS) 
-             * s - keep seen/unseen information across sessions (set or clear \SEEN flag via STORE, also set \SEEN during APPEND/COPY/        FETCH BODY[...]) 
-             * w - write (set or clear flags other than \SEEN and \DELETED via STORE, also set them during APPEND/COPY) 
-             * i - insert (perform APPEND, COPY into mailbox) 
-             * p - post (send mail to submission address for mailbox, not enforced by IMAP4 itself) 
-             * k - create mailboxes (CREATE new sub-mailboxes in any implementation-defined hierarchy, parent mailbox for the new mailbox name in RENAME) 
-             * x - delete mailbox (DELETE mailbox, old mailbox name in RENAME) 
-             * t - delete messages (set or clear \DELETED flag via STORE, set \DELETED flag during APPEND/COPY) 
-             * e - perform EXPUNGE and expunge as a part of CLOSE 
-             * a - administer (perform SETACL/DELETEACL/GETACL/LISTRIGHTS) 
-             * Os Atributos da ACL para pastas compartilhadas são definidos no arquivo sharemailbox.js, na função setaclfromuser 
-             * Os Atributos da ACL para contas compartilhadas são definidos no arquivo shared_accounts.js, na função setaclfromuser 
-			 */
-			$acl_share_delete = (stripos($acl,'t') !== false && stripos($acl,'e') !== false); 
- 		 
- 	        if (!$acl_share_delete) {  
+        if (substr($folder,0,4) == 'user'){
+        	$acl = $this->getacltouser($folder, isset($params['decoded']));
+
+        	/*
+			* l - lookup (mailbox is visible to LIST/LSUB commands, SUBSCRIBE mailbox)
+			* r - read (SELECT the mailbox, perform STATUS)
+			* s - keep seen/unseen information across sessions (set or clear \SEEN flag via STORE, also set \SEEN during APPEND/COPY/        FETCH BODY[...])
+			* w - write (set or clear flags other than \SEEN and \DELETED via STORE, also set them during APPEND/COPY)
+			* i - insert (perform APPEND, COPY into mailbox)
+			* p - post (send mail to submission address for mailbox, not enforced by IMAP4 itself)
+			* k - create mailboxes (CREATE new sub-mailboxes in any implementation-defined hierarchy, parent mailbox for the new mailbox name in RENAME)
+			* x - delete mailbox (DELETE mailbox, old mailbox name in RENAME)
+			* t - delete messages (set or clear \DELETED flag via STORE, set \DELETED flag during APPEND/COPY)
+			* e - perform EXPUNGE and expunge as a part of CLOSE
+			* a - administer (perform SETACL/DELETEACL/GETACL/LISTRIGHTS)
+			* Os Atributos da ACL para pastas compartilhadas são definidos no arquivo sharemailbox.js, na função setaclfromuser
+			* Os Atributos da ACL para contas compartilhadas são definidos no arquivo shared_accounts.js, na função setaclfromuser
+			*/
+			$acl_share_delete = (stripos($acl,'t') !== false && stripos($acl,'e') !== false);
+
+			if (!$acl_share_delete) {
 				$return['status'] = false;
 				return $return;
@@ -3514,7 +3588,7 @@
 					imap_close($mbox_stream);
 				
-				$msg_error = "move_messages() line ".__LINE__.": ". imap_last_error()." folder:".$newmailbox; 
-                trigger_error($msg_error); 
-                return $msg_error; 
+				$msg_error = "move_messages() line ".__LINE__.": ". imap_last_error()." folder:".$newmailbox;
+				trigger_error($msg_error);
+				return $msg_error;
 			}
 		}
@@ -3731,4 +3805,8 @@
 			$this->mbox = $this->open_mbox($folder);
 
+		if($offsetEnd == 0 && $offsetBegin == 0){
+			$offsetEnd = imap_num_msg($this->mbox);
+			$offsetBegin = 1;
+		}
 		return $this->messages_sort($sort_box_type,$sort_box_reverse, $search_box_type,$offsetBegin,$offsetEnd,$folder);
 	}
@@ -3878,7 +3956,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);
@@ -4322,32 +4401,28 @@
 		$mbox_acl = imap_getacl($mbox_stream, 'INBOX');
 
-		$oldAcls = array('d' , 'c' , 'a'); 
-        $newAcls = array('xte','ik', ''); 
-
-        $return = array(); 
+		$oldAcls = array('d' , 'c' , 'a');
+		$newAcls = array('xte','ik', '');
+
+		$return = array();
 		foreach ($mbox_acl as $user => $acl)
 		{
-				if($user == $this->username)  
-                            continue; 
-
-                    //Compatibiliza acls no padrão antigo para o novo 
-                    $acl = str_replace($oldAcls, $oldAcls, $acl); 
-
-                    $return[$user] = array( 
-                                    'cn' => $this->ldap->uid2cn($user) , 
-                                    'acls' => $acl 
-                                    ); 
-            } 
-            return $return; 
-    } 
-
-    function setacl($params) 
-    { 
-            $old_users = $this->getacl(); 
-            $new_users = unserialize($params['acls']); 
-
-            $mbox_stream = $this->open_mbox(); 
-            $serverString = "{".$this->imap_server.":".$this->imap_port.$this->imap_options."}"; 
-            $mailboxes_list = imap_getmailboxes($mbox_stream, $serverString, "user".$this->imap_delimiter.$this->username."*");                 
+			if($user == $this->username) 
+				continue;
+
+			//Compatibiliza acls no padrão antigo para o novo
+			$acl = str_replace($oldAcls, $oldAcls, $acl);
+
+			$return[$user] = array(
+					'cn' => $this->ldap->uid2cn($user) ,
+					'acls' => $acl
+					);
+		}
+		return $return;
+	}
+
+	function setacl($params)
+	{
+		$old_users = $this->getacl();
+		$new_users = unserialize($params['acls']);
 
             foreach ($new_users as $user => $value) { 
@@ -4358,37 +4433,47 @@
                     } 
             } 
-
-            foreach ($new_users as $user => $value)
+		$serverString = "{".$this->imap_server.":".$this->imap_port.$this->imap_options."}";
+		$mailboxes_list = imap_getmailboxes($mbox_stream, $serverString, "user".$this->imap_delimiter.$this->username."*");                
+
+		foreach ($new_users as $user => $value) {
+			if(isset($old_users[$user]) && $value['acls'] == $old_users[$user]['acls'])
+			{
+				unset($old_users[$user]);
+				unset($new_users[$user]);
+			}
+		}
+
+		foreach ($new_users as $user => $value)
 		{
-			if (is_array($mailboxes_list)) 
-            { 
-                foreach ($mailboxes_list as $key => $val) 
-                { 
-                    $folder = str_replace($serverString, "", imap_utf7_decode($val->name)); 
-                    //$folder = str_replace("&-", "&", $folder); 
- 	                $folder = imap_utf7_encode($folder); 
-                    imap_setacl ($mbox_stream, $folder, "$user", $value['acls']); 
-
-                } 
-            } 
-            if(isset($old_users[$user])) 
-                    unset($old_users[$user]); 
-            } 
-
-            foreach ($old_users as $user => $value)
+	        if (is_array($mailboxes_list))
+	        {
+	            foreach ($mailboxes_list as $key => $val)
+	            {
+	                $folder = str_replace($serverString, "", imap_utf7_decode($val->name));
+	                //$folder = str_replace("&-", "&", $folder);
+					$folder = imap_utf7_encode($folder);
+	                imap_setacl ($mbox_stream, $folder, "$user", $value['acls']);
+
+	            }
+	        }
+	        if(isset($old_users[$user]))
+	        	unset($old_users[$user]);
+		}
+
+		foreach ($old_users as $user => $value)
 		{
-			if (is_array($mailboxes_list)) 
-            { 
-                foreach ($mailboxes_list as $key => $val) 
-                { 
-                    $folder = str_replace($serverString, "", imap_utf7_decode($val->name)); 
-                    //$folder = str_replace("&-", "&", $folder); 
- 	                $folder = imap_utf7_encode($folder); 
-                    imap_setacl ($mbox_stream, $folder, "$user", ""); 
-
-                } 
-            } 
-            } 
-
+	        if (is_array($mailboxes_list))
+	        {
+	            foreach ($mailboxes_list as $key => $val)
+	            {
+	                $folder = str_replace($serverString, "", imap_utf7_decode($val->name));
+	                //$folder = str_replace("&-", "&", $folder);
+					$folder = imap_utf7_encode($folder);
+	                imap_setacl ($mbox_stream, $folder, "$user", "");
+
+	            }
+	        }
+		}
+		
 
 		return true;
@@ -4407,10 +4492,11 @@
 		//Afim de tratar as pastas compartilhadas, verificandos as permissoes de operacao sobre as mesmas
 		//No caso de se tratar da caixa do proprio usuario logado, utiliza a sintaxe abaixo
-		if(substr($user,0,5) != 'user'.$this->imap_delimiter) 
- 	            $mbox_acl = imap_getacl($mbox_stream, 'user'.$this->imap_delimiter.$user); 
+		if(substr($user,0,5) != 'user'.$this->imap_delimiter)
+			$mbox_acl = imap_getacl($mbox_stream, 'user'.$this->imap_delimiter.$user);
 		else
-		  $mbox_acl = imap_getacl($mbox_stream, $user); 
- 	                
- 	    return (isset($mbox_acl[$this->username])) ? $mbox_acl[$this->username] : '';
+		  	$mbox_acl = imap_getacl($mbox_stream, $user);
+		
+		return (isset($mbox_acl[$this->username])) ? $mbox_acl[$this->username] : '';
+               
 	}
 
@@ -4723,5 +4809,6 @@
  		$array_params = explode(";;", $params); 
  		$id_msg   = $array_params[0]; 
- 		$msg_user = $array_params[1]; 
+ 		$msg_user = $array_params[1];
+ 		$msg_folder = $array_params[2];
  	    $msg_folder = $array_params[2]; 
  		
@@ -5294,4 +5381,5 @@
 				foreach ($messages as $k => $m) {
 					$headers = imap_fetch_overview($this->mbox, $m, FT_UID);
+
 					$date = explode(" ", $headers[0]->date); 
 					$result[$m."_".$folder] = array (
@@ -5325,4 +5413,5 @@
 		}
 		$r = $this->get_info_msg(array('msg_number' => $message_number, 'msg_folder' =>urlencode($message_folder), 'alarm' => ($alarm)));
+
 		return $r;
 	}
Index: branches/2.4/expressoMail1_2/inc/class.exporteml.inc.php
===================================================================
--- branches/2.4/expressoMail1_2/inc/class.exporteml.inc.php	(revision 5934)
+++ branches/2.4/expressoMail1_2/inc/class.exporteml.inc.php	(revision 7228)
@@ -16,5 +16,5 @@
 	var $mbox_stream;
 	var $tempDir;
-	
+
 	function ExportEml() {
 	   
@@ -50,5 +50,5 @@
 		return $sEMail;
 	}
-	
+
 	// create EML File.
 	// Funcao alterada para tratar a exportacao
@@ -62,5 +62,5 @@
             $header    = imap_headerinfo($this->mbox_stream, imap_msgno($this->mbox_stream, $id), 80, 255);
             $subject = $this->decode_subject($header->fetchsubject);
-            
+			
             if (strlen($subject) > 60)
                 $subject = substr($subject, 0, 59);
@@ -214,5 +214,4 @@
 		// se encontram em um mesmo folder
 		if (count($sorted_msgs)==1){
-							
 			$array_names_keys = array_keys($sorted_msgs);
 			$this->folder = mb_convert_encoding($array_names_keys[0], "UTF7-IMAP","UTF-8, ISO-8859-1, UTF7-IMAP");
@@ -228,10 +227,15 @@
 				$fileName       = $this->CreateFileEml($sEMLData, $tempDir, $msg_number[0]."_".$_SESSION[ 'phpgw_session' ][ 'session_id' ]);
 		
-				
+				$header    = imap_headerinfo($this->mbox_stream, imap_msgno($this->mbox_stream, $msg_number[0]), 80, 255);
+            	$subject = $this->decode_subject(html_entity_decode($header->fetchsubject));
+
 				imap_close($this->mbox_stream);
 				if (!$fileName) {
 					return false;
 				}else{
-					return $tempDir.'/'.$fileName;
+					$return = array();
+					$return[] = $tempDir.'/'.$fileName;
+					$return[] = $subject;
+					return $return;
 				}
 			}
@@ -271,5 +275,5 @@
 			}
 
-			return $file;
+			return $file;			
 		
 		//exporta mensagens de diferentes pastas
@@ -362,5 +366,4 @@
 				$file = false;
 			}
-
             return $file;
 		
@@ -369,5 +372,5 @@
 		{
 			$this-> folder = $params['folder'];
-				$this->folder = mb_convert_encoding($this->folder, "UTF7-IMAP","UTF-8, ISO-8859-1, UTF7-IMAP");
+			$this->folder = mb_convert_encoding($this->folder, "UTF7-IMAP","UTF-8, ISO-8859-1, UTF7-IMAP");
 			$array_ids = explode(',', $params['msgs_to_export']);
 			$error = False;
@@ -383,4 +386,7 @@
 				$sEMLData       = $this->parseEml($header, $body);                     
 				$fileName       = $this->CreateFileEml($sEMLData, $tempDir, $array_ids[0]."_".$_SESSION[ 'phpgw_session' ][ 'session_id' ]);
+			
+				$header    = imap_headerinfo($this->mbox_stream, imap_msgno($this->mbox_stream, $array_ids[0]), 80, 255);
+	            $subject = $this->decode_subject(html_entity_decode($header->fetchsubject));
 
 				imap_close($this->mbox_stream);
@@ -388,5 +394,8 @@
 					return false;
 				} else {
-					return $tempDir.'/'.$fileName;
+					$return = array();
+					$return[] = $tempDir.'/'.$fileName;
+					$return[] = $subject;
+					return $return;
 				}
 			}
@@ -416,4 +425,6 @@
 				{               
 					$file = $tempDir.'/'.$nameFileZip;
+					$ret[] = $file;
+				    return $ret;  
 				} else {
 					$file = false;
@@ -424,5 +435,4 @@
 				$file = false;
 			}
-
 			return $file;
 		}
@@ -453,9 +463,15 @@
 			$fileName       = $this->CreateFileEml($sEMLData, $tempDir, $array_ids[0]."_".$_SESSION[ 'phpgw_session' ][ 'session_id' ]);
 
+			$header    = imap_headerinfo($this->mbox_stream, imap_msgno($this->mbox_stream, $array_ids[0]), 80, 255);
+            $subject = $this->decode_subject(html_entity_decode($header->fetchsubject));
+
 			imap_close($this->mbox_stream);
 			if (!$fileName) {
 				return false;
 			} else {
-				return $tempDir.'/'.$fileName;
+				$return = array();
+				$return[] = $tempDir.'/'.$fileName;
+				$return[] = $subject;
+				return $return;
 			}
 		}
Index: branches/2.4/expressoMail1_2/inc/class.ldap_functions.inc.php
===================================================================
--- branches/2.4/expressoMail1_2/inc/class.ldap_functions.inc.php	(revision 7083)
+++ branches/2.4/expressoMail1_2/inc/class.ldap_functions.inc.php	(revision 7228)
@@ -88,8 +88,8 @@
 		$this->ldap_context = $_SESSION['phpgw_info']['expressomail']['server']['ldap_context'];
 
-		if( isset($_SESSION['phpgw_info']['expressomail']['server']['ldap_master_host']) && 
-            isset($_SESSION['phpgw_info']['expressomail']['server']['ldap_master_root_dn']) && 
-            isset($_SESSION['phpgw_info']['expressomail']['server']['ldap_master_root_pw']) && 
-            $_SESSION['phpgw_info']['expressomail']['server']['ldap_master_host'] &&
+		if( isset($_SESSION['phpgw_info']['expressomail']['server']['ldap_master_host']) &&
+			isset($_SESSION['phpgw_info']['expressomail']['server']['ldap_master_root_dn']) &&
+			isset($_SESSION['phpgw_info']['expressomail']['server']['ldap_master_root_pw']) &&
+			$_SESSION['phpgw_info']['expressomail']['server']['ldap_master_host'] &&
 			$_SESSION['phpgw_info']['expressomail']['server']['ldap_master_root_dn'] &&
 			$_SESSION['phpgw_info']['expressomail']['server']['ldap_master_root_pw']) {
@@ -114,6 +114,6 @@
 		$ID			= $params['ID'];
 		
-                $ldapService = ServiceLocator::getService('ldap');
-                $filter =  $ldapService->getSearchFilter($params['search_for']);
+		$ldapService = ServiceLocator::getService('ldap');
+		$filter =  $ldapService->getSearchFilter($params['search_for']);
 
 		$contacts_result = array();
@@ -132,42 +132,42 @@
 		if ($this->ds)
 		{
-                    $ldapService->connection = $this->ds;
-				if($extendedinfo)
-                                        $justthese = array("cn", "mail", "telephonenumber", "uid","uidNumber", "mobile", "phpgwaccountvisible", "employeenumber", "ou");
-				else 
-					$justthese = array("cn", "mail", "telephoneNumber", "phpgwAccountVisible", "uidNumber","uid");
-                $types = false;
-
-                if( $field == 'null' || $ID == 'null' )
+			$ldapService->connection = $this->ds;
+			if($extendedinfo)
+				$justthese = array("cn", "mail", "telephonenumber", "uid","uidNumber", "mobile", "phpgwaccountvisible", "employeenumber", "ou");
+			else 
+				$justthese = array("cn", "mail", "telephoneNumber", "phpgwAccountVisible", "uidNumber","uid");
+			$types = false;
+
+			if( $field == 'null' || $ID == 'null' )
  			{
-                    $justthese[] = "jpegphoto";
-                    $types = 'u';
-                }
+				$justthese[] = "jpegphoto";
+				$types = 'u';
+			}
 
 		$filter = $ldapService->getSearchFilter( $params['search_for'], $types );
 
 		$sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese, 0, $this->max_result);
-			
-				if(!$sr)
-					return null;
-
-				$count_entries = ldap_count_entries($this->ds,$sr);
-
-                $info = ldap_get_entries($this->ds, $sr);
+
+		if(!$sr)
+			return null;
+
+		$count_entries = ldap_count_entries($this->ds,$sr);
+
+		$info = ldap_get_entries($this->ds, $sr);
 
 	    // New search only on user sector
 	    if ($count_entries == $this->max_result)
 	    {
-                $overload = $count_entries;
-				}
-				else
-				{
-				$catalogsNum=count($this->external_srcs);
-		for ($i=0; $i<=$catalogsNum; $i++)	{
+			$overload = $count_entries;
+		}
+		else
+		{
+			$catalogsNum=count($this->external_srcs);
+				for ($i=0; $i<=$catalogsNum; $i++)	{
 					if ($this->external_srcs[$i]["quicksearch"]) { 
 						$this->ldapConnect(true,$i);
 						$filter="(|(cn=*$search_for*)(mail=*$search_for*))";
 						if($extendedinfo)
-                			$justthese = array("cn", "mail", "telephonenumber", "uid","uidNumber", "mobile", "phpgwaccountvisible", "employeenumber", "ou");
+							$justthese = array("cn", "mail", "telephonenumber", "uid","uidNumber", "mobile", "phpgwaccountvisible", "employeenumber", "ou");
 						else 
 							$justthese = array("cn", "mail", "telephoneNumber", "phpgwAccountVisible","uidNumber", "uid");
@@ -185,19 +185,19 @@
 			}
 
-	    $tmp = array(); 
-        $tmp_users_from_user_org = array(); 
-
-        for ($i=0; $i<$info["count"]; $i++) 
-        { 
-                $key = $info[$i]["mail"][0] . '%' . $info[$i]["telephonenumber"][0] . '%'. $info[$i]["mobile"][0] . '%' . $info[$i]["uid"][0] . '%' . $info[$i]["jpegphoto"]['count'] . '%' . $info[$i]["employeenumber"][0] . '%' .    $info[$i]["ou"][0]; 
-
-                if (/*(!$quickSearch_only_in_userSector) &&*/ preg_match("/$user_sector_dn/i", $info[$i]['dn'])) 
+		$tmp = array();
+		$tmp_users_from_user_org = array();
+
+		for ($i=0; $i<$info["count"]; $i++)
+		{
+			$key = $info[$i]["mail"][0] . '%' . $info[$i]["telephonenumber"][0] . '%'. $info[$i]["mobile"][0] . '%' . $info[$i]["uid"][0] . '%' . $info[$i]["jpegphoto"]['count'] . '%' . $info[$i]["employeenumber"][0] . '%' . 	$info[$i]["ou"][0];
+
+			if (/*(!$quickSearch_only_in_userSector) &&*/ preg_match("/$user_sector_dn/i", $info[$i]['dn']))
 			{
-						$tmp_users_from_user_org[$key] = utf8_decode($info[$i]["cn"][0]); 
-	                    continue; 
-	            } 
-
-	            $tmp[$key] = utf8_decode($info[$i]["cn"][0]); 
-	    } 
+				$tmp_users_from_user_org[$key] = utf8_decode($info[$i]["cn"][0]);
+				continue;
+			}
+
+			$tmp[$key] = utf8_decode($info[$i]["cn"][0]);
+		}
 
 			natcasesort($tmp_users_from_user_org);
@@ -219,5 +219,5 @@
 				}
 				$contacts_result['quickSearch_only_in_userSector'] = $quickSearch_only_in_userSector;
-		    $contacts_result['maxResult'] = $ldapService->limit; 
+				$contacts_result['maxResult'] = $ldapService->limit;
 			}
 			else
@@ -328,5 +328,5 @@
 							return $this->quickSearch($params);
 						else
-							return $this->quickSearchAll($params);							
+							return $this->quickSearchAll($params);
                 }
             }
@@ -340,5 +340,5 @@
         * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
         * @sponsor    Caixa Econômica Federal
-        * @author     Prognus Software Livre <airton@prognus.com.br | prognus@prognus.com.br>
+        * @author     ProgquickSearchAllnus Software Livre <airton@prognus.com.br | prognus@prognus.com.br>
         * @param      <array> <$param> <parametros vindos do cliente>
         * @return     <array> <$retorno> <Array com os usuários de todos os catálogos, de acordo com o parâmetro>
@@ -405,5 +405,5 @@
         * @return     <array> <$retorno> <Array com os usuários do Catálogo Global, de acordo com o parâmetro>
         */
-        function quickSearchGlobal($params, $all=false) 
+        function quickSearchGlobal($params, $all=false)
         {              
             include_once dirname(__FILE__). '/../../header.inc.php';
@@ -482,5 +482,6 @@
 					$search = ldap_get_entries($this->ds, $sr);
 					for ($j=0; $j<$search["count"]; $j++) {
-						$info_return[] = $search[$j];
+						$search[$j]['isExternal'] = true;
+                        $info_return[] = $search[$j];
 					}
 					$info_return["count"] = count($info_return)-1;
@@ -488,5 +489,5 @@
 			}
 			//---------------------------------------------------------------//
-			
+
             if($all == false)
                 $info_return['type_catalog'] = "G";
@@ -494,15 +495,14 @@
 			$info_return['extra_ldap_fields'] = $campos_extras; 
 			
-			foreach($info_return as &$value){ 
-                    $value['type_contact'] = "G"; 
-
-                    //Converte a descrição dos filtros para ISO8859 corrigindo inconsitências com caractéres especiais 
-                    if(isset($value['vacationinfo']) && isset($value['vacationinfo'][0]) && $value['vacationinfo'][0] != '') 
-                            $value['vacationinfo'][0] = $this->toISO8859($value['vacationinfo'][0]); 
-            } 
+			foreach($info_return as &$value){
+				$value['type_contact'] = "G";
+
+				//Converte a descrição dos filtros para ISO8859 corrigindo inconsitências com caractéres especiais
+				if(isset($value['vacationinfo']) && isset($value['vacationinfo'][0]) && $value['vacationinfo'][0] != '')
+					$value['vacationinfo'][0] = $this->toISO8859($value['vacationinfo'][0]);
+			}
 
 			$info_return['search_for'] = $params['search_for'];
-			
-            return $info_return;  
+            return $info_return; 
         } 
 	
@@ -898,24 +898,24 @@
 	function getSharedUsersFrom($params){
 		$filter = '';
-		$i = 0;          
-        //Added to save if must save sent messages in shared folder 
-        $acl_save_sent_in_shared = array(); 
-        
-        if($params['uids']) { 
-                $uids = explode(";",$params['uids']); 
-                $this->imap = new imap_functions();                      
-                foreach($uids as $index => $uid){ 
-                        $params = array(); 
-                        //Added to save if user has create permission 
-                        $acl_create_message = array(); 
-                        $acl = $this->imap->getacltouser($uid ,true); 
-   
-                        if ( preg_match("/p/",$acl )){                          
-                            $filter .= "(uid=$uid)";                                                     
-                            $acl_save_sent_in_shared[ $i ] =$uid; 
-                            $i++; 
-                                                                        
-                        }                                                        
-                }                        
+        $i = 0;         
+        //Added to save if must save sent messages in shared folder
+        $acl_save_sent_in_shared = array();
+       
+        if($params['uids']) {
+                $uids = explode(";",$params['uids']);
+                $this->imap = new imap_functions();                     
+                foreach($uids as $index => $uid){
+                        $params = array();
+                        //Added to save if user has create permission
+                        $acl_create_message = array();
+                        $acl = $this->imap->getacltouser($uid ,true);
+  
+                        if ( preg_match("/p/",$acl )){                         
+                            $filter .= "(uid=$uid)";                                                    
+                            $acl_save_sent_in_shared[ $i ] =$uid;
+                            $i++;
+                                                                       
+                        }                                                       
+                }                       
         }
 		
@@ -937,5 +937,5 @@
 				}
 			}
-		
+
 			$info['myname'] = $_SESSION['phpgw_info']['expressomail']['user']['fullname'];
 
@@ -953,14 +953,14 @@
 				$result = ldap_get_entries($this->ds, $sr);
 				for ($j = 0;$j < $result["count"]; $j++){
-					$result[$j]['cn'][0] = utf8_decode($result[$j]['cn'][0]); 
-                    $result[$j]['mail'][0] = $result[$j]['mail'][0]; 
-                    $result[$j]['save_shared'][0] = 'n'; 
-                    $info[$info['count']] = $result[$j]; 
-                    $info['count'] = (int)$info['count'] + 1; 					
+					$result[$j]['cn'][0] = utf8_decode($result[$j]['cn'][0]);
+					$result[$j]['mail'][0] = $result[$j]['mail'][0];
+					$result[$j]['save_shared'][0] = 'n';
+					$info[$info['count']] = $result[$j];
+					$info['count'] = (int)$info['count'] + 1;			
 				}
 			}
 
 			$_SESSION['phpgw_info']['expressomail']['user']['shared_mailboxes'] = $info;
-			
+
 			return $info;
 		}
Index: branches/2.4/expressoMail1_2/inc/hook_settings.inc.php
===================================================================
--- branches/2.4/expressoMail1_2/inc/hook_settings.inc.php	(revision 6055)
+++ branches/2.4/expressoMail1_2/inc/hook_settings.inc.php	(revision 7228)
@@ -345,4 +345,10 @@
 create_check_box('Show previous message, after delete actual message?','delete_and_show_previous_message','Enable this option if you want to read the next message everytime you delete a message');
 create_check_box('Do you wanna receive an alert for new messages?','alert_new_msg','Everytime you receive new messages you will be informed');
+
+
+create_check_box('Wish you receive notifications for: "New messages", "Filter criteria", "Event alerts"?','notifications','Everytime you receive new messages you will be informed');
+
+
+
 create_check_box('Show default view on main screen?','mainscreen_showmail','Show unread messages in your home page');
 create_check_box('Do you want to use remove attachments function?','remove_attachments_function','It allow you to remove attachments from messages');
@@ -507,4 +513,6 @@
 }
 
+create_check_box('Would you like to have a read receipt option to read messages?','confirm_read_message','');
+
 $default = array(
 	'text' => lang('simple text'),
Index: branches/2.4/expressoMail1_2/inc/class.dynamic_contacts.inc.php
===================================================================
--- branches/2.4/expressoMail1_2/inc/class.dynamic_contacts.inc.php	(revision 5134)
+++ 	(revision )
@@ -1,200 +1,0 @@
-<?php
-/**********************************************************************************\
-	* ExpressoMail1_2                 										   *
-	* by Gustavo Sandini Linden (gustavo.linden@serpro.gov.br)						   *
-	* ---------------------------------------------------------------------------------*
-	*  This program is free software; you can redistribute it and/or modify it         *
-	*  under the terms of the GNU General Public License as published by the           *
-	*  Free Software Foundation; either version 2 of the License, or (at your          *
-	*  option) any later version.											           *
-	\**********************************************************************************/
-	
-include_once('class.db_functions.inc.php');
-include_once('class.functions.inc.php');
-	
-	/**
-	 * dynamic_contacts - User's dynamic contact class
-	 * @package dynamic_contacts
-	 * @author Gustavo S. Linden
-	 * @copyright 2008 - Gustavo S. Linden
-	 * 
-	 * TODO: Check if email already exists in contactcenter!!
-	 * 
-	 */	
-	class dynamic_contacts
-	{
-		public $contacts;
-		public $db;
-		public $number_of_contacts;
-		public $functions; 
-		
-		/**
-     	* Constructor
-     	* 
-       	*/
-		function __construct()
-		{
-			$this->db = new db_functions();
-			$this->contacts = $this->db->get_dynamic_contacts();
-			$this->number_of_contacts = $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['number_of_contacts'];
-			$this->functions = new functions();
-		}
-		
-		/**
-		* get dynamic contacts
-		*
-		* @return array $contacts The list of fields to be returned. The format is:
-				$contacts = array(
-					'timestamp' => '1220558565',
-					'email => 'some@email'
-				);
-		*/
-		function get_dynamic_contacts()
-		{
-			return $this->contacts;  
-		}
-		
-		/**
-		* get number of contacts
-		*
-		* @return int $number_of_contacts 
-		* maximum number of contact allowed by administration
-		* if not set return undefined  
-		*/
-		function get_number_of_contacts()
-		{
-			return $this->number_of_contacts;  
-		}
-	
-		/**
-		* get dynamic contacts in string format
-		*
-		* @return string $contact of contacts in format ';some@email,;other@email,'
-		* this is used in js/DropDownContacts.js  
-		*/
-		function dynamic_contact_toString()
-		{
-			$contact='';
-			if($this->contacts)
-			{
-				foreach($this->contacts as $item => $valor)
-					$contact .= str_replace("#",";",$this->contacts[$item]['email']) . ',';
-				//Retira ultima virgula.
-				$contact = substr($contact,0,(strlen($contact) - 1));
-				return $contact;
-			}
-			else
-				return false;
-		}
-		
-		/**
-		* add dynamic contacts in database
-		*
-		* this function runs thru the array and check if the email sent has new contacts
-		* or not. If the contact is new, insert new array $contact in array $contacts else
-		* search existing contact to update timestamp. 
-		*
-		* @param string $full_email_address to add eg. 'some@address,other@email,email@address' 
-		* @return array $contacts The list of fields to be returned. The format is:
-				$contacts = array(
-					'timestamp' => '1220558565',
-					'email => 'some@email'
-				);
-		* this is used in inc/class.db_function.inc.php to insert/update in database  
-		*/
-		function add_dynamic_contacts($full_email_address)
-		{
-			// Trim all whitespaces and duplicated commas from full_email_address
-			$full_email_address = preg_replace('{(,)\1+}',',',$full_email_address);
-			$parse_address = imap_rfc822_parse_adrlist($full_email_address, "");
-			$new_contacts = array();
-			foreach ($parse_address as $val)
-			{
-				if ($val->mailbox == "INVALID_ADDRESS")
-					continue;
-				if ($this->contact_exist_in_ContactCenter($val->mailbox."@".$val->host))
-					continue;
-
-				if(!$this->contacts) // Used one time to insert the first contact in database
-				{
-					$this->db->insert_contact($val->personal."#".$val->mailbox."@".$val->host);
-					// Just new contact added.
-					$new_contacts[] = $val->personal.";".$val->mailbox."@".$val->host; 
-					$this->contacts = $this->db->get_dynamic_contacts();
-				}
-				else
-				{
-					$older_contact_time=time();
-					$new_contact_flag = true; // Assume that all email are new in dynamic contact
-					foreach($this->contacts as $item => $valor)
-					{
-						if($this->contacts[$item]['email'] == $val->personal."#".$val->mailbox."@".$val->host) // check if email already exists
-						{	
-							$this->contacts[$item]['timestamp'] = time(); //update timestamp of email
-							$new_contact_flag = false; //email exist!
-						}
-						if($this->contacts[$item]['timestamp'] < $older_contact_time) //search for oldest email
-						{
-							$older_contact = $item; 
-							$older_contact_time = $this->contacts[$item]['timestamp'];
-						}
-					}
-					if ($new_contact_flag == true) //new contact!
-					{
-						// Just new contact added.
-						$new_contacts[] = $val->personal.";".$val->mailbox."@".$val->host;
-						if($this->number_of_contacts > count($this->contacts))
-						{
-							$this->contacts[] = array( 'timestamp'	=> time(),
-														'email'         => $val->personal."#".$val->mailbox."@".$val->host);
-						}
-						if($this->number_of_contacts <= count($this->contacts))
-						{
-							$this->contacts[$older_contact] = array( 'timestamp'	=> time(),
-																		'email'         => $val->personal."#".$val->mailbox."@".$val->host);
-						}
-					}
-				}
-			}
-			$this->db->update_contacts($this->contacts);
-			return implode(",;",$new_contacts);
-		}
-		
-		/**
-		* Verify if contact exist in ContactCenter
-		*
-		* this function gets an email and check if the email sent is already on users's personal contacts
-		* or not.  
-		*
-		* @param string $full_email_address to add eg. 'some@address,other@email,email@address' 
-		* @return boolean  
-		*/
-		function contact_exist_in_ContactCenter($email)
-		{
-			$contactcenter_string = $this->db->get_cc_contacts();
-			$cc_email = explode(",",$contactcenter_string);
-			foreach ($cc_email as $item => $valor) 
-			{
-				$aux = explode(";",$cc_email[$item]);
-				if($email == $aux[1])
-				{
-					return true;	
-				}
-				  
-			}
-			return false;
-		}
-		
-		/**
-		* delete dynamic contacts from database
-		*
-		* This function removes the dynamic contacts of the current user from the database.
-		* It uses inc/class.db_function.inc.php to remove.
-		*
-		*/
-		function delete_dynamic_contacts()
-		{
-			$this->db->remove_dynamic_contact($this->db->user_id,__LINE__,__FILE__);
-		}
-	}
-?>
