[Fusionforge-commits] FusionForge branch master updated. a77e6da09c34929a2a72bc7152d934a34c00f6d3

Franck Villaume nerville at fusionforge.org
Fri Oct 17 10:38:34 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  a77e6da09c34929a2a72bc7152d934a34c00f6d3 (commit)
      from  9a4f09b4513cd3db6c45940bdf408e5663b2e9a5 (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 a77e6da09c34929a2a72bc7152d934a34c00f6d3
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Fri Oct 17 10:36:17 2014 +0200

    partial [#658]: docman webdav: support rename directory and file

diff --git a/src/common/docman/include/webdav.php b/src/common/docman/include/webdav.php
index 0a10a11..625e2f4 100644
--- a/src/common/docman/include/webdav.php
+++ b/src/common/docman/include/webdav.php
@@ -414,6 +414,7 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 			$arr_dest = explode('/', rtrim($options['dest'], '/'));
 		}
 
+		// are we doing something ?
 		$arr_diff1 = array_diff($arr_dest, $arr_path);
 		$arr_diff2 = array_diff($arr_path, $arr_dest);
 		if ((count($arr_diff1) == 0) && (count($arr_diff2) == 0)) {
@@ -421,6 +422,14 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 		}
 
 		/**
+		 rebuild the dest element and src element to find what are we doing :
+		 1) moving a file to a new dir ?
+		 2) moving a dir to a new dir ?
+		 3) renaming a file ?
+		 4) renaming a dir ?
+		*/
+
+		/**
 		 * 4 is coming from the url: /docman/view.php/6/webdav/the/directory
 		 * 1 = docman
 		 * 2 = view.php
@@ -429,51 +438,62 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 		 * the rest is the path /the/directory
 		 */
 		if ( 4 < count($arr_path)) {
-			$subpath = '';
+			$src_element = '';
 			for ($i = 5; $i < count($arr_path); $i++){
-				$subpath .= '/'.$arr_path[$i];
+				$src_element .= '/'.$arr_path[$i];
 			}
 		}
 
-		if (empty($subpath)) {
-			$subpath = '/';
+		if (empty($src_element)) {
+			$src_element = '/';
 		}
 
 		if ( 4 < count($arr_dest)) {
-			$subdestpath = '';
-			for ($i = 5; $i < count($arr_dest) -1; $i++){
-				$subdestpath .= '/'.$arr_dest[$i];
+			$dest_element = '';
+			for ($i = 5; $i < count($arr_dest) - 1; $i++){
+				$dest_element .= '/'.$arr_dest[$i];
 			}
 		}
 
-		if (empty($subdestpath)) {
-			$subdestpath = '/';
+		if (empty($dest_element)) {
+			$dest_element = '/';
 		}
 
-		$analysed_path = $this->analyse($subpath, $group_id);
-		$analysed_destpath = $this->analyse($subdestpath, $group_id);
+		$analysed_src_element = $this->analyse($src_element, $group_id);
+		$analysed_dest_element = $this->analyse($dest_element, $group_id);
 		$g = group_get_object($group_id);
-		if ($analysed_path['docid']) {
-			$d = new Document($g, $analysed_path['docid']);
-			if ($analysed_destpath['isdir']) {
-				if ($d->update($d->getFileName(), $d->getFileType(), false, $analysed_destpath['doc_group'], $d->getName(), $d->getDescription(), $d->getStateID())) {
+		if (isset($analysed_src_element['doc_id'])) {
+			// we are playing with a file
+			if ($analysed_dest_element['isdir']) {
+				$d = new Document($g, $analysed_src_element['docid']);
+				if ($d->getDocGroupID() == $analysed_dest_element['doc_group']) {
+					// we are renaming the file
+					$filename = end($arr_dest);
+				} else {
+					// we are moving the file to a new directory
+					$filename = $d->getFileName();
+				}
+				if ($d->update($filename, $d->getFileType(), false, $analysed_dest_element['doc_group'], $d->getName(), $d->getDescription(), $d->getStateID())) {
 					return '201';
 				}
 				return '403';
-			} else {
-				return '409';
 			}
-		} elseif ($analysed_path['isdir']) {
-			$dg = new DocumentGroup($g, $analysed_path['doc_group']);
-			if ($analysed_destpath['isdir']) {
-				if ($dg->update($dg->getName(), $analysed_destpath['doc_group'], 1)) {
+		} elseif ($analysed_src_element['isdir']) {
+			// we are playing with a directory
+			if ($analysed_dest_element['isdir']) {
+				$src_dg = new DocumentGroup($g, $analysed_src_element['doc_group']);
+				if ($src_dg->getParentID() == $analysed_dest_element['doc_group']) {
+					// we are renaming the directory
+					$dirname = end($arr_dest);
+				} else {
+					// we are moving the directory to a new directory
+					$dirname = $src_dg->getName();
+				}
+				if ($src_dg->update($dirname, $analysed_dest_element['doc_group'], 1)) {
 					return '201';
 				}
 				return '403';
-			} else {
-				return '409';
 			}
-			return '403';
 		}
 		return '403';
 	}

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

Summary of changes:
 src/common/docman/include/webdav.php |   68 ++++++++++++++++++++++------------
 1 file changed, 44 insertions(+), 24 deletions(-)


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list