Index: /trunk/expressoMail1_2/inc/class.ldap_functions.inc.php
===================================================================
--- /trunk/expressoMail1_2/inc/class.ldap_functions.inc.php	(revision 344)
+++ /trunk/expressoMail1_2/inc/class.ldap_functions.inc.php	(revision 371)
@@ -595,27 +595,42 @@
 		return false;
 	}
-	function getSharedUsersFrom($params){		
-		$uids = explode(";",$params['uids']);
-
-		$this->imap = new imap_functions();
+	function getSharedUsersFrom($params){						
 		$filter = '';
-
-		foreach($uids as $index => $uid){
-			$params = array();		
-			$acl = $this->imap->getacltouser($uid);
-			if(preg_match("/a/",$acl))
-				$filter .= "(uid=$uid)";
-		}
-
-		$this->ldapRootConnect(false);
-		$filter="(&(phpgwAccountType=u)(|$filter))";
-		if ($this->ds) {					
+		$i = 0;
+		if($params['uids']) {
+			$uids = explode(";",$params['uids']);		
+			$this->imap = new imap_functions();		
+			foreach($uids as $index => $uid){
+				$params = array();		
+				$acl = $this->imap->getacltouser($uid);
+				if(preg_match("/a/",$acl))
+					$filter .= "(uid=$uid)";
+			}
+		}
+		
+		$this->ldapRootConnect(false);		
+		if ($this->ds) {
 			$justthese = array("cn","mail");
-			$sr		=	ldap_search($this->ds, $this->ldap_context, $filter, $justthese);
-			ldap_sort($this->ds,$sr,"cn");			
-			$info 	= 	ldap_get_entries($this->ds, $sr);
-			$info['myname'] = $_SESSION['phpgw_info']['expressomail']['user']['fullname'];						
-			for ($i = 0;$i < $info["count"]; $i++)
-				$info[$i]['cn'][0] = utf8_decode($info[$i]['cn'][0]);
+			if($filter) {
+				$filter="(&(phpgwAccountType=u)(|$filter))";
+				$sr		=	ldap_search($this->ds, $this->ldap_context, $filter, $justthese);
+				ldap_sort($this->ds,$sr,"cn");			
+				$info 	= 	ldap_get_entries($this->ds, $sr);										
+				for ($i = 0;$i < $info["count"]; $i++)
+					$info[$i]['cn'][0] = utf8_decode($info[$i]['cn'][0]);
+			}
+			$info['myname'] = $_SESSION['phpgw_info']['expressomail']['user']['fullname'];
+			
+			//Find institucional_account.
+			$filter="(&(phpgwAccountType=i)(mailForwardingAddress=".$_SESSION['phpgw_info']['expressomail']['user']['email']."))";
+			$sr	= ldap_search($this->ds, $this->ldap_context, $filter, $justthese);			
+			if(!ldap_count_entries($this->ds,$sr))
+				return $info;
+			ldap_sort($this->ds,$sr,"cn");
+			$result = ldap_get_entries($this->ds, $sr);
+			for ($j = 0;$j < $result["count"]; $j++){
+				$info[$i]['cn'][0] = utf8_decode($result[$j]['cn'][0]);
+				$info[$i++]['mail'][0] = $result[$j]['mail'][0];
+			}
 			return $info;
 		}
Index: /trunk/expressoMail1_2/js/draw_api.js
===================================================================
--- /trunk/expressoMail1_2/js/draw_api.js	(revision 356)
+++ /trunk/expressoMail1_2/js/draw_api.js	(revision 371)
@@ -1733,4 +1733,7 @@
 	// The element was loaded and populated...so return.
 	if(el_shared_users){	
+		// Nothing to work...so return.
+		if(el_shared_users.options.length == 0)
+			return;
 		tr1_1.style.display = '';
 		for (var x = 0; x < el_shared_users.options.length; x++) {
@@ -1761,27 +1764,22 @@
       }
     }
-	// Nothing to work...so return.
-	if(sharedUsers.length == 0) 
-		return;
 
 	// Handler function for cExecute
 	var h_user = function(data) {
-		if(data.length == 0) {
-			return false;			
-		}
-		tr1_1.style.display = '';
-		var _option = document.createElement("OPTION");
-		_option.text =  '"'+data.myname+'" <'+Element("user_email").value+'>';
-		_option.value  = data.myname+";"+Element("user_email").value;
-		sel_from.options[sel_from.options.length] = _option;
-	
-		var options = '';
-		for (var x = 0; x < data.length; x++)	{
+		if(data.length > 0) {
+			tr1_1.style.display = '';
 			var _option = document.createElement("OPTION");
-			_option.text = '"'+data[x].cn[0] + '" <'+data[x].mail[0]+'>';
-			_option.value = data[x].cn[0] + ';'+data[x].mail[0];
-			sel_from.options[sel_from.options.length] = _option	;
-		}
-		
+			_option.text =  '"'+data.myname+'" <'+Element("user_email").value+'>';
+			_option.value  = data.myname+";"+Element("user_email").value;
+			sel_from.options[sel_from.options.length] = _option;
+	
+			var options = '';
+			for (var x = 0; x < data.length; x++)	{
+				var _option = document.createElement("OPTION");
+				_option.text = '"'+data[x].cn[0] + '" <'+data[x].mail[0]+'>';
+				_option.value = data[x].cn[0] + ';'+data[x].mail[0];
+				sel_from.options[sel_from.options.length] = _option	;
+			}
+		}
 		var shared_users_from = Element("el_shared_users");
 		if(!shared_users_from) {
