From c11d6be2e0ce86211eaa22c5cffe8cb497f71ac4 Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 8 May 2003 11:48:21 +0000 Subject: [PATCH] *** empty log message *** --- presentation/lookAndFeel/knowledgeTree/discussions/addCommentBL.php | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ presentation/lookAndFeel/knowledgeTree/discussions/addCommentUI.inc | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionBL.php | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionUI.inc | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 407 insertions(+), 0 deletions(-) create mode 100644 presentation/lookAndFeel/knowledgeTree/discussions/addCommentBL.php create mode 100644 presentation/lookAndFeel/knowledgeTree/discussions/addCommentUI.inc create mode 100644 presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionBL.php create mode 100644 presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionUI.inc diff --git a/presentation/lookAndFeel/knowledgeTree/discussions/addCommentBL.php b/presentation/lookAndFeel/knowledgeTree/discussions/addCommentBL.php new file mode 100644 index 0000000..581b848 --- /dev/null +++ b/presentation/lookAndFeel/knowledgeTree/discussions/addCommentBL.php @@ -0,0 +1,99 @@ +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/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/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/presentation/Html.inc"); + + $oPatternCustom = & new PatternCustom(); + + if(checksession) { + if (isset($fAddComment)) { + if ($fDocumentID > 0) { + $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); + $oUser = User::get($oComment->getUserID()); + + $oPatternCustom->setHtml(getCommentBody($oComment->getBody(), $oComment->getSubject(),$oComment->getDate(),$iDocumentID,$oUser->getUserName())) ; + } + } else if (isset($fAddCommentSubmit)) { + $iThreadID = DiscussionThread::getThreadIDforDoc($iDocumentID); + + if ($iThreadID > 0){ + if ($_POST["NewComment"] != "" and $_POST["NewCommentSubject"] != "") + { + // Create the new comment + $oComment = & new DiscussionComment(urlencode($_POST["NewComment"]),$_POST["NewCommentSubject"],$_SESSION["userID"],$iDocumentID); + $oComment->setThreadID($iThreadID); + $oComment->create(); + + if($oComment->getID() > 0) { + $oThread = DiscussionThread::get($iThreadID); + $oThread->setLastCommentID($oComment->getID()); + $oThread->setNumberOfReplies(); + if ($oThread->Update()) { + $oPatternCustom->addHtml(getSubmitSuccessPage($iDocumentID)); + }else { + $oPatternCustom->addHtml(getViewFailPage("Thread Object failed to update.")); + } + }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 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")); + } + + } // end of if checksession + + $main->setCentralPayload($oPatternCustom); + $main->render(); +} +?> diff --git a/presentation/lookAndFeel/knowledgeTree/discussions/addCommentUI.inc b/presentation/lookAndFeel/knowledgeTree/discussions/addCommentUI.inc new file mode 100644 index 0000000..9bba5fa --- /dev/null +++ b/presentation/lookAndFeel/knowledgeTree/discussions/addCommentUI.inc @@ -0,0 +1,103 @@ +
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; +} + +function renderHeading($sHeading) { + global $default; + + $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); + $sColor = $default->siteMap->getSectionColour($sSectionName, "th"); + $sToRender = "\n"; + $sToRender .= "\n"; + $sToRender .= "\n"; + $sToRender .= "\n"; + $sToRender .= "
$sHeading
\n"; + return $sToRender; +} + +function renderDocumentPath($iDocumentID) { + global $default; + + $oDocument = & Document::get($iDocumentID); + $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); + $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); + $sDocumentPath = displayFolderPathLink(Folder::getFolderPathAsArray($oDocument->getFolderID()), Folder::getFolderPathNamesAsArray($oDocument->getFolderID()), "$default->rootUrl/control.php?action=browse") . " > "; + $sDocumentPath .= "rootUrl/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewBL.php?fDocumentID=" . $oDocument->getID() . "&fForInlineView=1\">" . $oDocument->getName() . ""; + return "
$sDocumentPath
\n"; +} + + +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 .= "\n"; + $sToRender .= "
\n"; + $sToRender .= "
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\">
Subject\n"; + $sToRender .= "
Body
\n"; + $sToRender .= ""; + } + return $sToRender; + +} + +function getCommentBody($sCommentBody, $sCommentSubject,$dDate,$iDocumentID, $sUserName) { + global $default; + + $sHeading = "Document Comment"; + + $sToRender .= renderHeading($sHeading); + $sToRender .= renderDocumentPath($iDocumentID); + $sToRender .= "
 Author: $sUserName"; + $sToRender .= ""; + $sToRender .= ""; + $sToRender .= ""; + $sToRender .= "
Subject: $sCommentSubjectDate: $dDate

$sCommentBody
"; + 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 new file mode 100644 index 0000000..7bcd8f8 --- /dev/null +++ b/presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionBL.php @@ -0,0 +1,85 @@ +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"); //### + + 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/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/presentation/Html.inc"); + + $oPatternCustom = & new PatternCustom(); + +if(checksession) { + if (isset($fForDiscussion)) { + if ($fDocumentID > 0) { + $iThreadID = DiscussionThread::getThreadIDforDoc($fDocumentID); + if ($iThreadID) {// if thread ID does exist + $oThread = DiscussionThread::get($iThreadID); + if($oThread) { // if thread object exists + // Iterate through the number of comments + $sAllCommentID = $oThread->getAllCommentID(); + $arrAllCommentID = explode(",", $sAllCommentID); + $iNumMax = $oThread->getNumberOfReplies(); + for ($i = 0; $i < $iNumMax; $i++) { + $iCommentID = $arrAllCommentID[$i]; + $oComment = DiscussionComment::get($iCommentID); + $oUser = User::get($oComment->getUserID()); + $oPatternCustom->addHtml(getViewComment($i+1,$oThread,$oComment,$oUser)); + } + // On opening, increment the number of views of current thread & update database + if($_SESSION['Discussion'][0]->bViews !=true ){ + $oThread->setNumberOfViews(); + if($oThread->Update() == false) $oPatternCustom->addHtml("Failed to update. Please Contact Database Administrator in this regard") ; + $_SESSION['Discussion'][0]->bViews = true; + } + } else { $oPatternCustom->setHtml(getViewFailPage("")) ;} + } else { $oPatternCustom->addHtml(getViewFailPage("No threadID for this document.")); } + } 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"); + $oPatternCustom->setHtml(getCommentBody($oComment,$iDocumentID,$oUser)) ; + } + } else if (isset($fReplyComment)){ + $oPatternCustom->setHtml("###" . count($_POST) . "###" . $Comment . "###" . $CommentSubject); + } else { // If no discussion exists + } + + } // end of if checksession + + $main->setCentralPayload($oPatternCustom); + $main->render(); + +} +?> diff --git a/presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionUI.inc b/presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionUI.inc new file mode 100644 index 0000000..3e15ff4 --- /dev/null +++ b/presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionUI.inc @@ -0,0 +1,120 @@ +0){ + $sToRender = $sMessage; + } + else $sToRender = "Current document has no discussion. Press the ADD button to start a discussion."; + + return $sToRender; +} + +function renderHeading($sHeading) { + global $default; + + $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); + $sColor = $default->siteMap->getSectionColour($sSectionName, "th"); + $sToRender = "\n"; + $sToRender .= "\n"; + $sToRender .= "\n"; + $sToRender .= "\n"; + $sToRender .= "
$sHeading
\n"; + return $sToRender; +} + +function renderDocumentPath($iDocumentID) { + global $default; + + $oDocument = & Document::get($iDocumentID); + $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); + $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); + $sDocumentPath = displayFolderPathLink(Folder::getFolderPathAsArray($oDocument->getFolderID()), Folder::getFolderPathNamesAsArray($oDocument->getFolderID()), "$default->rootUrl/control.php?action=browse") . " > "; + $sDocumentPath .= "rootUrl/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewBL.php?fDocumentID=" . $oDocument->getID() . "&fForInlineView=1\">" . $oDocument->getName() . ""; + return "
$sDocumentPath
\n"; +} + +function getViewComment($iNum,$oThread,$oComment,$oUser) { + global $default; + + $iSubjectChars = 59; + // If iNum is odd then highlight it + if (($iNum%2) == 1) $BGcolor = "#F5F6EE"; + if (($iNum%2) == 0) $UserBGcolor = "#F5F6EE"; + + // If the Subject string is too long + if (strlen($oComment->getSubject())>$iSubjectChars ) $dotdot = " ..."; + if (strlen($oUser->getUserName())> 13 ) $Userdotdot = " ..."; + + // If this is the first Subject line then create a table + if ($iNum == 1) { + $sHeading = "Document Discussion Comments"; + + $sToRender .= renderHeading($sHeading ); + $sToRender .= renderDocumentPath($oThread->getDocumentID()); + $sToRender .= ""; + $sToRender .= ""; + $sToRender .= ""; + $sToRender .= ""; + $sToRender .= "
Views: " . $oThread->getNumberOfViews() . "Replies: " . $oThread->getNumberOfReplies() . "
\n"; + $sToRender .= "
graphicsUrl/widgets/addcomment.gif\" border=\"0\" />
\n"; + $sToRender .= "\n"; + $sToRender .= "\n"; + $sToRender .= "\n"; + $sToRender .= "\n"; + $sToRender .= "\n"; + } + + $sToRender .= "\n"; + $sToRender .= "\n"; + $sToRender .= "\n"; + + // If this is the last subject line then close the table + if ($iNum == $iNumMax) { $sToRender .= "
     SubjectAuthorDate
$iNum.  getID() . "&iDocumentID=" . $oThread->getDocumentID() . "\" title=\"" . $oComment->getSubject() . "\">" . substr($oComment->getSubject(),0,$iSubjectChars ) . $dotdot . "getUserName()\">" . substr($oUser->getUserName(),0,10) . $Userdotdot . "" . $oComment->getDate() . "
\n\n";} + return $sToRender; +} + +//function getCommentBody($sCommentBody, $sCommentSubject,$dDate,$iDocumentID, $sUserName) { +function getCommentBody($oComment, $iDocumentID, $oUser) { + global $default; + + $sHeading = "Document Comment"; + + $sToRender .= renderHeading($sHeading); + $sToRender .= renderDocumentPath($iDocumentID); + + $sToRender .= "
\n"; + $sToRender .= "\n"; + $sToRender .= ""; + $sToRender .= "
Author: " . $oUser->getUserName() . "\n"; + $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 .= "
Subject: "; + $sToRender .= "getSubject() . "\">"; + $sToRender .= "Date: " . $oComment->getDate() . "
"; + $sToRender .= "
"; + + + return $sToRender; +} + +function viewDiscussionPage() { + global $default; + + $sToRender = ""; + return $sToRender; +} +?> \ No newline at end of file -- libgit2 0.21.4