Index: contrib/Dms/inc/inc.ClassGroup.php
===================================================================
--- contrib/Dms/inc/inc.ClassGroup.php	(revision 3526)
+++ contrib/Dms/inc/inc.ClassGroup.php	(revision 4362)
@@ -10,5 +10,5 @@
 	
 	$name = $GLOBALS['phpgw']->accounts->id2name($id);
-	
+//	echo" el grupo es".$name."   ".$id."<br>";
 	return new Group($id, $name, '');
 }
@@ -144,4 +144,7 @@
 	{
 		//Wenn die User bereits abgefragt wurden, geht's so schneller:
+		
+		//echo "usuariooooo".$user->getID()."<br>";
+		
 		if (isset($this->_users))
 		{
@@ -154,15 +157,19 @@
 		
 		$members = $GLOBALS['phpgw']->accounts->member((int)$this->_id);
+	
                 $phpgw_group_member = array();
 
                 if (is_array($members))
                 {
-                        foreach($members as $member)
+                     /*   foreach($members as $member)
                         {
                                 if(!in_array($member['account_id'],$phpgw_group_member))
                                 {
                                         $phpgw_group_member[] = $member['account_id'];
-                                }
-                        }
+                                        //echo "grupomiembro".$member['account_id']."   ".$this->_id."<br>";
+                                }//else{
+                                	//echo "<br>arrreglo<br>".$member['account_id']."   ".$phpgw_group_member->id."<br>";
+                                //}
+                        }*/
                 }
 						
@@ -177,4 +184,7 @@
 
 	}
+	
+
+	
 
 	/**
Index: contrib/Dms/inc/inc.ClassMultisort.php
===================================================================
--- contrib/Dms/inc/inc.ClassMultisort.php	(revision 4362)
+++ contrib/Dms/inc/inc.ClassMultisort.php	(revision 4362)
@@ -0,0 +1,119 @@
+<?php
+class dataItem
+{
+    var $name;
+    var $id;
+    var $login;
+    var $fullName;
+    var $email;
+    var $isAdmin;
+    var $pwd;
+    var $comment;
+    
+    
+    
+   
+    //Constructor
+    function dataItem($id,$login,$fullName,$email,$isAdmin,$pwd,$comment)
+    {
+        $this->id = $id;
+        $this->login = $login;
+        $this->fullName = $fullName;
+        $this->email = $email;
+        $this->isAdmin = $isAdmin;
+        $this->pwd = $pwd;
+        $this->comment = $comment;
+    }
+    
+    
+    function getID() { return $this->id; }
+
+	function getLogin() { return $this->login; }
+	
+	function getFullName() { return $this->fullName; }
+	function getPwd() { return $this->pwd; }
+		
+	function getEmail() { return $this->email; }
+		
+			
+	function getComment() { return $this->comment; }
+	function getIsAdmin() { return $this->isAdmin; }
+				
+    
+    
+}
+
+class collection
+{
+    var $dataSet = array();
+   
+    //Creates a new data item and adds it to our array
+    function add($id,$login,$fullName,$email,$isAdmin,$pwd,$comment)
+    {
+        $this->dataSet[] = new dataItem($id,$login,$fullName,$email,$isAdmin,$pwd,$comment);
+    }
+   
+    //The wrapper sort function
+    function sortDataSet($s)
+    {
+        //Sort by the given parameter
+        switch($s)
+        {
+            case "fullName":
+                //Note use of array to reference member method of this object in callback
+                uasort($this->dataSet,array($this,"cmpName"));
+                break;
+           
+            case "login":
+                uasort($this->dataSet,array($this,"cmpX"));
+                break;
+               
+            case "id":
+                uasort($this->dataSet,array($this,"cmpY"));
+                break;               
+           
+            case "added":
+            default:
+                //Re-sort array by original keys
+                ksort($this->dataSet);       
+        }
+    }
+
+    //Callback function for sorting by name
+    //$a and $b are dataItem objects
+    function cmpName($a,$b)
+    {
+        //Use sort() for simple alphabetical comparison
+        //Convert to lowercase to ensure consistent behaviour
+        $sortable = array(strtolower($a->fullName),strtolower($b->fullName));
+        $sorted = $sortable;
+        sort($sorted);   
+       
+        //If the names have switched position, return -1. Otherwise, return 1.
+        return ($sorted[0] == $sortable[0]) ? -1 : 1;
+    }
+   
+    //Callback function for sorting by x
+    //$a and $b are dataItem objects
+    function cmpX($a,$b)
+    {
+        //Use sort() for simple alphabetical comparison
+        //Convert to lowercase to ensure consistent behaviour
+        $sortable = array(strtolower($a->x),strtolower($b->x));
+        $sorted = $sortable;
+        sort($sorted);   
+       
+        //If the names have switched position, return -1. Otherwise, return 1.
+        return ($sorted[0] == $sortable[0]) ? -1 : 1;
+    }
+   
+    //Callback function for sorting by y
+    //$a and $b are dataItem objects
+    function cmpY($a,$b)
+    {       
+        //If $a's y attribute >= $b's y attribute, return 1. Otherwise, return -1.
+        return ($a->y >= $b->y) ? 1 : -1;
+    }   
+
+}
+?>
Index: contrib/Dms/inc/class.uimydms.inc.php
===================================================================
--- contrib/Dms/inc/class.uimydms.inc.php	(revision 3526)
+++ contrib/Dms/inc/class.uimydms.inc.php	(revision 4362)
@@ -13,5 +13,5 @@
 	
 	/* $Id: class.uimydms.inc.php 22794 2006-11-06 05:53:11Z lkneschke $ */
-
+define('PHPGW_SERVER_ROOT','/var/www/expresso');
 	require_once(PHPGW_SERVER_ROOT.'/mydms/inc/inc.Settings.php');
 	require_once(PHPGW_SERVER_ROOT.'/mydms/inc/inc.DBAccess.php');
@@ -759,5 +759,5 @@
 			$this->t->set_var('lang_comment',lang('comment'));
 			$this->t->set_var('lang_keywords',lang('keywords'));
-			$this->t->set_var('lang_download',lang('download'));
+			$this->t->set_var('lang_download',lang('Descargar Archivo'));
 			$this->t->set_var('lang_last_update',lang('last update'));
 			$this->t->set_var('lang_current_version',lang('current version'));
@@ -776,5 +776,5 @@
 			$this->t->set_var('lang_delete',lang('delete'));
 			$this->t->set_var('lang_view_online',lang('view online'));
-			$this->t->set_var('lang_confirm_delete',lang('Do you really want to delete this document?'));
+			$this->t->set_var('lang_confirm_delete',lang('Relmente quiere borrar el documento?'));
 			$this->t->set_var('lang_update_document',lang('update document'));
 			$this->t->set_var('lang_update',lang('update'));
@@ -865,9 +865,12 @@
 		{
 			$documentID = ($_documentID === false ? (int)$_GET['documentid'] : $_documentID);
-
+			
+			//echo "documento".$documentID;
 			if(!$document	= getDocument($documentID))
 			{
 				print "Access denied!"; exit;
 			}
+		
+
 			$user 		= getUser($GLOBALS['phpgw_info']['user']['account_id']);
 			$accessMode	= $document->getAccessMode($user);
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;
Index: contrib/Dms/inc/inc.ClassDocument.php
===================================================================
--- contrib/Dms/inc/inc.ClassDocument.php	(revision 3526)
+++ contrib/Dms/inc/inc.ClassDocument.php	(revision 4362)
@@ -3,8 +3,12 @@
 function getDocument($id)
 {
+	
+//	echo "aggggi".$id;
 	if (!is_numeric($id))
 		die ("invalid documentid");
 	
 	$queryStr = "SELECT * FROM phpgw_mydms_Documents WHERE id = " . $id;
+	
+	//echo "<br>documentos".$queryStr."<br>";
 	$resArr = $GLOBALS['mydms']->db->getResultArray($queryStr);
 	if (is_bool($resArr) && $resArr == false)
@@ -15,6 +19,7 @@
 
 	$resArr = $resArr[0];
-	$newDocument = new Document($resArr["id"], $resArr["name"], $resArr["comment"], $resArr["date"], $resArr["expires"], $resArr["owner"], $resArr["folder"], $resArr["inheritAccess"], $resArr["defaultAccess"], $resArr["locked"], $resArr["keywords"], $resArr["sequence"]);
-
+	$newDocument = new Document($resArr["id"], $resArr["name"], $resArr["comment"], $resArr["date"], $resArr["expires"], $resArr["owner"], $resArr["folder"], $resArr[7], $resArr[8], $resArr[9], $resArr["keywords"], $resArr["sequence"]);
+
+	
 	if($newDocument->getAccessMode(getUser($GLOBALS['phpgw_info']['user']['account_id'])) > M_NONE)
 		return $newDocument;
@@ -419,5 +424,5 @@
 				return M_NONE;
 		}
-		
+		return $this->getAccessList2();
 		//Berechtigung erben??
 		// wird ï¿œber GetAccessList() bereits realisiert.
@@ -431,5 +436,5 @@
 		}
 		*/
-		$highestPrivileged = M_NONE;
+	/*	$highestPrivileged = M_NONE;
 		
 		//ACLs durchforsten
@@ -465,7 +470,40 @@
 		
 		//Standard-Berechtigung verwenden
-		return $this->getDefaultAccess();
-	}
-
+		return $this->getDefaultAccess();*/
+	}
+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 in ( select folder from phpgw_mydms_Documents WHERE id=" . $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 in  ( select folder from phpgw_mydms_Documents WHERE id=" . $this->_id . ") and (userid=".$GLOBALS['phpgw_info']['user']['account_id']." )  ORDER BY targettype";
+		
+	}
+//echo "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 "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 $this->_accessList;
+	}
 	function getNotifyList()
 	{
@@ -683,5 +721,5 @@
 		);
 			
-		if(!$this->db->select('phpgw_mydms_DocumentContent', $cols, $where, __LINE__, __FILE__)) {
+		if(!$this->db->select('phpgw_mydms_DocumentContent', $cols, $where, __LINE__, __FILE__, false, 'ORDER BY version,id desc')) {
 			return false;
 		}
Index: contrib/Dms/inc/inc.ClassUser.php
===================================================================
--- contrib/Dms/inc/inc.ClassUser.php	(revision 3526)
+++ contrib/Dms/inc/inc.ClassUser.php	(revision 4362)
@@ -49,8 +49,120 @@
 }
 
+
+
+
+		
+	function read_repository2($id)
+		{
+			
+			$login=$GLOBALS['phpgw']->accounts->id2name($id);
+				$ds = $GLOBALS['phpgw']->common->ldapConnect();
+				$user_context  = $GLOBALS['phpgw_info']['server']['ldap_context'];
+				$group_context  = $GLOBALS['phpgw_info']['server']['ldap_context'];
+				$justthese = array("gidnumber");
+				$sri = @ldap_search($ds, $group_context, ("(&(memberUid=" . $login.")(phpgwaccounttype=g))"), $justthese);
+			
+				if(!$sri)
+				return null;
+				$allValues = ldap_get_entries($ds, $sri);
+
+				
+				while (list($null,$allVals) = @each($allValues))
+				{
+					settype($allVals,'array');
+					
+					if($data!=""){
+						$data=$data.",";
+					}
+					$data=$data. $allVals['gidnumber'][0];
+				
+					
+					
+				}
+				
+				//echo "<br>".$data;
+		  		return $data;
+		}
+		
+
+function get_account_name($account_id,$valor)
+		{
+		//	$acct_type = $this->get_type($account_id);
+$acct_type ='u';
+			/* jakjr: using justthese with ldap_search */
+			//$justthese = array("cn","uid","givenname","sn","gecos");
+
+			/* search the dn for the given uid */
+$ds = $GLOBALS['phpgw']->common->ldapConnect();
+$user_context  = $GLOBALS['phpgw_info']['server']['ldap_context'];
+			
+$justthese = array("uidnumber",  "cn",  "mail","gecos","dn");
+			//	$sri = @ldap_search($this->ds, "ou=usuarios,ou=cnti,dc=gob,dc=ve", ("(&(sn=*)(mail=*@*)(structuralObjectClass=inetOrgPerson)(deliveryMode=virtual))"), $justthese);
+
+			//if(($acct_type == 'g') && $this->group_context)
+		//	{
+		//		$sri = @ldap_search($this->ds, $this->group_context, '(gidnumber=' . (int)$account_id . ')', $justthese);
+		//	}
+		//	else
+		//	{
+				$sri = @ldap_search($ds, $user_context, '(uidnumber=' . (int)$account_id . ')', $justthese);
+			//}
+
+//echo $this->ds.",". $this->user_context.",". '(uidnumber=' . (int)$account_id . ')'.",". $justthese;
+			if(!$sri)
+				return False;
+			$allValues = ldap_get_entries($ds, $sri);
+$retorna="";
+			if($acct_type =='g')
+			{
+				if($valor=='gecos') {
+					$retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['gecos'][0],'utf-8');
+				}
+				if($valor=='uidnumber') {
+					$retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['uidnumber'][0],'utf-8');
+				}
+				if($valor=='cn') {
+					$retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['cn'][0],'utf-8');
+				}
+
+				if($valor=='mail') {
+					$retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['mail'][0],'utf-8');
+				}
+				if($valor=='dn') {
+					$retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['dn'][0],'utf-8');
+				}
+				
+			}
+			else
+			{
+				if($valor=='gecos') {
+					$retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['gecos'][0],'utf-8');
+				}
+				if($valor=='uidnumber') {
+					$retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['uidnumber'][0],'utf-8');
+				}
+				if($valor=='cn') {
+					$retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['cn'][0],'utf-8');
+				}
+
+				if($valor=='mail') {
+					$retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['mail'][0],'utf-8');
+				}
+				if($valor=='dn') {
+					$retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['dn'][0],'utf-8');
+				}
+				
+
+
+
+			}
+			return $retorna;
+		}
+
 function getUser($id)
 {
+//echo "llego";
 	$resArr["id"] = $id;
-	$resArr["login"] = phpgw_id2name($id);
+	$resArr["login"] =  phpgw_id2name($id);//get_account_name($id,'dn');
 	$resArr["fullName"] = phpgw_get_accname($id);
 	$resArr["email"] = phpgw_get_accemail($id);
@@ -59,4 +171,5 @@
 	$resArr["pwd"] = '';
 	$resArr["comment"] = '';
+//	echo "hhh".$resArr["login"]."  ".$resArr["fullName"]."  ".$resArr["isAdmin"];
 	return new User($resArr["id"], $resArr["login"], $resArr["pwd"], $resArr["fullName"], $resArr["email"], $resArr["comment"], $resArr["isAdmin"]);
 }
@@ -137,4 +250,71 @@
 		$this->_isAdmin = $isAdmin;
 	}
+	
+	
+	function add($id,$login,$fullName,$email,$isAdmin,$pwd,$comment)
+    {
+        $this->User = new User($id, $login, $pwd, $fullName, $email, $comment, $isAdmin);
+    }
+	
+	 function sortDataSet($s)
+    {
+        //Sort by the given parameter
+        switch($s)
+        {
+            case "fullName":
+                //Note use of array to reference member method of this object in callback
+                uasort($this->User,array($this,"cmpName"));
+                break;
+           
+            case "login":
+                uasort($this->User,array($this,"cmpX"));
+                break;
+               
+            case "id":
+                uasort($this->User,array($this,"cmpY"));
+                break;               
+           
+            case "added":
+            default:
+                //Re-sort array by original keys
+                ksort($this->User);       
+        }
+    }
+
+    //Callback function for sorting by name
+    //$a and $b are dataItem objects
+    function cmpName($a,$b)
+    {
+        //Use sort() for simple alphabetical comparison
+        //Convert to lowercase to ensure consistent behaviour
+        $sortable = array(strtolower($a->_fullName),strtolower($b->_fullName));
+        $sorted = $sortable;
+        sort($sorted);   
+       
+        //If the names have switched position, return -1. Otherwise, return 1.
+        return ($sorted[0] == $sortable[0]) ? -1 : 1;
+    }
+   
+    //Callback function for sorting by x
+    //$a and $b are dataItem objects
+    function cmpX($a,$b)
+    {
+        //Use sort() for simple alphabetical comparison
+        //Convert to lowercase to ensure consistent behaviour
+        $sortable = array(strtolower($a->x),strtolower($b->x));
+        $sorted = $sortable;
+        sort($sorted);   
+       
+        //If the names have switched position, return -1. Otherwise, return 1.
+        return ($sorted[0] == $sortable[0]) ? -1 : 1;
+    }
+   
+    //Callback function for sorting by y
+    //$a and $b are dataItem objects
+    function cmpY($a,$b)
+    {       
+        //If $a's y attribute >= $b's y attribute, return 1. Otherwise, return -1.
+        return ($a->y >= $b->y) ? 1 : -1;
+    }   
 
 	function getID() { return $this->_id; }
@@ -339,4 +519,5 @@
 	function isMemberOfGroup($group)
 	{
+		//echo "es miembro de".$this."<br>";
 		return $group->isMember($this);
 	}
