Index: trunk/expressoAdmin1_2/inc/class.bomanagers.inc.php
===================================================================
--- trunk/expressoAdmin1_2/inc/class.bomanagers.inc.php	(revision 63)
+++ trunk/expressoAdmin1_2/inc/class.bomanagers.inc.php	(revision 64)
@@ -26,61 +26,14 @@
 			}
 			
-			//Recebe valores do POST
-			$manager = array(
-			'lid'						=> $_POST['manager_lid'],
-			'context'					=> $_POST['context'],
-			
-			'add_users'					=> $_POST['add_users'],
-			'edit_users'				=> $_POST['edit_users'],
-			'delete_users'				=> $_POST['delete_users'],
-			'rename_users'				=> $_POST['rename_users'],
-			'view_users'				=> $_POST['view_users'],
-			'manipulate_corporative_information' => $_POST['manipulate_corporative_information'],
-			'add_groups'				=> $_POST['add_groups'],
-			'edit_groups'				=> $_POST['edit_groups'],
-			'delete_groups'				=> $_POST['delete_groups'],
-			'edit_email_groups'			=> $_POST['edit_email_groups'],
-			'change_users_password'		=> $_POST['change_users_password'],
-			'change_users_quote'		=> $_POST['change_users_quote'],
-			'set_user_default_password'	=> $_POST['set_user_default_password'],
-			'empty_user_inbox'			=> $_POST['empty_user_inbox'],
-			'edit_sambausers_attributes'=> $_POST['edit_sambausers_attributes'],
-			'edit_sambadomains'			=> $_POST['edit_sambadomains'],
-			'add_email_lists'			=> $_POST['add_maillists'],
-			'edit_email_lists'			=> $_POST['edit_maillists'],
-			'delete_email_lists'		=> $_POST['delete_maillists'],			
-			'create_sectors'			=> $_POST['create_sectors'],
-			'edit_sectors'				=> $_POST['edit_sectors'],
-			'delete_sectors'			=> $_POST['delete_sectors'],
-			'view_global_sessions'		=> $_POST['view_global_sessions'],
-			'view_logs'					=> $_POST['view_logs'],
-			'create_computers'			=> $_POST['create_computers'],
-			'edit_computers'			=> $_POST['edit_computers'],
-			'delete_computers'			=> $_POST['delete_computers'],
-					
-			'apps'						=> $_POST['applications_list']
-			);
-			
-			// Soma os niveis de acesso criando uma ACL
-			$acl = 0;
-			$acl = $acl + $manager['add_users'] + $manager['edit_users'] + $manager['delete_users'] + $manager['rename_users'] + $manager['view_users'] + $manager['manipulate_corporative_information'];
-			$acl = $acl + $manager['add_groups'] + $manager['edit_groups'] + $manager['delete_groups'] + $manager['edit_email_groups'];
-			$acl = $acl + $manager['change_users_password'] + $manager['change_users_quote'] + $manager['set_user_default_password'] + $manager['empty_user_inbox'];
-			$acl = $acl + $manager['edit_sambausers_attributes'] + $manager['edit_sambadomains'];
-			$acl = $acl + $manager['add_email_lists'] + $manager['edit_email_lists'] + $manager['delete_email_lists'];
-			$acl = $acl + $manager['create_sectors'] + $manager['edit_sectors'] + $manager['delete_sectors'] + $manager['view_global_sessions'];
-			$acl = $acl + $manager['create_computers'] + $manager['edit_computers'] + $manager['delete_computers'];
-			$acl = $acl + $manager['view_logs'];
-
-			//Escrevre no Banco
+			//Escrevre no Banco a ACL do gerente
 			$sql = "INSERT INTO phpgw_expressoadmin (manager_lid, context, acl) "
-			. "VALUES('" . $manager['lid'] . "','" . $manager['context'] . "','" . $acl . "')";
+			. "VALUES('" . $_POST['manager_lid'] . "','" . $_POST['context'] . "','" . $this->make_manager_acl($_POST) . "')";
 			$GLOBALS['phpgw']->db->query($sql);
 			
 			//Escrevre no Banco as aplicações que o gerente tem direito de disponibilizar aos seus usuarios.
-			foreach($manager['apps'] as $app=>$value)
+			foreach($_POST['applications_list'] as $app=>$value)
 			{
 				$sql = "INSERT INTO phpgw_expressoadmin_apps (manager_lid, context, app) "
-				. "VALUES('" . $manager['lid'] . "','" . $manager['context'] . "','" . $app . "')";
+				. "VALUES('" . $_POST['manager_lid'] . "','" . $_POST['context'] . "','" . $app . "')";
 				$GLOBALS['phpgw']->db->query($sql);
 			}
@@ -99,74 +52,27 @@
 				return False;
 			}
-
-			//recebe valores do POST
-			$manager = array(
-			'old_lid'					=> $_POST['old_manager_lid'],
-			'old_context'				=> $_POST['old_context'],
-			'lid'						=> $_POST['manager_lid'],
-			'context'					=> $_POST['context'],
 			
-			'add_users'					=> $_POST['add_users'],
-			'edit_users'				=> $_POST['edit_users'],
-			'delete_users'				=> $_POST['delete_users'],
-			'rename_users'				=> $_POST['rename_users'],
-			'view_users'				=> $_POST['view_users'],
-			'manipulate_corporative_information' => $_POST['manipulate_corporative_information'],
-			'add_groups'				=> $_POST['add_groups'],
-			'edit_groups'				=> $_POST['edit_groups'],
-			'delete_groups'				=> $_POST['delete_groups'],
-			'edit_email_groups'			=> $_POST['edit_email_groups'],			
-			'change_users_password'		=> $_POST['change_users_password'],
-			'change_users_quote'		=> $_POST['change_users_quote'],
-			'set_user_default_password'	=> $_POST['set_user_default_password'],
-			'empty_user_inbox'			=> $_POST['empty_user_inbox'],
-			'edit_sambausers_attributes'=> $_POST['edit_sambausers_attributes'],
-			'edit_sambadomains'			=> $_POST['edit_sambadomains'],
-			'add_email_lists'			=> $_POST['add_maillists'],
-			'edit_email_lists'			=> $_POST['edit_maillists'],
-			'delete_email_lists'		=> $_POST['delete_maillists'],
-			'create_sectors'			=> $_POST['create_sectors'],
-			'edit_sectors'				=> $_POST['edit_sectors'],
-			'delete_sectors'			=> $_POST['delete_sectors'],
-			'view_global_sessions'		=> $_POST['view_global_sessions'],
-			'view_logs'					=> $_POST['view_logs'],
-			'create_computers'			=> $_POST['create_computers'],
-			'edit_computers'			=> $_POST['edit_computers'],
-			'delete_computers'			=> $_POST['delete_computers'],
+			//Executa update na tabela para atualizar ACL
+			$sql = "UPDATE phpgw_expressoadmin SET manager_lid = '".$_POST['manager_lid']
+			. "',context = '".$_POST['context']
+			. "',acl = '" . $this->make_manager_acl($_POST)
+			. "' WHERE manager_lid = '" . $_POST['old_manager_lid']."' AND context = '" . $_POST['old_context'] ."'";
+			$GLOBALS['phpgw']->db->query($sql);
 			
-			'apps'						=> $_POST['applications_list']
-			);
-			
-			// Soma os niveis de acesso criando uma ACL
-			$acl = 0;
-			$acl = $acl + $manager['add_users'] + $manager['edit_users'] + $manager['delete_users'] + $manager['rename_users'] + $manager['view_users'] + $manager['manipulate_corporative_information'];
-			$acl = $acl + $manager['add_groups'] + $manager['edit_groups'] + $manager['delete_groups'] + $manager['edit_email_groups'];
-			$acl = $acl + $manager['change_users_password'] + $manager['change_users_quote'] + $manager['set_user_default_password'] + $manager['empty_user_inbox'];
-			$acl = $acl + $manager['edit_sambausers_attributes'] + $manager['edit_sambadomains'];
-			$acl = $acl + $manager['add_email_lists'] + $manager['edit_email_lists'] + $manager['delete_email_lists'];
-			$acl = $acl + $manager['create_sectors'] + $manager['edit_sectors'] + $manager['delete_sectors'] + $manager['view_global_sessions'];
-			$acl = $acl + $manager['create_computers'] + $manager['edit_computers'] + $manager['delete_computers'];
-			$acl = $acl + $manager['view_logs'];
-			
-			//Executa update na tabela
-			$sql = "UPDATE phpgw_expressoadmin SET manager_lid = '".$manager['lid']
-			. "',context = '".$manager['context']
-			. "',acl = '".$acl
-			. "' WHERE manager_lid = '".$manager['old_lid']."' AND context = '" . $manager['old_context'] ."'";
-			$GLOBALS['phpgw']->db->query($sql);
 			
 			//Deleta as aplicações e adiciona as novas.
 			//Deleta
 			$sql = "DELETE FROM phpgw_expressoadmin_apps WHERE "
-			. "manager_lid = '".$manager['old_lid']."' AND "
-			. "context = '".$manager['old_context']."'";
-			$GLOBALS['phpgw']->db->query($sql);		
+			. "manager_lid = '" . $_POST['old_manager_lid']."' AND "
+			. "context = '" . $_POST['old_context']."'";
+			$GLOBALS['phpgw']->db->query($sql);
+					
 			// Adiciona
-			if (count($manager['apps']))
+			if (count($_POST['applications_list']))
 			{
-				foreach($manager['apps'] as $app=>$value)
+				foreach($_POST['applications_list'] as $app=>$value)
 				{
 					$sql = "INSERT INTO phpgw_expressoadmin_apps (manager_lid, context, app) "
-					. "VALUES('" . $manager['lid'] . "','" . $manager['context'] . "','" . $app . "')";
+					. "VALUES('" . $_POST['manager_lid'] . "','" . $_POST['context'] . "','" . $app . "')";
 					$GLOBALS['phpgw']->db->query($sql);
 				}
@@ -176,5 +82,20 @@
 			ExecMethod('expressoAdmin1_2.uimanagers.list_managers');
 			return True;
-		}		
+		}
+		
+		function make_manager_acl($array_post)
+		{
+			$total_manager_acl = 0;
+			foreach ($array_post as $atribute=>$value)
+			{
+				$acl  = strstr($atribute, 'acl_');
+
+				if ($acl !== false)
+				{
+					$total_manager_acl += $value;
+				}
+			}
+			return $total_manager_acl;
+		}
 	}
 ?>
