Index: trunk/expressoAdmin1_2/inc/class.uisectors.inc.php
===================================================================
--- trunk/expressoAdmin1_2/inc/class.uisectors.inc.php	(revision 3887)
+++ trunk/expressoAdmin1_2/inc/class.uisectors.inc.php	(revision 5133)
@@ -20,6 +20,5 @@
 			'validate_data_sectors_edit'	=> True,
 			'delete_sector'					=> True,
-			'css'							=> True,
-			'view_cota'						=> True
+			'css'							=> True
 		);
 
@@ -47,5 +46,8 @@
 
 			// Verifica se o administrador tem acesso.
-
+			if (!$this->functions->check_acl($manager_lid,'list_sectors'))
+			{
+				$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
+			}
 			
 			unset($GLOBALS['phpgw_info']['flags']['noheader']);
@@ -61,6 +63,5 @@
 			$p->set_block('sectors','row_empty','row_empty');
 			
-			//$sectors_info = $this->functions->get_sectors_list($contexts);
-			$sectors_info = $this->functions->get_organizations2($contexts);
+			$sectors_info = $this->functions->get_sectors_list($contexts);
 			
 			$var = Array(
@@ -68,7 +69,7 @@
 				'back_url'				=> $GLOBALS['phpgw']->link('/expressoAdmin1_2/index.php'),
 				'context_display'		=> $context_display,
-				'lang_inactives'			=> lang('list inactives'),
-				'lang_ver_cota'		=> lang('view cota')
-			);
+				'lang_inactives'			=> lang('list inactives')
+			);
+
 			$p->set_var($var);
 			$p->set_var($this->functions->make_dinamic_lang($p, 'list'));
@@ -97,15 +98,13 @@
 					$var = Array(
 						'tr_color'    => $tr_color,
-						'sector_name'  => $sector['display'],
-						'cota_link' => $this->row_action('view','cota',$sector['dn']),
+						'sector_name'  => $sector,
+						'add_link' => $this->row_action('add','sector',$context)
 					);	
 					
-					if ($this->functions->check_acl($manager_lid,'create_sectors'))
-						$p->set_var('add_link',$this->row_action('add','sector',$sector['dn']));
-					else
-						$p->set_var('add_link',' ');
+					$var['sector_name'] = utf8_decode($var['sector_name']);
+
 									
 					if(isset($GLOBALS['phpgw_info']['server']['time_to_account_expires']))
-						$var['inactives_link'] = $this->row_action('list_inactive','users',$sector['dn'],'uiaccounts');
+						$var['inactives_link'] = $this->row_action('list_inactive','users',$context,'uiaccounts');
 					else
 						$var['inactives_link'] = lang('disabled');
@@ -115,5 +114,5 @@
 					if ($can_edit)
 					{
-						$p->set_var('edit_link',$this->row_action('edit','sector',$sector['dn']));
+						$p->set_var('edit_link',$this->row_action('edit','sector',utf8_decode($context)));
 					}
 					else
@@ -124,5 +123,5 @@
 					if ($can_delete)
 					{
-						$p->set_var('delete_link',$this->row_action('delete','sector',$sector['dn']));
+						$p->set_var('delete_link',$this->row_action('delete','sector',utf8_decode($context)));
 					}
 					else
@@ -139,10 +138,5 @@
 			$p->set_var($var);
 			
-			if ($this->functions->check_acl($manager_lid,'create_sectors')) {
 				$p->set_var('input_add','<input type="submit" value="' . lang('Add Sectors') . '">');
-			}
-			else {
-				$p->set_var('input_add',' ');
-			}
 			
 			$p->parse('rows','row_empty',True);
@@ -163,4 +157,6 @@
 				$context = $_GET['context'];
 				$combo_manager_org = $this->functions->get_organizations( $context, '', true, true, true );
+				$combo_manager_org = preg_replace("/\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''",$combo_manager_org);
+				$combo_manager_org = utf8_decode($combo_manager_org);
 			}
 			else
@@ -193,8 +189,4 @@
 				'context'			=> $context == '' ? $GLOBALS['phpgw_info']['server']['ldap_context'] : $context,
 				'sector'			=> $_POST['sector'],
-				'associated_domain'		=> $_POST['associated_domain'],
-				'disk_quota'        => $_POST['disk_quota'],
-				'users_quota'       => $_POST['users_quota'],
-				'file_manager_quota'=> $_POST['file_manager_quota'],
 				'manager_org'		=> $combo_manager_org,
 				'sector_visible_checked'=> $_POST['sector_visible'] ? 'checked' : '',
@@ -202,12 +194,6 @@
 			);
 			
-			if($this->functions->db_functions->use_cota_control()) {
-				$var["open_comment_cotas"] = "";
-				$var["close_comment_cotas"] ="";
-			}
-			else {
-				$var["open_comment_cotas"] = "<!--";
-				$var["close_comment_cotas"] ="-->";
-			}	
+			$var['sector'] = preg_replace("/\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''",$var['sector']);
+			$var['sector'] = utf8_decode($var['sector']);
 			
 			$p->set_var($var);
@@ -225,5 +211,11 @@
 			$context = $_GET['context'];
 
-			$combo_manager_org = $this->functions->get_organizations($_GET['context'], '', true, true, true);
+			$context = utf8_encode($context);
+			$context = preg_replace("/\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''",$context);
+
+			$combo_manager_org = $this->functions->get_organizations($context, '', true, true, true);
+
+			$combo_manager_org = utf8_decode(preg_replace("/\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''",$combo_manager_org));
+
 			$combo_manager_org = substr( $combo_manager_org, 0, ( strpos($combo_manager_org, '</option>') + 9 ) );
 
@@ -250,8 +242,4 @@
 			{
 				$sector_info = $this->so->get_info($context);
-				$sector_disk_quota = $sector_info[0]['diskquota'][0];
-				$sector_users_quota = $sector_info[0]['usersquota'][0];
-				$sector_file_manager_quota = $sector_info[0]['filemanagerquota'][0];
-				$sector_associated_domain = $sector_info[0]['associateddomain'][0];
 				$_POST['sector_visible'] = $sector_info[0]['phpgwaccountvisible'][0];
 			} 
@@ -266,78 +254,17 @@
 				'manager_org'		=> $combo_manager_org,
 				'sector_visible_checked'=> $_POST['sector_visible'] ? 'checked' : '',
-				'associated_domain'        => $_POST['associated_domain'] == '' ? $sector_associated_domain : $_POST['associated_domain'],
-				'disk_quota'        => $_POST['disk_quota'] == '' ? $sector_disk_quota : $_POST['disk_quota'],
-				'users_quota'       => $_POST['users_quota'] == '' ? $sector_users_quota : $_POST['users_quota'],
-				'file_manager_quota'=> $_POST['file_manager_quota'] == '' ? $sector_file_manager_quota : $_POST['file_manager_quota'],
+				
 				'lang_add'			=> lang('Add'),
 				'disable'			=> 'disabled',
 				'error_messages'	=> $_POST['error_messages'] == '' ? '' : "<script type='text/javascript'>alert('".$_POST['error_messages']."')</script>",
-				'lang_disk_quota'   => lang('disk quota'),
-				'lang_users_quota'  => lang('users quota')
-			);
-			if($this->functions->db_functions->use_cota_control()) {
-				$var["open_comment_cotas"] = "";
-				$var["close_comment_cotas"] ="";
-			}
-			else {
-				$var["open_comment_cotas"] = "<!--";
-				$var["close_comment_cotas"] ="-->";
-			}
+			);
+
+			$var['sector'] = preg_replace("/\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''",$var['sector']);
+			$var['sector'] = utf8_decode($var['sector']);
+			
 			$p->set_var($var);
 			$p->set_var($this->functions->make_dinamic_lang($p, 'list'));
-			
+
 			$p->pfp('out','edit_sector');
-		}
-		
-		function view_cota()
-		{
-			$context = $_GET['context'];
-			$a_tmp = explode(",", ldap_dn2ufn($context));
-
-			$sector_name = $a_tmp[0];
-			if($this->functions->db_functions->use_cota_control()) {
-				$sector_info = $this->so->get_info($context);
-				$sector_disk_cota = $sector_info[0]['diskquota'][0];
-				$sector_users_cota = $sector_info[0]['usersquota'][0];
-			}
-			else {
-				$sector_disk_cota = lang('cotas control disabled');
-				$sector_users_cota = lang('cotas control disabled');				
-			}
-
-
-			unset($GLOBALS['phpgw_info']['flags']['noheader']);
-			unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
-			$GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Edit Sector');
-			$GLOBALS['phpgw']->common->phpgw_header();
-			
-			// Set o template
-			$p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
-			$p->set_file(Array('ver_cota' => 'sectors_cota.tpl'));
-			
-		
-			// Seta variaveis utilizadas pelo tpl.
-			$var = Array(
-				'back_url'			=> $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uisectors.list_sectors'),
-				'th_bg'				=> $GLOBALS['phpgw_info']['theme']['th_bg'],
-				'context'			=> $context,
-				'sector'			=> $sector_name,
-				'disk_cota'        => $sector_disk_cota,
-				'users_cota'       => $sector_users_cota,
-				'actual_users'		=> $this->functions->get_num_users($context),
-				'actual_disk'		=> round($this->functions->get_actual_disk_usage($context),2),				
-				
-				'lang_back'			=> lang('Back'),
-				'lang_context'		=> lang('Context'),
-				'lang_sector_name'	=> lang('Sector name'),
-				'lang_disk_cota'   => lang('disk usage cota'),
-				'lang_users_cota'  => lang('user number cota'),
-				'lang_user_number'  => lang('user number'),
-				'lang_disk_used'    => lang('disk usage'),				
-				'error_messages'	=> $_POST['error_messages'] == '' ? '' : "<script type='text/javascript'>alert('".$_POST['error_messages']."')</script>",
-			);
-			$p->set_var($var);
-
-			$p->pfp('out','ver_cota');
 		}			
 		
@@ -371,4 +298,7 @@
 			$acl = $this->functions->read_acl($account_lid);
 			$manager_context = $acl[0]['context'];
+			
+			$manager_context = utf8_encode($manager_context);
+			$manager_context = preg_replace("/\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''",$manager_context);
 			
 			// Verifica se tem acesso a este modulo
@@ -394,8 +324,9 @@
 			$sector_name = $tmp_sector_name[1];
 			
+
 			// Get users of sector
-			$sector_users		= $this->so->get_sector_users($_GET['context']);
-			$sector_groups		= $this->so->get_sector_groups($_GET['context']);
-			$sector_subsectors	= $this->so->get_sector_subsectors($_GET['context']);
+			$sector_users		= $this->so->get_sector_users(utf8_encode($_GET['context']));
+			$sector_groups		= $this->so->get_sector_groups(utf8_encode($_GET['context']));
+			$sector_subsectors	= $this->so->get_sector_subsectors(utf8_encode($_GET['context']));
 			
 			$users_list = '';
@@ -415,5 +346,5 @@
 			{
 				if ($subsector['dn'] != $_GET['context'])
-					$subsectors_list .= $subsector['ou'][0] . '<br>';
+					$subsectors_list .= utf8_decode($subsector['ou'][0] . '<br>');
 			}
 
@@ -431,4 +362,6 @@
 				'sectors_list'				=> $subsectors_list 
 			);
+			$var['sector_name'] = preg_replace("/\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''",$var['sector_name']);
+
 			$p->set_var($var);
 			$p->set_var($this->functions->make_dinamic_lang($p, 'list'));
