diff --git a/presentation/lookAndFeel/knowledgeTree/discussions/addCommentBL.php b/presentation/lookAndFeel/knowledgeTree/discussions/addCommentBL.php
index 9bbeddf..cc412ed 100644
--- a/presentation/lookAndFeel/knowledgeTree/discussions/addCommentBL.php
+++ b/presentation/lookAndFeel/knowledgeTree/discussions/addCommentBL.php
@@ -10,53 +10,47 @@
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("$default->fileSystemRoot/lib/visualpatterns/PatternMainPage.inc");
- //require_once("addUnitUI.inc");
- //require_once("../adminUI.inc");
- require_once("addCommentUI.inc"); //###
+ require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCreate.inc");
+ require_once("$default->fileSystemRoot/lib/visualpatterns/PatternMainPage.inc");
+ require_once("addCommentUI.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();
- if(checksession) {
- if (isset($fAddComment)) {
- if ($fDocumentID > 0) {
- //if (isset($fNewThread))
-
+ if(checkSession()) {
+ if (isset($fAddComment)) { // User wishes to add a comment
+ if ($fDocumentID > 0) { // The document ID is positive
$main->setFormAction($_SERVER['PHP_SELF'] . "?fAddCommentSubmit=1&iDocumentID=$fDocumentID");
$oPatternCustom->setHtml(getAddComment($fDocumentID,$sSubject,$sBody));
}
- else {
- //nothing
- }
+ else { // And invalid Document ID was sent
+ main->setErrorMessage("The Document id cannot be lss than 0. ID is invalid.");
+ }
- } else if (isset($fViewComment)){
+ } else if (isset($fViewComment)){ // User wishes to view a comment
+
if (isset($iCommentID)) {
$oComment = DiscussionComment::get($iCommentID);
$oUser = User::get($oComment->getUserID());
$oPatternCustom->setHtml(getCommentBody($oComment->getBody(), $oComment->getSubject(),$oComment->getDate(),$iDocumentID,$oUser->getUserName())) ;
}
+
} 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
+
+ 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();
@@ -64,8 +58,8 @@ if (checkSession()) {
}
else { // Update the existing thread
$iThreadID = DiscussionThread::getThreadIDforDoc($iDocumentID);
- }
-
+ }
+
if ($iThreadID > 0){
// Create the new comment
$oComment = & new DiscussionComment(urlencode($_POST["NewComment"]),$_POST["NewCommentSubject"],$_SESSION["userID"],$iDocumentID);
@@ -73,49 +67,52 @@ if (checkSession()) {
$oComment->create();
if($oComment->getID() > 0) {
+
$oThread = DiscussionThread::get($iThreadID);
$oThread->setLastCommentID($oComment->getID());
if ($oThread->getFirstCommentID() == -1){ // if it is a new Thread
+
$oThread->setFirstCommentID($oComment->getID());
}
- if($_SESSION['Discussion' . $iDocumentID][0]->bViews != true ){
+ if($_SESSION['Discussion' . $iDocumentID][0]->bViews != true ){ // Session variable is set to true if user views the thread
+
$oThread->setNumberOfViews();
$_SESSION['Discussion' . $iDocumentID][0]->bViews = true;
}
$oThread->setNumberOfReplies();
- if ($oThread->Update()) {
+
+ if ($oThread->Update()) { //
+
$oPatternCustom->addHtml(getSubmitSuccessPage($iDocumentID));
}else {
- $oPatternCustom->addHtml(getViewFailPage("Thread Object failed to update."));
+ $main->setErrorMessage("Thread Object failed to update");
}
+
}else {
- $oPatternCustom->addHtml(getViewFailPage("Comment Object failed in creation.") );
+ $main->setErrorMessage("Comment Object failed in creation");
}
-
- }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.") );
+
+ }else{ // There is no thread id for this document
+ $main->setErrorMessage("No threadID($iThreadID) exists for this document");
+ }// End Of if for THREAD ID test
+
+ }else { // the user has not entered BOTH a subject and a text body
+ $main->setErrorMessage("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
+ } // 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 (isset($fNewThread)){ // Start adding a new Thread
+ $oPatternCustom->addHtml(getAddComment($fDocumentID,"Re: " . $CommentSubject , "\n\n\n[Start Text Body]\n\n" . $Comment . "\n\n[End Text Body]"));
+
+ } 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));
-
+ $oPatternCustom->addHtml(getAddComment($fDocumentID, $CommentSubject , $Comment ));
+
+ } else { // If no discussion exists
+ $main->setErrorMessage("Error: No discussion thread available");
}
-
- else { // If no discussion exists
- $oPatternCustom->setHtml(getViewFailPage("Comment"));
- }
-
} // end of if checksession
$main->setCentralPayload($oPatternCustom);
diff --git a/presentation/lookAndFeel/knowledgeTree/discussions/addCommentUI.inc b/presentation/lookAndFeel/knowledgeTree/discussions/addCommentUI.inc
index bbb845a..24dad54 100644
--- a/presentation/lookAndFeel/knowledgeTree/discussions/addCommentUI.inc
+++ b/presentation/lookAndFeel/knowledgeTree/discussions/addCommentUI.inc
@@ -8,31 +8,24 @@
*
*/
-// On a successful save
+/**
+ * Submission of comment SUCCESS page
+ *
+ * @param $iDocumentID -> a valid Document ID
+ */
function getSubmitSuccessPage($iDocumentID){
global $default;
- $sMessage = "Your submission has been successful.";
-
+ $sMessage = "Your submission has been successful.";
$sToRender .= "$sMessage
graphicsUrl/widgets/back.gif\" border=\"0\" />";
-// $sToRender .= "";
-// $sToRender .= "";
return $sToRender;
}
-// If there are no threads to view for a document
-function getViewFailPage($sMessage)
-{
- global $default;
-
- if (strlen($sMessage)>0){
- $sToRender = $sMessage;
- }
- else $sToRender = "Current document has no discussion. Press the ADD button to start a discussion.";
-
- return $sToRender;
-}
-
+/**
+ * Renders the heading for the page
+ *
+ * @param $sHeading -> text heading for the page
+ */
function renderHeading($sHeading) {
global $default;
@@ -46,6 +39,11 @@ function renderHeading($sHeading) {
return $sToRender;
}
+/**
+ * Renders the path for the document
+ *
+ * @param $fDocumentID -> a valid document ID
+ */
function renderDocumentPath($iDocumentID) {
global $default;
@@ -57,13 +55,16 @@ function renderDocumentPath($iDocumentID) {
return "
$sDocumentPath
\n";
}
-
+/**
+ * Display the ADD COMMENT page
+ *
+ * @param $fDocumentID -> a valid Document ID
+ * @param $sSubject -> a Subject text
+ * @param $sBody -> a Body text
+ */
function getAddComment($fDocumentID, $sSubject, $sBody) {
global $default;
-
- //$iThreadID = DiscussionThread::getThreadIDforDoc($fDocumentID);
-
-
+
$sHeading = "Add a Comment";
$sToRender .= renderHeading($sHeading);
$sToRender .= renderDocumentPath($fDocumentID);
@@ -71,13 +72,22 @@ function getAddComment($fDocumentID, $sSubject, $sBody) {
$sToRender .= "
\n";
- return $sToRender;
-
+ return $sToRender;
}
+/**
+ * Display the comment: Body text included
+ * Prints out 1 comment
+ * User needs to call this function many times to list all comments
+ *
+ * @param $sCommentBody -> Some body text
+ * @param $iComment Subject -> Some subject text
+ * @param $dDate -> Date comment was created
+ * @param $iDocumentID -> a valid document ID
+ * @param $sUserName -> Name of creator of comment
+ */
function getCommentBody($sCommentBody, $sCommentSubject,$dDate,$iDocumentID, $sUserName) {
global $default;
@@ -93,10 +103,4 @@ function getCommentBody($sCommentBody, $sCommentSubject,$dDate,$iDocumentID, $sU
return $sToRender;
}
-function viewDiscussionPage() {
- global $default;
-
- $sToRender = "";
- return $sToRender;
-}
?>
\ No newline at end of file
diff --git a/presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionBL.php b/presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionBL.php
index 3c81423..c6d3296 100644
--- a/presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionBL.php
+++ b/presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionBL.php
@@ -26,7 +26,7 @@ if (checkSession()) {
$oPatternCustom = & new PatternCustom();
-if(checksession) {
+if(checkSession()) {
if (isset($fForDiscussion)) {
if ($fDocumentID > 0) {
$iThreadID = DiscussionThread::getThreadIDforDoc($fDocumentID);
@@ -49,33 +49,29 @@ if(checksession) {
if($oThread->Update() == false) $oPatternCustom->addHtml("Failed to update. Please Contact Database Administrator in this regard") ;
$_SESSION['Discussion' . $fDocumentID][0]->bViews = true;
}
- } else { $oPatternCustom->setHtml(getViewFailPage("")) ;}
- } else { // No current thread, option to create one
-
- $oPatternCustom->addHtml(getNewThreadOption($fDocumentID));
-
-
- }
- } else { }
- } else if (isset($fViewComment)){
- if (isset($iCommentID)) {
+ } else {
+ $main->setErrorMessage("Error creating discussion thread object");
+ }
+ } else { // No current thread, option to create one
+ $main->setErrorMessage("No discussion thread is currently available");
+ $oPatternCustom->addHtml(getNewThreadOption($fDocumentID));
+ }
+ } else { // Doument id is negative
+ $main->setErrorMessage("Invalid Document ID. ID may not be negative.");
+ }
+ } else if (isset($fViewComment)){ // User wants to view a comment
+ if (isset($iCommentID)) { // Check if a comment ID exists
$oComment = DiscussionComment::get($iCommentID);
- $oUser = User::get($oComment->getUserID());
-
+ $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($fNewThread)){
-
-
-
- } else { // If no discussion exists
+ }else { // If no discussion exists
+ $main->setErrorMessage("Invalid function. No such functionality exists for this page.");
}
-
} // end of if checksession
$main->setCentralPayload($oPatternCustom);
- $main->render();
-
+ $main->render();
}
?>
diff --git a/presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionUI.inc b/presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionUI.inc
index 334653f..77a2b87 100644
--- a/presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionUI.inc
+++ b/presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionUI.inc
@@ -22,10 +22,14 @@ function getViewFailPage($sMessage)
return $sToRender;
}
+/**
+ * Page to create a new thread
+ *
+ * @param $fDocumentID -> a valid document ID
+ */
function getNewThreadOption($fDocumentID) {
- global $default;
+ 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\">";
@@ -34,6 +38,11 @@ function getNewThreadOption($fDocumentID) {
return $sToRender;
}
+/**
+ * Renders the heading for the page
+ *
+ * @param $sHeading -> text heading for the page
+ */
function renderHeading($sHeading) {
global $default;
@@ -47,6 +56,11 @@ function renderHeading($sHeading) {
return $sToRender;
}
+/**
+ * Renders the path for the document
+ *
+ * @param $fDocumentID -> a valid document ID
+ */
function renderDocumentPath($iDocumentID) {
global $default;
@@ -58,6 +72,16 @@ function renderDocumentPath($iDocumentID) {
return "
$sDocumentPath
\n";
}
+/**
+ * Views the list of comments for a document
+ * Prints out 1 comment
+ * User needs to call this function many times to list all comments
+ *
+ * @param $iNum -> its the iterative index of the current comment
+ * @param $iThread -> a valid Thread Object
+ * @param $oComment -> a valid Comment Object
+ * @param $oUser -> a valid User Object (Logged in user)
+ */
function getViewComment($iNum,$oThread,$oComment,$oUser) {
global $default;
@@ -98,7 +122,13 @@ function getViewComment($iNum,$oThread,$oComment,$oUser) {
return $sToRender;
}
-//function getCommentBody($sCommentBody, $sCommentSubject,$dDate,$iDocumentID, $sUserName) {
+/**
+ * Views a single thread comment with its text body
+ *
+ * @param $iDocumentID -> a valid Document ID
+ * @param $oComment -> a valid Comment Object
+ * @param $oUser -> a valid User Object (Logged in user)
+ */
function getCommentBody($oComment, $iDocumentID, $oUser) {
global $default;
@@ -112,21 +142,14 @@ function getCommentBody($oComment, $iDocumentID, $oUser) {
$sToRender .= "graphicsUrl/widgets/reply.gif); BORDER-LEFT: 0px groove; WIDTH: 40px; BORDER-BOTTOM: 0px groove; HEIGHT: 18; BACKGROUND-COLOR: white\" height=\"20\" value=\" \" width=\"200\"> ";
$sToRender .= "\n";
$sToRender .= "