Commit aa6d69b73343b2133675f5c08ddab39e8d581e0f
1 parent
b6a4f6e9
(#2977) changed to use correct pattern
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2696 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
74 additions
and
88 deletions
presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionBL.php
| @@ -26,96 +26,82 @@ | @@ -26,96 +26,82 @@ | ||
| 26 | */ | 26 | */ |
| 27 | 27 | ||
| 28 | require_once("../../../../config/dmsDefaults.php"); | 28 | require_once("../../../../config/dmsDefaults.php"); |
| 29 | +require_once("viewDiscussionUI.inc"); | ||
| 30 | +require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc"); | ||
| 31 | +require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); | ||
| 32 | +require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); | ||
| 33 | +require_once("$default->fileSystemRoot/lib/users/User.inc"); | ||
| 34 | +require_once("$default->fileSystemRoot/lib/security/Permission.inc"); | ||
| 35 | +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); | ||
| 36 | +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternBrowsableSearchResults.inc"); | ||
| 37 | +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListFromQuery.inc"); | ||
| 38 | +require_once("$default->fileSystemRoot/lib/discussions/DiscussionThread.inc"); | ||
| 39 | +require_once("$default->fileSystemRoot/lib/discussions/DiscussionComment.inc"); | ||
| 40 | +require_once("$default->fileSystemRoot/presentation/Html.inc"); | ||
| 29 | 41 | ||
| 30 | -if (checkSession()) { | ||
| 31 | -// require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCreate.inc"); | ||
| 32 | - require_once("viewDiscussionUI.inc"); | ||
| 33 | - require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc"); | ||
| 34 | - require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); | ||
| 35 | - require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); | ||
| 36 | - require_once("$default->fileSystemRoot/lib/users/User.inc"); | ||
| 37 | - require_once("$default->fileSystemRoot/lib/security/Permission.inc"); | ||
| 38 | - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | ||
| 39 | - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); | ||
| 40 | - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternBrowsableSearchResults.inc"); | ||
| 41 | - //require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc"); | ||
| 42 | - require_once("$default->fileSystemRoot/lib/discussions/DiscussionThread.inc"); | ||
| 43 | - require_once("$default->fileSystemRoot/lib/discussions/DiscussionComment.inc"); | ||
| 44 | - require_once("$default->fileSystemRoot/presentation/Html.inc"); | 42 | +if (checkSession()) { |
| 43 | + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | ||
| 44 | + $oPatternCustom = & new PatternCustom(); | ||
| 45 | + if (isset($fForDiscussion)) { | ||
| 46 | + if ($fDocumentID > 0) { | ||
| 47 | + $iThreadID = DiscussionThread::getThreadIDforDoc($fDocumentID); | ||
| 48 | + if ($iThreadID) {// if thread ID does exist | ||
| 49 | + $oThread = DiscussionThread::get($iThreadID); | ||
| 50 | + if($oThread) { // if thread object exists | ||
| 51 | + // Iterate through the number of comments | ||
| 52 | + $sAllCommentID = $oThread->getAllCommentID(); | ||
| 53 | + $arrAllCommentID = explode(",", $sAllCommentID); | ||
| 54 | + $iNumMax = $oThread->getNumberOfReplies(); | ||
| 55 | + | ||
| 56 | + $sQuery = "SELECT 1 as ForView, subject, username, date, discussion_comments.id as com_id, discussion_threads.document_id as doc_id " . | ||
| 57 | + "FROM (discussion_comments INNER JOIN users ON discussion_comments.user_id = users.id) INNER JOIN discussion_threads ON discussion_threads.id = discussion_comments.thread_id " . | ||
| 58 | + "WHERE discussion_threads.id = " . $iThreadID . | ||
| 59 | + " ORDER BY date DESC"; | ||
| 45 | 60 | ||
| 46 | - $oPatternCustom = & new PatternCustom(); | ||
| 47 | - | ||
| 48 | -if(checkSession()) { | ||
| 49 | - if (isset($fForDiscussion)) { | ||
| 50 | - if ($fDocumentID > 0) { | ||
| 51 | - $iThreadID = DiscussionThread::getThreadIDforDoc($fDocumentID); | ||
| 52 | - if ($iThreadID) {// if thread ID does exist | ||
| 53 | - $oThread = DiscussionThread::get($iThreadID); | ||
| 54 | - if($oThread) { // if thread object exists | ||
| 55 | - // Iterate through the number of comments | ||
| 56 | - $sAllCommentID = $oThread->getAllCommentID(); | ||
| 57 | - $arrAllCommentID = explode(",", $sAllCommentID); | ||
| 58 | - $iNumMax = $oThread->getNumberOfReplies(); | ||
| 59 | - | ||
| 60 | - $sQuery = "SELECT 1 as ForView, subject, username, date, discussion_comments.id as com_id, discussion_threads.document_id as doc_id " . | ||
| 61 | - "FROM (discussion_comments INNER JOIN users ON discussion_comments.user_id = users.id) INNER JOIN discussion_threads ON discussion_threads.id = discussion_comments.thread_id " . | ||
| 62 | - "WHERE discussion_threads.id = " . $iThreadID . | ||
| 63 | - " ORDER BY date DESC"; | ||
| 64 | - | ||
| 65 | - $aColumns = array("subject", "username", "date"); | ||
| 66 | - $aColumnNames = array("<font color=white>Subject </font>", "<font color=white>User</font>", "<font color=white>Date</font>"); | ||
| 67 | - $aColumnTypes = array(3,1,1); | ||
| 68 | - | ||
| 69 | - $aQueryStringVars = array("fViewComment", "iCommentID", "iDocumentID"); | ||
| 70 | - $aQueryStringCols = array("ForView", "com_id", "doc_id"); | ||
| 71 | - | ||
| 72 | - for ($i = 0; $i < $iNumMax; $i++) { | ||
| 73 | - $aHyperLinkURL[$i] =$_SERVER['PHP_SELF'] ; | ||
| 74 | - } | ||
| 75 | - | ||
| 76 | - if (!isset($fStartIndex)) { $iStartIndex = 0 ;} | ||
| 77 | - else { $iStartIndex = $fStartIndex ;} | ||
| 78 | - | ||
| 79 | - | ||
| 80 | - | ||
| 81 | - $oSearchResults = & new PatternBrowseableSearchResults ($sQuery, $oThread->getNumberOfReplies(), $aColumns, $aColumnTypes, $aColumnNames, $aHyperLinkURL, $aQueryStringCols, $aQueryStringVars); | ||
| 82 | - $oSearchResults->setStartIndex($iStartIndex); | ||
| 83 | - $oSearchResults->setQueryString("&fDocumentID=$fDocumentID&fForDiscussion=1"); | ||
| 84 | - $sToRender .= renderHeading("Document Discussion Thread"); | ||
| 85 | - $sToRender .= renderDocumentPath($oThread->getDocumentID()); | ||
| 86 | - $oPatternCustom->addHtml($sToRender); | ||
| 87 | - $oPatternCustom->addHtml(getPageButtons($oThread)); | ||
| 88 | - $oPatternCustom->addHtml($oSearchResults->render()); | ||
| 89 | - | ||
| 90 | - // On opening, increment the number of views of current thread & update database | ||
| 91 | - if($_SESSION['Discussion' . $fDocumentID][0]->bViews !=true ){ | ||
| 92 | - $oThread->setNumberOfViews(); | ||
| 93 | - if($oThread->Update() == false) $oPatternCustom->addHtml("Failed to update. Please Contact Database Administrator in this regard") ; | ||
| 94 | - $_SESSION['Discussion' . $fDocumentID][0]->bViews = true; | ||
| 95 | - } | ||
| 96 | - } else { | ||
| 97 | - $main->setErrorMessage("Error creating discussion thread object"); | ||
| 98 | - } | ||
| 99 | - } else { // No current thread, option to create one | ||
| 100 | - $main->setErrorMessage("No discussion thread is currently available"); | ||
| 101 | - $oPatternCustom->addHtml(getNewThreadOption($fDocumentID)); | ||
| 102 | - } | ||
| 103 | - } else { // Doument id is negative | ||
| 104 | - $main->setErrorMessage("Invalid Document ID. ID may not be negative."); | ||
| 105 | - } | ||
| 106 | - } else if (isset($fViewComment)){ // User wants to view a comment | ||
| 107 | - if (isset($iCommentID)) { // Check if a comment ID exists | ||
| 108 | - $oComment = DiscussionComment::get($iCommentID); | ||
| 109 | - $oUser = User::get($oComment->getUserID()); | ||
| 110 | - $main->setFormAction("$default->rootUrl/presentation/lookAndFeel/knowledgeTree/discussions/addCommentBL.php?fDocumentID=$iDocumentID&fCommentID=$iCommentID&fReplyComment=1"); | ||
| 111 | - $oPatternCustom->setHtml(getCommentBody($oComment,$iDocumentID,$oUser)) ; | ||
| 112 | - } | ||
| 113 | - }else { // If no discussion exists | ||
| 114 | - $main->setErrorMessage("Invalid function. No such functionality exists for this page."); | ||
| 115 | - } | ||
| 116 | - } // end of if checksession | ||
| 117 | - | 61 | + $aColumns = array("subject", "username", "date"); |
| 62 | + $aColumnNames = array("<font color=white>Subject </font>", "<font color=white>User</font>", "<font color=white>Date</font>"); | ||
| 63 | + $aColumnTypes = array(3,1,1); | ||
| 64 | + $aQueryStringVars = array("fViewComment", "iCommentID", "iDocumentID"); | ||
| 65 | + $aQueryStringCols = array("ForView", "com_id", "doc_id"); | ||
| 66 | + | ||
| 67 | + for ($i = 0; $i < $iNumMax; $i++) { | ||
| 68 | + $aHyperLinkURL[$i] = $_SERVER['PHP_SELF'] ; | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + $oSearchResults = & new PatternTableSqlQuery ($sQuery, $aColumns, $aColumnTypes, $aColumnNames, "100%", $aHyperLinkURL, $aQueryStringCols, $aQueryStringVars); | ||
| 72 | + $sToRender .= renderHeading("Document Discussion Thread"); | ||
| 73 | + $sToRender .= renderDocumentPath($oThread->getDocumentID()); | ||
| 74 | + $oPatternCustom->addHtml($sToRender); | ||
| 75 | + $oPatternCustom->addHtml(getPageButtons($oThread)); | ||
| 76 | + $oPatternCustom->addHtml($oSearchResults->render()); | ||
| 77 | + | ||
| 78 | + // On opening, increment the number of views of current thread & update database | ||
| 79 | + if($_SESSION['Discussion' . $fDocumentID][0]->bViews !=true ){ | ||
| 80 | + $oThread->setNumberOfViews(); | ||
| 81 | + if($oThread->Update() == false) $oPatternCustom->addHtml("Failed to update. Please Contact Database Administrator in this regard") ; | ||
| 82 | + $_SESSION['Discussion' . $fDocumentID][0]->bViews = true; | ||
| 83 | + } | ||
| 84 | + } else { | ||
| 85 | + $main->setErrorMessage("Error creating discussion thread object"); | ||
| 86 | + } | ||
| 87 | + } else { // No current thread, option to create one | ||
| 88 | + $main->setErrorMessage("No discussion thread is currently available"); | ||
| 89 | + $oPatternCustom->addHtml(getNewThreadOption($fDocumentID)); | ||
| 90 | + } | ||
| 91 | + } else { // Doument id is negative | ||
| 92 | + $main->setErrorMessage("Invalid Document ID. ID may not be negative."); | ||
| 93 | + } | ||
| 94 | + } else if (isset($fViewComment)){ // User wants to view a comment | ||
| 95 | + if (isset($iCommentID)) { // Check if a comment ID exists | ||
| 96 | + $oComment = DiscussionComment::get($iCommentID); | ||
| 97 | + $oUser = User::get($oComment->getUserID()); | ||
| 98 | + $main->setFormAction("$default->rootUrl/presentation/lookAndFeel/knowledgeTree/discussions/addCommentBL.php?fDocumentID=$iDocumentID&fCommentID=$iCommentID&fReplyComment=1"); | ||
| 99 | + $oPatternCustom->setHtml(getCommentBody($oComment,$iDocumentID,$oUser)) ; | ||
| 100 | + } | ||
| 101 | + } else { // If no discussion exists | ||
| 102 | + $main->setErrorMessage("Invalid function. No such functionality exists for this page."); | ||
| 103 | + } | ||
| 118 | $main->setCentralPayload($oPatternCustom); | 104 | $main->setCentralPayload($oPatternCustom); |
| 119 | $main->render(); | 105 | $main->render(); |
| 120 | } | 106 | } |
| 121 | -?> | 107 | -?> |
| 108 | +?> | ||
| 122 | \ No newline at end of file | 109 | \ No newline at end of file |