Index: branches/2.4/expressoMail1_2/inc/class.imap_functions.inc.php
===================================================================
--- branches/2.4/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 6840)
+++ branches/2.4/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 6859)
@@ -4281,110 +4281,78 @@
 	{
 		$this->ldap = new ldap_functions();
-
-		$return = array();
 		$mbox_stream = $this->open_mbox();
 		$mbox_acl = imap_getacl($mbox_stream, 'INBOX');
 
-		$i = 0;
+		$oldAcls = array('d' , 'c' , 'a'); 
+        $newAcls = array('xte','ik', ''); 
+
+        $return = array(); 
 		foreach ($mbox_acl as $user => $acl)
 		{
-			if ($user != $this->username)
-			{
-				$return[$i]['uid'] = $user;
-				$return[$i]['cn'] = $this->ldap->uid2cn($user);
-			}
-			$i++;
-		}
-		return $return;
-	}
-
-	function setacl($params)
-	{
-		$old_users = $this->getacl();
-		if (!count($old_users))
-			$old_users = array();
-
-		$tmp_array = array();
-		foreach ($old_users as $index => $user_info)
+				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."*");                 
+
+            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)
 		{
-			$tmp_array[$index] = $user_info['uid'];
-		}
-		$old_users = $tmp_array;
-
-		$users = unserialize($params['users']);
-		if (!count($users))
-			$users = array();
-
-		//$add_share = array_diff($users, $old_users);
-		$remove_share = array_diff($old_users, $users);
-
-		$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 (count($add_share))
+			if (is_array($mailboxes_list)) 
+            { 
+                foreach ($mailboxes_list as $key => $val) 
+                { 
+                    $folder = str_replace($serverString, "", imap_utf7_decode($val->name)); 
+                    $folder = str_replace("&-", "&", $folder); 
+                    imap_setacl ($mbox_stream, $folder, "$user", $value['acls']); 
+
+                } 
+            } 
+            if(isset($old_users[$user])) 
+                    unset($old_users[$user]); 
+            } 
+
+            foreach ($old_users as $user => $value)
 		{
-			foreach ($add_share as $index=>$uid)
-			{
-		        if (is_array($mailboxes_list))
-        		{
-                	foreach ($mailboxes_list as $key => $val)
-                	{
-                        $folder = str_replace($serverString, "", imap_utf7_decode($val->name));
-						imap_setacl ($mbox_stream, $folder, "$uid", "lrswipcda");
-                	}
-        		}
-			}
-		}*/
-
-		if (count($remove_share))
-		{
-			foreach ($remove_share as $index=>$uid)
-			{
-                            if (is_array($mailboxes_list))
-                            {
-                                foreach ($mailboxes_list as $key => $val)
-                                {
-                                    $folder = str_replace($serverString, "", imap_utf7_decode($val->name));
-                                    $folder = str_replace("&-", "&", $folder);
-                                    imap_setacl ($mbox_stream, $folder, "$uid", "");
-                                }
-                            }
-			}
-		}
+			if (is_array($mailboxes_list)) 
+            { 
+                foreach ($mailboxes_list as $key => $val) 
+                { 
+                    $folder = str_replace($serverString, "", imap_utf7_decode($val->name)); 
+                    $folder = str_replace("&-", "&", $folder); 
+                    imap_setacl ($mbox_stream, $folder, "$user", ""); 
+
+                } 
+            } 
+            } 
+
 
 		return true;
 	}
 
-	function getaclfromuser($params)
-	{
-		$useracl = $params['user'];
-		$return = array();
-		$mbox_stream = $this->open_mbox();
-		if($params['getShared']){		
-			 $mbox_acl = imap_getacl($mbox_stream, 'user'.$this->imap_delimiter.$useracl); 		
-			foreach ($mbox_acl as $user => $acl)
-			{
-				if (($user == $this->username) && ($user != $useracl))
-				{
-					$return[$useracl] = $acl;
-				}
-			}			 
-		}else {	
-			$mbox_acl = imap_getacl($mbox_stream, 'INBOX');
-			foreach ($mbox_acl as $user => $acl)
-			{
-				if (($user != $this->username) && ($user == $useracl))
-				{
-					$return[$user] = $acl;
-				}
-			}
-		}
-		if(count($return) == 0)
-				$return[$useracl] = 'false';
-				
-		return $return;
-	}
 
 	function getacltouser($user, $decode = false)
@@ -4408,33 +4376,4 @@
                 else 
                     return '';
-	}
-
-
-	function setaclfromuser($params)
-	{
-		$user = $params['user'];
-		$acl = $params['acl'];
-
-		$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 (is_array($mailboxes_list))
-		{
-			foreach ($mailboxes_list as $key => $val)
-			{
-				$folder = str_replace($serverString, "", imap_utf7_encode($val->name));
-				$folder = str_replace("&-", "&", $folder);
-				if (!imap_setacl ($mbox_stream, $folder, $user, $acl))
-				{
-					$return = imap_last_error();
-				}
-			}
-		}
-		if (isset($return))
-			return $return;
-		else
-			return true;
 	}
 
Index: branches/2.4/expressoMail1_2/inc/class.ldap_functions.inc.php
===================================================================
--- branches/2.4/expressoMail1_2/inc/class.ldap_functions.inc.php	(revision 6754)
+++ branches/2.4/expressoMail1_2/inc/class.ldap_functions.inc.php	(revision 6859)
@@ -88,5 +88,8 @@
 		$this->ldap_context = $_SESSION['phpgw_info']['expressomail']['server']['ldap_context'];
 
-		if($_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']) {
Index: branches/2.4/expressoMail1_2/inc/class.functions.inc.php
===================================================================
--- branches/2.4/expressoMail1_2/inc/class.functions.inc.php	(revision 6754)
+++ branches/2.4/expressoMail1_2/inc/class.functions.inc.php	(revision 6859)
@@ -18,5 +18,5 @@
                     
                     $zones = $this->getTimezones();
-                    $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['timezone'] = $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['timezone'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['timezone'] : sprintf("%s", array_search("America/Sao_Paulo", $zones));
+                    $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['timezone'] = isset($GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['timezone']) ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['timezone'] : sprintf("%s", array_search("America/Sao_Paulo", $zones));
 
                     $timezone_index = $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['timezone'];
Index: branches/2.4/expressoMail1_2/js/sharemailbox.js
===================================================================
--- branches/2.4/expressoMail1_2/js/sharemailbox.js	(revision 6754)
+++ branches/2.4/expressoMail1_2/js/sharemailbox.js	(revision 6859)
@@ -2,4 +2,6 @@
 	{
 		this.xtools 		= new xtools('../expressoMail1_2/templates/');
+
+        var users;
 	}
 
@@ -33,47 +35,46 @@
 	cShareMailbox.prototype.getaclfromuser = function(user)
 	{
-		var handler_getaclfromuser = function(data)
-		{
-			Element('em_input_readAcl').checked		= false;
-			Element('em_input_deleteAcl').checked	= false;
-			Element('em_input_writeAcl').checked	= false;
-			Element('em_input_sendAcl').checked		= false;
-			
-            Element('em_input_deleteAcl').disabled	= true;
-            Element('em_input_writeAcl').disabled	= true;
-			
-			if (data[user].indexOf('lrs',0) >= 0)
-			{
-				Element('em_input_sendAcl').disabled = false;
-				Element('em_input_deleteAcl').disabled = false;
-                Element('em_input_writeAcl').disabled = false ;
-				Element('em_input_readAcl').checked = true;
-			}
-			else
-			{
-				Element('em_input_sendAcl').disabled = true;
-			}
-			
-			if (data[user].indexOf('d',0) >= 0)
-			{
-				Element('em_input_deleteAcl').checked = true;
-				Element('em_input_deleteAcl').disabled = false;
-			}
-			
-			if (data[user].indexOf('w',0) >= 0)
-			{
-				Element('em_input_writeAcl').checked = true;
-                Element('em_input_writeAcl').disabled = false
-			}
-			
-			if (data[user] != "false" && data[user].indexOf('p',0) >= 0)
-			{
-				Element('em_input_sendAcl').disabled = false;
-				Element('em_input_sendAcl').checked = true;
-			}			
-
-		}
-		
-		cExecute ("$this.imap_functions.getaclfromuser&user="+user, handler_getaclfromuser);
+	Element('em_input_readAcl').checked             = false; 
+    Element('em_input_deleteAcl').checked   = false; 
+    Element('em_input_writeAcl').checked    = false; 
+    Element('em_input_sendAcl').checked             = false; 
+     
+Element('em_input_deleteAcl').disabled      = true; 
+Element('em_input_writeAcl').disabled       = true; 
+     
+    if ((this.users[user].acls.indexOf('l',0) >= 0) && 
+            (this.users[user].acls.indexOf('r',0) >= 0) && 
+            (this.users[user].acls.indexOf('s',0) >= 0) ) 
+    { 
+            Element('em_input_sendAcl').disabled = false; 
+            Element('em_input_deleteAcl').disabled = false; 
+    Element('em_input_writeAcl').disabled = false ; 
+            Element('em_input_readAcl').checked = true; 
+    } 
+    else 
+            Element('em_input_sendAcl').disabled = true; 
+     
+     
+    if ((this.users[user].acls.indexOf('x',0) >= 0) && 
+            (this.users[user].acls.indexOf('t',0) >= 0) && 
+            (this.users[user].acls.indexOf('e',0) >= 0) ) 
+    { 
+            Element('em_input_deleteAcl').checked = true; 
+            Element('em_input_deleteAcl').disabled = false; 
+    } 
+     
+    if ((this.users[user].acls.indexOf('w',0) >= 0) && 
+            (this.users[user].acls.indexOf('i',0) >= 0) && 
+            (this.users[user].acls.indexOf('k',0) >= 0) ) 
+    { 
+            Element('em_input_writeAcl').checked = true; 
+    Element('em_input_writeAcl').disabled = false 
+    } 
+     
+    if (this.users[user].acls != "false" && this.users[user].acls.indexOf('p',0) >= 0) 
+    { 
+            Element('em_input_sendAcl').disabled = false; 
+            Element('em_input_sendAcl').checked = true; 
+    }                        
 	}
 	
@@ -105,24 +106,18 @@
             Element('em_input_deleteAcl').checked	= false;
             Element('em_input_writeAcl').disabled	= true;
-            Element('em_input_writeAcl').checked	= false;
-                        
+            Element('em_input_writeAcl').checked	= false;             
 		}
 				
 		if (Element('em_input_deleteAcl').checked)
-			acl += 'ida';
+			acl += 'xte';
 
 		if (Element('em_input_writeAcl').checked) {
-			acl += 'wc';			
+			acl += 'wik';			
 		}		
 		if (Element('em_input_sendAcl').checked){
-			acl += 'pa';			
-		}
-		
-		var handler_setaclfromuser = function(data) {
-			if (!data)
-				alert(data);	
-			return true;
-		}
-		cExecute ("$this.imap_functions.setaclfromuser&user="+user+"&acl="+acl, handler_setaclfromuser);
+			acl += 'p';                      
+        } 
+
+        this.users[user].acls = acl;
 	}
 	
@@ -172,6 +167,5 @@
 									click: function()
 									{
-										$(this).dialog("destroy");
-										div.removeChild(div.firstChild);	
+										$(div).dialog("close");	
 									},
 									style: "margin-top: -2.1em" 
@@ -180,51 +174,28 @@
 									text: get_lang("Save"),
 									click: function()
-									{
-										// Needed select all options from select
-										var users_setacl = new Array();
-										var select_users = Element('em_select_sharefolders_users');
-
-										for(var i = 0; i < select_users.options.length; i++)
-										{
-											users_setacl[i] = select_users.options[i].value;
-										}
-										var attributes = connector.serialize(users_setacl);
-										
-										var handler_save = function(data)
-										{
-											if (data)
-											{
-												var sharedFoldersUsers = document.getElementById('em_select_sharefolders_users');
-												
-												for( var i = 0;i < sharedFoldersUsers.options.length; i++ )
-												{
-													if( sharedFoldersUsers.options[i].selected )
-													{
-														var value	= sharedFoldersUsers.options[i].value;
-														var text	= sharedFoldersUsers.options[i].text;
-														sharedFoldersUsers.options[i].parentNode.removeChild(sharedFoldersUsers.options[i]);
-														sharedFoldersUsers.options[sharedFoldersUsers.options.length] = new Option( text, value, false, false);
-													}
-												}
-												
-												Element('em_input_readAcl').checked		= false;
-												Element('em_input_deleteAcl').checked	= false;
-												Element('em_input_writeAcl').checked	= false;
-												Element('em_input_sendAcl').checked		= false;
-												
-									            Element('em_input_deleteAcl').disabled	= true;
-									            Element('em_input_writeAcl').disabled 	= true;
-												Element('em_input_sendAcl').disabled	= true;
-
-												//$("#sharemailbox").empty();
-												//$("#sharemailbox").dialog("destroy");
-												$("#sharemailbox").parents().find(".ui-icon-closethick").trigger("click");
-												
-												write_msg(get_lang('Shared options saved with success'));
-
-											}
-										}
-
-										cExecute ("$this.imap_functions.setacl", handler_save, 'users='+attributes);
+									{                                                                        
+	                                        $.ajax({ 
+	                                                       url: 'controller.php?' + $.param( { 
+	                                                                                                  action: '$this.imap_functions.setacl', 
+	                                                                                              acls: connector.serialize(sharemailbox.users)}  
+	                                                                                              ), 
+	                                                          success: function( data ){ 
+	                                                              data = connector.unserialize( data ); 
+	                                                               
+	                                                              if( data ) 
+	                                                                  { 
+	                                                                        write_msg(get_lang('Shared options saved with success')); 
+	                                                                        $(div).dialog("close"); 
+
+	                                                                  } 
+	                                                          }, 
+	                                                          beforeSend: function( jqXHR, settings ){ 
+	                                                                connector.showProgressBar(); 
+	                                                          }, 
+	                                                          complete: function( jqXHR, settings ){ 
+	                                                                connector.hideProgressBar(); 
+	                                                          } 
+
+	                                                   }); 
 										
 									},
@@ -267,9 +238,7 @@
 
 		var selectSharedFolders = Element('em_select_sharefolders_users');
-		
-		for( var i in optionsData )
-		{
-			selectSharedFolders.options[selectSharedFolders.options.length] = new Option(optionsData[i].cn, optionsData[i].uid, false, false);
-		}
+		this.users = optionsData; 
+ 	    for( var i in optionsData )      
+ 	            selectSharedFolders.options[selectSharedFolders.options.length] = new Option(optionsData[i].cn, i, false, false);
 	}
 	
@@ -331,4 +300,9 @@
 					}
 				}
+				var newobject = new Object; 
+                newobject.cn = select_available_users.options[i].text; 
+                newobject.acls = ""; 
+                this.users[select_available_users.options[i].value] = newobject;
+
 			}
 		}
@@ -339,4 +313,7 @@
 			select_users.outerHTML = select_users.outerHTML;
 		}
+
+
+
 	}
 
@@ -349,20 +326,7 @@
 		var user = select.options[select.selectedIndex].value;
 		
-		var handler_setaclfromuser = function(data) {
-			if (!data)
-				alert(data);	
-			return true;
-		}
-		
-		cExecute ("$this.imap_functions.setaclfromuser&user="+user+"&acl="+acl, handler_setaclfromuser);
-	  
-	
-		for( var i = 0 ; i < select_users.options.length; i++ )
-		{
-			if( select_users.options[i].selected )
-			{
-				select_users.options[i--] = null;
-			}
-		}
+		delete this.users[user]; 
+ 		 
+ 	    select.options[select.selectedIndex] = null;
 		
 		Element('em_input_readAcl').checked = false;
@@ -371,4 +335,5 @@
 		Element('em_input_sendAcl').checked = false;
 	
+
 	}
 		
