[Fusionforge-commits] FusionForge branch Branch_5_3 updated. dd68bb576eeba151d0617f90b4d1d07c1d6f2a7a

Franck Villaume nerville at fusionforge.org
Sun Apr 6 20:23:17 CEST 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, Branch_5_3 has been updated
       via  dd68bb576eeba151d0617f90b4d1d07c1d6f2a7a (commit)
       via  39ea31e222f837c3ce3039e57bc82730932171a0 (commit)
       via  09ed54a3284c18fa989a05f81b766afad44be4e0 (commit)
       via  f177fb4ef74523b7a15a7b548e744b94fa4ab6be (commit)
      from  88c6541211e4e3aac8969129a170fc8b8ded9229 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit dd68bb576eeba151d0617f90b4d1d07c1d6f2a7a
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Sun Apr 6 20:18:57 2014 +0200

    docman webdav: fix GET, enable support for dolphin, cadaver

diff --git a/src/common/docman/include/webdav.php b/src/common/docman/include/webdav.php
index 47255bc..0e689b3 100644
--- a/src/common/docman/include/webdav.php
+++ b/src/common/docman/include/webdav.php
@@ -68,7 +68,7 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 	}
 
 	/**
-	 * PROPFIND - use by any webdav client like cadaver
+	 * PROPFIND - use by any webdav client like cadaver / dolphin
 	 * called by HTTP_WebDAV_Server
 	 *
 	 * @param	array	$options	options passed by previous functions in HTTP_WebDAV_Server
@@ -162,16 +162,16 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 				} else {
 					$lastmodifieddate = $arr['createdate'];
 				}
-				$files["files"][$i] = array();
-				$files["files"][$i]["path"] = $path.'/'.$arr['filename'];
-				$files["files"][$i]["props"] = array();
-				$files["files"][$i]["props"][] = $this->mkprop("displayname", $arr['filename']);
-				$files["files"][$i]["props"][] = $this->mkprop("creationdate", $arr['createdate']);
-				$files["files"][$i]["props"][] = $this->mkprop("getlastmodified", $lastmodifieddate);
-				$files["files"][$i]["props"][] = $this->mkprop("lastaccessed", '');
-				$files["files"][$i]["props"][] = $this->mkprop("ishidden", false);
-				$files["files"][$i]["props"][] = $this->mkprop("getcontentlength", $arr['filesize']);
-				$files["files"][$i]["props"][] = $this->mkprop("getcontenttype", $arr['filetype']);
+				$files['files'][$i] = array();
+				$files['files'][$i]['path'] = $path.'/'.$arr['filename'];
+				$files['files'][$i]['props'] = array();
+				$files['files'][$i]['props'][] = $this->mkprop('displayname', $arr['filename']);
+				$files['files'][$i]['props'][] = $this->mkprop('creationdate', $arr['createdate']);
+				$files['files'][$i]['props'][] = $this->mkprop('getlastmodified', $lastmodifieddate);
+				$files['files'][$i]['props'][] = $this->mkprop('lastaccessed', '');
+				$files['files'][$i]['props'][] = $this->mkprop('ishidden', false);
+				$files['files'][$i]['props'][] = $this->mkprop('getcontentlength', $arr['filesize']);
+				$files['files'][$i]['props'][] = $this->mkprop('getcontenttype', $arr['filetype']);
 			}
 		} else {
 			$res = db_query_params('select filename,filetype,filesize,createdate,updatedate from doc_data where group_id = $1 and docid = $2',
@@ -185,16 +185,16 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 			} else {
 				$lastmodifieddate = $arr['createdate'];
 			}
-			$files["files"][0] = array();
-			$files["files"][0]["path"] = $path.'/'.$arr['filename'];
-			$files["files"][0]["props"] = array();
-			$files["files"][0]["props"][] = $this->mkprop("displayname", $arr['filename']);
-			$files["files"][0]["props"][] = $this->mkprop("creationdate", $arr['createdate']);
-			$files["files"][0]["props"][] = $this->mkprop("getlastmodified", $lastmodifieddate);
-			$files["files"][0]["props"][] = $this->mkprop("lastaccessed", '');
-			$files["files"][0]["props"][] = $this->mkprop("ishidden", false);
-			$files["files"][0]["props"][] = $this->mkprop("getcontentlength", $arr['filesize']);
-			$files["files"][0]["props"][] = $this->mkprop("getcontenttype", $arr['filetype']);
+			$files['files'][0] = array();
+			$files['files'][0]['path'] = $path.'/'.$arr['filename'];
+			$files['files'][0]['props'] = array();
+			$files['files'][0]['props'][] = $this->mkprop('displayname', $arr['filename']);
+			$files['files'][0]['props'][] = $this->mkprop('creationdate', $arr['createdate']);
+			$files['files'][0]['props'][] = $this->mkprop('getlastmodified', $lastmodifieddate);
+			$files['files'][0]['props'][] = $this->mkprop('lastaccessed', '');
+			$files['files'][0]['props'][] = $this->mkprop('ishidden', false);
+			$files['files'][0]['props'][] = $this->mkprop('getcontentlength', $arr['filesize']);
+			$files['files'][0]['props'][] = $this->mkprop('getcontenttype', $arr['filetype']);
 		}
 		return '200';
 	}
@@ -276,10 +276,13 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 
 			echo "</ul>";
 			echo "</body></html>\n";
+			//do not set return value... yet. The current implementation is rather buggy.
 		} else {
-			session_redirect('/docman/view.php/'.$group_id.'/'.$analysed_path['docid'].'/'.$analysed_path['filename']);
+			$g = group_get_object($group_id);
+			$d = new Document($g, $analysed_path['docid']);
+			$options['data'] = $d->getFileData();
+			return true;
 		}
-		exit;
 	}
 
 	function PUT(&$options) {

commit 39ea31e222f837c3ce3039e57bc82730932171a0
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Sun Apr 6 15:25:57 2014 +0200

    docman: make mkcol usable, fix propfind, use HTML helpers

diff --git a/src/CHANGES b/src/CHANGES
index 2d7c88a..5c5b0f7 100644
--- a/src/CHANGES
+++ b/src/CHANGES
@@ -1,3 +1,6 @@
+Fusionforge-X.X:
+* Docman: Basic Webdav write mkcol support (TrivialDev)
+
 FusionForge-5.3:
 * Widget: MyArtifacts Enhancement : add monitored artifacts (TrivialDev)
 * Trackers: Attachements moved to filesystem to allow larger attachments & reduce DB size (Alcatel-Lucent)
diff --git a/src/common/docman/include/webdav.php b/src/common/docman/include/webdav.php
index 66a19aa..47255bc 100644
--- a/src/common/docman/include/webdav.php
+++ b/src/common/docman/include/webdav.php
@@ -3,7 +3,7 @@
  * FusionForge Documentation Manager
  *
  * Copyright 2010-2011, Franck Villaume - Capgemini
- * Copyright 2012, Franck Villaume - TrivialDev
+ * Copyright 2012,2014, Franck Villaume - TrivialDev
  * http://fusionforge.org
  *
  * This file is part of FusionForge. FusionForge is free software;
@@ -76,7 +76,7 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 	 * @return 	string	http status
 	 */
 	function PROPFIND(&$options, &$files) {
-		$arr_path = explode('/',$options['path']);
+		$arr_path = explode('/', rtrim($options['path'], '/'));
 		$group_id = $arr_path[3];
 
 		$this->doWeUseDocman($group_id);
@@ -105,8 +105,8 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 		if ($analysed_path['isdir']) {
 			$i = 0;
 			$files["files"] = array();
-			$path = $options['path'];
-			$res = db_query_params('select * from doc_groups where group_id = $1 and doc_group = $2',
+			$path = rtrim($options['path'], '/');
+			$res = db_query_params('select * from doc_groups where group_id = $1 and doc_group = $2 and stateid = 1',
 						array($group_id, $analysed_path['doc_group']));
 			if (!$res)
 				return '404';
@@ -127,7 +127,7 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 			$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',
+			$res = db_query_params('select * from doc_groups where group_id = $1 and parent_doc_group = $2 and stateid = 1',
 						array($group_id, $analysed_path['doc_group']));
 			if (!$res)
 				return '404';
@@ -173,8 +173,29 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 				$files["files"][$i]["props"][] = $this->mkprop("getcontentlength", $arr['filesize']);
 				$files["files"][$i]["props"][] = $this->mkprop("getcontenttype", $arr['filetype']);
 			}
-		}
+		} else {
+			$res = db_query_params('select filename,filetype,filesize,createdate,updatedate from doc_data where group_id = $1 and docid = $2',
+				array($group_id, $analysed_path['docid']));
+			if (!$res)
+				return '404';
 
+			$arr = db_fetch_array($res);
+			if ($arr['updatedate']) {
+				$lastmodifieddate = $arr['updatedate'];
+			} else {
+				$lastmodifieddate = $arr['createdate'];
+			}
+			$files["files"][0] = array();
+			$files["files"][0]["path"] = $path.'/'.$arr['filename'];
+			$files["files"][0]["props"] = array();
+			$files["files"][0]["props"][] = $this->mkprop("displayname", $arr['filename']);
+			$files["files"][0]["props"][] = $this->mkprop("creationdate", $arr['createdate']);
+			$files["files"][0]["props"][] = $this->mkprop("getlastmodified", $lastmodifieddate);
+			$files["files"][0]["props"][] = $this->mkprop("lastaccessed", '');
+			$files["files"][0]["props"][] = $this->mkprop("ishidden", false);
+			$files["files"][0]["props"][] = $this->mkprop("getcontentlength", $arr['filesize']);
+			$files["files"][0]["props"][] = $this->mkprop("getcontenttype", $arr['filetype']);
+		}
 		return '200';
 	}
 
@@ -185,11 +206,19 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 	 * @param	array	$options	options passed by previous functions in HTTP_WebDAV_Server
 	 */
 	function GET(&$options) {
-		$arr_path = explode('/', $options['path']);
+		$arr_path = explode('/', rtrim($options['path'], '/'));
 		$group_id = $arr_path[3];
 
 		$this->doWeUseDocman($group_id);
 
+		/**
+		 * 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++){
@@ -204,9 +233,9 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 		$analysed_path = $this->analyse($subpath, $group_id);
 
 		if ($analysed_path['isdir']) {
-			echo "<html><meta http-equiv='Content-Type' content='text/html charset=UTF-8' /><head><title>Index of ".htmlspecialchars($subpath)."</title></head>\n";
+			echo "<html><meta http-equiv='Content-Type' content='text/html charset=UTF-8' /><head><title>"._('Index of').' '.htmlspecialchars($subpath)."</title></head>\n";
 			echo "<body>\n";
-			echo "<h1>Index of ".htmlspecialchars($subpath)."</h1>\n";
+			echo html_e('h1', array(), _('Index of').' '.htmlspecialchars($subpath));
 			echo "<ul>";
 			if ( '/' != $subpath ) {
 				if ('/' == strrchr($options['path'], '/')) {
@@ -217,10 +246,10 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 				$back_url = substr($options['path'], 0, strrpos($options['path'], strrchr($lastpath,'/')));
 				echo util_make_link($back_url, '..');
 			}
-			$res = db_query_params('select * from doc_groups where group_id = $1 and parent_doc_group = $2',
+			$res = db_query_params('select groupname from doc_groups where group_id = $1 and parent_doc_group = $2 and stateid = 1',
 						array($group_id, $analysed_path['doc_group']));
 			if (!$res) {
-				exit_error(_('webdav db error:').' '.db_error(),'docman');
+				exit_error(_('webdav db error')._(': ').db_error(),'docman');
 			}
 			if ( '/' != substr($subpath,-1)) {
 				$subpath .= '/';
@@ -231,16 +260,16 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 			$res = db_query_params('select filename, filetype from doc_data where group_id = $1 and doc_group = $2 and stateid = 1',
 						array($group_id, $analysed_path['doc_group']));
 			if (!$res) {
-				exit_error(_('webdav db error:').' '.db_error(),'docman');
+				exit_error(_('webdav db error')._(': ').db_error(),'docman');
 			}
 			while ($arr = db_fetch_array($res)) {
 				switch ($arr['filetype']) {
 					case "URL": {
-						echo '<li>'.util_make_link($arr['filename'], $arr['filename'], array(), true).'</li>';
+						echo html_e('li', array(), util_make_link($arr['filename'], $arr['filename'], array(), true), false);
 						break;
 					}
 					default: {
-						echo '<li>'.util_make_link('/docman/view.php/'.$group_id.'/webdav'.$subpath.$arr['filename'], $arr['filename']).'</li>';
+						echo html_e('li', array(), util_make_link('/docman/view.php/'.$group_id.'/webdav'.$subpath.$arr['filename'], $arr['filename']), false);
 					}
 				}
 			}
@@ -254,17 +283,32 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 	}
 
 	function PUT(&$options) {
+		$arr_path = explode('/', rtrim($options['path'], '/'));
+		$group_id = $arr_path[3];
+		if (!forge_check_perm('docman', $group_id, 'approve')) {
+			return '403';
+		}
+		$this->doWeUseDocman($group_id);
 	}
 
-	function MKCOL(&$options) {
+	function DELETE(&$options) {
+		$arr_path = explode('/', rtrim($options['path'], '/'));
+		$group_id = $arr_path[3];
 		if (!forge_check_perm('docman', $group_id, 'approve')) {
 			return '403';
 		}
-		$arr_path = explode('/', $options['path']);
-		$group_id = $arr_path[3];
+		$this->doWeUseDocman($group_id);
+	}
 
+	function MKCOL(&$options) {
+		$arr_path = explode('/', rtrim($options['path'], '/'));
+		$group_id = $arr_path[3];
+		if (!forge_check_perm('docman', $group_id, 'approve')) {
+			return '403';
+		}
 		$this->doWeUseDocman($group_id);
-		$coltocreate = $arr_path[count($arr_path) - 2];
+
+		$coltocreate = $arr_path[count($arr_path) - 1];
 		$dgId = $this->findDgID($arr_path, $group_id);
 		if ($dgId >= 0) {
 			$g = group_get_object($group_id);
@@ -288,22 +332,27 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 	 * @return	int	the document group id
 	 */
 	function findDgID($arr_path, $group_id) {
-		$dgId = -1;
-		if ($arr_path[count($arr_path) - 3] == 'webdav') {
+		if ($arr_path[count($arr_path) - 2] == 'webdav') {
 			// we are in root directory
 			return 0;
+		} else {
+			$path = array_slice($arr_path, 5, count($arr_path) - 6);
+			$parent_doc_group = 0;
+			foreach ($path as $name) {
+				$parent_doc_group = $this->findPdgIdFromPath($name, $parent_doc_group, $group_id);
+			}
 		}
-		$res = db_query_params('select doc_group from doc_groups where group_id = $1 and groupname = $2',
-						array($group_id, $arr_path[count($arr_path) - 3]));
+		return $parent_doc_group;
+	}
+
+	function findPdgIdFromPath($name, $parent_doc_group, $group_id) {
+		$res = db_query_params('select doc_group from doc_groups where group_id = $1 and groupname = $2 and stateid = 1 and parent_doc_group = $3',
+						array($group_id, $name, $parent_doc_group));
 		if (!$res) {
-			exit_error(_('webdav db error:').' '.db_error(),'docman');
-		}
-		if (db_numrows($res) == 1) {
-			//lucky guy, there is only one directory with this name
-			$arr = db_fetch_array($result);
-			$dgId = $arr['doc_group'];
+			exit_error(_('webdav db error')._(': ').db_error(),'docman');
 		}
-		return $dgId;
+		$arr = db_fetch_array($res);
+		return $arr['doc_group'];
 	}
 
 	/**
@@ -342,10 +391,10 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 	 */
 	function whatIsIt($string, $group_id, $path_array) {
 		$return_path_array['isdir'] = false;
-		$res = db_query_params('select doc_group from doc_groups where group_id = $1 and groupname = $2 and parent_doc_group = $3',
+		$res = db_query_params('select doc_group from doc_groups where group_id = $1 and groupname = $2 and parent_doc_group = $3 and stateid = 1',
 							array($group_id, $string, $path_array['doc_group']));
 		if (!$res) {
-			exit_error(_('webdav db error:').' '.db_error(),'docman');
+			exit_error(_('webdav db error')._(': ').db_error(),'docman');
 		}
 
 		while ($arr = db_fetch_array($res)) {

commit 09ed54a3284c18fa989a05f81b766afad44be4e0
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Sat Apr 5 12:02:24 2014 +0200

    docman: webdav, set http status rather than boolean

diff --git a/src/common/docman/include/webdav.php b/src/common/docman/include/webdav.php
index 995f63e..66a19aa 100644
--- a/src/common/docman/include/webdav.php
+++ b/src/common/docman/include/webdav.php
@@ -73,7 +73,7 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 	 *
 	 * @param	array	$options	options passed by previous functions in HTTP_WebDAV_Server
 	 * @param	array	$files		files passed by previous functions in HTTP_WebDAV_Server
-	 * @return bool
+	 * @return 	string	http status
 	 */
 	function PROPFIND(&$options, &$files) {
 		$arr_path = explode('/',$options['path']);
@@ -109,7 +109,7 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 			$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;
+				return '404';
 
 			$arr = db_fetch_array($res);
 			if ($arr['updatedate']) {
@@ -130,7 +130,7 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 			$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)
-				return false;
+				return '404';
 
 			while ($arr = db_fetch_array($res)) {
 				$i++;
@@ -153,7 +153,7 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 			$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)
-				return false;
+				return '404';
 
 			while ($arr = db_fetch_array($res)) {
 				$i++;
@@ -175,7 +175,7 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 			}
 		}
 
-		return true;
+		return '200';
 	}
 
 	/**
@@ -258,7 +258,7 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 
 	function MKCOL(&$options) {
 		if (!forge_check_perm('docman', $group_id, 'approve')) {
-			return false;
+			return '403';
 		}
 		$arr_path = explode('/', $options['path']);
 		$group_id = $arr_path[3];
@@ -273,11 +273,11 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 
 			$dg = new DocumentGroup($g);
 			if (!$dg->create($coltocreate, $dgId)) {
-				return false;
+				return '409';
 			}
-			return true;
+			return '201';
 		}
-		return false;
+		return '405';
 	}
 
 	/**

commit f177fb4ef74523b7a15a7b548e744b94fa4ab6be
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Sat Apr 5 11:56:01 2014 +0200

    docman: webdav, add initial & basic support for mkcol

diff --git a/src/common/docman/include/webdav.php b/src/common/docman/include/webdav.php
index b7adc50..995f63e 100644
--- a/src/common/docman/include/webdav.php
+++ b/src/common/docman/include/webdav.php
@@ -35,6 +35,7 @@
  */
 
 require_once 'HTTP/WebDAV/Server.php';
+require_once $gfcommon.'/docman/DocumentGroup.class.php';
 
 class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 
@@ -42,7 +43,7 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 	 * checkAuth - implement checkAuth called by HTTP_WebDAV_Server
 	 * to ensure authentication against user and pass
 	 *
-	 * @param	int		$group_id	group id
+	 * @param	int	$group_id	group id
 	 * @param	string	$user		username
 	 * @param	string	$pass		password
 	 * @return	bool	success
@@ -214,7 +215,7 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 					$lastpath = $options['path'];
 				}
 				$back_url = substr($options['path'], 0, strrpos($options['path'], strrchr($lastpath,'/')));
-				echo '<a href="'.util_make_uri($back_url).'">..</a>';
+				echo util_make_link($back_url, '..');
 			}
 			$res = db_query_params('select * from doc_groups where group_id = $1 and parent_doc_group = $2',
 						array($group_id, $analysed_path['doc_group']));
@@ -225,7 +226,7 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 				$subpath .= '/';
 			}
 			while ($arr = db_fetch_array($res)) {
-				echo '<li><a href="'.util_make_uri('/docman/view.php/'.$group_id.'/webdav'.$subpath.$arr['groupname']).'">'.$arr['groupname'].'</a></li>';
+				echo '<li>'.util_make_link('/docman/view.php/'.$group_id.'/webdav'.$subpath.$arr['groupname'], $arr['groupname']).'</li>';
 			}
 			$res = db_query_params('select filename, filetype from doc_data where group_id = $1 and doc_group = $2 and stateid = 1',
 						array($group_id, $analysed_path['doc_group']));
@@ -235,11 +236,11 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 			while ($arr = db_fetch_array($res)) {
 				switch ($arr['filetype']) {
 					case "URL": {
-						echo '<li><a href="'.$arr['filename'].'">'.$arr['filename'].'</a></li>';
+						echo '<li>'.util_make_link($arr['filename'], $arr['filename'], array(), true).'</li>';
 						break;
 					}
 					default: {
-						echo '<li><a href="'.util_make_uri('/docman/view.php/'.$group_id.'/webdav'.$subpath.$arr['filename']).'">'.$arr['filename'].'</a></li>';
+						echo '<li>'.util_make_link('/docman/view.php/'.$group_id.'/webdav'.$subpath.$arr['filename'], $arr['filename']).'</li>';
 					}
 				}
 			}
@@ -249,10 +250,62 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 		} else {
 			session_redirect('/docman/view.php/'.$group_id.'/'.$analysed_path['docid'].'/'.$analysed_path['filename']);
 		}
-
 		exit;
 	}
 
+	function PUT(&$options) {
+	}
+
+	function MKCOL(&$options) {
+		if (!forge_check_perm('docman', $group_id, 'approve')) {
+			return false;
+		}
+		$arr_path = explode('/', $options['path']);
+		$group_id = $arr_path[3];
+
+		$this->doWeUseDocman($group_id);
+		$coltocreate = $arr_path[count($arr_path) - 2];
+		$dgId = $this->findDgID($arr_path, $group_id);
+		if ($dgId >= 0) {
+			$g = group_get_object($group_id);
+			if (!$g || !is_object($g))
+				exit_no_group();
+
+			$dg = new DocumentGroup($g);
+			if (!$dg->create($coltocreate, $dgId)) {
+				return false;
+			}
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * findDgID - get the ID of the document group where we are
+	 *
+	 * @param	array	$arr_path	the path as array
+	 * @param	int	$group_id	the project groupid
+	 * @return	int	the document group id
+	 */
+	function findDgID($arr_path, $group_id) {
+		$dgId = -1;
+		if ($arr_path[count($arr_path) - 3] == 'webdav') {
+			// we are in root directory
+			return 0;
+		}
+		$res = db_query_params('select doc_group from doc_groups where group_id = $1 and groupname = $2',
+						array($group_id, $arr_path[count($arr_path) - 3]));
+		if (!$res) {
+			exit_error(_('webdav db error:').' '.db_error(),'docman');
+		}
+		if (db_numrows($res) == 1) {
+			//lucky guy, there is only one directory with this name
+			$arr = db_fetch_array($result);
+			$dgId = $arr['doc_group'];
+		}
+		return $dgId;
+	}
+
 	/**
 	 * analyse - find if the path is a file or a directory
 	 *

-----------------------------------------------------------------------

Summary of changes:
 src/CHANGES                          |    3 +
 src/common/docman/include/webdav.php |  179 +++++++++++++++++++++++++++-------
 2 files changed, 145 insertions(+), 37 deletions(-)


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list