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  43ceb455bd7171d4273b321a0b16b6118806de41 (commit)
      from  d8530c6c8cbb78b9e7915c0401a78af2e06ae645 (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=43ceb455bd7171d4273b321a0b16b6118806de41

commit 43ceb455bd7171d4273b321a0b16b6118806de41
Author: Franck Villaume <[email protected]>
Date:   Sun Dec 18 19:01:43 2016 +0100

    document review: initial support for comment

diff --git a/src/common/docman/DocumentReview.class.php 
b/src/common/docman/DocumentReview.class.php
index 97b2702..0f29702 100644
--- a/src/common/docman/DocumentReview.class.php
+++ b/src/common/docman/DocumentReview.class.php
@@ -240,7 +240,7 @@ class DocumentReview extends FFError {
 
        function getCommentAction() {
                global $HTML;
-               return util_make_link('#', $HTML->getEditFilePic(_('Comment the 
review'), 'remindercomment'), array('id' => 'review_action_comment', 'onclick' 
=> 'javascript:controllerListFile.toggleCommentReviewView({review: 
'.$this->getID().'})'), true);
+               return util_make_link('#', $HTML->getEditFilePic(_('Comment the 
review'), 'remindercomment'), array('id' => 'review_action_comment', 'onclick' 
=> 'javascript:controllerListFile.toggleCommentReviewView({review: 
'.$this->getID().', groupId: '.$this->Document->Group->getID().', docid: 
'.$this->Document->getID().'})'), true);
        }
 
        function showCompleteFormHTML() {
@@ -323,9 +323,11 @@ class DocumentReview extends FFError {
                        $return .= html_e('input', array('type' => 'hidden', 
'id' => 'new_review', 'name' => 'new_review', 'value' => 0));
                        $return .= html_e('input', array('type' => 'hidden', 
'id' => 'review_id', 'name' => 'review_id', 'value' => 0));
                        $return .= html_e('input', array('type' => 'hidden', 
'id' => 'review_complete', 'name' => 'review_complete', 'value' => 0));
+                       $return .= html_e('input', array('type' => 'hidden', 
'id' => 'review_newcomment', 'name' => 'review_newcomment', 'value' => 0));
                        $return .= html_ac(html_ap() -1);
                        $return .= html_e('div', array('id' => 
'editfile-userstatusreview'), '', false);
                        $return .= html_e('div', array('id' => 
'editfile-completedreview'), '', false);
+                       $return .= html_e('div', array('id' => 
'editfile-commentreview'), '', false);
                        $javascript = 
'jQuery("#datepicker_end_review_date").datepicker({dateFormat: 
"'.$date_format_js.'"});';
                        $return .= html_e('script', array( 
'type'=>'text/javascript', 'id' => 'editfile-datepickerreview-script'), 
'//<![CDATA['."\n".$javascript."\n".'//]]>');
                } else {
@@ -334,6 +336,43 @@ class DocumentReview extends FFError {
                return $return;
        }
 
+       function showCommentFormHTML() {
+               global $HTML;
+               $return = $HTML->listTableTop();
+               $cells = array();
+               $cells[] = array(_('Comment').utils_requiredField()._(':'), 
'style' => 'width: 30%;');
+               $cells[][] = html_e('textarea', array('id' => 'review-comment', 
'name' => 'review-comment', 'style' => 'width: 100%; box-sizing: border-box;', 
'rows' => 3, 'required' => 'required', 'pattern' => '.{10,}', 'placeholder' => 
_('Add your comment').' '.sprintf(_('(at least %s characters)'), 
DOCMAN__REVIEW_DESCRIPTION_MIN_SIZE), 'maxlength' => 
DOCMAN__REVIEW_DESCRIPTION_MAX_SIZE), '', false);
+               $return .= $HTML->multiTableRow(array(), $cells);
+               $cells = array();
+               $cells[][] = _('Attachment')._(':');
+               $cells[][] = html_e('input', array('type' => 'file', 'name' => 
'review-attachment')).html_e('br').'('._('max upload size')._(': 
').human_readable_bytes(util_get_maxuploadfilesize()).')';
+               $return .= $HTML->multiTableRow(array(), $cells);
+               $return .= $HTML->listTableBottom();
+               return $return;
+       }
+
+       function showCommentsHTML() {
+               global $HTML;
+               $return = '';
+               $drcf = new DocumentReviewCommentFactory($this);
+               if ($drcf->getNbComments()) {
+                       $return .= $HTML->listTableTop(array(_('Date'), 
_('Author'), _('Comment'), _('Attachment')));
+                       $comments = $drcf->getComments();
+                       foreach ($comments as $comment) {
+                               $cells = array();
+                               $cells[][] = 
strftime(_('%Y-%m-%d'),$comment->getCreateDate());
+                               $cells[][] = $comment->getPosterRealName();
+                               $cells[][] = $comment->getReviewComment();
+                               $cells[][] = $comment->getAttachment();
+                               $return .= $HTML->multiTableRow(array(), 
$cells);
+                       }
+                       $return .= $HTML->listTableTop();
+               } else {
+                       $return .= $HTML->information(_('No comment posted.'));
+               }
+               return $return;
+       }
+
        function showUsersStatusHTML() {
                global $HTML;
                $mandatoryUsers = $this->getMandatoryUsers();
diff --git a/src/common/docman/DocumentReviewComment.class.php 
b/src/common/docman/DocumentReviewComment.class.php
index e87e6ba..83b56af 100644
--- a/src/common/docman/DocumentReviewComment.class.php
+++ b/src/common/docman/DocumentReviewComment.class.php
@@ -22,4 +22,78 @@
  */
 
 class DocumentReviewComment extends FFError {
+       /**
+        * The DocumentReview object.
+        *
+        * @var object  $DocumentReview.
+        */
+       var $DocumentReview;
+
+       /**
+        * The data values
+        *
+        * @var array   $data_array
+        */
+       var $data_array = array();
+
+       function __construct(&$DocumentReview, $commentid = false, $arr = 
false) {
+               parent::__construct();
+               if (!$DocumentReview || !is_object($DocumentReview)) {
+                       $this->setError(_('No Valid DocumentReview Object'));
+                       return false;
+               }
+               if ($DocumentReview->isError()) {
+                       $this->setError(_('DocumentReview')._(': 
').$DocumentReview->getErrorMessage());
+                       return false;
+               }
+               $this->DocumentReview =& $DocumentReview;
+               if ($commentid) {
+                       $this->fetchData($commentid);
+               }
+               return true;
+       }
+
+       function fetchData($commentid) {
+               $res = db_query_params('SELECT * FROM doc_review_comments WHERE 
commentid = $1', array($commentid));
+               if ($res) {
+                       $this->data_array = db_fetch_array($res);
+               }
+       }
+
+       function getCreateDate() {
+               return $this->data_array['createdate'];
+       }
+
+       function getPosterID() {
+               return $this->data_array['userid'];
+       }
+
+       function getPosterRealName() {
+               $userObject = user_get_object($this->getPosterID());
+               return $userObject->getRealName();
+       }
+
+       function getReviewComment() {
+               $result = util_gen_cross_ref($this->data_array['rcomment'], 
$this->DocumentReview->Document->Group->getID());
+               $result = nl2br($result);
+               return $result;
+       }
+
+       function getAttachment() {
+               return '';
+       }
+
+       function create($userid, $reviewid, $rcomment, $createdate) {
+               db_begin();
+               $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;
+               }
+       }
 }
diff --git a/src/common/docman/DocumentReviewCommentFactory.class.php 
b/src/common/docman/DocumentReviewCommentFactory.class.php
index 6e925fc..8033294 100644
--- a/src/common/docman/DocumentReviewCommentFactory.class.php
+++ b/src/common/docman/DocumentReviewCommentFactory.class.php
@@ -52,6 +52,13 @@ class DocumentReviewCommentFactory extends FFError {
        }
 
        function getComments() {
-               return array();
+               $commentsArr = array();
+               $res = db_query_params('SELECT commentid FROM 
doc_review_comments WHERE revid = $1 ORDER BY createdate DESC', 
array($this->DocumentReview->getID()));
+               if ($res && (db_numrows($res) > 0)) {
+                       while ($arr = db_fetch_array($res)) {
+                               $commentsArr[] = new 
DocumentReviewComment($this->DocumentReview, $arr['commentid']);
+                       }
+               }
+               return $commentsArr;
        }
 }
diff --git a/src/common/docman/actions/editfile.php 
b/src/common/docman/actions/editfile.php
index 642b012..08c1d59 100644
--- a/src/common/docman/actions/editfile.php
+++ b/src/common/docman/actions/editfile.php
@@ -199,6 +199,8 @@ switch ($subaction) {
                $reviewvalidatedocument = 
getIntFromRequest('review-validatedocument');
                $reviewfinalstatus = getIntFromRequest('review-finalstatus');
                $reviewcurrentversion = 
getIntFromRequest('review-currentversion');
+               $reviewnewcomment = getIntFromRequest('review_newcomment');
+               $reviewcomment = getStringFromRequest('review-comment');
                if ($reviewversionserialid) {
                        if ($new_review) {
                                $dr = new DocumentReview($d);
@@ -207,6 +209,14 @@ switch ($subaction) {
                                } else {
                                        $error_msg = $dr->getErrorMessage();
                                }
+                       } elseif ($reviewnewcomment) {
+                               $dr = new DocumentReview($d, $reviewid);
+                               $drc = new DocumentReviewComment($dr);
+                               if ($drc->create(user_getid(), $reviewid, 
$reviewcomment, time())) {
+                                       $feedback = _('Review commented 
successfully');
+                               } else {
+                                       $error_msg = $drc->getErrorMessage();
+                               }
                        } else {
                                $dr = new DocumentReview($d, $reviewid);
                                if ($reviewcompletedchecked) {
@@ -227,7 +237,7 @@ switch ($subaction) {
                                }
                        }
                } else {
-                       $warning_msg = _('Missing version to create review');
+                       $warning_msg = _('Missing flag action');
                }
                break;
 }
diff --git a/src/common/docman/actions/getdocreviewcomments.php 
b/src/common/docman/actions/getdocreviewcomments.php
new file mode 100644
index 0000000..2c025c6
--- /dev/null
+++ b/src/common/docman/actions/getdocreviewcomments.php
@@ -0,0 +1,56 @@
+<?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.
+ */
+
+/* please do not add require here : use www/docman/index.php to add require */
+/* global variables used */
+global $group_id; // id of group
+global $HTML;
+
+$sysdebug_enable = false;
+$result = array();
+
+if (!forge_check_perm('docman', $group_id, 'approve')) {
+       $result['html'] = $HTML->error_msg(_('Document Manager Action 
Denied.'));
+       echo json_encode($result);
+       exit;
+}
+$docid = getIntFromRequest('docid');
+$revid = getIntFromRequest('revid');
+if ($docid && $revid) {
+       $documentObject = document_get_object($docid, $group_id);
+       if ($documentObject && !$documentObject->isError()) {
+               $dr = new DocumentReview($documentObject, $revid);
+               if ($dr && !$dr->isError()) {
+                       $result['html'] .= 
$dr->showCommentFormHTML().$dr->showCommentsHTML();
+               } else {
+                       $result['html'] = $HTML->warning_msg(_('Cannot retrieve 
review')._(': ').$revid);
+               }
+       } else {
+               $result['html'] = $HTML->warning_msg(_('Cannot retrieve 
document')._(': ').$docid);
+       }
+} else {
+       $result['html'] = $HTML->warning_msg(_('No document ID or no review id. 
Cannot retrieve comments.'));
+}
+
+echo json_encode($result);
+exit;
diff --git a/src/db/20161218-document-review3.sql 
b/src/db/20161218-document-review3.sql
new file mode 100644
index 0000000..5f53866
--- /dev/null
+++ b/src/db/20161218-document-review3.sql
@@ -0,0 +1,16 @@
+CREATE SEQUENCE doc_review_comments_pk_seq
+    START WITH 1
+    INCREMENT BY 1
+    MAXVALUE 2147483647
+    NO MINVALUE
+    CACHE 1;
+
+CREATE SEQUENCE doc_review_attachments_pk_seq
+    START WITH 1
+    INCREMENT BY 1
+    MAXVALUE 2147483647
+    NO MINVALUE
+    CACHE 1;
+
+ALTER TABLE doc_review_comments ALTER COLUMN commentid SET DEFAULT 
nextval('doc_review_comments_pk_seq'::text);
+ALTER TABLE doc_review_attachments ALTER COLUMN attachid SET DEFAULT 
nextval('doc_review_attachments_pk_seq'::text);
diff --git a/src/www/docman/index.php b/src/www/docman/index.php
index e348e55..985791e 100644
--- a/src/www/docman/index.php
+++ b/src/www/docman/index.php
@@ -34,6 +34,8 @@ require_once $gfcommon.'docman/DocumentGroup.class.php';
 require_once $gfcommon.'docman/DocumentGroupFactory.class.php';
 require_once $gfcommon.'docman/DocumentReview.class.php';
 require_once $gfcommon.'docman/DocumentReviewFactory.class.php';
+require_once $gfcommon.'docman/DocumentReviewComment.class.php';
+require_once $gfcommon.'docman/DocumentReviewCommentFactory.class.php';
 require_once $gfcommon.'docman/DocumentVersion.class.php';
 require_once $gfcommon.'docman/DocumentVersionFactory.class.php';
 require_once $gfcommon.'docman/include/utils.php';
diff --git a/src/www/docman/scripts/DocManController.js 
b/src/www/docman/scripts/DocManController.js
index 645b3a2..d57e240 100644
--- a/src/www/docman/scripts/DocManController.js
+++ b/src/www/docman/scripts/DocManController.js
@@ -187,6 +187,7 @@ DocManListFileController.prototype =
                        jQuery('#editfile-userstatusreview').remove();
                        jQuery('#editfile-completedreview').remove();
                        jQuery('#editfile-datepickerreview-script').remove();
+                       jQuery('#editfile-commentreview').remove();
                }, this));
        },
 
@@ -398,6 +399,7 @@ DocManListFileController.prototype =
                jQuery('#doc_group').empty();
                jQuery('#editfile-userstatusreview').empty();
                jQuery('#editfile-completedreview').empty();
+               jQuery('#editfile-commentreview').empty();
                 for (var i = 0; i < this.docparams.docgroupDict.length; i++) {
                         
jQuery('#doc_group').append(jQuery('<option>').text(this.docparams.docgroupDict[i][1]).attr('value',
 this.docparams.docgroupDict[i][0]));
                 };
@@ -526,6 +528,7 @@ DocManListFileController.prototype =
        },
 
        toggleAddReviewView: function() {
+               jQuery('#review_newcomment').val(0);
                jQuery('#review-title').val('');
                jQuery('#review-description').val('');
                jQuery('#datepicker_end_review_date').val('');
@@ -537,6 +540,7 @@ DocManListFileController.prototype =
                jQuery('#review-select-optional-users').gentleSelect({columns: 
3, itemWidth: 150});
                jQuery('#editfile-userstatusreview').empty();
                jQuery('#editfile-completedreview').empty();
+               jQuery('#editfile-commentreview').empty();
                if (jQuery('#editfile-createreview').is(':visible')) {
                        jQuery('#editfile-createreview').hide();
                        jQuery('#new_review').val(0);
@@ -548,6 +552,8 @@ DocManListFileController.prototype =
 
        toggleEditReviewView: function(params) {
                this.review = params;
+               jQuery('#editfile-commentreview').empty();
+               jQuery('#review_newcomment').val(0);
                if (jQuery('#editfile-createreview').is(':visible')) {
                        jQuery('#editfile-createreview').hide();
                        jQuery('#new_review').val(0);
@@ -591,6 +597,24 @@ DocManListFileController.prototype =
                }
        },
 
+       toggleCommentReviewView: function(params) {
+               this.comment = params;
+               jQuery('#editfile-createreview').hide();
+               jQuery('#new_review').val(0);
+               jQuery('#review_id').val(0);
+               jQuery('#review_complete').val(0);
+               jQuery('#review_newcomment').val(1);
+               jQuery('#review_id').val(this.comment.review);
+               jQuery('#editfile-userstatusreview').empty();
+               jQuery('#editfile-completedreview').empty();
+               jQuery.getJSON(this.listfileparams.docManURL + '/?group_id=' + 
this.comment.groupId + 
'&action=getdocreviewcomments&docid='+this.comment.docid+'&revid='+this.comment.review
 , jQuery.proxy(function(data){
+                       jQuery('#editfile-commentreview').empty();
+                       if (typeof data.html != 'undefined') {
+                               
jQuery('#editfile-commentreview').prepend(data.html);
+                       }
+               }, this.comment));
+       },
+
        toggleEditVersionView: function(params) {
                this.version = params;
                jQuery('#new_version').val(0);

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

Summary of changes:
 src/common/docman/DocumentReview.class.php         | 41 +++++++++++-
 src/common/docman/DocumentReviewComment.class.php  | 74 ++++++++++++++++++++++
 .../docman/DocumentReviewCommentFactory.class.php  |  9 ++-
 src/common/docman/actions/editfile.php             | 12 +++-
 ...viewuserstatus.php => getdocreviewcomments.php} |  5 +-
 src/db/20161218-document-review3.sql               | 16 +++++
 src/www/docman/index.php                           |  2 +
 src/www/docman/scripts/DocManController.js         | 24 +++++++
 8 files changed, 177 insertions(+), 6 deletions(-)
 copy src/common/docman/actions/{getdocreviewuserstatus.php => 
getdocreviewcomments.php} (94%)
 create mode 100644 src/db/20161218-document-review3.sql


hooks/post-receive
-- 
FusionForge

_______________________________________________
Fusionforge-commits mailing list
[email protected]
http://lists.fusionforge.org/cgi-bin/mailman/listinfo/fusionforge-commits

Reply via email to