[Fusionforge-commits] FusionForge branch master updated. v6.0.5-1250-gb7f0de4

Franck Villaume nerville at libremir.placard.fr.eu.org
Sun Dec 18 14:53:17 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  b7f0de45de9ac23ab660b74b4c0024dcb1a978c7 (commit)
      from  72baa3290954ad79fae1beba82ef044f42df90b3 (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=b7f0de45de9ac23ab660b74b4c0024dcb1a978c7

commit b7f0de45de9ac23ab660b74b4c0024dcb1a978c7
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Sun Dec 18 14:52:58 2016 +0100

    documen review: support validation, support activate document when pending, support make current version, display tag when document version is reviewed and validated

diff --git a/src/common/docman/Document.class.php b/src/common/docman/Document.class.php
index d0c2373..f16446f 100644
--- a/src/common/docman/Document.class.php
+++ b/src/common/docman/Document.class.php
@@ -1223,6 +1223,11 @@ class Document extends FFObject {
 	function getPermalink() {
 		return '/docman/d_follow.php/'.$this->getID();
 	}
+
+	function hasValidatedReview() {
+		$dv = documentversion_get_object($this->getVersion(), $this->getID(), $this->Group->getID());
+		return $dv->hasValidatedReview();
+	}
 }
 
 // Local Variables:
diff --git a/src/common/docman/DocumentReview.class.php b/src/common/docman/DocumentReview.class.php
index 8ef4969..fc5b5f9 100644
--- a/src/common/docman/DocumentReview.class.php
+++ b/src/common/docman/DocumentReview.class.php
@@ -136,6 +136,10 @@ class DocumentReview extends FFError {
 			case 2:
 				$img = $HTML->getClosedTicketPic(_('Closed'), _('Closed'));
 				break;
+			case 4:
+				$img = $HTML->getTagPic(_('Validated'), _('Validated'));
+				break;
+			case 3:
 			default:
 				$img = $HTML->getErrorPic(_('On error'), _('On error'));
 				break;
@@ -249,12 +253,23 @@ class DocumentReview extends FFError {
 		if ($this->Document->getStateID() == 3) {
 			$cells = array();
 			$cells[][] = _('Validate the document?')._(':');
-			$cells[][] = html_e('input', array('type' => 'checkbox', 'name' => 'review-validatedocument', 'value' => 1));
+			$cells[][] = html_e('input', array('type' => 'checkbox', 'name' => 'review-validatedocument', 'value' => 1 ,'title' => _('Tick if you want to move from pending to active status this document.')));
+			$return .= $HTML->multiTableRow(array(), $cells);
+		}
+		$dv = documentversion_get_object($this->getVersion(), $this->Document->getID(), $this->Document->Group->getID());
+		if (!$dv->isCurrent()) {
+			$cells = array();
+			$cells[][] = _('Make this version as current')._(':');
+			$cells[][] = html_e('input', array('type' => 'checkbox', 'name' => 'review-currentversion', 'value' => 1 ,'title' => _('Tick if you want to make this document version as the current version.')));
 			$return .= $HTML->multiTableRow(array(), $cells);
 		}
 		$cells = array();
+		$cells[][] = _('Final Status')._(':');
+		$cells[][] = html_build_select_box_from_arrays(array(2,4), array(_('Closed'), _('Validated')), 'review-finalstatus', false, false, '', false, '', false, array('id' => 'review-finalstatus'));
+		$return .= $HTML->multiTableRow(array(), $cells);
+		$cells = array();
 		$cells[][] = _('Conclusion Comment')._(':');
-		$cells[][] = html_e('textarea', array('id' => 'review-completedcomment', 'name' => 'review-completedcomment', 'style' => 'width: 100%; box-sizing: border-box;', 'rows' => 3, 'required' => 'required', 'pattern' => '.{10,}', 'placeholder' => _('Description').' '.sprintf(_('(at least %s characters)'), DOCMAN__REVIEW_DESCRIPTION_MIN_SIZE), 'maxlength' => DOCMAN__REVIEW_DESCRIPTION_MAX_SIZE), '', false);
+		$cells[][] = html_e('textarea', array('id' => 'review-completedcomment', 'name' => 'review-completedcomment', 'style' => 'width: 100%; box-sizing: border-box;', 'rows' => 3, 'required' => 'required', 'pattern' => '.{10,}', 'placeholder' => _('Final comment').' '.sprintf(_('(at least %s characters)'), DOCMAN__REVIEW_DESCRIPTION_MIN_SIZE), 'maxlength' => DOCMAN__REVIEW_DESCRIPTION_MAX_SIZE), '', false);
 		$return .= $HTML->multiTableRow(array(), $cells);
 		$return .= $HTML->listTableBottom();
 		$return .= html_ac(html_ap() -1);
@@ -428,7 +443,7 @@ class DocumentReview extends FFError {
 			$body .= _('Review submitter')._(': ').$createdbyuser->getRealName().' ('.$createdbyuser->getUnixName().") \n";
 			$body .= "\n\n-------------------------------------------------------\n".
 				_('Please review, visit')._(':').
-				"\n\n" . util_make_url('/docman/?group_id='.$this->Document->Group->getID().'&view=listfile&dirid='.$this->Document->getDocGroupID().'&filedetailid='.$this->Document->getID());
+				"\n\n" . util_make_url($this->Document->getPermalink());
 
 			foreach ($users as $user) {
 				$userObject = user_get_object($user[1]);
@@ -576,16 +591,34 @@ class DocumentReview extends FFError {
 		return false;
 	}
 
-	function close($reviewversionserialid, $reviewtitle, $reviewdescription) {
+	function close($reviewversionserialid, $reviewtitle, $reviewdescription, $reviewfinalstatus, $reviewvalidatedocument, $reviewcurrentversion) {
+		db_begin();
 		$res = db_query_params('UPDATE doc_review SET (enddate, title, description, statusid) = ($1, $2, $3, $4) WHERE revid = $5',
-					array(time(), $reviewtitle, $reviewdescription, 2, $this->getID()));
+					array(time(), $reviewtitle, $reviewdescription, $reviewfinalstatus, $this->getID()));
 		if ($res) {
 			if ($reviewversionserialid != $this->getSerialID()) {
+				unset($this->version);
 				db_query_params('UPDATE doc_review_version SET serialid = $1 WHERE revid = $2', array($reviewversionserialid, $this->getID()));
 			}
+			if ($reviewvalidatedocument && !$this->Document->setState('1')) {
+				$this->setError($this->Document->getErrorMessage());
+				db_rollback();
+				return false;
+			}
+
+			if ($reviewcurrentversion) {
+				$dv = documentversion_get_object($this->getVersion(), $this->Document->getID(), $this->Document->Group->GetID());
+				if (!$dv->update($this->getVersion(), $dv->getTitle(), $dv->getDescription(), $dv->getFiletype(), $dv->getFilename(), $dv->getFilesize(), time(), 1, $dv->getComment())) {
+					$this->setError($dv->getErrorMessage());
+					db_rollback();
+					return false;
+				}
+			}
+			db_commit();
 			return true;
 		} else {
 			$this->setError(db_error());
+			db_rollback();
 			return false;
 		}
 	}
diff --git a/src/common/docman/DocumentReviewFactory.class.php b/src/common/docman/DocumentReviewFactory.class.php
index a56906f..1195f49 100644
--- a/src/common/docman/DocumentReviewFactory.class.php
+++ b/src/common/docman/DocumentReviewFactory.class.php
@@ -87,7 +87,7 @@ class DocumentReviewFactory extends FFError {
 				$cells[][] = $dr->getStatusIcon();
 				$cells[][] = strftime(_('%Y-%m-%d'), $dr->getStartdate());
 				$overdue = '';
-				if (($dr->getStatusID() != 2) && (time() > $dr->getEnddate())) {
+				if (($dr->getStatusID() != 2 && $dr->getStatusID() != 4) && (time() > $dr->getEnddate())) {
 					$overdue = $HTML->getErrorPic(_('Review overdue'), 'overdue');
 				}
 				$cells[][] = strftime(_('%Y-%m-%d'), $dr->getEnddate()).$overdue;
@@ -97,7 +97,7 @@ class DocumentReviewFactory extends FFError {
 				$actions = '';
 				$user = session_get_user();
 				$users = $dr->getUsers(array(1, 2));
-				if ($dr->getStatusID() != 2) {
+				if ($dr->getStatusID() != 2 && $dr->getStatusID() != 4) {
 					if ($user->getID() == $dr->getCreatedBy()) {
 						$actions .= $dr->getReminderAction().$dr->getEditAction().$dr->getCompleteAction();
 					}
diff --git a/src/common/docman/DocumentVersion.class.php b/src/common/docman/DocumentVersion.class.php
index 78ee099..076b39f 100644
--- a/src/common/docman/DocumentVersion.class.php
+++ b/src/common/docman/DocumentVersion.class.php
@@ -403,4 +403,14 @@ class DocumentVersion extends FFError {
 		}
 		return true;
 	}
+
+	function hasValidatedReview() {
+		$res = db_query_params('SELECT statusid FROM doc_review, doc_review_version
+					WHERE statusid = $1 AND doc_review.revid = doc_review_version.revid AND doc_review_version.serialid = $2',
+					array(4, $this->getID()));
+		if ($res && (db_numrows($res) > 0)) {
+			return true;
+		}
+		return false;
+	}
 }
diff --git a/src/common/docman/actions/editfile.php b/src/common/docman/actions/editfile.php
index 24b468c..642b012 100644
--- a/src/common/docman/actions/editfile.php
+++ b/src/common/docman/actions/editfile.php
@@ -196,6 +196,9 @@ switch ($subaction) {
 		$reviewid = getIntFromRequest('review_id');
 		$reviewcompletedchecked = getIntFromRequest('review-completedchecked');
 		$reviewconclusioncomment = getStringFromRequest('review-completedcomment', '');
+		$reviewvalidatedocument = getIntFromRequest('review-validatedocument');
+		$reviewfinalstatus = getIntFromRequest('review-finalstatus');
+		$reviewcurrentversion = getIntFromRequest('review-currentversion');
 		if ($reviewversionserialid) {
 			if ($new_review) {
 				$dr = new DocumentReview($d);
@@ -210,7 +213,7 @@ switch ($subaction) {
 					if (strlen($reviewconclusioncomment) > 0) {
 						$reviewdescription = $reviewconclusioncomment;
 					}
-					if ($dr->close($reviewversionserialid, $reviewtitle, $reviewdescription)) {
+					if ($dr->close($reviewversionserialid, $reviewtitle, $reviewdescription, $reviewfinalstatus, $reviewvalidatedocument, $reviewcurrentversion)) {
 						$feedback = _('Review closed successfully');
 					} else {
 						$error_msg = $dr->getErrorMessage();
diff --git a/src/common/docman/views/listfile.php b/src/common/docman/views/listfile.php
index 1d42139..9612bf4 100644
--- a/src/common/docman/views/listfile.php
+++ b/src/common/docman/views/listfile.php
@@ -286,7 +286,10 @@ if (isset($nested_docs[$dirid]) && is_array($nested_docs[$dirid])) {
 		$cells[][] = 'D'.$d->getID();
 		$nextcell = '';
 		if (($d->getUpdated() && $time_new > (time() - $d->getUpdated())) || $time_new > (time() - $d->getCreated())) {
-			$nextcell = $HTML->getNewPic(_('Created or updated since less than 7 days'), 'new').' ';
+			$nextcell .= $HTML->getNewPic(_('Created or updated since less than 7 days'), 'new').' ';
+		}
+		if ($d->hasValidatedReview()) {
+			$nextcell .= $HTML->getTagPic(_('Document reviewed and validated'), 'reviewed').' ';
 		}
 		$cells[] = array($nextcell.$d->getFileName(), 'style' => 'word-wrap: break-word; max-width: 250px;');
 		$cells[] = array($d->getName(), 'style' => 'word-wrap: break-word; max-width: 250px;');
diff --git a/src/common/docman/views/listtrashfile.php b/src/common/docman/views/listtrashfile.php
index 19910e6..d491111 100644
--- a/src/common/docman/views/listtrashfile.php
+++ b/src/common/docman/views/listtrashfile.php
@@ -172,6 +172,9 @@ if (isset($nested_docs[$dirid]) && is_array($nested_docs[$dirid])) {
 		if (($d->getUpdated() && $time_new > (time() - $d->getUpdated())) || $time_new > (time() - $d->getCreated())) {
 			$nextcell.= $HTML->getNewPic(_('Created or updated since less than 7 days'), 'new', array('class' => 'docman-newdocument')).' ';
 		}
+		if ($d->hasValidatedReview()) {
+			$nextcell .= $HTML->getTagPic(_('Document reviewed and validated'), 'reviewed').' ';
+		}
 		$cells[] = array($nextcell.$d->getFileName(), 'style' => 'word-wrap: break-word; max-width: 250px;');
 		$cells[] = array($d->getName(), 'style' => 'word-wrap: break-word; max-width: 250px;');
 		$cells[] = array($d->getDescription(), 'style' => 'word-wrap: break-word; max-width: 250px;');
diff --git a/src/common/docman/views/pendingfiles.php b/src/common/docman/views/pendingfiles.php
index 8da8629..694246c 100644
--- a/src/common/docman/views/pendingfiles.php
+++ b/src/common/docman/views/pendingfiles.php
@@ -84,7 +84,10 @@ jQuery(document).ready(function() {
 			$cells[][] = 'D'.$d->getID();
 			$nextcell = '';
 			if (($d->getUpdated() && $time_new > (time() - $d->getUpdated())) || $time_new > (time() - $d->getCreated())) {
-				$nextcell.= $HTML->getNewPic(_('Created or updated since less than 7 days'), 'new', array('class' => 'docman-newdocument')).' ';
+				$nextcell .= $HTML->getNewPic(_('Created or updated since less than 7 days'), 'new', array('class' => 'docman-newdocument')).' ';
+			}
+			if ($d->hasValidatedReview()) {
+				$nextcell .= $HTML->getTagPic(_('Document reviewed and validated'), 'reviewed').' ';
 			}
 			$cells[] = array($nextcell.$d->getFileName(), 'style' => 'word-wrap: break-word; max-width: 250px;');
 			$cells[] = array($d->getName(), 'style' => 'word-wrap: break-word; max-width: 250px;');
diff --git a/src/db/20161217-document-review2.sql b/src/db/20161217-document-review2.sql
new file mode 100644
index 0000000..66af44f
--- /dev/null
+++ b/src/db/20161217-document-review2.sql
@@ -0,0 +1 @@
+ INSERT INTO doc_review_status (statusid, name) VALUES (4, 'success');

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

Summary of changes:
 src/common/docman/Document.class.php              |  5 +++
 src/common/docman/DocumentReview.class.php        | 43 ++++++++++++++++++++---
 src/common/docman/DocumentReviewFactory.class.php |  4 +--
 src/common/docman/DocumentVersion.class.php       | 10 ++++++
 src/common/docman/actions/editfile.php            |  5 ++-
 src/common/docman/views/listfile.php              |  5 ++-
 src/common/docman/views/listtrashfile.php         |  3 ++
 src/common/docman/views/pendingfiles.php          |  5 ++-
 src/db/20161217-document-review2.sql              |  1 +
 9 files changed, 71 insertions(+), 10 deletions(-)
 create mode 100644 src/db/20161217-document-review2.sql


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list