[Fusionforge-commits] FusionForge branch master updated. v6.0.5-1259-g65fb349

Franck Villaume nerville at libremir.placard.fr.eu.org
Mon Dec 19 15:18:04 CET 2016


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  65fb349c37c5955ad9ba2a6a466452e07af409a0 (commit)
       via  f4b60a9bbf7e0ef17ed43e7898dbbc764006f9ba (commit)
       via  d015c9ad0895874bd388fc21644f5bf2f60ee646 (commit)
      from  297dade94dc312c5791f10cab1b34b96caad54e0 (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 -----------------------------------------------------------------
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=65fb349c37c5955ad9ba2a6a466452e07af409a0

commit 65fb349c37c5955ad9ba2a6a466452e07af409a0
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Mon Dec 19 15:17:31 2016 +0100

    sync CHANGES

diff --git a/src/CHANGES b/src/CHANGES
index 3476ef0..693105b 100644
--- a/src/CHANGES
+++ b/src/CHANGES
@@ -10,6 +10,7 @@ FusionForge 6.X:
 * Docman: support private directory. (TrivialDev)
 * Docman: support document versioning. (TrivialDev)
 * Docman: support cross ref. forum, documents, task or artifact. (TrivialDev)
+* Docman: add new document review feature. to review version, document and post comment to a document. (TrivialDev)
 * Core System: support object association n-n, bidirectional (Artifact, Document, FRSRelease) (TrivialDev)
 * FRS: link package release to tracker roadmap. (TrivialDev)
 * Layout: new dynamic quickNav menu: based on user activity to select 5 more visited projects (TrivialDev)

https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=f4b60a9bbf7e0ef17ed43e7898dbbc764006f9ba

commit f4b60a9bbf7e0ef17ed43e7898dbbc764006f9ba
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Mon Dec 19 15:15:23 2016 +0100

    document review: view attachment of a comment

diff --git a/src/common/docman/DocumentReviewComment.class.php b/src/common/docman/DocumentReviewComment.class.php
index a78ab8a..c558773 100644
--- a/src/common/docman/DocumentReviewComment.class.php
+++ b/src/common/docman/DocumentReviewComment.class.php
@@ -119,7 +119,7 @@ class DocumentReviewComment extends FFError {
 		$res = db_query_params('SELECT * FROM doc_review_attachments WHERE commentid = $1', array($this->getID()));
 		if ($res && (db_numrows($res) > 0)) {
 			$attachArr = db_fetch_array($res);
-			return util_make_link('/docman/view.php/', $attachArr['filename']);
+			return util_make_link('/docman/view.php/'.$this->DocumentReview->Document->Group->getID().'/review/'.$attachArr['attachid'], $attachArr['filename']);
 		} else {
 			return '';
 		}
diff --git a/src/common/docman/DocumentReviewCommentAttachment.class.php b/src/common/docman/DocumentReviewCommentAttachment.class.php
new file mode 100644
index 0000000..aae8c26
--- /dev/null
+++ b/src/common/docman/DocumentReviewCommentAttachment.class.php
@@ -0,0 +1,61 @@
+<?php
+/**
+ * FusionForge Documentation Manager
+ *
+ * Copyright 2016, Franck Villaume - TrivialDev
+ * http://fusionforge.org
+ *
+ * This file is part of FusionForge. FusionForge is free software;
+ * you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the Licence, or (at your option)
+ * any later version.
+ *
+ * FusionForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FusionForge; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+require_once $gfcommon.'/docman/DocumentReviewStorage.class.php';
+
+class DocumentReviewCommentAttachment extends FFError {
+
+	/**
+	 * The data values
+	 *
+	 * @var	array	$data_array
+	 */
+	var $data_array = array();
+
+	function __construct($attachid) {
+		parent::__construct();
+		$res = db_query_params('SELECT * FROM doc_review_attachments WHERE attachid = $1', array($attachid));
+		$this->data_array = db_fetch_array($res);
+		return true;
+	}
+
+	function getID() {
+		return $this->data_array['attachid'];
+	}
+
+	function getFileName() {
+		return $this->data_array['filename'];
+	}
+
+	function getFileType() {
+		return $this->data_array['filetype'];
+	}
+
+	function getFilePath() {
+		return DocumentReviewStorage::instance()->get($this->getID());
+	}
+
+	function getFileData() {
+		return file_get_contents($this->getFilePath());
+	}
+}
diff --git a/src/www/docman/view.php b/src/www/docman/view.php
index a2b94fe..7be2026 100644
--- a/src/www/docman/view.php
+++ b/src/www/docman/view.php
@@ -30,6 +30,7 @@ require_once $gfcommon.'include/pre.php';
 require_once $gfcommon.'docman/Document.class.php';
 require_once $gfcommon.'docman/DocumentFactory.class.php';
 require_once $gfcommon.'docman/DocumentGroupFactory.class.php';
+require_once $gfcommon.'docman/DocumentReviewCommentAttachment.class.php';
 require_once $gfcommon.'docman/include/utils.php';
 
 global $warning_msg;
@@ -124,6 +125,18 @@ if (is_numeric($docid)) {
 	utils_headers_download($dv->getFileName(), $dv->getFileType(), $length);
 	readfile_chunked($file_path);
 
+} elseif ($docid === 'review') {
+	session_require_perm('docman', $group_id, 'approve');
+	// let get the specific ids
+	$attachid = (int)$arr[5];
+
+	$drca = new DocumentReviewCommentAttachment($attachid);
+	ob_end_clean();
+	$file_path = $drca->getFilePath();
+	$length = filesize($file_path);
+	utils_headers_download($drca->getFileName(), $drca->getFileType(), $length);
+	readfile_chunked($file_path);
+
 } elseif ($docid === 'backup') {
 	if (extension_loaded('zip')) {
 		session_require_perm('docman', $group_id, 'admin');

https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=d015c9ad0895874bd388fc21644f5bf2f60ee646

commit d015c9ad0895874bd388fc21644f5bf2f60ee646
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Mon Dec 19 14:40:47 2016 +0100

    document review: initial support for attachment in document review comment

diff --git a/src/GNUmakefile b/src/GNUmakefile
index b63b9c5..b35b3f7 100644
--- a/src/GNUmakefile
+++ b/src/GNUmakefile
@@ -99,6 +99,7 @@ install-web: install-base-dirs
 	$(CP_R) --no-clobber etc/httpd.conf* $(DESTDIR)$(config_path)
 	$(INSTALL) -d -m 00700 $(DESTDIR)$(data_path)/docman/
 	$(INSTALL) -d -m 00700 $(DESTDIR)$(data_path)/download/
+	$(INSTALL) -d -m 00700 $(DESTDIR)$(data_path)/download/review/
 	$(INSTALL) -d -m 00700 $(DESTDIR)$(data_path)/forum/
 	$(INSTALL) -d -m 00700 $(DESTDIR)$(data_path)/forum/pending/
 	$(INSTALL) -d -m 00700 $(DESTDIR)$(data_path)/tracker/
diff --git a/src/common/docman/DocumentReviewComment.class.php b/src/common/docman/DocumentReviewComment.class.php
index 3c34cc2..a78ab8a 100644
--- a/src/common/docman/DocumentReviewComment.class.php
+++ b/src/common/docman/DocumentReviewComment.class.php
@@ -21,6 +21,8 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+require_once $gfcommon.'/docman/DocumentReviewStorage.class.php';
+
 class DocumentReviewComment extends FFError {
 	/**
 	 * The DocumentReview object.
@@ -57,7 +59,13 @@ class DocumentReviewComment extends FFError {
 		$res = db_query_params('SELECT * FROM doc_review_comments WHERE commentid = $1', array($commentid));
 		if ($res) {
 			$this->data_array = db_fetch_array($res);
+			return true;
 		}
+		return false;
+	}
+
+	function getID() {
+		return $this->data_array['commentid'];
 	}
 
 	function getCreateDate() {
@@ -84,8 +92,37 @@ class DocumentReviewComment extends FFError {
 		return $result;
 	}
 
+	function attachFile($filename, $filetype, $createdate, $data) {
+		db_begin();
+		$filesize = filesize($data);
+		$res = db_query_params('INSERT INTO doc_review_attachments (createdate, commentid, filename, filetype, filesize) VALUES ($1, $2, $3, $4, $5)',
+					array($createdate, $this->getID(), $filename, $filetype, $filesize));
+		$attachid = db_insertid($res, 'doc_review_attachments', 'attachid');
+		if ($attachid) {
+			if (!DocumentReviewStorage::instance()->store($attachid, $data)) {
+				DocumentReviewStorage::instance()->rollback();
+				db_rollback();
+				$this->setError(DocumentReviewStorage::instance()->getErrorMessage());
+				return false;
+			}
+			DocumentReviewStorage::instance()->commit();
+			db_commit();
+			return true;
+		} else {
+			db_rollback();
+			$this->setError(db_error());
+			return false;
+		}
+	}
+
 	function getAttachment() {
-		return '';
+		$res = db_query_params('SELECT * FROM doc_review_attachments WHERE commentid = $1', array($this->getID()));
+		if ($res && (db_numrows($res) > 0)) {
+			$attachArr = db_fetch_array($res);
+			return util_make_link('/docman/view.php/', $attachArr['filename']);
+		} else {
+			return '';
+		}
 	}
 
 	function create($userid, $reviewid, $rcomment, $createdate) {
@@ -93,12 +130,14 @@ class DocumentReviewComment extends FFError {
 		$res = db_query_params('INSERT INTO doc_review_comments (revid, userid, rcomment, createdate) VALUES ($1, $2, $3, $4)',
 					array($reviewid, $userid, $rcomment, $createdate));
 		if ($res) {
-			db_commit();
-			return true;
-		} else {
-			db_rollback();
-			$this->setError(db_error());
-			return false;
+			$commentid = db_insertid($res, 'doc_review_comments', 'commentid');
+			if ($this->fetchData($commentid)) {
+				db_commit();
+				return true;
+			}
 		}
+		db_rollback();
+		$this->setError(db_error());
+		return false;
 	}
 }
diff --git a/src/common/docman/DocumentReviewStorage.class.php b/src/common/docman/DocumentReviewStorage.class.php
index 99f2684..2b97067 100644
--- a/src/common/docman/DocumentReviewStorage.class.php
+++ b/src/common/docman/DocumentReviewStorage.class.php
@@ -56,6 +56,6 @@ class DocumentReviewStorage extends Storage {
 	}
 
 	function get_storage_path() {
-		return forge_get_config('data_path').'/docmanreview';
+		return forge_get_config('data_path').'/docman/review/';
 	}
 }
diff --git a/src/common/docman/actions/editfile.php b/src/common/docman/actions/editfile.php
index 061fe6d..3a10d70 100644
--- a/src/common/docman/actions/editfile.php
+++ b/src/common/docman/actions/editfile.php
@@ -217,6 +217,21 @@ switch ($subaction) {
 					$error_msg = $dr->getErrorMessage();
 				}
 			} elseif ($reviewnewcomment) {
+				$reviewattachment = getUploadedFile('review-attachment');
+				if (!empty($reviewattachment) && $reviewattachment['name']) {
+					if (!is_uploaded_file($reviewattachment['tmp_name'])) {
+						$error_msg = sprintf(_('Invalid file attack attempt %s.'), $reviewattachment['name']);
+						session_redirect($urlparam);
+					}
+					$data = $reviewattachment['tmp_name'];
+					$filename = $reviewattachment['name'];
+					if (function_exists('finfo_open')) {
+						$finfo = finfo_open(FILEINFO_MIME_TYPE);
+						$filetype = finfo_file($finfo, $reviewattachment['tmp_name']);
+					} else {
+						$filetype = $reviewattachment['type'];
+					}
+				}
 				$dr = new DocumentReview($d, $reviewid);
 				$drc = new DocumentReviewComment($dr);
 				$now = time();
@@ -224,6 +239,9 @@ switch ($subaction) {
 					if ($reviewdone) {
 						$dr->setUserDone(user_getid(), $now);
 					}
+					if (isset($filename)) {
+						$drc->attachFile($filename, $filetype, $now, $data);
+					}
 					$feedback = _('Review commented successfully');
 				} else {
 					$error_msg = $drc->getErrorMessage();
diff --git a/src/post-install.d/web/web.sh b/src/post-install.d/web/web.sh
index 1306978..0f2ac09 100755
--- a/src/post-install.d/web/web.sh
+++ b/src/post-install.d/web/web.sh
@@ -95,6 +95,7 @@ case "$1" in
 	# Setup Docman/FRS/Forum/Tracker/RSS attachments
 	# (not done in 'make install' because e.g. dpkg ignores existing dirs, cf. DP10.9[1])
 	chown $apache_user: $data_path/docman/
+	chown $apache_user: $data_path/docman/review/
 	chown $apache_user: $data_path/download/
 	chown $apache_user: $data_path/forum/
 	chown $apache_user: $data_path/forum/pending/

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

Summary of changes:
 src/CHANGES                                        |  1 +
 src/GNUmakefile                                    |  1 +
 src/common/docman/DocumentReviewComment.class.php  | 53 ++++++++++++++++---
 .../DocumentReviewCommentAttachment.class.php      | 61 ++++++++++++++++++++++
 src/common/docman/DocumentReviewStorage.class.php  |  2 +-
 src/common/docman/actions/editfile.php             | 18 +++++++
 src/post-install.d/web/web.sh                      |  1 +
 src/www/docman/view.php                            | 13 +++++
 8 files changed, 142 insertions(+), 8 deletions(-)
 create mode 100644 src/common/docman/DocumentReviewCommentAttachment.class.php


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list