[Fusionforge-commits] r14523 - in trunk/src: common/docman common/docman/include db

Franck VILLAUME nerville at fusionforge.org
Sun Oct 2 20:35:49 CEST 2011


Author: nerville
Date: 2011-10-02 20:35:49 +0200 (Sun, 02 Oct 2011)
New Revision: 14523

Added:
   trunk/src/db/20111002-docman-doc_groups-createdate-updatedate.sql
Modified:
   trunk/src/common/docman/DocumentGroup.class.php
   trunk/src/common/docman/include/webdav.php
Log:
add support for createdate and updatedate in doc_groups: useful for webdav

Modified: trunk/src/common/docman/DocumentGroup.class.php
===================================================================
--- trunk/src/common/docman/DocumentGroup.class.php	2011-10-02 18:08:45 UTC (rev 14522)
+++ trunk/src/common/docman/DocumentGroup.class.php	2011-10-02 18:35:49 UTC (rev 14523)
@@ -134,11 +134,12 @@
 			return false;
 		}
 
-		$result = db_query_params('INSERT INTO doc_groups (group_id,groupname,parent_doc_group,stateid) VALUES ($1, $2, $3, $4)',
+		$result = db_query_params('INSERT INTO doc_groups (group_id,groupname,parent_doc_group,stateid,createdate) VALUES ($1, $2, $3, $4, $5)',
 						array ($this->Group->getID(),
 							htmlspecialchars($name),
 							$parent_doc_group,
-							'1')
+							'1',
+							time())
 						);
 		if ($result && db_affected_rows($result) > 0) {
 			$this->clearError();

Modified: trunk/src/common/docman/include/webdav.php
===================================================================
--- trunk/src/common/docman/include/webdav.php	2011-10-02 18:08:45 UTC (rev 14522)
+++ trunk/src/common/docman/include/webdav.php	2011-10-02 18:35:49 UTC (rev 14523)
@@ -65,6 +65,7 @@
 				}
 			}
 		}
+
 		return false;
 	}
 
@@ -104,9 +105,16 @@
 		if ($g->isError())
 			return false;
 
+		/* 4 is coming from the url: http://yourforge/docman/6/webdav/the/directory
+			1 = http://yourforge
+			2 = docman
+			3 = id group
+			4 = webdav
+			the rest is the path /the/directory
+		*/
 		if ( 4 < count($arr_path)) {
 			$subpath = '';
-			for ($i=5; $i<count($arr_path); $i++){
+			for ($i = 5; $i < count($arr_path); $i++){
 				$subpath .= '/'.$arr_path[$i];
 			}
 		}
@@ -115,36 +123,41 @@
 			$subpath = '/';
 		}
 
-		$analysed_path = $this->analyse($subpath,$group_id);
+		$analysed_path = $this->analyse($subpath, $group_id);
 
 		if ($analysed_path['isdir']) {
 			$i = 0;
 			$files["files"] = array();
 			$path = $options['path'];
-			$name = basename($path);
+			$res = db_query_params('select * from doc_groups where group_id = $1 and doc_group = $2',
+						array($group_id, $analysed_path['doc_group']));
+			if (!$res)
+				return false;
+
+			$arr = db_fetch_array($res);
 			$files["files"][$i] = array();
 			$files["files"][$i]["path"] = $path;
 			$files["files"][$i]["props"] = array();
-			$files["files"][$i]["props"][] = $this->mkprop("displayname", $name);
-			$files["files"][$i]["props"][] = $this->mkprop("creationdate", '');
-			$files["files"][$i]["props"][] = $this->mkprop("getlastmodified", '');
+			$files["files"][$i]["props"][] = $this->mkprop("displayname", $arr['groupname']);
+			$files["files"][$i]["props"][] = $this->mkprop("creationdate", $arr['createdate']);
+			$files["files"][$i]["props"][] = $this->mkprop("getlastmodified", $arr['updatedate']);
 			$files["files"][$i]["props"][] = $this->mkprop("lastaccessed", '');
 			$files["files"][$i]["props"][] = $this->mkprop("ishidden", false);
 			$files["files"][$i]["props"][] = $this->mkprop("resourcetype", "collection");
 			$files["files"][$i]["props"][] = $this->mkprop("getcontenttype", "httpd/unix-directory");
 			$res = db_query_params('select * from doc_groups where group_id = $1 and parent_doc_group = $2',
 						array($group_id, $analysed_path['doc_group']));
-			if (!$res) {
+			if (!$res)
 				return false;
-			}
+
 			while ($arr = db_fetch_array($res)) {
 				$i++;
 				$files["files"][$i] = array();
 				$files["files"][$i]["path"]  = $path.'/'.$arr['groupname'];
 				$files["files"][$i]["props"] = array();
 				$files["files"][$i]["props"][] = $this->mkprop("displayname", $arr['groupname']);
-				$files["files"][$i]["props"][] = $this->mkprop("creationdate", '');
-				$files["files"][$i]["props"][] = $this->mkprop("getlastmodified", '');
+				$files["files"][$i]["props"][] = $this->mkprop("creationdate", $arr['createdate']);
+				$files["files"][$i]["props"][] = $this->mkprop("getlastmodified", $arr['updatedate']);
 				$files["files"][$i]["props"][] = $this->mkprop("lastaccessed", '');
 				$files["files"][$i]["props"][] = $this->mkprop("ishidden", false);
 				$files["files"][$i]["props"][] = $this->mkprop("resourcetype","collection");
@@ -152,9 +165,9 @@
 			}
 			$res = db_query_params('select filename,filetype,filesize,createdate,updatedate from doc_data where group_id = $1 and doc_group = $2',
 				array($group_id, $analysed_path['doc_group']));
-			if (!$res) {
+			if (!$res)
 				return false;
-			}
+
 			while ($arr = db_fetch_array($res)) {
 				$i++;
 				$files["files"][$i] = array();
@@ -169,6 +182,7 @@
 				$files["files"][$i]["props"][] = $this->mkprop("getcontenttype", $arr['filetype']);
 			}
 		}
+
 		return true;
 	}
 
@@ -285,6 +299,7 @@
 			}
 			$analysed_path = $this->whatIsIt($path_arr[$i], $group_id, $analysed_path);
 		}
+
 		return $analysed_path;
 	}
 

Added: trunk/src/db/20111002-docman-doc_groups-createdate-updatedate.sql
===================================================================
--- trunk/src/db/20111002-docman-doc_groups-createdate-updatedate.sql	                        (rev 0)
+++ trunk/src/db/20111002-docman-doc_groups-createdate-updatedate.sql	2011-10-02 18:35:49 UTC (rev 14523)
@@ -0,0 +1,2 @@
+alter table doc_groups add column updatedate integer DEFAULT 0 NOT NULL;
+alter table doc_groups add column createdate integer DEFAULT 0 NOT NULL;




More information about the Fusionforge-commits mailing list