Index: trunk/expressoAdmin1_2/inc/class.uiaccounts.inc.php
===================================================================
--- trunk/expressoAdmin1_2/inc/class.uiaccounts.inc.php	(revision 72)
+++ trunk/expressoAdmin1_2/inc/class.uiaccounts.inc.php	(revision 81)
@@ -307,4 +307,6 @@
 				'changequote_disabled'			=> $this->functions->check_acl($manager_lid,'change_users_quote') ? '' : 'readonly',
 				'imapDelimiter'					=> $_SESSION['phpgw_info']['expresso']['email_server']['imapDelimiter'],
+				'input_mailalternateaddress_fields' => '<input type="text" name="mailalternateaddress[]" id="mailalternateaddress" autocomplete="off" value="{mailalternateaddress}" {disabled} size=30>',
+				'input_mailforwardingaddress_fields'=> '<input type="text" name="mailforwardingaddress[]" id="mailforwardingaddress" autocomplete="off" value="{mailforwardingaddress}" {disabled} size=30>',
 
 				//Third ABA
@@ -530,4 +532,33 @@
 					}
 				}
+			}
+			
+			// Mail Alternate & Forwarding
+			if (is_array($user_info['mailalternateaddress']))
+			{
+				for ($i = 0; $i < $user_info['mailalternateaddress']['count']; $i++)
+				{
+					if ($i > 0)
+						$input_mailalternateaddress_fields .= '<br>';
+					$input_mailalternateaddress_fields .= '<input type="text" name="mailalternateaddress[]" id="mailalternateaddress" autocomplete="off" value="'.$user_info['mailalternateaddress'][$i].'" {disabled} size=30>';
+				}
+			}
+			else
+			{
+				$input_mailalternateaddress_fields = '<input type="text" name="mailalternateaddress[]" id="mailalternateaddress" autocomplete="off" value="" {disabled} size=30>';
+			}
+
+			if (is_array($user_info['mailforwardingaddress']))
+			{
+				for ($i = 0; $i < $user_info['mailforwardingaddress']['count']; $i++)
+				{
+					if ($i > 0)
+						$input_mailforwardingaddress_fields .= '<br>';
+					$input_mailforwardingaddress_fields .= '<input type="text" name="mailforwardingaddress[]" id="mailforwardingaddress" autocomplete="off" value="'.$user_info['mailforwardingaddress'][$i].'" {disabled} size=30>';
+				}
+			}
+			else
+			{
+				$input_mailforwardingaddress_fields = '<input type="text" name="mailforwardingaddress[]" id="mailforwardingaddress" autocomplete="off" value="" {disabled} size=30>';
 			}
 
@@ -624,6 +655,10 @@
 				'accountstatus_checked'		=> $user_info['accountstatus'] == 'active' ? 'CHECKED' : '',
 				'mail'						=> $user_info['mail'],
-				'mailalternateaddress'		=> $user_info['mailalternateaddress'],
-				'mailforwardingaddress'		=> $user_info['mailforwardingaddress'],
+				
+				//'mailalternateaddress'		=> $user_info['mailalternateaddress'],
+				//'mailforwardingaddress'		=> $user_info['mailforwardingaddress'],
+				'input_mailalternateaddress_fields'	=> $input_mailalternateaddress_fields,
+				'input_mailforwardingaddress_fields'=> $input_mailforwardingaddress_fields,
+				
 				'deliverymode_checked'		=> $user_info['deliverymode'] == 'forwardOnly' ? 'CHECKED' : '',
 				
Index: trunk/expressoAdmin1_2/inc/class.user.inc.php
===================================================================
--- trunk/expressoAdmin1_2/inc/class.user.inc.php	(revision 72)
+++ trunk/expressoAdmin1_2/inc/class.user.inc.php	(revision 81)
@@ -111,9 +111,15 @@
 						
 				// Cria user_info no caso de ter alias e forwarding email.
-				if ($params['mailalternateaddress'] != '')
-					$user_info['mailAlternateAddress']	= $params['mailalternateaddress'];
-			
-				if ($params['mailforwardingaddress'] != '')
-					$user_info['mailForwardingAddress'] = $params['mailforwardingaddress'];
+				foreach ($params['mailalternateaddress'] as $index=>$mailalternateaddress)
+				{
+					if ($mailalternateaddress != '')
+						$user_info['mailAlternateAddress'][] = $mailalternateaddress;
+				}
+			
+				foreach ($params['mailforwardingaddress'] as $index=>$mailforwardingaddress)
+				{
+					if ($mailforwardingaddress != '')
+						$user_info['mailForwardingAddress'][] = $mailforwardingaddress;
+				}
 				
 				if ($params['deliverymode'])
@@ -273,15 +279,14 @@
 			$dn = 'uid=' . $old_values['uid'] . ',' . strtolower($old_values['context']);
 			$diff = array_diff($new_values, $old_values);
+			
 			/*
 			echo '<pre>';
 			echo '--- OLD: ';
-			print_r($old_values['passwd_expired']);
+			print_r($old_values);
 			echo '<br>--- NEW: ';
-			print_r($new_values['passwd_expired']);
+			print_r($new_values);
 			echo '<br>';
-			print_r($diff);
-			return;
 			*/
-			
+
 			$manager_account_lid = $_SESSION['phpgw_session']['session_lid'];
 			if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) &&
@@ -338,4 +343,5 @@
 					$this->db_functions->write_log("alterado mail do usuario",'',$dn,'','');
 				}
+				/*
 				if (($diff['mailalternateaddress']) && ($old_values['mailalternateaddress'] != ''))
 				{
@@ -348,4 +354,5 @@
 					$this->db_functions->write_log("alterado mailforwardingaddress do usuario",'',$dn,'','');
 				}
+				*/
 				if (($diff['telephonenumber']) && ($old_values['telephonenumber'] != ''))
 				{
@@ -460,5 +467,5 @@
 			
 			////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-			// ADD ou REMOVE some attributes
+			// ADD or REMOVE some attributes
 			////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 			
@@ -546,6 +553,4 @@
 				if (($old_values['accountstatus'] == '') && ($new_values['accountstatus'] != ''))
 				{
-					echo '<pre>';
-					print_r($old_values);
 					$ldap_add['accountstatus'] = 'active';
 					$this->db_functions->write_log("ativado conta de email do usuario",'',$dn,'','');
@@ -556,4 +561,5 @@
 					$this->db_functions->write_log("desativado conta de email do usuario",'',$dn,'','');
 				}
+				/*
 				////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 				// MAILALTERNATEADDRESS
@@ -580,4 +586,71 @@
 					$this->db_functions->write_log("removido mailforwardingaddress ao usuario",'',$dn,'','');
 				}
+				*/
+				
+				////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+				// MAILALTERNATEADDRESS
+				if (!$new_values['mailalternateaddress'])
+					$new_values['mailalternateaddress'] = array();
+				if (!$old_values['mailalternateaddress'])
+					$old_values['mailalternateaddress'] = array();
+				$add_mailalternateaddress = array_diff($new_values['mailalternateaddress'], $old_values['mailalternateaddress']);
+				$remove_mailalternateaddress = array_diff($old_values['mailalternateaddress'], $new_values['mailalternateaddress']);
+				foreach ($add_mailalternateaddress as $index=>$mailalternateaddress)
+				{
+					if ($mailalternateaddress != '')
+					{
+						$ldap_add['mailalternateaddress'][] = $mailalternateaddress;
+						$this->db_functions->write_log("adicionado mailalternateaddress $mailalternateaddress ao usuario $dn",'',$dn,'','');
+					}
+				}
+				foreach ($remove_mailalternateaddress as $index=>$mailalternateaddress)
+				{
+					if ($mailalternateaddress != '')
+					{
+						if ($index !== 'count')
+						{
+							$ldap_remove['mailalternateaddress'][] = $mailalternateaddress;
+							$this->db_functions->write_log("removido mailalternateaddress $mailalternateaddress do usuario $dn",'',$dn,'','');
+						}
+					}
+				}
+				
+				////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+				// MAILFORWARDINGADDRESS
+				if (!$new_values['mailforwardingaddress'])
+					$new_values['mailforwardingaddress'] = array();
+				if (!$old_values['mailforwardingaddress'])
+					$old_values['mailforwardingaddress'] = array();
+				$add_mailforwardingaddress = array_diff($new_values['mailforwardingaddress'], $old_values['mailforwardingaddress']);
+				$remove_mailforwardingaddress = array_diff($old_values['mailforwardingaddress'], $new_values['mailforwardingaddress']);
+				foreach ($add_mailforwardingaddress as $index=>$mailforwardingaddress)
+				{
+					if ($mailforwardingaddress != '')
+					{
+						$ldap_add['mailforwardingaddress'][] = $mailforwardingaddress;
+						$this->db_functions->write_log("adicionado mailforwardingaddress $mailforwardingaddress ao usuario $dn",'',$dn,'','');
+					}
+				}
+				foreach ($remove_mailforwardingaddress as $index=>$mailforwardingaddress)
+				{
+					if ($mailforwardingaddress != '')
+					{
+						if ($index !== 'count')
+						{
+							$ldap_remove['mailforwardingaddress'][] = $mailforwardingaddress;
+							$this->db_functions->write_log("removido mailforwardingaddress $mailforwardingaddress do usuario $dn",'',$dn,'','');
+						}
+					}
+				}
+				
+				echo '<pre>';
+				print_r($add_mailalternateaddress);
+				print_r($remove_mailalternateaddress);
+				echo '---<br>';
+				print_r($new_values['mailforwardingaddress']);
+				print_r($add_mailforwardingaddress);
+				print_r($remove_mailforwardingaddress);
+				
+				
 				////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 				// Delivery Mode
@@ -723,4 +796,5 @@
 			if (count($ldap_add))
 			{
+				echo 'ldap-add<br>';
 				print_r($ldap_add);
 				$result = $this->ldap_functions->add_user_attributes($dn, $ldap_add);
@@ -736,4 +810,6 @@
 			if (count($ldap_remove))
 			{
+				echo 'ldap-remove<br>';
+				print_r($ldap_remove);
 				$result = $this->ldap_functions->remove_user_attributes($dn, $ldap_remove);
 				if (!$result['status'])
Index: trunk/expressoAdmin1_2/inc/class.uimanagers.inc.php
===================================================================
--- trunk/expressoAdmin1_2/inc/class.uimanagers.inc.php	(revision 64)
+++ trunk/expressoAdmin1_2/inc/class.uimanagers.inc.php	(revision 81)
@@ -18,5 +18,4 @@
 			'delete_managers'	=> True,
 			'edit_managers' 	=> True,
-			'copy_managers' 	=> True,
 			'validate'			=> True
 		);
@@ -398,37 +397,4 @@
 		}
 		
-		function copy_managers()
-		{
-			
-			
-			
-			/*
-			echo '<pre>';
-			print_r($_GET);
-			$manager_lid = $_GET['manager_lid'];
-			
-			//Pego ACL do gerente
-			$manager = $this->functions->read_acl($manager_lid);
-			//Cria vetor da ACL
-			$manager_acl = $this->functions->make_array_acl($manager[0]['acl']);
-
-			//Pesquisa no Banco e pega os valores dos apps.
-			$query = "SELECT * FROM phpgw_expressoadmin_apps WHERE manager_lid = '" . $manager_lid . "' AND context = '" . $_GET['context'] . "'";
-			$GLOBALS['phpgw']->db->query($query);
-			$i=0;
-			$manager[0]['apps'] = array();
-			while($GLOBALS['phpgw']->db->next_record())
-			{
-				$tmp[$i] = $GLOBALS['phpgw']->db->row();
-				$_POST['applications_list'][$tmp[$i]['app']] = 1;
-				$manager[0]['apps'][$tmp[$i]['app']] = 1;
-				$i++;
-			}
-
-			print_r($manager);
-			
-			*/
-		}
-		
 		function make_lang($ram_lang)
 		{
Index: trunk/expressoAdmin1_2/inc/class.bosectors.inc.php
===================================================================
--- trunk/expressoAdmin1_2/inc/class.bosectors.inc.php	(revision 64)
+++ trunk/expressoAdmin1_2/inc/class.bosectors.inc.php	(revision 81)
@@ -46,4 +46,8 @@
 			$sector_info['objectClass'][1]	= 'organizationalUnit';
 			$sector_info['objectClass'][2]	= 'phpgwAccount';
+			
+			$systemName = $GLOBALS['phpgw_info']['server']['system_name'];
+			if ($systemName != '')
+				$sector_info['phpgwSystem'] = strtolower($systemName);
 			
 			if ($_POST['sector_visible'])
Index: trunk/expressoAdmin1_2/inc/class.ldap_functions.inc.php
===================================================================
--- trunk/expressoAdmin1_2/inc/class.ldap_functions.inc.php	(revision 72)
+++ trunk/expressoAdmin1_2/inc/class.ldap_functions.inc.php	(revision 81)
@@ -774,6 +774,6 @@
 				$result['accountstatus']		= $entry[0]['accountstatus'][0];
 				$result['mail']					= $entry[0]['mail'][0];
-				$result['mailalternateaddress']	= $entry[0]['mailalternateaddress'][0];
-				$result['mailforwardingaddress']= $entry[0]['mailforwardingaddress'][0];
+				$result['mailalternateaddress']	= $entry[0]['mailalternateaddress'];
+				$result['mailforwardingaddress']= $entry[0]['mailforwardingaddress'];
 				$result['deliverymode']			= $entry[0]['deliverymode'][0];
 				$result['userPasswordRFC2617']	= $entry[0]['userpasswordrfc2617'][0];
Index: trunk/expressoAdmin1_2/inc/class.functions.inc.php
===================================================================
--- trunk/expressoAdmin1_2/inc/class.functions.inc.php	(revision 64)
+++ trunk/expressoAdmin1_2/inc/class.functions.inc.php	(revision 81)
@@ -411,5 +411,5 @@
 			
 			$justthese = array("dn");
-			$filter = "(ou=*)";
+			$filter = "(&(ou=*)(phpgwSystem=celepar))";
 			
 			foreach ($contexts as $context)
@@ -428,10 +428,4 @@
 	        foreach ($a_sectors as $context)
     	    {
-				// Necessário, pq em uma busca com ldapsearch ou=*, traz tb o próprio ou.
-				/* 
-				if (strtolower($dn) == $contexts[0])
-					continue;
-				*/
-
 				$array_dn = ldap_explode_dn ( $context, 1 );
 
Index: trunk/expressoAdmin1_2/js/jscode/groups.js
===================================================================
--- trunk/expressoAdmin1_2/js/jscode/groups.js	(revision 73)
+++ trunk/expressoAdmin1_2/js/jscode/groups.js	(revision 81)
@@ -210,4 +210,5 @@
 		select_usersInGroup.innerHTML = 'lixo' + new_options + select_usersInGroup.innerHTML;
 		select_usersInGroup.outerHTML = select_usersInGroup.outerHTML;
+		document.getElementById('ea_input_searchUser').value = "";
 	}
 }
Index: trunk/expressoAdmin1_2/js/jscode/maillists.js
===================================================================
--- trunk/expressoAdmin1_2/js/jscode/maillists.js	(revision 73)
+++ trunk/expressoAdmin1_2/js/jscode/maillists.js	(revision 81)
@@ -233,4 +233,5 @@
 		select_usersInMaillist.innerHTML = 'lixo' + new_options + select_usersInMaillist.innerHTML;
 		select_usersInMaillist.outerHTML = select_usersInMaillist.outerHTML;
+		document.getElementById('ea_input_searchUser').value = "";
 	}
 }
Index: trunk/expressoAdmin1_2/js/jscode/users.js
===================================================================
--- trunk/expressoAdmin1_2/js/jscode/users.js	(revision 72)
+++ trunk/expressoAdmin1_2/js/jscode/users.js	(revision 81)
@@ -696,2 +696,22 @@
 	}
 }
+
+function add_input_mailalternateaddress()
+{
+	var input = document.createElement("INPUT");
+	input.size = 30;
+	input.name = "mailalternateaddress[]";
+	input.setAttribute("autocomplete","off");
+	document.getElementById("td_input_mailalternateaddress").appendChild(document.createElement("br"));
+	document.getElementById("td_input_mailalternateaddress").appendChild(input);
+}
+
+function add_input_mailforwardingaddress()
+{
+	var input = document.createElement("INPUT");
+	input.size = 30;
+	input.name = "mailforwardingaddress[]";
+	input.setAttribute("autocomplete","off");
+	document.getElementById("td_input_mailforwardingaddress").appendChild(document.createElement("br"));
+	document.getElementById("td_input_mailforwardingaddress").appendChild(input);
+}
Index: trunk/expressoAdmin1_2/templates/default/accounts_form.tpl
===================================================================
--- trunk/expressoAdmin1_2/templates/default/accounts_form.tpl	(revision 72)
+++ trunk/expressoAdmin1_2/templates/default/accounts_form.tpl	(revision 81)
@@ -158,10 +158,18 @@
 		<tr bgcolor={row_off}>
 			<td>{lang_aliasemail}:</td>
-			<td><input type="text" name="mailalternateaddress" id="mailalternateaddress" autocomplete="off" value="{mailalternateaddress}" {disabled} size=30></td>
+			<td id="td_input_mailalternateaddress">
+				{input_mailalternateaddress_fields}
+				<!--<input type="text" name="mailalternateaddress[]" id="mailalternateaddress" autocomplete="off" value="{mailalternateaddress}" {disabled} size=30>-->
+				<span style="cursor:pointer" onclick="javascript:add_input_mailalternateaddress();"> +</span>
+			</td>
 		</tr>
 
 		<tr bgcolor={row_on}>
 			<td>{lang_forwardingemail}:</td>
-			<td><input type="text" name="mailforwardingaddress" id="mailforwardingaddress" autocomplete="off" value="{mailforwardingaddress}" {disabled} size=30></td>
+			<td id="td_input_mailforwardingaddress">
+				{input_mailforwardingaddress_fields}
+				<!--<input type="text" name="mailforwardingaddress[]" id="mailforwardingaddress" autocomplete="off" value="{mailforwardingaddress}" {disabled} size=30>-->
+				<span style="cursor:pointer" onclick="javascript:add_input_mailforwardingaddress();"> +</span>
+			</td>
 		</tr>
 
