Index: branches/2.4/expressoAdmin1_2/inc/class.uisectors.inc.php
===================================================================
--- branches/2.4/expressoAdmin1_2/inc/class.uisectors.inc.php	(revision 5133)
+++ branches/2.4/expressoAdmin1_2/inc/class.uisectors.inc.php	(revision 6660)
@@ -20,5 +20,6 @@
 			'validate_data_sectors_edit'	=> True,
 			'delete_sector'					=> True,
-			'css'							=> True
+			'css'                                                   => True, 
+ 	                'view_cota'                                             => True 
 		);
 
@@ -63,5 +64,6 @@
 			$p->set_block('sectors','row_empty','row_empty');
 			
-			$sectors_info = $this->functions->get_sectors_list($contexts);
+			//$sectors_info = $this->functions->get_sectors_list($contexts); 
+ 	                $sectors_info = $this->functions->get_organizations2($contexts); 
 			
 			$var = Array(
@@ -69,5 +71,6 @@
 				'back_url'				=> $GLOBALS['phpgw']->link('/expressoAdmin1_2/index.php'),
 				'context_display'		=> $context_display,
-				'lang_inactives'			=> lang('list inactives')
+				'lang_inactives'                        => lang('list inactives'), 
+ 	                        'lang_ver_cota'         => lang('view cota')
 			);
 
@@ -95,9 +98,9 @@
 				{
 					$tr_color = $this->nextmatchs->alternate_row_color($tr_color);
-					
 					$var = Array(
 						'tr_color'    => $tr_color,
-						'sector_name'  => $sector,
-						'add_link' => $this->row_action('add','sector',$context)
+						'sector_name'  => $sector['display'], 
+ 	                                        'cota_link' => $this->row_action('view','cota',$sector['dn']), 
+ 	                                        'add_link' => $this->row_action('add','sector',$sector['dn']) 
 					);	
 					
@@ -106,5 +109,5 @@
 									
 					if(isset($GLOBALS['phpgw_info']['server']['time_to_account_expires']))
-						$var['inactives_link'] = $this->row_action('list_inactive','users',$context,'uiaccounts');
+						$var['inactives_link'] = $this->row_action('list_inactive','users',$sector['dn'],'uiaccounts'); 
 					else
 						$var['inactives_link'] = lang('disabled');
@@ -114,5 +117,5 @@
 					if ($can_edit)
 					{
-						$p->set_var('edit_link',$this->row_action('edit','sector',utf8_decode($context)));
+						$p->set_var('edit_link',$this->row_action('edit','sector',$sector['dn'])); 
 					}
 					else
@@ -123,5 +126,5 @@
 					if ($can_delete)
 					{
-						$p->set_var('delete_link',$this->row_action('delete','sector',utf8_decode($context)));
+						$p->set_var('delete_link',$this->row_action('delete','sector',$sector['dn'])); 
 					}
 					else
@@ -189,9 +192,20 @@
 				'context'			=> $context == '' ? $GLOBALS['phpgw_info']['server']['ldap_context'] : $context,
 				'sector'			=> $_POST['sector'],
+				'disk_quota'        => $_POST['disk_quota'], 
+ 	                        'users_quota'       => $_POST['users_quota'], 
 				'manager_org'		=> $combo_manager_org,
 				'sector_visible_checked'=> $_POST['sector_visible'] ? 'checked' : '',
 				'error_messages'	=> $_POST['error_messages'] == '' ? '' : "<script type='text/javascript'>alert('".$_POST['error_messages']."')</script>",
 			);
-			
+
+		        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']);
@@ -242,4 +256,6 @@
 			{
 				$sector_info = $this->so->get_info($context);
+                                $sector_disk_quota = $sector_info[0]['diskquota'][0]; 
+ 	                        $sector_users_quota = $sector_info[0]['usersquota'][0]; 
 				$_POST['sector_visible'] = $sector_info[0]['phpgwaccountvisible'][0];
 			} 
@@ -254,9 +270,21 @@
 				'manager_org'		=> $combo_manager_org,
 				'sector_visible_checked'=> $_POST['sector_visible'] ? 'checked' : '',
+                                'disk_quota'        => $_POST['disk_quota'] == '' ? $sector_disk_quota : $_POST['disk_quota'], 
+ 	                        'users_quota'       => $_POST['users_quota'] == '' ? $sector_users_quota : $_POST['users_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']);
@@ -267,5 +295,57 @@
 
 			$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'); 
+                }         
 		
 		function validate_data_sectors_add()
