Index: trunk/phpgwapi/inc/class.vfs_sql.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.vfs_sql.inc.php	(revision 1627)
+++ trunk/phpgwapi/inc/class.vfs_sql.inc.php	(revision 1648)
@@ -620,9 +620,5 @@
 				$data = array ();
 			}
-
-			/* ExpressoLivre principle: In your home you do what you want*/
-			if (strpos($data['string'],$this->my_home) === 0)
-				return True;
-
+	
 			$default_values = array
 				(
@@ -639,4 +635,15 @@
 				return True;
 			}
+
+			/* ExpressoLivre principle: In your home you do what you want*/
+			if (strpos($data['string'],$this->my_home) === 0)
+				return True;
+			if ($data['relatives'][0] == RELATIVE_NONE || $data['relatives'][0] == RELATIVE_ALL)
+			{
+				$path = explode('/',$data['string']);
+				$data['string'] = '/'.$path[1].'/'.$path[2];
+			}
+
+
 
 			if (!$data['owner_id'])
@@ -703,21 +710,10 @@
 				   We don't use ls () to get owner_id as we normally would,
 				   because ls () calls acl_check (), which would create an infinite loop
-				*/
-				$query = $GLOBALS['phpgw']->db->query ("SELECT owner_id FROM phpgw_vfs WHERE directory='".
-					$GLOBALS['phpgw']->db->db_addslashes($p2->fake_leading_dirs_clean)."' AND name='".
-					$GLOBALS['phpgw']->db->db_addslashes($p2->fake_name_clean)."'" . $this->extra_sql (array ('query_type' => VFS_SQL_SELECT)), __LINE__, __FILE__);
-				$GLOBALS['phpgw']->db->next_record ();
-
-				$owner_id = $GLOBALS['phpgw']->db->Record['owner_id'];
+				 */
+				$owner_id = $this->ownerOf($p2->fake_leading_dirs_clean,$p2->fake_name_clean);
 			}
 			else
 			{
 				$owner_id = $data['owner_id'];
-			}
-
-			/* This is correct.  The ACL currently doesn't handle undefined values correctly */
-			if (!$owner_id)
-			{
-				$owner_id = 0;
 			}
 
@@ -781,4 +777,16 @@
 				return False;
 			}
+		}
+		function ownerOf($base,$path){
+			$query = $GLOBALS['phpgw']->db->query ("SELECT owner_id FROM phpgw_vfs WHERE directory='".
+			$GLOBALS['phpgw']->db->db_addslashes($base)."' AND name='".
+			$GLOBALS['phpgw']->db->db_addslashes($path)."' ".$this->extra_sql (array ('query_type' => VFS_SQL_SELECT)), __LINE__, __FILE__);
+			$GLOBALS['phpgw']->db->next_record();
+			$owner_id = $GLOBALS['phpgw']->db->Record['owner_id'];
+			if (!$owner_id)
+			{
+				$owner_id = 0;
+			}
+			return $owner_id;
 		}
 
@@ -856,5 +864,5 @@
 			$path = explode('/',$data['string']);
 			$quota = $this->get_quota(array('string' => '/'.$path[1].'/'.$path[2]));
-			if ($quota > 0 && $this->get_size($data) >= $quota * 1024 * 1024)
+			if ($quota > 0 && $this->get_size('/'.$path[1].'/'.$path[2]) >= $quota * 1024 * 1024)
 				return false;
 
@@ -887,16 +895,4 @@
 				$acl_operation = PHPGW_ACL_ADD;
 			}
-			// In your dir you can do anything you want
-			$path = explode('/',$p->fake_full_path);
-			if (!$this->acl_check (array(
-					'string'	=> '/'.$path[1].'/'.$path[2],
-					'relatives'	=> array ($p->mask),
-					'operation'	=> $acl_operation
-				))
-			)
-			{
-				return False;
-			}
-
 			umask(0177);
 
@@ -1098,5 +1094,5 @@
 			$path = explode('/',$data['to']);
 			$quota = $this->get_quota(array('string' => '/'.$path[1].'/'.$path[2]));
-			$size = $this->get_size(array('string' => $data['to'], 'relatives' => $data['relatives'][1]));
+			$size = $this->get_size(array('string' => '/'.$path[1].'/'.$path[2], 'relatives' => $data['relatives'][1]));
 			if ($quota > 0 && $size >= $quota * 1024 * 1024)
 				return false;
@@ -1363,8 +1359,15 @@
 				$data = array ();
 			}
-
-			$path = explode('/',$data['to']);
-			$quota = $this->get_quota(array('string' => '/'.$path[1].'/'.$path[2]));
-			$size = $this->get_size(array('string' => $data['to'], 'relatives' => $data['relatives'][1]));
+  			if ($data['relatives'][1] == RELATIVE_NONE)
+			{
+				$path = explode('/',$data['to']);
+				$quota = $this->get_quota(array('string' => '/'.$path[1].'/'.$path[2]));
+				$size = $this->get_size(array('string' => '/'.$path[1].'/'.$path[2], 'relatives' => $data['relatives'][1]));
+			}
+			else
+			{
+				$quota = $this->get_quota(array('string' => $this->my_home));
+				$size = $this->get_size(array('string' => $this->my_home, 'relatives' => $data['relatives'][1]));
+			}
 			if ($quota > 0 && $size >= $quota * 1024 * 1024)
 				return false;
@@ -1391,23 +1394,7 @@
 				)
 			);
-			// In your dir you can do anything you want
-			$path = explode('/',$t->fake_full_path);
+
 			if (!$this->acl_check (array(
-					'string'	=> '/'.$path[1].'/'.$path[2],
-					'relatives'	=> array ($f->mask),
-					'operation'	=> PHPGW_ACL_READ
-				))
-				|| !$this->acl_check (array(
-					'string'	=> '/'.$path[1].'/'.$path[2],
-					'relatives'	=> array ($f->mask),
-					'operation'	=> PHPGW_ACL_DELETE
-				))
-			)
-			{
-				return False;
-			}
-
-			if (!$this->acl_check (array(
-					'string'	=> '/'.$path[1].'/'.$path[2],
+					'string'	=> $data['to'],
 					'relatives'	=> array ($t->mask),
 					'operation'	=> PHPGW_ACL_ADD
@@ -1425,5 +1412,5 @@
 			{
 				if (!$this->acl_check (array(
-						'string'	=> '/'.$path[1].'/'.$path[2],
+						'string'	=> $data['to'],
 						'relatives'	=> array ($t->mask),
 						'operation'	=> PHPGW_ACL_EDIT
@@ -1615,16 +1602,4 @@
 				)
 			);
-			// Inside the folder that you have pemission you can do anything you want
-			$path = explode('/',$p->fake_full_path);
-			if (!$this->acl_check (array(
-					'string'	=> '/'.$path[1].'/'.$path[2],
-					'relatives'	=> array ($p->mask),
-					'operation'	=> PHPGW_ACL_DELETE
-				))
-			)
-			{
-				return False;
-			}
-
 			if (!$this->file_exists (array(
 					'string'	=> $data['string'],
