Index: branches/2.2/expressoAdmin1_2/inc/class.bosectors.inc.php
===================================================================
--- branches/2.2/expressoAdmin1_2/inc/class.bosectors.inc.php	(revision 3850)
+++ branches/2.2/expressoAdmin1_2/inc/class.bosectors.inc.php	(revision 3887)
@@ -86,4 +86,10 @@
 			}
 			
+			if( isset($_POST['file_manager_quota']) )
+			{
+				$controlled_by_quota = true;
+				$sector_info['fileManagerQuota'] = (trim($_POST['file_manager_quota']) != "") ? $_POST['file_manager_quota'] : "0";
+			}
+			
 			if($controlled_by_quota)
 				$sector_info['objectClass'][]	= 'phpgwQuotaControlled';
@@ -136,5 +142,7 @@
 			
 			//Modifica o conteúdo das cotas.
-			if( (isset($_POST['disk_quota']) ) && (isset($_POST['users_quota']) ) ) { //se for passado alguma coisa, lógico
+			if( (isset($_POST['disk_quota']) ) 
+				|| (isset($_POST['users_quota']) ) 
+				|| (isset($_POST['file_manager_quota']) )) { //se for passado alguma coisa, lógico
 				if(!$controlled_by_quota) {
 					$ldap_mod_add['objectClass'][] = 'phpgwQuotaControlled';
@@ -145,4 +153,5 @@
 				$ldap_mod_replace['diskQuota'] = $_POST['disk_quota'];
 				$ldap_mod_replace['usersQuota'] = $_POST['users_quota'];
+				$ldap_mod_replace['fileManagerQuota'] = $_POST['file_manager_quota'];
 				$this->so->replace_attribute($sector_info[0]['dn'], $ldap_mod_replace);
 			}
Index: branches/2.2/expressoAdmin1_2/inc/class.uisectors.inc.php
===================================================================
--- branches/2.2/expressoAdmin1_2/inc/class.uisectors.inc.php	(revision 3359)
+++ branches/2.2/expressoAdmin1_2/inc/class.uisectors.inc.php	(revision 3887)
@@ -196,4 +196,5 @@
 				'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' : '',
@@ -251,4 +252,5 @@
 				$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];
@@ -267,4 +269,5 @@
 				'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',
Index: branches/2.2/expressoAdmin1_2/inc/class.functions.inc.php
===================================================================
--- branches/2.2/expressoAdmin1_2/inc/class.functions.inc.php	(revision 3549)
+++ branches/2.2/expressoAdmin1_2/inc/class.functions.inc.php	(revision 3887)
@@ -683,8 +683,8 @@
 		}
 		
-		//Checa se existe quota em disco para mais um usuï¿œrio no setor... se existir retorna true, senï¿œo false.
+		//Checa se existe quota em disco para mais um usuário no setor... se existir retorna true, senão false.
 		function existe_quota_disco($setor,$quota_novo_usuario) {
 			settype($quota_novo_usuario,"float");		
-			$quota_novo_usuario /= 1024; //A quota vï¿œm da interface em megabytes, deve se tornar gigabyte.
+			$quota_novo_usuario /= 1024; //A quota vêm da interface em megabytes, deve se tornar gigabyte.
 
 			$nova_quota = $this->get_actual_disk_usage($setor['dn']) + $quota_novo_usuario;
@@ -695,15 +695,70 @@
 		}
 		
+		function has_file_disk_quota($home_directory,$quota) {
+			$uid = substr($home_directory,strpos($home_directory,"/home/")+6);
+			$context = $this->get_ou_context_from_uid($uid);
+			
+			$sector = $this->get_info($context);
+			$new_quota = $this->get_actual_disk_usage($sector[0]['dn'],'FileManager',$uid) + $quota;
+			if(( $new_quota > $sector[0]['filemanagerquota'][0] ) && ($sector[0]['filemanagerquota'][0] != -1)) {
+				return false;
+			}
+			return true;
+		}
+		
+		function get_ou_context_from_uid($uid,$referral = false) {
+			$dn			= $GLOBALS['phpgw_info']['server']['ldap_root_dn'];
+			$passwd		= $GLOBALS['phpgw_info']['server']['ldap_root_pw'];
+			$ldap_conn	= ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']);
+			$context = $GLOBALS['phpgw_info']['server']['ldap_context'];
+			
+			ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+			
+			if ($referral)
+				ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 1);
+			else
+				ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0);
+			
+			ldap_bind($ldap_conn,$dn,$passwd);
+			$filter="(&(objectClass=phpgwAccount)(uid=$uid))";
+			$search=ldap_search($ldap_conn, $context, $filter);
+			$result = ldap_get_entries($ldap_conn, $search);
+			
+			if($result['count']>0){
+				$dn = $result[0]['dn'];
+				return substr($dn,strpos($dn,$uid.",")+strlen($uid.","));
+			}
+			else
+				return false;
+		}
+		
 		// Soma as quotas de todos os usuï¿œrios daquele contexto.
-		function get_actual_disk_usage($context) {
+		function get_actual_disk_usage($context,$app='expressoMail',$user=null) {
 			$quota_usada=0;
 			$contexts = array($context);
 			$usuarios = $this->get_list('accounts', '', $contexts);
 
-			$imap_functions = new imap_functions();
-			foreach($usuarios as $usuario) {
-				$temp = $imap_functions->get_user_info($usuario['account_lid']);
-				if($temp['mailquota'] != -1) //Usuï¿œrio sem cota nï¿œo conta...
-					$quota_usada += ($temp['mailquota'] / 1024);
+			if($app=='expressoMail') {
+				$imap_functions = new imap_functions();	
+				foreach($usuarios as $usuario) {
+					$temp = $imap_functions->get_user_info($usuario['account_lid']);
+					if($temp['mailquota'] != -1) //Usuï¿œrio sem cota nï¿œo conta...
+						$quota_usada += ($temp['mailquota'] / 1024);
+				}
+			}
+			else if($app=='FileManager'){ //FileManager
+				$uids = '';
+				foreach($usuarios as $usuario) {
+					if($usuario['account_lid']!=$user)
+						$uids.="'/home/".$usuario['account_lid']."',";
+				}
+				$uids.="'a'"; //hack the last comma
+				$query = "select 1 as num,sum(quota_size) as quota from phpgw_vfs_quota where directory in ($uids) group by num";
+				$GLOBALS['phpgw']->db->query($query);
+				if($GLOBALS['phpgw']->db->next_record())
+				{
+					$result = $GLOBALS['phpgw']->db->row();
+					$quota_usada = $result["quota"];
+				}			
 			}
 			return $quota_usada;
Index: branches/2.2/expressoAdmin1_2/templates/default/sectors_form.tpl
===================================================================
--- branches/2.2/expressoAdmin1_2/templates/default/sectors_form.tpl	(revision 1991)
+++ branches/2.2/expressoAdmin1_2/templates/default/sectors_form.tpl	(revision 3887)
@@ -49,4 +49,12 @@
    			</td>
  		</tr>
+ 		<tr>  
+   			<td>
+   				{lang_file_manager_quota}:
+   			</td>
+   			<td>
+				<input type="text" autocomplete="off" name="file_manager_quota" value={file_manager_quota}>
+   			</td>
+ 		</tr>
 		{close_comment_cotas}
   		<tr>  
