Commit 6dd3862aa8412bda1f63a15ebfb2d34f55937f9a
1 parent
63fe4978
Double checked error handling and comments
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1790 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
4 changed files
with
136 additions
and
116 deletions
presentation/lookAndFeel/knowledgeTree/discussions/addCommentBL.php
| @@ -10,53 +10,47 @@ | @@ -10,53 +10,47 @@ | ||
| 10 | require_once("../../../../config/dmsDefaults.php"); | 10 | require_once("../../../../config/dmsDefaults.php"); |
| 11 | 11 | ||
| 12 | if (checkSession()) { | 12 | if (checkSession()) { |
| 13 | - //require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc"); | ||
| 14 | - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCreate.inc"); | ||
| 15 | - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternMainPage.inc"); | ||
| 16 | - //require_once("addUnitUI.inc"); | ||
| 17 | - //require_once("../adminUI.inc"); | ||
| 18 | - require_once("addCommentUI.inc"); //### | ||
| 19 | 13 | ||
| 14 | + require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCreate.inc"); | ||
| 15 | + require_once("$default->fileSystemRoot/lib/visualpatterns/PatternMainPage.inc"); | ||
| 16 | + require_once("addCommentUI.inc"); //### | ||
| 20 | require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc"); | 17 | require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc"); |
| 21 | require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); | 18 | require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); |
| 22 | require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); | 19 | 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"); | 20 | + require_once("$default->fileSystemRoot/lib/users/User.inc"); |
| 27 | require_once("$default->fileSystemRoot/lib/security/permission.inc"); | 21 | require_once("$default->fileSystemRoot/lib/security/permission.inc"); |
| 28 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | 22 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); |
| 29 | require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); | 23 | 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"); | 24 | + require_once("$default->fileSystemRoot/lib/discussions/DiscussionThread.inc"); //### |
| 25 | + require_once("$default->fileSystemRoot/lib/discussions/DiscussionComment.inc"); //### | ||
| 34 | require_once("$default->fileSystemRoot/presentation/Html.inc"); | 26 | require_once("$default->fileSystemRoot/presentation/Html.inc"); |
| 35 | 27 | ||
| 36 | $oPatternCustom = & new PatternCustom(); | 28 | $oPatternCustom = & new PatternCustom(); |
| 37 | 29 | ||
| 38 | - if(checksession) { | ||
| 39 | - if (isset($fAddComment)) { | ||
| 40 | - if ($fDocumentID > 0) { | ||
| 41 | - //if (isset($fNewThread)) | ||
| 42 | - | 30 | + if(checkSession()) { |
| 31 | + if (isset($fAddComment)) { // User wishes to add a comment | ||
| 32 | + if ($fDocumentID > 0) { // The document ID is positive | ||
| 43 | $main->setFormAction($_SERVER['PHP_SELF'] . "?fAddCommentSubmit=1&iDocumentID=$fDocumentID"); | 33 | $main->setFormAction($_SERVER['PHP_SELF'] . "?fAddCommentSubmit=1&iDocumentID=$fDocumentID"); |
| 44 | $oPatternCustom->setHtml(getAddComment($fDocumentID,$sSubject,$sBody)); | 34 | $oPatternCustom->setHtml(getAddComment($fDocumentID,$sSubject,$sBody)); |
| 45 | } | 35 | } |
| 46 | - else { | ||
| 47 | - //nothing | ||
| 48 | - } | 36 | + else { // And invalid Document ID was sent |
| 37 | + main->setErrorMessage("The Document id cannot be lss than 0. ID is invalid."); | ||
| 38 | + } | ||
| 49 | 39 | ||
| 50 | - } else if (isset($fViewComment)){ | 40 | + } else if (isset($fViewComment)){ // User wishes to view a comment |
| 41 | + | ||
| 51 | if (isset($iCommentID)) { | 42 | if (isset($iCommentID)) { |
| 52 | $oComment = DiscussionComment::get($iCommentID); | 43 | $oComment = DiscussionComment::get($iCommentID); |
| 53 | $oUser = User::get($oComment->getUserID()); | 44 | $oUser = User::get($oComment->getUserID()); |
| 54 | 45 | ||
| 55 | $oPatternCustom->setHtml(getCommentBody($oComment->getBody(), $oComment->getSubject(),$oComment->getDate(),$iDocumentID,$oUser->getUserName())) ; | 46 | $oPatternCustom->setHtml(getCommentBody($oComment->getBody(), $oComment->getSubject(),$oComment->getDate(),$iDocumentID,$oUser->getUserName())) ; |
| 56 | } | 47 | } |
| 48 | + | ||
| 57 | } else if (isset($fAddCommentSubmit)) { | 49 | } else if (isset($fAddCommentSubmit)) { |
| 58 | if ($_POST["NewComment"] != "" and $_POST["NewCommentSubject"] != "") { | 50 | if ($_POST["NewComment"] != "" and $_POST["NewCommentSubject"] != "") { |
| 59 | - if (isset($fNewThread)){ // Create a New Thread for this document as it doesn't exist | 51 | + |
| 52 | + if (isset($fNewThread)){ // Create a New Thread for this document as it doesn't exist | ||
| 53 | + | ||
| 60 | // Create the thread Object | 54 | // Create the thread Object |
| 61 | $oThread = & new DiscussionThread(-1,$iDocumentID, $_SESSION["userID"]); | 55 | $oThread = & new DiscussionThread(-1,$iDocumentID, $_SESSION["userID"]); |
| 62 | $oThread->create(); | 56 | $oThread->create(); |
| @@ -64,8 +58,8 @@ if (checkSession()) { | @@ -64,8 +58,8 @@ if (checkSession()) { | ||
| 64 | } | 58 | } |
| 65 | else { // Update the existing thread | 59 | else { // Update the existing thread |
| 66 | $iThreadID = DiscussionThread::getThreadIDforDoc($iDocumentID); | 60 | $iThreadID = DiscussionThread::getThreadIDforDoc($iDocumentID); |
| 67 | - } | ||
| 68 | - | 61 | + } |
| 62 | + | ||
| 69 | if ($iThreadID > 0){ | 63 | if ($iThreadID > 0){ |
| 70 | // Create the new comment | 64 | // Create the new comment |
| 71 | $oComment = & new DiscussionComment(urlencode($_POST["NewComment"]),$_POST["NewCommentSubject"],$_SESSION["userID"],$iDocumentID); | 65 | $oComment = & new DiscussionComment(urlencode($_POST["NewComment"]),$_POST["NewCommentSubject"],$_SESSION["userID"],$iDocumentID); |
| @@ -73,49 +67,52 @@ if (checkSession()) { | @@ -73,49 +67,52 @@ if (checkSession()) { | ||
| 73 | $oComment->create(); | 67 | $oComment->create(); |
| 74 | 68 | ||
| 75 | if($oComment->getID() > 0) { | 69 | if($oComment->getID() > 0) { |
| 70 | + | ||
| 76 | $oThread = DiscussionThread::get($iThreadID); | 71 | $oThread = DiscussionThread::get($iThreadID); |
| 77 | $oThread->setLastCommentID($oComment->getID()); | 72 | $oThread->setLastCommentID($oComment->getID()); |
| 78 | if ($oThread->getFirstCommentID() == -1){ // if it is a new Thread | 73 | if ($oThread->getFirstCommentID() == -1){ // if it is a new Thread |
| 74 | + | ||
| 79 | $oThread->setFirstCommentID($oComment->getID()); | 75 | $oThread->setFirstCommentID($oComment->getID()); |
| 80 | } | 76 | } |
| 81 | - if($_SESSION['Discussion' . $iDocumentID][0]->bViews != true ){ | 77 | + if($_SESSION['Discussion' . $iDocumentID][0]->bViews != true ){ // Session variable is set to true if user views the thread |
| 78 | + | ||
| 82 | $oThread->setNumberOfViews(); | 79 | $oThread->setNumberOfViews(); |
| 83 | $_SESSION['Discussion' . $iDocumentID][0]->bViews = true; | 80 | $_SESSION['Discussion' . $iDocumentID][0]->bViews = true; |
| 84 | } | 81 | } |
| 85 | $oThread->setNumberOfReplies(); | 82 | $oThread->setNumberOfReplies(); |
| 86 | - if ($oThread->Update()) { | 83 | + |
| 84 | + if ($oThread->Update()) { // | ||
| 85 | + | ||
| 87 | $oPatternCustom->addHtml(getSubmitSuccessPage($iDocumentID)); | 86 | $oPatternCustom->addHtml(getSubmitSuccessPage($iDocumentID)); |
| 88 | }else { | 87 | }else { |
| 89 | - $oPatternCustom->addHtml(getViewFailPage("Thread Object failed to update.")); | 88 | + $main->setErrorMessage("Thread Object failed to update"); |
| 90 | } | 89 | } |
| 90 | + | ||
| 91 | }else { | 91 | }else { |
| 92 | - $oPatternCustom->addHtml(getViewFailPage("Comment Object failed in creation.") ); | 92 | + $main->setErrorMessage("Comment Object failed in creation"); |
| 93 | } | 93 | } |
| 94 | - | ||
| 95 | - }else{ | ||
| 96 | - $oPatternCustom->addHtml(getViewFailPage("No threadID($iThreadID) exists for this document" . $astr )); | ||
| 97 | - }// End Of if for THREAD ID test | ||
| 98 | - }else { | ||
| 99 | - $oPatternCustom->addHtml(getViewFailPage("The subject line and/or body may be empty.") ); | 94 | + |
| 95 | + }else{ // There is no thread id for this document | ||
| 96 | + $main->setErrorMessage("No threadID($iThreadID) exists for this document"); | ||
| 97 | + }// End Of if for THREAD ID test | ||
| 98 | + | ||
| 99 | + }else { // the user has not entered BOTH a subject and a text body | ||
| 100 | + $main->setErrorMessage("The subject line and/or body may be empty"); | ||
| 100 | $main->setFormAction($_SERVER['PHP_SELF'] . "?fAddCommentSubmit=1&iDocumentID=$fDocumentID"); | 101 | $main->setFormAction($_SERVER['PHP_SELF'] . "?fAddCommentSubmit=1&iDocumentID=$fDocumentID"); |
| 101 | $oPatternCustom->addHtml(getAddComment($fDocumentID,$_POST["NewCommentSubject"],$_POST["NewComment"])); | 102 | $oPatternCustom->addHtml(getAddComment($fDocumentID,$_POST["NewCommentSubject"],$_POST["NewComment"])); |
| 102 | - } // end of IF for Subject and Body test | ||
| 103 | - | ||
| 104 | - } else if (isset($fReplyComment)){ // if user is replying to existing comment | 103 | + } // end of IF for Subject and Body test |
| 104 | + | ||
| 105 | + } else if (isset($fReplyComment)){ // if user is replying to existing comment | ||
| 105 | $main->setFormAction($_SERVER['PHP_SELF'] . "?fAddCommentSubmit=1&iDocumentID=$fDocumentID"); | 106 | $main->setFormAction($_SERVER['PHP_SELF'] . "?fAddCommentSubmit=1&iDocumentID=$fDocumentID"); |
| 106 | - $oPatternCustom->addHtml(getAddComment($fDocumentID,"Re: " . $CommentSubject , "\n\n\n[Start Text Body]\n\n" . $Comment . "\n\n[End Text Body]")); | ||
| 107 | - | ||
| 108 | - }else if (isset($fNewThread)){ // Start adding a new Thread | 107 | + $oPatternCustom->addHtml(getAddComment($fDocumentID,"Re: " . $CommentSubject , "\n\n\n[Start Text Body]\n\n" . $Comment . "\n\n[End Text Body]")); |
| 108 | + | ||
| 109 | + } else if (isset($fNewThread)){ // Start adding a new Thread | ||
| 109 | $main->setFormAction($_SERVER['PHP_SELF'] . "?fAddCommentSubmit=1&iDocumentID=$fDocumentID&fNewThread=1"); | 110 | $main->setFormAction($_SERVER['PHP_SELF'] . "?fAddCommentSubmit=1&iDocumentID=$fDocumentID&fNewThread=1"); |
| 110 | - $oPatternCustom->addHtml(getAddComment($fDocumentID, $CommentSubject , $Comment )); | ||
| 111 | - //$oPatternCustom->addHtml(getAddComment($fDocumentID,$CommentSubject,$Comment)); | ||
| 112 | - | 111 | + $oPatternCustom->addHtml(getAddComment($fDocumentID, $CommentSubject , $Comment )); |
| 112 | + | ||
| 113 | + } else { // If no discussion exists | ||
| 114 | + $main->setErrorMessage("Error: No discussion thread available"); | ||
| 113 | } | 115 | } |
| 114 | - | ||
| 115 | - else { // If no discussion exists | ||
| 116 | - $oPatternCustom->setHtml(getViewFailPage("Comment")); | ||
| 117 | - } | ||
| 118 | - | ||
| 119 | } // end of if checksession | 116 | } // end of if checksession |
| 120 | 117 | ||
| 121 | $main->setCentralPayload($oPatternCustom); | 118 | $main->setCentralPayload($oPatternCustom); |
presentation/lookAndFeel/knowledgeTree/discussions/addCommentUI.inc
| @@ -8,31 +8,24 @@ | @@ -8,31 +8,24 @@ | ||
| 8 | * | 8 | * |
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | -// On a successful save | 11 | +/** |
| 12 | + * Submission of comment SUCCESS page | ||
| 13 | + * | ||
| 14 | + * @param $iDocumentID -> a valid Document ID | ||
| 15 | + */ | ||
| 12 | function getSubmitSuccessPage($iDocumentID){ | 16 | function getSubmitSuccessPage($iDocumentID){ |
| 13 | global $default; | 17 | global $default; |
| 14 | - $sMessage = "Your submission has been successful."; | ||
| 15 | - | 18 | + $sMessage = "Your submission has been successful."; |
| 16 | $sToRender .= "$sMessage<br><br><a href=\"" . generateControllerLink("viewDiscussion", "fDocumentID=" . $iDocumentID . "&fForDiscussion=1") . "\"><img src=\"$default->graphicsUrl/widgets/back.gif\" border=\"0\" /></a>"; | 19 | $sToRender .= "$sMessage<br><br><a href=\"" . generateControllerLink("viewDiscussion", "fDocumentID=" . $iDocumentID . "&fForDiscussion=1") . "\"><img src=\"$default->graphicsUrl/widgets/back.gif\" border=\"0\" /></a>"; |
| 17 | -// $sToRender .= ""; | ||
| 18 | -// $sToRender .= ""; | ||
| 19 | 20 | ||
| 20 | return $sToRender; | 21 | return $sToRender; |
| 21 | } | 22 | } |
| 22 | 23 | ||
| 23 | -// If there are no threads to view for a document | ||
| 24 | -function getViewFailPage($sMessage) | ||
| 25 | -{ | ||
| 26 | - global $default; | ||
| 27 | - | ||
| 28 | - if (strlen($sMessage)>0){ | ||
| 29 | - $sToRender = $sMessage; | ||
| 30 | - } | ||
| 31 | - else $sToRender = "Current document has no discussion. Press the ADD button to start a discussion."; | ||
| 32 | - | ||
| 33 | - return $sToRender; | ||
| 34 | -} | ||
| 35 | - | 24 | +/** |
| 25 | + * Renders the heading for the page | ||
| 26 | + * | ||
| 27 | + * @param $sHeading -> text heading for the page | ||
| 28 | + */ | ||
| 36 | function renderHeading($sHeading) { | 29 | function renderHeading($sHeading) { |
| 37 | global $default; | 30 | global $default; |
| 38 | 31 | ||
| @@ -46,6 +39,11 @@ function renderHeading($sHeading) { | @@ -46,6 +39,11 @@ function renderHeading($sHeading) { | ||
| 46 | return $sToRender; | 39 | return $sToRender; |
| 47 | } | 40 | } |
| 48 | 41 | ||
| 42 | +/** | ||
| 43 | + * Renders the path for the document | ||
| 44 | + * | ||
| 45 | + * @param $fDocumentID -> a valid document ID | ||
| 46 | + */ | ||
| 49 | function renderDocumentPath($iDocumentID) { | 47 | function renderDocumentPath($iDocumentID) { |
| 50 | global $default; | 48 | global $default; |
| 51 | 49 | ||
| @@ -57,13 +55,16 @@ function renderDocumentPath($iDocumentID) { | @@ -57,13 +55,16 @@ function renderDocumentPath($iDocumentID) { | ||
| 57 | return "<table border=0 cellpadding=\"5\" width = 100%><tr><td bgcolor=\"$sTDBGColour\">$sDocumentPath</td></tr></table>\n"; | 55 | return "<table border=0 cellpadding=\"5\" width = 100%><tr><td bgcolor=\"$sTDBGColour\">$sDocumentPath</td></tr></table>\n"; |
| 58 | } | 56 | } |
| 59 | 57 | ||
| 60 | - | 58 | +/** |
| 59 | + * Display the ADD COMMENT page | ||
| 60 | + * | ||
| 61 | + * @param $fDocumentID -> a valid Document ID | ||
| 62 | + * @param $sSubject -> a Subject text | ||
| 63 | + * @param $sBody -> a Body text | ||
| 64 | + */ | ||
| 61 | function getAddComment($fDocumentID, $sSubject, $sBody) { | 65 | function getAddComment($fDocumentID, $sSubject, $sBody) { |
| 62 | global $default; | 66 | global $default; |
| 63 | - | ||
| 64 | - //$iThreadID = DiscussionThread::getThreadIDforDoc($fDocumentID); | ||
| 65 | - | ||
| 66 | - | 67 | + |
| 67 | $sHeading = "Add a Comment"; | 68 | $sHeading = "Add a Comment"; |
| 68 | $sToRender .= renderHeading($sHeading); | 69 | $sToRender .= renderHeading($sHeading); |
| 69 | $sToRender .= renderDocumentPath($fDocumentID); | 70 | $sToRender .= renderDocumentPath($fDocumentID); |
| @@ -71,13 +72,22 @@ function getAddComment($fDocumentID, $sSubject, $sBody) { | @@ -71,13 +72,22 @@ function getAddComment($fDocumentID, $sSubject, $sBody) { | ||
| 71 | $sToRender .= "<td align=right><input onmouseover=\"this.style.cursor='hand'\" 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 .= "<td align=right><input onmouseover=\"this.style.cursor='hand'\" 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 .= "<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 .= "<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 | - | 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 | 76 | ||
| 77 | - return $sToRender; | ||
| 78 | - | 77 | + return $sToRender; |
| 79 | } | 78 | } |
| 80 | 79 | ||
| 80 | +/** | ||
| 81 | + * Display the comment: Body text included | ||
| 82 | + * Prints out 1 comment | ||
| 83 | + * User needs to call this function many times to list all comments | ||
| 84 | + * | ||
| 85 | + * @param $sCommentBody -> Some body text | ||
| 86 | + * @param $iComment Subject -> Some subject text | ||
| 87 | + * @param $dDate -> Date comment was created | ||
| 88 | + * @param $iDocumentID -> a valid document ID | ||
| 89 | + * @param $sUserName -> Name of creator of comment | ||
| 90 | + */ | ||
| 81 | function getCommentBody($sCommentBody, $sCommentSubject,$dDate,$iDocumentID, $sUserName) { | 91 | function getCommentBody($sCommentBody, $sCommentSubject,$dDate,$iDocumentID, $sUserName) { |
| 82 | global $default; | 92 | global $default; |
| 83 | 93 | ||
| @@ -93,10 +103,4 @@ function getCommentBody($sCommentBody, $sCommentSubject,$dDate,$iDocumentID, $sU | @@ -93,10 +103,4 @@ function getCommentBody($sCommentBody, $sCommentSubject,$dDate,$iDocumentID, $sU | ||
| 93 | return $sToRender; | 103 | return $sToRender; |
| 94 | } | 104 | } |
| 95 | 105 | ||
| 96 | -function viewDiscussionPage() { | ||
| 97 | - global $default; | ||
| 98 | - | ||
| 99 | - $sToRender = ""; | ||
| 100 | - return $sToRender; | ||
| 101 | -} | ||
| 102 | ?> | 106 | ?> |
| 103 | \ No newline at end of file | 107 | \ No newline at end of file |
presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionBL.php
| @@ -26,7 +26,7 @@ if (checkSession()) { | @@ -26,7 +26,7 @@ if (checkSession()) { | ||
| 26 | 26 | ||
| 27 | $oPatternCustom = & new PatternCustom(); | 27 | $oPatternCustom = & new PatternCustom(); |
| 28 | 28 | ||
| 29 | -if(checksession) { | 29 | +if(checkSession()) { |
| 30 | if (isset($fForDiscussion)) { | 30 | if (isset($fForDiscussion)) { |
| 31 | if ($fDocumentID > 0) { | 31 | if ($fDocumentID > 0) { |
| 32 | $iThreadID = DiscussionThread::getThreadIDforDoc($fDocumentID); | 32 | $iThreadID = DiscussionThread::getThreadIDforDoc($fDocumentID); |
| @@ -49,33 +49,29 @@ if(checksession) { | @@ -49,33 +49,29 @@ if(checksession) { | ||
| 49 | if($oThread->Update() == false) $oPatternCustom->addHtml("Failed to update. Please Contact Database Administrator in this regard") ; | 49 | if($oThread->Update() == false) $oPatternCustom->addHtml("Failed to update. Please Contact Database Administrator in this regard") ; |
| 50 | $_SESSION['Discussion' . $fDocumentID][0]->bViews = true; | 50 | $_SESSION['Discussion' . $fDocumentID][0]->bViews = true; |
| 51 | } | 51 | } |
| 52 | - } else { $oPatternCustom->setHtml(getViewFailPage("")) ;} | ||
| 53 | - } else { // No current thread, option to create one | ||
| 54 | - | ||
| 55 | - $oPatternCustom->addHtml(getNewThreadOption($fDocumentID)); | ||
| 56 | - | ||
| 57 | - | ||
| 58 | - } | ||
| 59 | - } else { } | ||
| 60 | - } else if (isset($fViewComment)){ | ||
| 61 | - if (isset($iCommentID)) { | 52 | + } else { |
| 53 | + $main->setErrorMessage("Error creating discussion thread object"); | ||
| 54 | + } | ||
| 55 | + } else { // No current thread, option to create one | ||
| 56 | + $main->setErrorMessage("No discussion thread is currently available"); | ||
| 57 | + $oPatternCustom->addHtml(getNewThreadOption($fDocumentID)); | ||
| 58 | + } | ||
| 59 | + } else { // Doument id is negative | ||
| 60 | + $main->setErrorMessage("Invalid Document ID. ID may not be negative."); | ||
| 61 | + } | ||
| 62 | + } else if (isset($fViewComment)){ // User wants to view a comment | ||
| 63 | + if (isset($iCommentID)) { // Check if a comment ID exists | ||
| 62 | $oComment = DiscussionComment::get($iCommentID); | 64 | $oComment = DiscussionComment::get($iCommentID); |
| 63 | - $oUser = User::get($oComment->getUserID()); | ||
| 64 | - | 65 | + $oUser = User::get($oComment->getUserID()); |
| 65 | $main->setFormAction("/presentation/lookAndFeel/knowledgeTree/discussions/addCommentBL.php?fDocumentID=$iDocumentID&fCommentID=$iCommentID&fReplyComment=1"); | 66 | $main->setFormAction("/presentation/lookAndFeel/knowledgeTree/discussions/addCommentBL.php?fDocumentID=$iDocumentID&fCommentID=$iCommentID&fReplyComment=1"); |
| 66 | $oPatternCustom->setHtml(getCommentBody($oComment,$iDocumentID,$oUser)) ; | 67 | $oPatternCustom->setHtml(getCommentBody($oComment,$iDocumentID,$oUser)) ; |
| 67 | } | 68 | } |
| 68 | - } else if (isset($fNewThread)){ | ||
| 69 | - | ||
| 70 | - | ||
| 71 | - | ||
| 72 | - } else { // If no discussion exists | 69 | + }else { // If no discussion exists |
| 70 | + $main->setErrorMessage("Invalid function. No such functionality exists for this page."); | ||
| 73 | } | 71 | } |
| 74 | - | ||
| 75 | } // end of if checksession | 72 | } // end of if checksession |
| 76 | 73 | ||
| 77 | $main->setCentralPayload($oPatternCustom); | 74 | $main->setCentralPayload($oPatternCustom); |
| 78 | - $main->render(); | ||
| 79 | - | 75 | + $main->render(); |
| 80 | } | 76 | } |
| 81 | ?> | 77 | ?> |
presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionUI.inc
| @@ -22,10 +22,14 @@ function getViewFailPage($sMessage) | @@ -22,10 +22,14 @@ function getViewFailPage($sMessage) | ||
| 22 | return $sToRender; | 22 | return $sToRender; |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | +/** | ||
| 26 | + * Page to create a new thread | ||
| 27 | + * | ||
| 28 | + * @param $fDocumentID -> a valid document ID | ||
| 29 | + */ | ||
| 25 | function getNewThreadOption($fDocumentID) { | 30 | function getNewThreadOption($fDocumentID) { |
| 26 | - global $default; | 31 | + global $default; |
| 27 | 32 | ||
| 28 | - $sToRender .= "No discussion thread is currently available.<br><br>"; | ||
| 29 | $sToRender .= "Would you like to create a new Discussion thread for this document?"; | 33 | $sToRender .= "Would you like to create a new Discussion thread for this document?"; |
| 30 | $sToRender .= " "; | 34 | $sToRender .= " "; |
| 31 | $sToRender .= "<a href=\"" . generateControllerLink("addComment", "fDocumentID=" . $fDocumentID . "&fNewThread=1") . "\"><img src=\"$default->graphicsUrl/widgets/new.gif\" border=\"0\"></a>"; | 35 | $sToRender .= "<a href=\"" . generateControllerLink("addComment", "fDocumentID=" . $fDocumentID . "&fNewThread=1") . "\"><img src=\"$default->graphicsUrl/widgets/new.gif\" border=\"0\"></a>"; |
| @@ -34,6 +38,11 @@ function getNewThreadOption($fDocumentID) { | @@ -34,6 +38,11 @@ function getNewThreadOption($fDocumentID) { | ||
| 34 | return $sToRender; | 38 | return $sToRender; |
| 35 | } | 39 | } |
| 36 | 40 | ||
| 41 | +/** | ||
| 42 | + * Renders the heading for the page | ||
| 43 | + * | ||
| 44 | + * @param $sHeading -> text heading for the page | ||
| 45 | + */ | ||
| 37 | function renderHeading($sHeading) { | 46 | function renderHeading($sHeading) { |
| 38 | global $default; | 47 | global $default; |
| 39 | 48 | ||
| @@ -47,6 +56,11 @@ function renderHeading($sHeading) { | @@ -47,6 +56,11 @@ function renderHeading($sHeading) { | ||
| 47 | return $sToRender; | 56 | return $sToRender; |
| 48 | } | 57 | } |
| 49 | 58 | ||
| 59 | +/** | ||
| 60 | + * Renders the path for the document | ||
| 61 | + * | ||
| 62 | + * @param $fDocumentID -> a valid document ID | ||
| 63 | + */ | ||
| 50 | function renderDocumentPath($iDocumentID) { | 64 | function renderDocumentPath($iDocumentID) { |
| 51 | global $default; | 65 | global $default; |
| 52 | 66 | ||
| @@ -58,6 +72,16 @@ function renderDocumentPath($iDocumentID) { | @@ -58,6 +72,16 @@ function renderDocumentPath($iDocumentID) { | ||
| 58 | return "<table border=0 cellpadding=\"5\" width = 100%><tr><td bgcolor=\"$sTDBGColour\">$sDocumentPath</td></tr></table>\n"; | 72 | return "<table border=0 cellpadding=\"5\" width = 100%><tr><td bgcolor=\"$sTDBGColour\">$sDocumentPath</td></tr></table>\n"; |
| 59 | } | 73 | } |
| 60 | 74 | ||
| 75 | +/** | ||
| 76 | + * Views the list of comments for a document | ||
| 77 | + * Prints out 1 comment | ||
| 78 | + * User needs to call this function many times to list all comments | ||
| 79 | + * | ||
| 80 | + * @param $iNum -> its the iterative index of the current comment | ||
| 81 | + * @param $iThread -> a valid Thread Object | ||
| 82 | + * @param $oComment -> a valid Comment Object | ||
| 83 | + * @param $oUser -> a valid User Object (Logged in user) | ||
| 84 | + */ | ||
| 61 | function getViewComment($iNum,$oThread,$oComment,$oUser) { | 85 | function getViewComment($iNum,$oThread,$oComment,$oUser) { |
| 62 | global $default; | 86 | global $default; |
| 63 | 87 | ||
| @@ -98,7 +122,13 @@ function getViewComment($iNum,$oThread,$oComment,$oUser) { | @@ -98,7 +122,13 @@ function getViewComment($iNum,$oThread,$oComment,$oUser) { | ||
| 98 | return $sToRender; | 122 | return $sToRender; |
| 99 | } | 123 | } |
| 100 | 124 | ||
| 101 | -//function getCommentBody($sCommentBody, $sCommentSubject,$dDate,$iDocumentID, $sUserName) { | 125 | +/** |
| 126 | + * Views a single thread comment with its text body | ||
| 127 | + * | ||
| 128 | + * @param $iDocumentID -> a valid Document ID | ||
| 129 | + * @param $oComment -> a valid Comment Object | ||
| 130 | + * @param $oUser -> a valid User Object (Logged in user) | ||
| 131 | + */ | ||
| 102 | function getCommentBody($oComment, $iDocumentID, $oUser) { | 132 | function getCommentBody($oComment, $iDocumentID, $oUser) { |
| 103 | global $default; | 133 | global $default; |
| 104 | 134 | ||
| @@ -112,21 +142,14 @@ function getCommentBody($oComment, $iDocumentID, $oUser) { | @@ -112,21 +142,14 @@ function getCommentBody($oComment, $iDocumentID, $oUser) { | ||
| 112 | $sToRender .= "<input onmouseover=\"this.style.cursor='hand'\" 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\"> "; | 142 | $sToRender .= "<input onmouseover=\"this.style.cursor='hand'\" 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\"> "; |
| 113 | $sToRender .= "</td></tr>\n"; | 143 | $sToRender .= "</td></tr>\n"; |
| 114 | $sToRender .= "<tr><td width=\"1\" style=\"background-color:#F5F6EE;\" valign=\"top\"><b>Subject: </b></td><td width=405 style=\"background-color:#F5F6EE;\">"; | 144 | $sToRender .= "<tr><td width=\"1\" style=\"background-color:#F5F6EE;\" valign=\"top\"><b>Subject: </b></td><td width=405 style=\"background-color:#F5F6EE;\">"; |
| 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() . "\">"; | 145 | + $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;width=80%\" readOnly value=\"" . $oComment->getSubject() . "\">"; |
| 116 | $sToRender .= "</td><td><b>Date: </b><font color=\"#056DCE\">" . $oComment->getDate() . "</font> </td></tr><tr><td colspan=3 valign=top>"; | 146 | $sToRender .= "</td><td><b>Date: </b><font color=\"#056DCE\">" . $oComment->getDate() . "</font> </td></tr><tr><td colspan=3 valign=top>"; |
| 117 | $sToRender .= "<TEXTAREA readOnly name=\"Comment\" id=\"Comment\" rows=40 cols=100 style=\"BORDER-WIDTH: 0px;FONT-FAMILY: sans-serif;\"> "; | 147 | $sToRender .= "<TEXTAREA readOnly name=\"Comment\" id=\"Comment\" rows=40 cols=100 style=\"BORDER-WIDTH: 0px;FONT-FAMILY: sans-serif;\"> "; |
| 118 | $sToRender .= urldecode($oComment->getBody()); | 148 | $sToRender .= urldecode($oComment->getBody()); |
| 119 | $sToRender .= "</textarea></td>"; | 149 | $sToRender .= "</textarea></td>"; |
| 120 | - $sToRender .= "</tr></table> "; | ||
| 121 | - | 150 | + $sToRender .= "</tr></table> "; |
| 122 | 151 | ||
| 123 | return $sToRender; | 152 | return $sToRender; |
| 124 | } | 153 | } |
| 125 | 154 | ||
| 126 | -function viewDiscussionPage() { | ||
| 127 | - global $default; | ||
| 128 | - | ||
| 129 | - $sToRender = ""; | ||
| 130 | - return $sToRender; | ||
| 131 | -} | ||
| 132 | ?> | 155 | ?> |
| 133 | \ No newline at end of file | 156 | \ No newline at end of file |