Index: contrib/Dms/inc/inc.ClassFolder.php
===================================================================
--- contrib/Dms/inc/inc.ClassFolder.php	(revision 3526)
+++ contrib/Dms/inc/inc.ClassFolder.php	(revision 4362)
@@ -4,6 +4,7 @@
 	if (!is_numeric($id))
 		die ("invalid folderid");
-
-	$queryStr = "SELECT * FROM phpgw_mydms_Folders WHERE id = " . $id;
+	$queryStr = "SELECT id,name,parent,comment,owner,inheritaccess,defaultaccess,sequence FROM phpgw_mydms_folders WHERE id = " . $id;
+	
+	//echo "<br>folderrrrr".$queryStr."<br>";
 	$resArr = $GLOBALS['mydms']->db->getResultArray($queryStr);
 		
@@ -15,14 +16,19 @@
 	$resArr = $resArr[0];
 	if($id == 1) {
-		$resArr["defaultAccess"] = M_READ;
-	}
-	$newFolder =  new Folder($resArr["id"], $resArr["name"], $resArr["parent"], $resArr["comment"], $resArr["owner"], $resArr["inheritAccess"], $resArr["defaultAccess"], $resArr["sequence"]);
+		$resArr[6] = M_READ;
+	}
+	//	echo $resArr["id"]."  ".$resArr[6]." ".$resArr["parent"]."   ".$id."  ".$GLOBALS['phpgw_info']['user']['account_id']." dddd ".$resArr[5]."  dddd ".$resArr["defaultAccess"];
 	
+	$newFolder =  new Folder($resArr["id"], $resArr["name"], $resArr["parent"], $resArr["comment"], $resArr["owner"], $resArr["inheritaccess"], $resArr["defaultaccess"], $resArr["sequence"]);
+	//echo "llll".$GLOBALS['phpgw_info']['user']['account_id']."   ".$resArr["inheritaccess"];
 	#print $resArr["name"]."<br>";
 	#print $newFolder->getAccessMode(getUser($GLOBALS['phpgw_info']['user']['account_id']))."<br>";
-	if($newFolder->getAccessMode(getUser($GLOBALS['phpgw_info']['user']['account_id'])) > 1)
-        	return $newFolder;
-	else
+	if($newFolder->getAccessMode(getUser($GLOBALS['phpgw_info']['user']['account_id'])) > 1){
+	//echo "retornoooo";    
+		return $newFolder;
+	}
+	else{
 		return false;
+	}
 }
 
@@ -45,4 +51,8 @@
 	function Folder($id, $name, $parentID, $comment, $ownerID, $inheritAccess, $defaultAccess, $sequence)
 	{
+		//echo "aaaaaccccseexxx".$inheritAccess;
+			if($inheritAccess=='f'){
+				unset($inheritAccess);
+			}	
 		$this->_id = $id;
 		$this->_name = $name;
@@ -53,7 +63,7 @@
 		$this->_defaultAccess = $defaultAccess;
 		$this->_sequence = $sequence;
-		
 		$this->db = clone($GLOBALS['phpgw']->db);
 		$this->db->set_app('mydms');
+	//	echo"accc".$defaultAccess."lll{Ã±{{Ã±".$inheritAccess;
 	}
 
@@ -67,5 +77,5 @@
 		$where	= array('id' => $this->_id);
 		
-		if(!$this->db->update('phpgw_mydms_Folders', $data, $where, __LINE__, __FILE__))
+		if(!$this->db->update('phpgw_mydms_folders', $data, $where, __LINE__, __FILE__))
 			return false;
 		
@@ -82,5 +92,5 @@
 		$where	= array('id' => $this->_id);
 		
-		if(!$this->db->update('phpgw_mydms_Folders', $data, $where, __LINE__, __FILE__))
+		if(!$this->db->update('phpgw_mydms_folders', $data, $where, __LINE__, __FILE__))
 			return false;
 		
@@ -105,5 +115,5 @@
 		$where	= array('id' => $this->_id);
 		
-		if(!$this->db->update('phpgw_mydms_Folders', $data, $where, __LINE__, __FILE__))
+		if(!$this->db->update('phpgw_mydms_folders', $data, $where, __LINE__, __FILE__))
 			return false;
 		
@@ -126,5 +136,5 @@
 		$where	= array('id' => $this->_id);
 		
-		if(!$this->db->update('phpgw_mydms_Folders', $data, $where, __LINE__, __FILE__))
+		if(!$this->db->update('phpgw_mydms_folders', $data, $where, __LINE__, __FILE__))
 			return false;
 		
@@ -151,5 +161,5 @@
 		$where	= array('id' => $this->_id);
 		
-		if(!$this->db->update('phpgw_mydms_Folders', $data, $where, __LINE__, __FILE__))
+		if(!$this->db->update('phpgw_mydms_folders', $data, $where, __LINE__, __FILE__))
 			return false;
 		
@@ -167,5 +177,5 @@
 		$where	= array('id' => $this->_id);
 		
-		if(!$this->db->update('phpgw_mydms_Folders', $data, $where, __LINE__, __FILE__))
+		if(!$this->db->update('phpgw_mydms_folders', $data, $where, __LINE__, __FILE__))
 			return false;
 		
@@ -181,5 +191,5 @@
 		$where	= array('id' => $this->_id);
 		
-		if(!$this->db->update('phpgw_mydms_Folders', $data, $where, __LINE__, __FILE__))
+		if(!$this->db->update('phpgw_mydms_folders', $data, $where, __LINE__, __FILE__))
 			return false;
 
@@ -192,5 +202,5 @@
 		if (!isset($this->_subFolders))
 		{
-			$queryStr = "SELECT * FROM phpgw_mydms_Folders WHERE parent = " . $this->_id . " ORDER BY sequence";
+			$queryStr = "SELECT * FROM phpgw_mydms_folders WHERE parent = " . $this->_id . " ORDER BY sequence";
 
 
@@ -226,5 +236,5 @@
 			'sequence'	=> $sequence,
 		);
-		$res = $this->db->insert('phpgw_mydms_Folders', $insertData, '', __LINE__, __FILE__, 'mydms');
+		$res = $this->db->insert('phpgw_mydms_folders', $insertData, '', __LINE__, __FILE__, 'mydms');
 
 		if (!$res)
@@ -233,5 +243,5 @@
 		unset($this->_subFolders);
 		
-		return getFolder($this->db->get_last_insert_id('phpgw_mydms_Folders','id'));
+		return getFolder($this->db->get_last_insert_id('phpgw_mydms_folders','id'));
 	}
 
@@ -307,7 +317,10 @@
 	function getDocuments()
 	{
+		
+	//	echo "aaaaaaaquoooooo";
 		if (!isset($this->_documents))
 		{
-			$queryStr = "SELECT * FROM phpgw_mydms_Documents WHERE folder = " . $this->_id . " ORDER BY sequence";
+			$queryStr = "SELECT * FROM phpgw_mydms_documents WHERE folder = " . $this->_id . " ORDER BY id desc,sequence";
+		//	echo "eeeeee".$queryStr;
 			$resArr = $GLOBALS['mydms']->db->getResultArray($queryStr);
 			if (is_bool($resArr) && !$resArr)
@@ -341,5 +354,5 @@
 			'sequence'	=> $sequence,
 		);
-		$res = $this->db->insert('phpgw_mydms_Documents', $insertData, '', __LINE__, __FILE__, 'mydms');
+		$res = $this->db->insert('phpgw_mydms_documents', $insertData, '', __LINE__, __FILE__, 'mydms');
 
 		if (!$res)
@@ -355,10 +368,10 @@
 		#	return false;
 		
-		$document = getDocument($this->db->get_last_insert_id('phpgw_mydms_Documents','id'));
+		$document = getDocument($this->db->get_last_insert_id('phpgw_mydms_documents','id'));
 		
 		$res = $document->addContent($comment, $owner, $tmpFile, $orgFileName, $fileType, $mimeType);
 		if (is_bool($res) && !$res)
 		{
-			$queryStr = "DELETE FROM phpgw_mydms_Documents WHERE id = " . $document->getID();
+			$queryStr = "DELETE FROM phpgw_mydms_documents WHERE id = " . $document->getID();
 			$GLOBALS['mydms']->db->getResult($queryStr);
 			return false;
@@ -389,11 +402,11 @@
 		
 		//Entfernen der Datenbankeintrï¿œge
-		$queryStr = "DELETE FROM phpgw_mydms_Folders WHERE id =  " . $this->_id;
-		if (!$GLOBALS['mydms']->db->getResult($queryStr))
-			return false;
-		$queryStr = "DELETE FROM phpgw_mydms_ACLs WHERE target = ". $this->_id. " AND targetType = " . T_FOLDER;
-		if (!$GLOBALS['mydms']->db->getResult($queryStr))
-			return false;
-		$queryStr = "DELETE FROM phpgw_mydms_Notify WHERE target = ". $this->_id. " AND targetType = " . T_FOLDER;
+		$queryStr = "DELETE FROM phpgw_mydms_folders WHERE id =  " . $this->_id;
+		if (!$GLOBALS['mydms']->db->getResult($queryStr))
+			return false;
+		$queryStr = "DELETE FROM phpgw_mydms_acls WHERE target = ". $this->_id. " AND targettype = " . T_FOLDER;
+		if (!$GLOBALS['mydms']->db->getResult($queryStr))
+			return false;
+		$queryStr = "DELETE FROM phpgw_mydms_notify WHERE target = ". $this->_id. " AND targettype = " . T_FOLDER;
 		if (!$GLOBALS['mydms']->db->getResult($queryStr))
 			return false;
@@ -415,6 +428,6 @@
 		if (!isset($this->_accessList))
 		{
-			$queryStr = "SELECT * FROM phpgw_mydms_ACLs WHERE targetType = ".T_FOLDER." AND target = " . $this->_id . " ORDER BY targetType";
-
+			$queryStr = "SELECT * FROM phpgw_mydms_acls WHERE targettype = ".T_FOLDER." AND target = " . $this->_id . " ORDER BY targettype";
+//echo "aqui".$queryStr ;
 			$resArr = $GLOBALS['mydms']->db->getResultArray($queryStr);
 
@@ -426,4 +439,6 @@
 			foreach ($resArr as $row)
 			{
+								//echo "el grupo de acceso es".$row[4]."   ".$row["groupid"]."<br>";
+				
 				if ($row["userid"] != -1)
 					array_push($this->_accessList["users"], new UserAccess($row["userid"], $row["mode"]));
@@ -435,8 +450,44 @@
 		return $this->_accessList;
 	}
+	
+	
+	
+function getAccessList2()
+	{
+		
+		$grupos=read_repository2($GLOBALS['phpgw_info']['user']['account_id']);
+	//	echo "".$GLOBALS['phpgw_info']['user']['account_id'];
+
+	if($grupos!=''){
+			$queryStr = "SELECT * FROM phpgw_mydms_acls WHERE targettype = ".T_FOLDER." AND target = " . $this->_id . " and (userid=".$GLOBALS['phpgw_info']['user']['account_id']." or groupid in (".$grupos."))  ORDER BY targettype";
+	}else{
+					$queryStr = "SELECT * FROM phpgw_mydms_acls WHERE targettype = ".T_FOLDER." AND target = " . $this->_id . " and (userid=".$GLOBALS['phpgw_info']['user']['account_id']." )  ORDER BY targettype";
+		
+	}
+//echo "<br>aqui".$queryStr ;
+			$resArr = $GLOBALS['mydms']->db->getResultArray($queryStr);
+
+
+			if (is_bool($resArr) && !$resArr)
+				return false;
+			
+			//$this->_accessList = array("groups" => array(), "users" => array());
+			foreach ($resArr as $row)
+			{
+				//echo "acceso".$row["mode"];
+								//echo "el grupo de acceso es".$row[4]."   ".$row["groupid"]."<br>";
+				return $row["mode"];
+				/*if ($row["userid"] != -1)
+					array_push($this->_accessList["users"], new UserAccess($row["userid"], $row["mode"]));
+				else //if ($row["groupID"] != -1)
+					array_push($this->_accessList["groups"], new GroupAccess($row["groupid"], $row["mode"]));*/
+			}
+		
+		return false;
+	}
 
 	function clearAccessList()
 	{
-		$queryStr = "DELETE FROM phpgw_mydms_ACLs WHERE targetType = " . T_FOLDER . " AND target = " . $this->_id;
+		$queryStr = "DELETE FROM phpgw_mydms_acls WHERE targettype = " . T_FOLDER . " AND target = " . $this->_id;
 		if (!$GLOBALS['mydms']->db->getResult($queryStr))
 			return false;
@@ -450,5 +501,5 @@
 		$userOrGroup = ($isUser) ? "userid" : "groupid";
 		
-		$queryStr = "INSERT INTO phpgw_mydms_ACLs (target, targetType, ".$userOrGroup.", mode) VALUES 
+		$queryStr = "INSERT INTO phpgw_mydms_acls (target, targettype, ".$userOrGroup.", mode) VALUES 
 					(".$this->_id.", ".T_FOLDER.", " . $userOrGroupID . ", " .$mode. ")";
 		if (!$GLOBALS['mydms']->db->getResult($queryStr))
@@ -463,5 +514,5 @@
 		$userOrGroup = ($isUser) ? "userID" : "groupID";
 		
-		$queryStr = "UPDATE phpgw_mydms_ACLs SET mode = " . $newMode . " WHERE targetType = ".T_FOLDER." AND target = " . $this->_id . " AND " . $userOrGroup . " = " . $userOrGroupID;
+		$queryStr = "UPDATE phpgw_mydms_acls SET mode = " . $newMode . " WHERE targettype = ".T_FOLDER." AND target = " . $this->_id . " AND " . $userOrGroup . " = " . $userOrGroupID;
 		if (!$GLOBALS['mydms']->db->getResult($queryStr))
 			return false;
@@ -475,5 +526,5 @@
 		$userOrGroup = ($isUser) ? "userID" : "groupID";
 		
-		$queryStr = "DELETE FROM phpgw_mydms_ACLs WHERE targetType = ".T_FOLDER." AND target = ".$this->_id." AND ".$userOrGroup." = " . $userOrGroupID;
+		$queryStr = "DELETE FROM phpgw_mydms_acls WHERE targettype = ".T_FOLDER." AND target = ".$this->_id." AND ".$userOrGroup." = " . $userOrGroupID;
 		if (!$GLOBALS['mydms']->db->getResult($queryStr))
 			return false;
@@ -492,4 +543,5 @@
 	function getAccessMode($user)
 	{
+		
 		GLOBAL $settings;
 
@@ -532,5 +584,7 @@
 		//ACLs durchforsten
 		$foundInACL = false;
-		$accessList = $this->getAccessList();
+		
+		return $this->getAccessList2();
+		/*$accessList = $this->getAccessList();
 		if (!$accessList) {
 			return false;
@@ -552,6 +606,10 @@
 		foreach ($accessList["groups"] as $groupAccess)
 		{
+			
 			if ($user->isMemberOfGroup($groupAccess->getGroup()))
 			{
+				
+						//	echo "entro grupoooo<br>";//.$groupAccess->getGroup()."  <br>";
+				
 				$foundInACL = true;
 				if ($groupAccess->getMode() > $highestPrivileged)
@@ -562,8 +620,8 @@
 		}
 		if ($foundInACL)
-			return $highestPrivileged;
+			return $highestPrivileged;*/
 		
 		//Standard-Berechtigung verwenden
-		return $this->getDefaultAccess();
+		//return $this->getDefaultAccess();
 	}
 
@@ -572,5 +630,5 @@
 		if (!isset($this->_notifyList))
 		{
-			$queryStr ="SELECT * FROM phpgw_mydms_Notify WHERE targetType = " . T_FOLDER . " AND target = " . $this->_id;
+			$queryStr ="SELECT * FROM phpgw_mydms_notify WHERE targettype = " . T_FOLDER . " AND target = " . $this->_id;
 			$resArr = $GLOBALS['mydms']->db->getResultArray($queryStr);
 			if (is_bool($resArr) && $resArr == false)
@@ -593,5 +651,5 @@
 		$userOrGroup = ($isUser) ? "userID" : "groupID";
 		
-		$queryStr = "INSERT INTO phpgw_mydms_Notify (target, targetType, " . $userOrGroup . ") VALUES (" . $this->_id . ", " . T_FOLDER . ", " . $userOrGroupID . ")";
+		$queryStr = "INSERT INTO phpgw_mydms_notify (target, targettype, " . $userOrGroup . ") VALUES (" . $this->_id . ", " . T_FOLDER . ", " . $userOrGroupID . ")";
 		if (!$GLOBALS['mydms']->db->getResult($queryStr))
 			return false;
@@ -605,5 +663,5 @@
 		$userOrGroup = ($isUser) ? "userID" : "groupID";
 		
-		$queryStr = "DELETE FROM phpgw_mydms_Notify WHERE target = " . $this->_id . " AND targetType = " . T_FOLDER . " AND " . $userOrGroup . " = " . $userOrGroupID;
+		$queryStr = "DELETE FROM phpgw_mydms_notify WHERE target = " . $this->_id . " AND targettype = " . T_FOLDER . " AND " . $userOrGroup . " = " . $userOrGroupID;
 		if (!$GLOBALS['mydms']->db->getResult($queryStr))
 			return false;
