Index: trunk/expressoAdmin1_2/inc/class.uiaccounts.inc.php
===================================================================
--- trunk/expressoAdmin1_2/inc/class.uiaccounts.inc.php	(revision 81)
+++ trunk/expressoAdmin1_2/inc/class.uiaccounts.inc.php	(revision 107)
@@ -280,4 +280,5 @@
 				'phpgwaccountstatus_checked'	=> 'CHECKED',
 				'photo_bin'						=> $GLOBALS['phpgw_info']['server']['webserver_url'].'/expressoAdmin1_2/templates/default/images/photo_celepar.png',
+				'display_picture'				=> $this->functions->check_acl($manager_lid,'edit_users_picture') ? '' : 'none', 
 				'disabled_delete_photo'			=> 'disabled',
 				'display_tr_default_password'	=> 'none',
@@ -625,4 +626,5 @@
 				'photo_bin'						=> $photo_bin,
 				'disabled_delete_photo'			=> $disabled_delete_photo,
+				'display_picture'				=> $this->functions->check_acl($manager_account_lid,'edit_users_picture') ? '' : 'none',
 				
 				'display_tr_default_password'	=> $this->functions->check_acl($manager_account_lid,'set_user_default_password') ? '' : 'none',
Index: trunk/expressoAdmin1_2/inc/class.user.inc.php
===================================================================
--- trunk/expressoAdmin1_2/inc/class.user.inc.php	(revision 81)
+++ trunk/expressoAdmin1_2/inc/class.user.inc.php	(revision 107)
@@ -191,5 +191,5 @@
 			
 				// Chama funcao para salvar foto no OpenLDAP.			
-				if ($_FILES['photo']['name'] != '')
+				if ( ($_FILES['photo']['name'] != '') && ($this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'edit_users_picture')) )
 				{
 					$result = $this->ldap_functions->ldap_save_photo($dn, $_FILES['photo']['tmp_name']);
@@ -535,10 +535,10 @@
 				////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 				// PHOTO
-				if ($new_values['delete_photo'])
+				if ( ($new_values['delete_photo']) && ($this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'edit_users_picture')) )
 				{
 					$this->ldap_functions->ldap_remove_photo($dn);
-					$this->db_functions->write_log("removido jpegphoto ao usuario",'',$dn,'','');
-				}
-				if ($_FILES['photo']['name'] != '')
+					$this->db_functions->write_log("removido jpegphoto do usuario",'',$dn,'','');
+				}
+				elseif ( ($_FILES['photo']['name'] != '') && ($this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'edit_users_picture')) )
 				{
 					if ($new_values['photo_exist'])
@@ -643,13 +643,4 @@
 					}
 				}
-				
-				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);
-				
 				
 				////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Index: trunk/expressoAdmin1_2/inc/class.uimanagers.inc.php
===================================================================
--- trunk/expressoAdmin1_2/inc/class.uimanagers.inc.php	(revision 81)
+++ trunk/expressoAdmin1_2/inc/class.uimanagers.inc.php	(revision 107)
@@ -149,6 +149,13 @@
 			
 			// App, create list of available apps
-			$applications_list = $this->make_app_list();
-			
+			$applications_list = $this->make_app_list('');
+			
+			if ($_POST['context'])
+			{
+				$contexts = split("%", $_POST['context']);
+				foreach ($contexts as $manager_context)
+					$input_context_fields .= "<input type='text' size=60 value=$manager_context></input><br>";
+			}
+			else
 			$input_context_fields = '<input type="text" size=60></input><br>';
 			
Index: trunk/expressoAdmin1_2/inc/class.functions.inc.php
===================================================================
--- trunk/expressoAdmin1_2/inc/class.functions.inc.php	(revision 89)
+++ trunk/expressoAdmin1_2/inc/class.functions.inc.php	(revision 107)
@@ -46,4 +46,56 @@
 			$array_acl = $this->make_array_acl($acl['acl']);
 			
+			switch($access)
+			{
+				case list_users:
+					if ($array_acl[acl_add_users] || $array_acl[acl_edit_users] || $array_acl[acl_delete_users] || $array_acl[acl_change_users_password] || $array_acl[acl_change_users_quote] || $array_acl[acl_edit_sambausers_attributes] || $array_acl[acl_view_users] || $array_acl[acl_manipulate_corporative_information])
+						return true;
+					break;
+				case list_groups:
+					if ($array_acl[acl_add_groups] || $array_acl[acl_edit_groups] || $array_acl[acl_delete_groups])
+						return true;
+					break;
+				case list_maillists:
+					if ($array_acl[acl_add_maillists] || $array_acl[acl_edit_maillists] || $array_acl[acl_delete_maillists])
+						return true;
+					break;
+				case list_sectors:
+					if ($array_acl[acl_create_sectors] || $array_acl[acl_edit_sectors] || $array_acl[acl_delete_sectors])
+						return true;
+					break;
+				case list_computers:
+					if ($array_acl[acl_create_computers] || $array_acl[acl_edit_computers] || $array_acl[acl_delete_computers])
+						return true;
+					break;
+
+				case display_groups:
+					if ( $array_acl[acl_edit_users] || $array_acl[acl_view_users] || ($array_acl[acl_edit_sambausers_attributes] && ($this->current_config['expressoAdmin_samba_support'] == 'true')) )
+						return true;
+					break;
+				case display_emailconfig:
+					if ($array_acl[acl_edit_users] || $array_acl[acl_view_users])
+						return true;
+					break;
+				case display_applications:
+					if ($array_acl[acl_edit_users] || $array_acl[acl_view_users])
+						return true;
+					break;
+				case display_emaillists:
+					if ($array_acl[acl_edit_users] || $array_acl[acl_view_users])
+						return true;
+					break;
+
+				default:
+					return $array_acl["acl_$access"];
+			}
+			return false;
+		}
+
+		/* OLD FUNCTION
+		function check_acl($account_lid, $access)
+		{
+			$acl = $this->read_acl($account_lid);
+			$array_acl = $this->make_array_acl($acl['acl']);
+			
 			//What access ?? In the IF, verify if have access.
 			switch($access)
@@ -73,4 +125,8 @@
 						return true;
 					break;
+				case edit_users_picture:
+					if ($array_acl[acl_edit_users_picture])
+						return true;
+					break;
 				case manipulate_corporative_information:
 					if ($array_acl[acl_manipulate_corporative_information])
@@ -93,5 +149,9 @@
 						return true;
 					break;
-				case edit_sambausers_attributes:
+				case edit_sambausers_attributes:				case list_maillists:
+					if ($array_acl[acl_add_maillists] || $array_acl[acl_edit_maillists] || $array_acl[acl_delete_maillists])
+						return true;
+					break;
+
 					if ($array_acl[acl_edit_sambausers_attributes])
 						return true;
@@ -202,8 +262,9 @@
 
 				default:
-					return false; 	
+					return $array_acl["acl_$access"];
 			}
 			return false;
 		}
+		*/
 		
 		// Read acl from db
@@ -227,35 +288,85 @@
 		
 		// Make a array read humam
-		// Last acl:	268435456, 536870912
+		// Last acl:	536.870.912
 		function make_array_acl($acl)
 		{
+			$array_acl_tmp = array();
+			$tmp = array(		"acl_add_users",
+							 	"acl_edit_users",
+							 	"acl_delete_users",
+							 	"acl_EMPTY1",
+							 	"acl_add_groups",
+							 	"acl_edit_groups",
+							 	"acl_delete_groups",
+							 	"acl_change_users_password",
+							 	"acl_add_maillists",
+							 	"acl_edit_maillists",
+							 	"acl_delete_maillists",
+							 	"acl_EMPTY2",
+							 	"acl_create_sectors",
+							 	"acl_edit_sectors",
+							 	"acl_delete_sectors",
+							 	"acl_edit_sambausers_attributes",
+							 	"acl_view_global_sessions",
+							 	"acl_view_logs",
+							 	"acl_change_users_quote",
+							 	"acl_set_user_default_password",
+							 	"acl_create_computers",
+							 	"acl_edit_computers",
+							 	"acl_delete_computers",
+							 	"acl_rename_users",
+							 	"acl_edit_sambadomains",
+							 	"acl_view_users",
+							 	"acl_edit_email_groups",
+							 	"acl_empty_user_inbox",
+							 	"acl_manipulate_corporative_information",
+							 	"acl_edit_users_picture"
+							 	);
+			
+			foreach ($tmp as $index => $right)
+			{
+				$bin = '';
+				for ($i=0; $i<$index; $i++)
+				{
+					$bin .= '0';
+				}
+				$bin = '1' . $bin;
+				
+				$array_acl[$right] = $acl & bindec($bin);
+			}			
+			return $array_acl;
+			/*
 			$array_acl['acl_add_users'] = $acl & 1;
 			$array_acl['acl_edit_users'] = $acl & 2;
 			$array_acl['acl_delete_users'] = $acl & 4;
-			$array_acl['acl_rename_users'] = $acl & 8388608;
-			$array_acl['acl_view_users'] = $acl & 33554432;
-			$array_acl['acl_manipulate_corporative_information'] = $acl & 268435456;
+			//8
 			$array_acl['acl_add_groups'] = $acl & 16;
 			$array_acl['acl_edit_groups'] = $acl & 32;
 			$array_acl['acl_delete_groups'] = $acl & 64;
-			$array_acl['acl_edit_email_groups'] = $acl & 67108864;
 			$array_acl['acl_change_users_password'] = $acl & 128;
-			$array_acl['acl_change_users_quote'] = $acl & 262144;
-			$array_acl['acl_set_user_default_password'] = $acl & 524288;
-			$array_acl['acl_empty_user_inbox'] = $acl & 134217728;
-			$array_acl['acl_edit_sambausers_attributes'] = $acl & 32768;
-			$array_acl['acl_edit_sambadomains'] = $acl & 16777216;
 			$array_acl['acl_add_maillists'] = $acl & 256;
 			$array_acl['acl_edit_maillists'] = $acl & 512;
 			$array_acl['acl_delete_maillists'] = $acl & 1024;
+			//2048
 			$array_acl['acl_create_sectors'] = $acl & 4096;
 			$array_acl['acl_edit_sectors'] = $acl & 8192;
 			$array_acl['acl_delete_sectors'] = $acl & 16384;
+			$array_acl['acl_edit_sambausers_attributes'] = $acl & 32768;
 			$array_acl['acl_view_global_sessions'] = $acl & 65536;
 			$array_acl['acl_view_logs'] = $acl & 131072;
+			$array_acl['acl_change_users_quote'] = $acl & 262144;
+			$array_acl['acl_set_user_default_password'] = $acl & 524288;
 			$array_acl['acl_create_computers'] = $acl & 1048576;
 			$array_acl['acl_edit_computers'] = $acl & 2097152;
 			$array_acl['acl_delete_computers'] = $acl & 4194304;
+			$array_acl['acl_rename_users'] = $acl & 8388608;
+			$array_acl['acl_edit_sambadomains'] = $acl & 16777216;
+			$array_acl['acl_view_users'] = $acl & 33554432;
+			$array_acl['acl_edit_email_groups'] = $acl & 67108864;
+			$array_acl['acl_empty_user_inbox'] = $acl & 134217728;
+			$array_acl['acl_manipulate_corporative_information'] = $acl & 268435456;
+			$array_acl['acl_edit_users_picture'] = $acl & 536870912;
 			return $array_acl;
+			*/
 		}
 		
