[Fusionforge-commits] FusionForge branch master updated. 9826fa62caf81010554a457a02d0beda7de4aec2

Franck Villaume nerville at fusionforge.org
Sun Apr 6 15:26:33 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, master has been updated
       via  9826fa62caf81010554a457a02d0beda7de4aec2 (commit)
       via  0eb925478c550af6658bbb2f582b4591280bc478 (commit)
      from  28a208400abf034b2c17ceba09f86619e825c083 (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 9826fa62caf81010554a457a02d0beda7de4aec2
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 c30e327..a4c1c42 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 0eb925478c550af6658bbb2f582b4591280bc478
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Sun Apr 6 15:22:06 2014 +0200

    util_make_link & translation

diff --git a/src/common/docman/DocumentGroup.class.php b/src/common/docman/DocumentGroup.class.php
index 20db449..fa208e8 100644
--- a/src/common/docman/DocumentGroup.class.php
+++ b/src/common/docman/DocumentGroup.class.php
@@ -238,7 +238,7 @@ class DocumentGroup extends Error {
 				break;
 			}
 			default: {
-				$this->setError( _('Unsupported injected file:') . ' ' .$uploaded_data_type);
+				$this->setError( _('Unsupported injected file')._(': ').$uploaded_data_type);
 				$returned = false;
 			}
 		}
@@ -407,7 +407,7 @@ class DocumentGroup extends Error {
 						array($this->getID(), $userid));
 
 		if (!$result) {
-			$this->setError(_('Unable To Remove Monitor').' : '.db_error());
+			$this->setError(_('Unable To Remove Monitor')._(': ').db_error());
 			return false;
 		}
 		return true;
@@ -428,7 +428,7 @@ class DocumentGroup extends Error {
 							array($this->getID(), $userid));
 
 			if (!$result) {
-				$this->setError(_('Unable To Add Monitor').' : '.db_error());
+				$this->setError(_('Unable To Add Monitor')._(': ').db_error());
 				return false;
 			}
 		}
@@ -444,7 +444,7 @@ class DocumentGroup extends Error {
 		$result = db_query_params('DELETE FROM docgroup_monitored_docman WHERE docgroup_id = $1',
 					array($this->getID()));
 		if (!$result) {
-			$this->setError(_('Unable To Clear Monitor').' : '.db_error());
+			$this->setError(_('Unable To Clear Monitor')._(': ').db_error());
 			return false;
 		}
 		return true;
diff --git a/src/plugins/hudson/include/hudson_Widget_JobTestResults.class.php b/src/plugins/hudson/include/hudson_Widget_JobTestResults.class.php
index f22b7af..3f6fdfa 100644
--- a/src/plugins/hudson/include/hudson_Widget_JobTestResults.class.php
+++ b/src/plugins/hudson/include/hudson_Widget_JobTestResults.class.php
@@ -89,7 +89,7 @@ class hudson_Widget_JobTestResults extends HudsonJobWidget {
 			$job = $this->job;
 			$test_result = $this->test_result;
 			$html .= '<div style="padding: 20px;">';
-			$html .= ' <a href="/plugins/hudson/?action=view_last_test_result&group_id='.$this->group_id.'&job_id='.$this->job_id.'">'.$test_result->getTestResultPieChart().'</a>';
+			$html .= util_make_link('/plugins/hudson/?action=view_last_test_result&group_id='.$this->group_id.'&job_id='.$this->job_id, $test_result->getTestResultPieChart());
 			$html .= '</div>';
 		} else {
 			if ($this->job != null) {

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

Summary of changes:
 src/CHANGES                                        |    3 +
 src/common/docman/DocumentGroup.class.php          |    8 +-
 src/common/docman/include/webdav.php               |  111 ++++++++++++++------
 .../include/hudson_Widget_JobTestResults.class.php |    2 +-
 4 files changed, 88 insertions(+), 36 deletions(-)


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list