Commit 683f7bdded8f853318d9b0489085aaac01424c01

Authored by omar
1 parent 0edc67a0

*** empty log message ***


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1770 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/discussions/addCommentBL.php
... ... @@ -36,14 +36,17 @@ if (checkSession()) {
36 36 $oPatternCustom = & new PatternCustom();
37 37  
38 38 if(checksession) {
39   - if (isset($fAddComment)) {
  39 + if (isset($fAddComment)) {
40 40 if ($fDocumentID > 0) {
  41 + //if (isset($fNewThread))
  42 +
41 43 $main->setFormAction($_SERVER['PHP_SELF'] . "?fAddCommentSubmit=1&iDocumentID=$fDocumentID");
42 44 $oPatternCustom->setHtml(getAddComment($fDocumentID,$sSubject,$sBody));
43 45 }
44 46 else {
45 47 //nothing
46 48 }
  49 +
47 50 } else if (isset($fViewComment)){
48 51 if (isset($iCommentID)) {
49 52 $oComment = DiscussionComment::get($iCommentID);
... ... @@ -51,12 +54,19 @@ if (checkSession()) {
51 54  
52 55 $oPatternCustom->setHtml(getCommentBody($oComment->getBody(), $oComment->getSubject(),$oComment->getDate(),$iDocumentID,$oUser->getUserName())) ;
53 56 }
54   - } else if (isset($fAddCommentSubmit)) {
55   - $iThreadID = DiscussionThread::getThreadIDforDoc($iDocumentID);
  57 + } else if (isset($fAddCommentSubmit)) {
  58 + if ($_POST["NewComment"] != "" and $_POST["NewCommentSubject"] != "") {
  59 + if (isset($fNewThread)){ // Create a New Thread for this document as it doesn't exist
  60 + // Create the thread Object
  61 + $oThread = & new DiscussionThread(-1,$iDocumentID, $_SESSION["userID"]);
  62 + $oThread->create();
  63 + $iThreadID = $oThread->getID();
  64 + }
  65 + else { // Update the existing thread
  66 + $iThreadID = DiscussionThread::getThreadIDforDoc($iDocumentID);
  67 + }
56 68  
57   - if ($iThreadID > 0){
58   - if ($_POST["NewComment"] != "" and $_POST["NewCommentSubject"] != "")
59   - {
  69 + if ($iThreadID > 0){
60 70 // Create the new comment
61 71 $oComment = & new DiscussionComment(urlencode($_POST["NewComment"]),$_POST["NewCommentSubject"],$_SESSION["userID"],$iDocumentID);
62 72 $oComment->setThreadID($iThreadID);
... ... @@ -65,6 +75,11 @@ if (checkSession()) {
65 75 if($oComment->getID() > 0) {
66 76 $oThread = DiscussionThread::get($iThreadID);
67 77 $oThread->setLastCommentID($oComment->getID());
  78 + if ($oThread->getFirstComment == -1){ // if it is a new Thread
  79 + $oThread->setFirstCommentID($oComment->getID());
  80 + $oThread->setNumberOfViews();
  81 + $oThread->setNumberOfReplies();
  82 + }
68 83 $oThread->setNumberOfReplies();
69 84 if ($oThread->Update()) {
70 85 $oPatternCustom->addHtml(getSubmitSuccessPage($iDocumentID));
... ... @@ -74,21 +89,29 @@ if (checkSession()) {
74 89 }else {
75 90 $oPatternCustom->addHtml(getViewFailPage("Comment Object failed in creation.") );
76 91 }
77   - }else {
78   - $oPatternCustom->addHtml(getViewFailPage("The subject line and/or body may be empty.") );
79   - $main->setFormAction($_SERVER['PHP_SELF'] . "?fAddCommentSubmit=1&iDocumentID=$fDocumentID");
80   - $oPatternCustom->addHtml(getAddComment($fDocumentID,$_POST["NewCommentSubject"],$_POST["NewComment"]));
81   - }
82   - }else{
83   - $oPatternCustom->addHtml(getViewFailPage("No threadID($iThreadID) exists for this document"));
84   - }
85 92  
  93 + }else{
  94 + $oPatternCustom->addHtml(getViewFailPage("No threadID($iThreadID) exists for this document" . $astr ));
  95 + }// End Of if for THREAD ID test
  96 + }else {
  97 + $oPatternCustom->addHtml(getViewFailPage("The subject line and/or body may be empty.") );
  98 + $main->setFormAction($_SERVER['PHP_SELF'] . "?fAddCommentSubmit=1&iDocumentID=$fDocumentID");
  99 + $oPatternCustom->addHtml(getAddComment($fDocumentID,$_POST["NewCommentSubject"],$_POST["NewComment"]));
  100 + } // end of IF for Subject and Body test
  101 +
86 102 } else if (isset($fReplyComment)){ // if user is replying to existing comment
87 103 $main->setFormAction($_SERVER['PHP_SELF'] . "?fAddCommentSubmit=1&iDocumentID=$fDocumentID");
88 104 $oPatternCustom->addHtml(getAddComment($fDocumentID,"Re: " . $CommentSubject , "\n\n\n[Start Text Body]\n\n" . $Comment . "\n\n[End Text Body]"));
89   -
90   - }else { // If no discussion exists
91   - $oPatternCustom->setHtml(getViewFailPage("No discussions exist"));
  105 +
  106 + }else if (isset($fNewThread)){ // Start adding a new Thread
  107 + $main->setFormAction($_SERVER['PHP_SELF'] . "?fAddCommentSubmit=1&iDocumentID=$fDocumentID&fNewThread=1");
  108 + $oPatternCustom->addHtml(getAddComment($fDocumentID, $CommentSubject , $Comment ));
  109 + //$oPatternCustom->addHtml(getAddComment($fDocumentID,$CommentSubject,$Comment));
  110 +
  111 + }
  112 +
  113 + else { // If no discussion exists
  114 + $oPatternCustom->setHtml(getViewFailPage("Comment"));
92 115 }
93 116  
94 117 } // end of if checksession
... ...
presentation/lookAndFeel/knowledgeTree/discussions/addCommentUI.inc
... ... @@ -61,20 +61,19 @@ function renderDocumentPath($iDocumentID) {
61 61 function getAddComment($fDocumentID, $sSubject, $sBody) {
62 62 global $default;
63 63  
64   - $iThreadID = DiscussionThread::getThreadIDforDoc($fDocumentID);
65   - $oThread = DiscussionThread::get($iThreadID);
66   - if($oThread) { // if thread object exists
67   - $sHeading = "Add a Comment";
68   -
69   - $sToRender .= renderHeading($sHeading);
70   - $sToRender .= renderDocumentPath($oThread->getDocumentID());
71   - $sToRender .= "<table width=\"100%\" border=0><tr><td></td>\n";
72   - $sToRender .= "<td align=right><input type=\"submit\" style=\"BORDER-RIGHT: 0px groove; BORDER-TOP: 0px groove; BACKGROUND-IMAGE: url($default->graphicsUrl/widgets/submit.gif); BORDER-LEFT: 0px groove; WIDTH: 45px; BORDER-BOTTOM: 0px groove; HEIGHT: 18; BACKGROUND-COLOR: white\" width=\"45\" height=\"20\" value=\" \" width=\"100\"></td></tr>\n";
73   - $sToRender .= "<br><tr><td valign=\"top\" width=10><b>Subject</b></td><td>\n";
74   - $sToRender .= "<input type=\"text\" style=\"width:100%\" name=\"NewCommentSubject\" id=\"NewCommentSubject\" value=\"$sSubject\"></td></tr>\n";
75   - $sToRender .= "<tr><td valign=\"top\"><b>Body</b></td><td><textarea style=\"width:100%\" rows=\"21\" name=\"NewComment\" id=\"NewComment\" style=\"FONT-STYLE: normal; FONT-FAMILY: sans-serif; FONT-VARIANT: normal\">$sBody</textarea></td></tr></table>\n";
76   - $sToRender .= "</table>";
77   - }
  64 + //$iThreadID = DiscussionThread::getThreadIDforDoc($fDocumentID);
  65 +
  66 +
  67 + $sHeading = "Add a Comment";
  68 + $sToRender .= renderHeading($sHeading);
  69 + $sToRender .= renderDocumentPath($fDocumentID);
  70 + $sToRender .= "<table width=\"100%\" border=0><tr><td></td>\n";
  71 + $sToRender .= "<td align=right><input type=\"submit\" style=\"BORDER-RIGHT: 0px groove; BORDER-TOP: 0px groove; BACKGROUND-IMAGE: url($default->graphicsUrl/widgets/submit.gif); BORDER-LEFT: 0px groove; WIDTH: 45px; BORDER-BOTTOM: 0px groove; HEIGHT: 18; BACKGROUND-COLOR: white\" width=\"45\" height=\"20\" value=\" \" width=\"100\"></td></tr>\n";
  72 + $sToRender .= "<br><tr><td valign=\"top\" width=10><b>Subject</b></td><td>\n";
  73 + $sToRender .= "<input type=\"text\" style=\"width:100%\" name=\"NewCommentSubject\" id=\"NewCommentSubject\" value=\"$sSubject\"></td></tr>\n";
  74 + $sToRender .= "<tr><td valign=\"top\"><b>Body</b></td><td><textarea style=\"width:100%\" rows=\"21\" name=\"NewComment\" id=\"NewComment\" style=\"FONT-STYLE: normal; FONT-FAMILY: sans-serif; FONT-VARIANT: normal\">$sBody</textarea></td></tr></table>\n";
  75 + $sToRender .= "</table>";
  76 +
78 77 return $sToRender;
79 78  
80 79 }
... ...
presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionBL.php
... ... @@ -3,34 +3,25 @@
3 3 * BL information for viewing a Discussion
4 4 *
5 5 * @author Omar Rahbeeni
6   -* @date 5 May 2003
  6 +* @date 8 May 2003
7 7 * @package presentation.lookAndFeel.knowledgeTree.
8 8 *
9 9 */
10 10  
11 11 require_once("../../../../config/dmsDefaults.php");
12 12  
13   -if (checkSession()) {
14   - //require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc");
15   - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCreate.inc");
16   - //require_once("addUnitUI.inc");
17   - //require_once("../adminUI.inc");
18   - require_once("viewDiscussionUI.inc"); //###
19   -
  13 +if (checkSession()) {
  14 + require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCreate.inc");
  15 + require_once("viewDiscussionUI.inc");
20 16 require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc");
21 17 require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc");
22 18 require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc");
23   - require_once("$default->fileSystemRoot/lib/users/User.inc");
24   - //require_once("../viewDiscussionUI.inc"); //###
25   - //require_once("$default->fileSystemRoot/lib/unitmanagement/Unit.inc");
26   - //require_once("$default->fileSystemRoot/lib/unitmanagement/UnitOrganisationLink.inc");
  19 + require_once("$default->fileSystemRoot/lib/users/User.inc");
27 20 require_once("$default->fileSystemRoot/lib/security/permission.inc");
28 21 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
29 22 require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");
30   - require_once("$default->fileSystemRoot/lib/discussions/DiscussionThread.inc"); //###
31   - require_once("$default->fileSystemRoot/lib/discussions/DiscussionComment.inc"); //###
32   - //require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc");
33   - //require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc");
  23 + require_once("$default->fileSystemRoot/lib/discussions/DiscussionThread.inc");
  24 + require_once("$default->fileSystemRoot/lib/discussions/DiscussionComment.inc");
34 25 require_once("$default->fileSystemRoot/presentation/Html.inc");
35 26  
36 27 $oPatternCustom = & new PatternCustom();
... ... @@ -59,20 +50,25 @@ if(checksession) {
59 50 $_SESSION['Discussion'][0]->bViews = true;
60 51 }
61 52 } else { $oPatternCustom->setHtml(getViewFailPage("")) ;}
62   - } else { $oPatternCustom->addHtml(getViewFailPage("No threadID for this document.")); }
  53 + } else { // No current thread, option to create one
  54 +
  55 + $oPatternCustom->addHtml(getNewThreadOption($fDocumentID));
  56 +
  57 +
  58 + }
63 59 } else { }
64 60 } else if (isset($fViewComment)){
65 61 if (isset($iCommentID)) {
66 62 $oComment = DiscussionComment::get($iCommentID);
67   - $oUser = User::get($oComment->getUserID());
68   -
69   - //$main->setFormAction(generateControllerLink("addComment", "fDocumentID=$iDocumentID&fCommentID=$iCommentID&fReplyComment=1"));
70   - $main->setFormAction("/presentation/lookAndFeel/knowledgeTree/discussions/addCommentBL.php?fDocumentID=$iDocumentID&fCommentID=$iCommentID&fReplyComment=1");
71   - //$main->setFormAction($_SERVER['PHP_SELF'] . "?fReplyComment=1");
  63 + $oUser = User::get($oComment->getUserID());
  64 +
  65 + $main->setFormAction("/presentation/lookAndFeel/knowledgeTree/discussions/addCommentBL.php?fDocumentID=$iDocumentID&fCommentID=$iCommentID&fReplyComment=1");
72 66 $oPatternCustom->setHtml(getCommentBody($oComment,$iDocumentID,$oUser)) ;
73 67 }
74   - } else if (isset($fReplyComment)){
75   - $oPatternCustom->setHtml("###" . count($_POST) . "###" . $Comment . "###" . $CommentSubject);
  68 + } else if (isset($fNewThread)){
  69 +
  70 +
  71 +
76 72 } else { // If no discussion exists
77 73 }
78 74  
... ...
presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionUI.inc
... ... @@ -22,6 +22,18 @@ function getViewFailPage($sMessage)
22 22 return $sToRender;
23 23 }
24 24  
  25 +function getNewThreadOption($fDocumentID) {
  26 + global $default;
  27 +
  28 + $sToRender .= "No discussion thread is currently available.<br><br>";
  29 + $sToRender .= "Would you like to create a new Discussion thread for this document?";
  30 + $sToRender .= "&nbsp;&nbsp;&nbsp;";
  31 + $sToRender .= "<a href=\"" . generateControllerLink("addComment", "fDocumentID=" . $fDocumentID . "&fNewThread=1") . "\"><img src=\"$default->graphicsUrl/widgets/new.gif\" border=\"0\" /></a> &nbsp;";
  32 + $sToRender .= "<a href=\"" . generateControllerLink("viewDocument", "fDocumentID=" . $fDocumentID) . "\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\" /></a>";
  33 +
  34 + return $sToRender;
  35 +}
  36 +
25 37 function renderHeading($sHeading) {
26 38 global $default;
27 39  
... ... @@ -64,12 +76,12 @@ function getViewComment($iNum,$oThread,$oComment,$oUser) {
64 76  
65 77 $sToRender .= renderHeading($sHeading );
66 78 $sToRender .= renderDocumentPath($oThread->getDocumentID());
67   - $sToRender .= "<table border=0 width=0><tr>";
68   - $sToRender .= "<td><b>Views: </b> " . $oThread->getNumberOfViews() . "</td>";
  79 + $sToRender .= "<table border=0 width=100%><tr>";
  80 + $sToRender .= "<td width=100><b>Views: </b> " . $oThread->getNumberOfViews() . "</td>";
69 81 $sToRender .= "<td width=20></td>";
70 82 $sToRender .= "<td><b>Replies: </b> " . $oThread->getNumberOfReplies() . "</td>";
71   - $sToRender .= "</tr></table>\n";
72   - $sToRender .= "<table border=0 width=100%><tr><td width=0></td><td align=right><a href=\"" . generateControllerLink("addComment", "fDocumentID=" . $oThread->getDocumentID() . "&fAddComment=1") . "\"><img src=\"$default->graphicsUrl/widgets/addcomment.gif\" border=\"0\" /></a></td></tr></table>\n";
  83 + $sToRender .= "<td align=right><a href=\"" . generateControllerLink("addComment", "fDocumentID=" . $oThread->getDocumentID() . "&fAddComment=1") . "\"><img src=\"$default->graphicsUrl/widgets/addcomment.gif\" border=\"0\" /></a></td>";
  84 + $sToRender .= "</tr></table><br>\n";
73 85 $sToRender .= "<table border=\"0\" width=\"100%\" cellspacing=0><tr>\n";
74 86 $sToRender .= "<td><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Subject</b></td>\n";
75 87 $sToRender .= "<td><b>Author</b></td>\n";
... ... @@ -97,12 +109,14 @@ function getCommentBody($oComment, $iDocumentID, $oUser) {
97 109  
98 110 $sToRender .= "<br><table width=100% border=0><tr ><td colspan=2><b>Author: </b>" . $oUser->getUserName() . "</td>\n";
99 111 $sToRender .= "<td align=right>\n";
100   - $sToRender .= "<input type=\"submit\" style=\"BORDER-RIGHT: 0px groove; BORDER-TOP: 0px groove; BACKGROUND-IMAGE: url($default->graphicsUrl/widgets/reply.gif); BORDER-LEFT: 0px groove; WIDTH: 40px; BORDER-BOTTOM: 0px groove; HEIGHT: 18; BACKGROUND-COLOR: white\" height=\"20\" value=\" \" width=\"200\">";
  112 + $sToRender .= "<input type=\"submit\" style=\"BORDER-RIGHT: 0px groove; BORDER-TOP: 0px groove; BACKGROUND-IMAGE: url($default->graphicsUrl/widgets/reply.gif); BORDER-LEFT: 0px groove; WIDTH: 40px; BORDER-BOTTOM: 0px groove; HEIGHT: 18; BACKGROUND-COLOR: white\" height=\"20\" value=\" \" width=\"200\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
101 113 $sToRender .= "</td></tr>\n";
102 114 $sToRender .= "<tr><td width=\"1\" style=\"background-color:#F5F6EE;\" valign=\"top\"><b>Subject: </b></td><td width=405 style=\"background-color:#F5F6EE;\">";
103 115 $sToRender .= "<input name=\"CommentSubject\" id=\"CommentSubject\" style=\"background-color:#F5F6EE;BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WIDTH: 100%; BORDER-RIGHT-WIDTH: 0px\" readOnly width=0 value=\"" . $oComment->getSubject() . "\">";
104   - $sToRender .= "</td><td><b>Date: </b><font color=\"#056DCE\">" . $oComment->getDate() . "</font></td></tr><tr><td colspan=3 valign=top>";
105   - $sToRender .= "<TEXTAREA readOnly name=\"Comment\" id=\"Comment\" style=\"BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; SCROLLBAR-SHADOW-COLOR: white; SCROLLBAR-3DLIGHT-COLOR: white; SCROLLBAR-ARROW-COLOR: white; SCROLLBAR-DARKSHADOW-COLOR: white; SCROLLBAR-BASE-COLOR: white; BORDER-RIGHT-WIDTH: 0px;FONT-FAMILY: sans-serif;\" rows=70 cols=40> ";
  116 + $sToRender .= "</td><td><b>Date: </b><font color=\"#056DCE\">" . $oComment->getDate() . "</font>&nbsp;&nbsp;&nbsp;</td></tr><tr><td colspan=3 valign=top>";
  117 + //$sToRender .= "<TEXTAREA readOnly name=\"Comment\" id=\"Comment\" style=\"BORDER-TOP-WIDTH: 1px; BORDER-LEFT-WIDTH: 1px; BORDER-BOTTOM-WIDTH: 0px; SCROLLBAR-SHADOW-COLOR: white; SCROLLBAR-3DLIGHT-COLOR: white; SCROLLBAR-ARROW-COLOR: white; SCROLLBAR-DARKSHADOW-COLOR: white; SCROLLBAR-BASE-COLOR: white; BORDER-RIGHT-WIDTH: 0px;FONT-FAMILY: sans-serif;\" rows=40 cols=96> ";
  118 + //$sToRender .= "<TEXTAREA readOnly name=\"Comment\" id=\"Comment\" style=\"BORDER-TOP-WIDTH: 1px; BORDER-LEFT-WIDTH: 1px; BORDER-BOTTOM-WIDTH: 0px; SCROLLBAR-SHADOW-COLOR: white; SCROLLBAR-3DLIGHT-COLOR: white; SCROLLBAR-ARROW-COLOR: white; SCROLLBAR-DARKSHADOW-COLOR: white; SCROLLBAR-BASE-COLOR: white; BORDER-RIGHT-WIDTH: 0px;FONT-FAMILY: sans-serif;\" rows=40 cols=96> ";
  119 + $sToRender .= "<TEXTAREA readOnly name=\"Comment\" id=\"Comment\" rows=40 cols=100 style=\"BORDER-WIDTH: 0px;FONT-FAMILY: sans-serif;\"> ";
106 120 $sToRender .= urldecode($oComment->getBody());
107 121 $sToRender .= "</textarea></td>";
108 122 $sToRender .= "</tr></table> ";
... ...