Commit b79b9a80e97ecd0b6241bc74d86e52f936f817ce

Authored by jacquiz
1 parent 1dab2d56

Type: Bug fix

Description:		Pass through the TreadID so that the comments for the correct
thread is displayed


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2874 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/discussions/addCommentBL.php
@@ -54,11 +54,14 @@ if(checkSession()) { @@ -54,11 +54,14 @@ if(checkSession()) {
54 // if this is a new thread, then set inReplyTo to -1 54 // if this is a new thread, then set inReplyTo to -1
55 $fInReplyTo = -1; 55 $fInReplyTo = -1;
56 } else { 56 } else {
  57 + // replying
57 // retrieve the thread id 58 // retrieve the thread id
58 - $iThreadID = DiscussionThread::getThreadIDforDoc($fDocumentID); 59 + //$iThreadID = DiscussionThread::getThreadIDforDoc($fDocumentID);
  60 + $default->log->info("adding comment: SEtting thread id: " . $fThreadID);
  61 + $iThreadID = $fThreadID;
59 } 62 }
60 if ($iThreadID) { 63 if ($iThreadID) {
61 - $default->log->info("addComment fInReplyTo=$fInReplyTo"); 64 + $default->log->info("addComment fInReplyTo=$fInReplyTo, threadID=$iThreadID");
62 // Create the new comment 65 // Create the new comment
63 $oComment = & new DiscussionComment($fComment, $fSubject, $_SESSION["userID"], $iThreadID, $fInReplyTo); 66 $oComment = & new DiscussionComment($fComment, $fSubject, $_SESSION["userID"], $iThreadID, $fInReplyTo);
64 $oComment->setThreadID($iThreadID); 67 $oComment->setThreadID($iThreadID);
@@ -92,7 +95,7 @@ if(checkSession()) { @@ -92,7 +95,7 @@ if(checkSession()) {
92 } else { // the user has not entered BOTH a subject and a text body 95 } else { // the user has not entered BOTH a subject and a text body
93 $main->setErrorMessage("The subject line and/or body should not be empty."); 96 $main->setErrorMessage("The subject line and/or body should not be empty.");
94 $main->setFormAction($_SERVER['PHP_SELF'] . "?fAddCommentSubmit=1&iDocumentID=$fDocumentID"); 97 $main->setFormAction($_SERVER['PHP_SELF'] . "?fAddCommentSubmit=1&iDocumentID=$fDocumentID");
95 - $oPatternCustom->addHtml(getAddComment($fDocumentID, $fSubject, $fComment, $fCommentID, 1)); 98 + $oPatternCustom->addHtml(getAddComment($fDocumentID, $fSubject, $fComment, $fCommentID, 1, $fThreadID));
96 } // end of IF for Subject and Body test 99 } // end of IF for Subject and Body test
97 } else if (isset($fReplyComment)) { // if user is replying to existing comment 100 } else if (isset($fReplyComment)) { // if user is replying to existing comment
98 $main->setFormAction($_SERVER['PHP_SELF'] . "?fAddCommentSubmit=1&iDocumentID=$fDocumentID"); 101 $main->setFormAction($_SERVER['PHP_SELF'] . "?fAddCommentSubmit=1&iDocumentID=$fDocumentID");
@@ -115,16 +118,16 @@ if(checkSession()) { @@ -115,16 +118,16 @@ if(checkSession()) {
115 $sReply = "Re: "; 118 $sReply = "Re: ";
116 } else { $sReply = ""; } 119 } else { $sReply = ""; }
117 120
118 - $oPatternCustom->addHtml(getAddComment($fDocumentID, $sReply . $oComment->getSubject() , urldecode($sReplyBody), $fCommentID, "-1" )); 121 + $oPatternCustom->addHtml(getAddComment($fDocumentID, $sReply . $oComment->getSubject() , urldecode($sReplyBody), $fCommentID, "-1" , $fThreadID));
119 122
120 } else if (isset($fNewThread)){ // Start adding a new Thread 123 } else if (isset($fNewThread)){ // Start adding a new Thread
121 $main->setFormAction($_SERVER['PHP_SELF'] . "?fAddCommentSubmit=1&iDocumentID=$fDocumentID&fNewThread=1"); 124 $main->setFormAction($_SERVER['PHP_SELF'] . "?fAddCommentSubmit=1&iDocumentID=$fDocumentID&fNewThread=1");
122 - $oPatternCustom->addHtml(getAddComment($fDocumentID, $CommentSubject ,$Comment, $fCommentID, "1")); 125 + $oPatternCustom->addHtml(getAddComment($fDocumentID, $CommentSubject ,$Comment, $fCommentID, "1", $fThreadID));
123 } else { 126 } else {
124 // input validation 127 // input validation
125 if (isset($fDocumentID)) { 128 if (isset($fDocumentID)) {
126 $main->setFormAction($_SERVER['PHP_SELF'] . "?fAddCommentSubmit=1&iDocumentID=$fDocumentID"); 129 $main->setFormAction($_SERVER['PHP_SELF'] . "?fAddCommentSubmit=1&iDocumentID=$fDocumentID");
127 - $oPatternCustom->setHtml(getAddComment($fDocumentID,$sSubject,$sBody, $fCommentID, 1)); 130 + $oPatternCustom->setHtml(getAddComment($fDocumentID,$sSubject,$sBody, $fCommentID, 1, $fThreadID));
128 } else { 131 } else {
129 $main->setErrorMessage("You did not specify a document to add a comment to."); 132 $main->setErrorMessage("You did not specify a document to add a comment to.");
130 } 133 }
presentation/lookAndFeel/knowledgeTree/discussions/addCommentUI.inc
@@ -45,7 +45,7 @@ function getSubmitSuccessPage($iDocumentID){ @@ -45,7 +45,7 @@ function getSubmitSuccessPage($iDocumentID){
45 * @param $sSubject -> a Subject text 45 * @param $sSubject -> a Subject text
46 * @param $sBody -> a Body text 46 * @param $sBody -> a Body text
47 */ 47 */
48 -function getAddComment($fDocumentID, $sSubject, $sBody, $iCommentID, $fNewComment = null) { 48 +function getAddComment($fDocumentID, $sSubject, $sBody, $iCommentID, $fNewComment = null, $fThreadID) {
49 global $default; 49 global $default;
50 50
51 $sHeading = "Add a Comment"; 51 $sHeading = "Add a Comment";
@@ -61,6 +61,7 @@ function getAddComment($fDocumentID, $sSubject, $sBody, $iCommentID, $fNewCommen @@ -61,6 +61,7 @@ function getAddComment($fDocumentID, $sSubject, $sBody, $iCommentID, $fNewCommen
61 $sToRender .= "<input type=\"hidden\" name=\"fNewComment\" value=\"1\"/>"; 61 $sToRender .= "<input type=\"hidden\" name=\"fNewComment\" value=\"1\"/>";
62 } else { // If the user is replying to a comment 62 } else { // If the user is replying to a comment
63 $sToRender .= "<input type=\"hidden\" name=\"fInReplyTo\" value=\"$iCommentID\"/>"; 63 $sToRender .= "<input type=\"hidden\" name=\"fInReplyTo\" value=\"$iCommentID\"/>";
  64 + $sToRender .= "<input type=\"hidden\" name=\"fThreadID\" value=\"". $fThreadID . "\"/>";
64 $sToRender .= "<td width=\"10\" valign=top><a href=\"" . generateControllerLink("viewComment", "fViewComment=1&iDocumentID=$fDocumentID&iCommentID=$iCommentID") . "\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=0 ></a></td></tr>\n"; 65 $sToRender .= "<td width=\"10\" valign=top><a href=\"" . generateControllerLink("viewComment", "fViewComment=1&iDocumentID=$fDocumentID&iCommentID=$iCommentID") . "\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=0 ></a></td></tr>\n";
65 } 66 }
66 $sToRender .= "<br><tr><td valign=\"top\" width=10><b>Subject</b></td><td colspan=2>\n"; 67 $sToRender .= "<br><tr><td valign=\"top\" width=10><b>Subject</b></td><td colspan=2>\n";
presentation/lookAndFeel/knowledgeTree/discussions/viewCommentBL.php
@@ -45,7 +45,7 @@ if (checkSession()) { @@ -45,7 +45,7 @@ if (checkSession()) {
45 $oComment = DiscussionComment::get($iCommentID); 45 $oComment = DiscussionComment::get($iCommentID);
46 $oUser = User::get($oComment->getUserID()); 46 $oUser = User::get($oComment->getUserID());
47 $main->setFormAction("$default->rootUrl/presentation/lookAndFeel/knowledgeTree/discussions/addCommentBL.php?fDocumentID=$iDocumentID&fCommentID=$iCommentID&fReplyComment=1"); 47 $main->setFormAction("$default->rootUrl/presentation/lookAndFeel/knowledgeTree/discussions/addCommentBL.php?fDocumentID=$iDocumentID&fCommentID=$iCommentID&fReplyComment=1");
48 - $oPatternCustom->setHtml(getCommentBody($oComment,$iDocumentID,$oUser)); 48 + $oPatternCustom->setHtml(getCommentBody($oComment,$iDocumentID,$oUser,$iThreadID));
49 } else { 49 } else {
50 $main->setErrorMessage("You didn't specify a comment to view"); 50 $main->setErrorMessage("You didn't specify a comment to view");
51 } 51 }
presentation/lookAndFeel/knowledgeTree/discussions/viewCommentUI.inc
@@ -31,8 +31,9 @@ @@ -31,8 +31,9 @@
31 * @param $iDocumentID -> a valid Document ID 31 * @param $iDocumentID -> a valid Document ID
32 * @param $oComment -> a valid Comment Object 32 * @param $oComment -> a valid Comment Object
33 * @param $oUser -> a valid User Object (Logged in user) 33 * @param $oUser -> a valid User Object (Logged in user)
  34 + * @param $iThreadID -> the ThreadID passed through
34 */ 35 */
35 -function getCommentBody($oComment, $iDocumentID, $oUser) { 36 +function getCommentBody($oComment, $iDocumentID, $oUser, $iThreadID) {
36 global $default; 37 global $default;
37 38
38 $sHeading = "Document Comment"; 39 $sHeading = "Document Comment";
@@ -61,7 +62,7 @@ function getCommentBody($oComment, $iDocumentID, $oUser) { @@ -61,7 +62,7 @@ function getCommentBody($oComment, $iDocumentID, $oUser) {
61 62
62 $sToRender .= "<br><table width=100% border=0><tr ><td colspan=2><b>Author: </b>" . $oUser->getUserName() . "</td>\n"; 63 $sToRender .= "<br><table width=100% border=0><tr ><td colspan=2><b>Author: </b>" . $oUser->getUserName() . "</td>\n";
63 $sToRender .= "<td align=right>\n"; 64 $sToRender .= "<td align=right>\n";
64 - $sToRender .= "<a href=\"" . generateControllerLink("addComment", "fDocumentID=" . $iDocumentID . "&fReplyComment=1&fCommentID=" . $oComment->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/reply.gif\" border=\"0\" /></a>"; 65 + $sToRender .= "<a href=\"" . generateControllerLink("addComment", "fDocumentID=" . $iDocumentID . "&fReplyComment=1&fCommentID=" . $oComment->getID()) . "&fThreadID=" . $iThreadID . "\"><img src=\"$default->graphicsUrl/widgets/reply.gif\" border=\"0\" /></a>";
65 $sToRender .= "</td><td width=30><a href=\"" . generateControllerLink("viewDiscussion", "fForDiscussion=1&fDocumentID=$iDocumentID") . "\"><img src=\"$default->graphicsUrl/widgets/back.gif\" border=0 ><a></td></tr>\n"; 66 $sToRender .= "</td><td width=30><a href=\"" . generateControllerLink("viewDiscussion", "fForDiscussion=1&fDocumentID=$iDocumentID") . "\"><img src=\"$default->graphicsUrl/widgets/back.gif\" border=0 ><a></td></tr>\n";
66 $sToRender .= "<tr><td width=\"1\" style=\"background-color:#F5F6EE;\" ><b>Subject: </b></td><td width=405 style=\"background-color:#F5F6EE;\">"; 67 $sToRender .= "<tr><td width=\"1\" style=\"background-color:#F5F6EE;\" ><b>Subject: </b></td><td width=405 style=\"background-color:#F5F6EE;\">";
67 $sToRender .= $oComment->getSubject(); 68 $sToRender .= $oComment->getSubject();
presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionUI.inc
@@ -86,7 +86,7 @@ function getViewComment($iNum, $oThread, $oComment, $sIndent) { @@ -86,7 +86,7 @@ function getViewComment($iNum, $oThread, $oComment, $sIndent) {
86 86
87 $sToRender .= "<tr>\n"; 87 $sToRender .= "<tr>\n";
88 $sToRender .= "\t<td style=\"background-color:$BGcolor\" width=450>\n"; 88 $sToRender .= "\t<td style=\"background-color:$BGcolor\" width=450>\n";
89 - $sToRender .= "\t\t$sIndent<a href=\"" . generateControllerLink("viewComment", "iCommentID=" . $oComment->getID() . "&iDocumentID=" . $oThread->getDocumentID()) . "\" title=\"" . $oComment->getSubject() . "\">\n"; 89 + $sToRender .= "\t\t$sIndent<a href=\"" . generateControllerLink("viewComment", "iCommentID=" . $oComment->getID() . "&iDocumentID=" . $oThread->getDocumentID() . "&iThreadID=" . $oThread->getID()) . "\" title=\"" . $oComment->getSubject() . "\">\n";
90 $sToRender .= substr($oComment->getSubject(),0,$iSubjectChars ) . $dotdot . "</a></td>\n"; 90 $sToRender .= substr($oComment->getSubject(),0,$iSubjectChars ) . $dotdot . "</a></td>\n";
91 $sToRender .= "\t<td style=\"background-color:$UserBGcolor\" width=\"100\" title=\"$sUserName\">\n"; 91 $sToRender .= "\t<td style=\"background-color:$UserBGcolor\" width=\"100\" title=\"$sUserName\">\n";
92 $sToRender .= "\t\t$sUserName</td>\n"; 92 $sToRender .= "\t\t$sUserName</td>\n";
@@ -119,7 +119,7 @@ function getPage($iDocumentID, $aDocumentThreads) { @@ -119,7 +119,7 @@ function getPage($iDocumentID, $aDocumentThreads) {
119 $aCommentTree = getCommentTree($aDocumentThreads[$i]->getID(), -1); 119 $aCommentTree = getCommentTree($aDocumentThreads[$i]->getID(), -1);
120 // now loop through the comments, and indent comments that have the same reply_to at the same level .... ?? 120 // now loop through the comments, and indent comments that have the same reply_to at the same level .... ??
121 for ($j=0; $j<count($aCommentTree); $j++) { 121 for ($j=0; $j<count($aCommentTree); $j++) {
122 - $default->log->info("commentTree[$j][comment]=" . $aCommentTree[$j]["comment"]); 122 + $default->log->info("commentTree[$j][comment]=" . arrayToString($aCommentTree[$j]["comment"]));
123 $sToRender .= getViewComment($iCount++, $aDocumentThreads[$i], $aCommentTree[$j]["comment"], getIndent($aCommentTree[$j]["level"])); 123 $sToRender .= getViewComment($iCount++, $aDocumentThreads[$i], $aCommentTree[$j]["comment"], getIndent($aCommentTree[$j]["level"]));
124 } 124 }
125 } 125 }