diff --git a/presentation/lookAndFeel/knowledgeTree/discussions/addCommentBL.php b/presentation/lookAndFeel/knowledgeTree/discussions/addCommentBL.php
index 581b848..94a876a 100644
--- a/presentation/lookAndFeel/knowledgeTree/discussions/addCommentBL.php
+++ b/presentation/lookAndFeel/knowledgeTree/discussions/addCommentBL.php
@@ -36,14 +36,17 @@ if (checkSession()) {
$oPatternCustom = & new PatternCustom();
if(checksession) {
- if (isset($fAddComment)) {
+ if (isset($fAddComment)) {
if ($fDocumentID > 0) {
+ //if (isset($fNewThread))
+
$main->setFormAction($_SERVER['PHP_SELF'] . "?fAddCommentSubmit=1&iDocumentID=$fDocumentID");
$oPatternCustom->setHtml(getAddComment($fDocumentID,$sSubject,$sBody));
}
else {
//nothing
}
+
} else if (isset($fViewComment)){
if (isset($iCommentID)) {
$oComment = DiscussionComment::get($iCommentID);
@@ -51,12 +54,19 @@ if (checkSession()) {
$oPatternCustom->setHtml(getCommentBody($oComment->getBody(), $oComment->getSubject(),$oComment->getDate(),$iDocumentID,$oUser->getUserName())) ;
}
- } else if (isset($fAddCommentSubmit)) {
- $iThreadID = DiscussionThread::getThreadIDforDoc($iDocumentID);
+ } else if (isset($fAddCommentSubmit)) {
+ if ($_POST["NewComment"] != "" and $_POST["NewCommentSubject"] != "") {
+ if (isset($fNewThread)){ // Create a New Thread for this document as it doesn't exist
+ // Create the thread Object
+ $oThread = & new DiscussionThread(-1,$iDocumentID, $_SESSION["userID"]);
+ $oThread->create();
+ $iThreadID = $oThread->getID();
+ }
+ else { // Update the existing thread
+ $iThreadID = DiscussionThread::getThreadIDforDoc($iDocumentID);
+ }
- if ($iThreadID > 0){
- if ($_POST["NewComment"] != "" and $_POST["NewCommentSubject"] != "")
- {
+ if ($iThreadID > 0){
// Create the new comment
$oComment = & new DiscussionComment(urlencode($_POST["NewComment"]),$_POST["NewCommentSubject"],$_SESSION["userID"],$iDocumentID);
$oComment->setThreadID($iThreadID);
@@ -65,6 +75,11 @@ if (checkSession()) {
if($oComment->getID() > 0) {
$oThread = DiscussionThread::get($iThreadID);
$oThread->setLastCommentID($oComment->getID());
+ if ($oThread->getFirstComment == -1){ // if it is a new Thread
+ $oThread->setFirstCommentID($oComment->getID());
+ $oThread->setNumberOfViews();
+ $oThread->setNumberOfReplies();
+ }
$oThread->setNumberOfReplies();
if ($oThread->Update()) {
$oPatternCustom->addHtml(getSubmitSuccessPage($iDocumentID));
@@ -74,21 +89,29 @@ if (checkSession()) {
}else {
$oPatternCustom->addHtml(getViewFailPage("Comment Object failed in creation.") );
}
- }else {
- $oPatternCustom->addHtml(getViewFailPage("The subject line and/or body may be empty.") );
- $main->setFormAction($_SERVER['PHP_SELF'] . "?fAddCommentSubmit=1&iDocumentID=$fDocumentID");
- $oPatternCustom->addHtml(getAddComment($fDocumentID,$_POST["NewCommentSubject"],$_POST["NewComment"]));
- }
- }else{
- $oPatternCustom->addHtml(getViewFailPage("No threadID($iThreadID) exists for this document"));
- }
+ }else{
+ $oPatternCustom->addHtml(getViewFailPage("No threadID($iThreadID) exists for this document" . $astr ));
+ }// End Of if for THREAD ID test
+ }else {
+ $oPatternCustom->addHtml(getViewFailPage("The subject line and/or body may be empty.") );
+ $main->setFormAction($_SERVER['PHP_SELF'] . "?fAddCommentSubmit=1&iDocumentID=$fDocumentID");
+ $oPatternCustom->addHtml(getAddComment($fDocumentID,$_POST["NewCommentSubject"],$_POST["NewComment"]));
+ } // end of IF for Subject and Body test
+
} else if (isset($fReplyComment)){ // if user is replying to existing comment
$main->setFormAction($_SERVER['PHP_SELF'] . "?fAddCommentSubmit=1&iDocumentID=$fDocumentID");
$oPatternCustom->addHtml(getAddComment($fDocumentID,"Re: " . $CommentSubject , "\n\n\n[Start Text Body]\n\n" . $Comment . "\n\n[End Text Body]"));
-
- }else { // If no discussion exists
- $oPatternCustom->setHtml(getViewFailPage("No discussions exist"));
+
+ }else if (isset($fNewThread)){ // Start adding a new Thread
+ $main->setFormAction($_SERVER['PHP_SELF'] . "?fAddCommentSubmit=1&iDocumentID=$fDocumentID&fNewThread=1");
+ $oPatternCustom->addHtml(getAddComment($fDocumentID, $CommentSubject , $Comment ));
+ //$oPatternCustom->addHtml(getAddComment($fDocumentID,$CommentSubject,$Comment));
+
+ }
+
+ else { // If no discussion exists
+ $oPatternCustom->setHtml(getViewFailPage("Comment"));
}
} // end of if checksession
diff --git a/presentation/lookAndFeel/knowledgeTree/discussions/addCommentUI.inc b/presentation/lookAndFeel/knowledgeTree/discussions/addCommentUI.inc
index 9bba5fa..182ac14 100644
--- a/presentation/lookAndFeel/knowledgeTree/discussions/addCommentUI.inc
+++ b/presentation/lookAndFeel/knowledgeTree/discussions/addCommentUI.inc
@@ -61,20 +61,19 @@ function renderDocumentPath($iDocumentID) {
function getAddComment($fDocumentID, $sSubject, $sBody) {
global $default;
- $iThreadID = DiscussionThread::getThreadIDforDoc($fDocumentID);
- $oThread = DiscussionThread::get($iThreadID);
- if($oThread) { // if thread object exists
- $sHeading = "Add a Comment";
-
- $sToRender .= renderHeading($sHeading);
- $sToRender .= renderDocumentPath($oThread->getDocumentID());
- $sToRender .= "
\n";
- $sToRender .= "";
- }
+ //$iThreadID = DiscussionThread::getThreadIDforDoc($fDocumentID);
+
+
+ $sHeading = "Add a Comment";
+ $sToRender .= renderHeading($sHeading);
+ $sToRender .= renderDocumentPath($fDocumentID);
+ $sToRender .= "\n";
+ $sToRender .= "";
+
return $sToRender;
}
diff --git a/presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionBL.php b/presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionBL.php
index 7bcd8f8..afca899 100644
--- a/presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionBL.php
+++ b/presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionBL.php
@@ -3,34 +3,25 @@
* BL information for viewing a Discussion
*
* @author Omar Rahbeeni
-* @date 5 May 2003
+* @date 8 May 2003
* @package presentation.lookAndFeel.knowledgeTree.
*
*/
require_once("../../../../config/dmsDefaults.php");
-if (checkSession()) {
- //require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc");
- require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCreate.inc");
- //require_once("addUnitUI.inc");
- //require_once("../adminUI.inc");
- require_once("viewDiscussionUI.inc"); //###
-
+if (checkSession()) {
+ require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCreate.inc");
+ require_once("viewDiscussionUI.inc");
require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc");
require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc");
require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc");
- require_once("$default->fileSystemRoot/lib/users/User.inc");
- //require_once("../viewDiscussionUI.inc"); //###
- //require_once("$default->fileSystemRoot/lib/unitmanagement/Unit.inc");
- //require_once("$default->fileSystemRoot/lib/unitmanagement/UnitOrganisationLink.inc");
+ require_once("$default->fileSystemRoot/lib/users/User.inc");
require_once("$default->fileSystemRoot/lib/security/permission.inc");
require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");
- require_once("$default->fileSystemRoot/lib/discussions/DiscussionThread.inc"); //###
- require_once("$default->fileSystemRoot/lib/discussions/DiscussionComment.inc"); //###
- //require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc");
- //require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc");
+ require_once("$default->fileSystemRoot/lib/discussions/DiscussionThread.inc");
+ require_once("$default->fileSystemRoot/lib/discussions/DiscussionComment.inc");
require_once("$default->fileSystemRoot/presentation/Html.inc");
$oPatternCustom = & new PatternCustom();
@@ -59,20 +50,25 @@ if(checksession) {
$_SESSION['Discussion'][0]->bViews = true;
}
} else { $oPatternCustom->setHtml(getViewFailPage("")) ;}
- } else { $oPatternCustom->addHtml(getViewFailPage("No threadID for this document.")); }
+ } else { // No current thread, option to create one
+
+ $oPatternCustom->addHtml(getNewThreadOption($fDocumentID));
+
+
+ }
} else { }
} else if (isset($fViewComment)){
if (isset($iCommentID)) {
$oComment = DiscussionComment::get($iCommentID);
- $oUser = User::get($oComment->getUserID());
-
- //$main->setFormAction(generateControllerLink("addComment", "fDocumentID=$iDocumentID&fCommentID=$iCommentID&fReplyComment=1"));
- $main->setFormAction("/presentation/lookAndFeel/knowledgeTree/discussions/addCommentBL.php?fDocumentID=$iDocumentID&fCommentID=$iCommentID&fReplyComment=1");
- //$main->setFormAction($_SERVER['PHP_SELF'] . "?fReplyComment=1");
+ $oUser = User::get($oComment->getUserID());
+
+ $main->setFormAction("/presentation/lookAndFeel/knowledgeTree/discussions/addCommentBL.php?fDocumentID=$iDocumentID&fCommentID=$iCommentID&fReplyComment=1");
$oPatternCustom->setHtml(getCommentBody($oComment,$iDocumentID,$oUser)) ;
}
- } else if (isset($fReplyComment)){
- $oPatternCustom->setHtml("###" . count($_POST) . "###" . $Comment . "###" . $CommentSubject);
+ } else if (isset($fNewThread)){
+
+
+
} else { // If no discussion exists
}
diff --git a/presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionUI.inc b/presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionUI.inc
index 3e15ff4..3484609 100644
--- a/presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionUI.inc
+++ b/presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionUI.inc
@@ -22,6 +22,18 @@ function getViewFailPage($sMessage)
return $sToRender;
}
+function getNewThreadOption($fDocumentID) {
+ global $default;
+
+ $sToRender .= "No discussion thread is currently available.
";
+ $sToRender .= "Would you like to create a new Discussion thread for this document?";
+ $sToRender .= " ";
+ $sToRender .= "
graphicsUrl/widgets/new.gif\" border=\"0\" /> ";
+ $sToRender .= "
graphicsUrl/widgets/cancel.gif\" border=\"0\" />";
+
+ return $sToRender;
+}
+
function renderHeading($sHeading) {
global $default;
@@ -64,12 +76,12 @@ function getViewComment($iNum,$oThread,$oComment,$oUser) {
$sToRender .= renderHeading($sHeading );
$sToRender .= renderDocumentPath($oThread->getDocumentID());
- $sToRender .= "
\n";
$sToRender .= "\n";
$sToRender .= "| Subject | \n";
$sToRender .= "Author | \n";
@@ -97,12 +109,14 @@ function getCommentBody($oComment, $iDocumentID, $oUser) {
$sToRender .= "
";