Commit 57b60d5d2ecbe98d1d81e0f8d4defdf996449ced
1 parent
83033f32
Move document discussion into the actions framework.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4114 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
11 changed files
with
265 additions
and
607 deletions
plugins/ktstandard/KTDiscussion.php
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | require_once(KT_LIB_DIR . '/actions/actionregistry.inc.php'); |
| 4 | +require_once(KT_LIB_DIR . '/discussions/DiscussionThread.inc'); | |
| 5 | +require_once(KT_LIB_DIR . '/discussions/DiscussionComment.inc'); | |
| 4 | 6 | |
| 5 | 7 | $oKTActionRegistry =& KTActionRegistry::getSingleton(); |
| 6 | 8 | |
| 7 | -class KTDocumentDiscussionAction extends KTBuiltInDocumentAction { | |
| 9 | +class KTDiscussionThreadListRenderer { | |
| 10 | + function render($context, $oThread) { | |
| 11 | + $this->oThread = $oThread; | |
| 12 | + $oTemplate = $context->oValidator->validateTemplate('ktstandard/action/discussion_thread_list_item'); | |
| 13 | + $oFirstComment = DiscussionComment::get($oThread->getFirstCommentId()); | |
| 14 | + if (PEAR::isError($oFirstComment)) { | |
| 15 | + return null; | |
| 16 | + } | |
| 17 | + $oLastComment = DiscussionComment::get($oThread->getLastCommentId()); | |
| 18 | + if (PEAR::isError($oLastComment)) { | |
| 19 | + return null; | |
| 20 | + } | |
| 21 | + $oCreator = User::get($oThread->getCreatorId()); | |
| 22 | + $oTemplate->setData(array( | |
| 23 | + 'thread' => $this->oThread, | |
| 24 | + 'first_comment' => $oFirstComment, | |
| 25 | + 'last_comment' => $oLastComment, | |
| 26 | + 'creator' => $oCreator, | |
| 27 | + 'context' => $context, | |
| 28 | + )); | |
| 29 | + return $oTemplate->render(); | |
| 30 | + } | |
| 31 | +} | |
| 32 | + | |
| 33 | +class KTCommentListRenderer { | |
| 34 | + function render($context, $oComment) { | |
| 35 | + $this->oComment = $oComment; | |
| 36 | + $oTemplate = $context->oValidator->validateTemplate('ktstandard/action/discussion_comment_list_item'); | |
| 37 | + $oCreator = User::get($oComment->getUserId()); | |
| 38 | + $oTemplate->setData(array( | |
| 39 | + 'comment' => $oComment, | |
| 40 | + 'creator' => $oCreator, | |
| 41 | + 'context' => $context, | |
| 42 | + )); | |
| 43 | + return $oTemplate->render(); | |
| 44 | + } | |
| 45 | +} | |
| 46 | + | |
| 47 | +class KTDocumentDiscussionAction extends KTDocumentAction { | |
| 8 | 48 | var $sBuiltInAction = 'viewDiscussion'; |
| 9 | 49 | var $sDisplayName = 'Discussion'; |
| 10 | 50 | var $sName = 'ktcore.actions.document.discussion'; |
| 51 | + | |
| 52 | + function do_main() { | |
| 53 | + $this->oPage->setBreadcrumbDetails("discussion"); | |
| 54 | + $oTemplate =& $this->oValidator->validateTemplate('ktstandard/action/discussion'); | |
| 55 | + | |
| 56 | + // Fields for new thread creation | |
| 57 | + $fields = array(); | |
| 58 | + $fields[] = new KTStringWidget("Subject", "The topic of discussion in this thread", "subject", "", $this->oPage, true); | |
| 59 | + $fields[] = new KTTextWidget("Body", "Your contribution to the discussion in this thread", "body", "", $this->oPage, true, null, null, array("cols" => 50, "rows" => 10)); | |
| 60 | + | |
| 61 | + $threads = DiscussionThread::getList(); | |
| 62 | + | |
| 63 | + $aTemplateData = array( | |
| 64 | + 'context' => &$this, | |
| 65 | + 'fields' => $fields, | |
| 66 | + 'threads' => $threads, | |
| 67 | + 'threadrenderer' => new KTDiscussionThreadListRenderer(), | |
| 68 | + ); | |
| 69 | + return $oTemplate->render($aTemplateData); | |
| 70 | + } | |
| 71 | + | |
| 72 | + function do_newthread() { | |
| 73 | + $aErrorOptions = array( | |
| 74 | + 'redirect_to' => array('main', sprintf('fDocumentId=%d', $this->oDocument->getId())), | |
| 75 | + ); | |
| 76 | + | |
| 77 | + $aErrorOptions['message'] = "No subject provided"; | |
| 78 | + $sSubject = KTUtil::arrayGet($_REQUEST, 'subject'); | |
| 79 | + $sSubject = $this->oValidator->validateString($sSubject, $aErrorOptions); | |
| 80 | + | |
| 81 | + $aErrorOptions['message'] = "No body provided"; | |
| 82 | + $sBody = KTUtil::arrayGet($_REQUEST, 'body'); | |
| 83 | + $sBody = $this->oValidator->validateString($sBody, $aErrorOptions); | |
| 84 | + | |
| 85 | + // Start the transaction around thread and comment creation | |
| 86 | + $this->startTransaction(); | |
| 87 | + | |
| 88 | + $oThread = DiscussionThread::createFromArray(array( | |
| 89 | + 'documentid' => $this->oDocument->getId(), | |
| 90 | + 'creatorid' => $this->oUser->getId(), | |
| 91 | + )); | |
| 92 | + $aErrorOptions['message'] = "There was an error creating a new thread"; | |
| 93 | + $this->oValidator->notError($oThread); | |
| 94 | + | |
| 95 | + $oComment = DiscussionComment::createFromArray(array( | |
| 96 | + 'threadid' => $oThread->getId(), | |
| 97 | + 'userid' => $this->oUser->getId(), | |
| 98 | + 'subject' => $sSubject, | |
| 99 | + 'body' => $sBody, | |
| 100 | + )); | |
| 101 | + $aErrorOptions['message'] = "There was an error adding the comment to the thread"; | |
| 102 | + $this->oValidator->notError($oComment); | |
| 103 | + | |
| 104 | + $oThread->setFirstCommentId($oComment->getId()); | |
| 105 | + $oThread->setLastCommentId($oComment->getId()); | |
| 106 | + $res = $oThread->update(); | |
| 107 | + $aErrorOptions['message'] = "There was an error updating the thread with the new comment"; | |
| 108 | + $this->oValidator->notError($res); | |
| 109 | + | |
| 110 | + // Thread and comment created correctly, commit to database | |
| 111 | + $this->commitTransaction(); | |
| 112 | + | |
| 113 | + $this->successRedirectToMain("New thread created", sprintf('fDocumentId=%d', $this->oDocument->getId())); | |
| 114 | + exit(0); | |
| 115 | + } | |
| 116 | + | |
| 117 | + function do_viewthread() { | |
| 118 | + $iThreadId = KTUtil::arrayGet($_REQUEST, 'fThreadId'); | |
| 119 | + $oThread = DiscussionThread::get($iThreadId); | |
| 120 | + | |
| 121 | + $iCommentId = $oThread->getFirstCommentId(); | |
| 122 | + $oComment = DiscussionComment::get($iCommentId); | |
| 123 | + | |
| 124 | + $this->aBreadcrumbs[] = array( | |
| 125 | + 'name' => 'discussion', | |
| 126 | + 'url' => $_SERVER['PHP_SELF'] . sprintf('?fDocumentId=%d', $this->oDocument->getId()), | |
| 127 | + ); | |
| 128 | + $this->aBreadcrumbs[] = array( | |
| 129 | + 'name' => $oComment->getSubject(), | |
| 130 | + ); | |
| 131 | + $this->oPage->setBreadcrumbDetails("viewing comments"); | |
| 132 | + $oTemplate =& $this->oValidator->validateTemplate('ktstandard/action/discussion_thread'); | |
| 133 | + // Fields for new thread creation | |
| 134 | + $fields = array(); | |
| 135 | + $fields[] = new KTStringWidget("Subject", "The topic of discussion in this thread", "subject", "", $this->oPage, true); | |
| 136 | + $fields[] = new KTTextWidget("Body", "Your contribution to the discussion in this thread", "body", "", $this->oPage, true, null, null, array("cols" => 50, "rows" => 10)); | |
| 137 | + | |
| 138 | + $aTemplateData = array( | |
| 139 | + 'context' => &$this, | |
| 140 | + 'fields' => $fields, | |
| 141 | + 'thread' => $oThread, | |
| 142 | + 'commentrenderer' => new KTCommentListRenderer(), | |
| 143 | + ); | |
| 144 | + return $oTemplate->render($aTemplateData); | |
| 145 | + } | |
| 146 | + | |
| 147 | + function do_postreply() { | |
| 148 | + $aErrorOptions = array( | |
| 149 | + 'redirect_to' => array('main', sprintf('fDocumentId=%d', $this->oDocument->getId())), | |
| 150 | + ); | |
| 151 | + $iThreadId = KTUtil::arrayGet($_REQUEST, 'fThreadId'); | |
| 152 | + $oThread = DiscussionThread::get($iThreadId); | |
| 153 | + | |
| 154 | + $this->oValidator->notError($oThread, $aErrorOptions); | |
| 155 | + | |
| 156 | + $aErrorOptions = array( | |
| 157 | + 'redirect_to' => array('viewthread', sprintf('fDocumentId=%d&fThreadId=%d', $this->oDocument->getId(), $oThread->getId())), | |
| 158 | + ); | |
| 159 | + | |
| 160 | + | |
| 161 | + $aErrorOptions['message'] = "No subject provided"; | |
| 162 | + $sSubject = KTUtil::arrayGet($_REQUEST, 'subject'); | |
| 163 | + $sSubject = $this->oValidator->validateString($sSubject, $aErrorOptions); | |
| 164 | + | |
| 165 | + $aErrorOptions['message'] = "No body provided"; | |
| 166 | + $sBody = KTUtil::arrayGet($_REQUEST, 'body'); | |
| 167 | + $sBody = $this->oValidator->validateString($sBody, $aErrorOptions); | |
| 168 | + | |
| 169 | + // Start the transaction comment creation | |
| 170 | + $this->startTransaction(); | |
| 171 | + | |
| 172 | + $oComment = DiscussionComment::createFromArray(array( | |
| 173 | + 'threadid' => $oThread->getId(), | |
| 174 | + 'userid' => $this->oUser->getId(), | |
| 175 | + 'subject' => $sSubject, | |
| 176 | + 'body' => $sBody, | |
| 177 | + )); | |
| 178 | + $aErrorOptions['message'] = "There was an error adding the comment to the thread"; | |
| 179 | + $this->oValidator->notError($oComment, $aErrorOptions); | |
| 180 | + | |
| 181 | + $oThread->setLastCommentId($oComment->getId()); | |
| 182 | + $res = $oThread->update(); | |
| 183 | + $aErrorOptions['message'] = "There was an error updating the thread with the new comment"; | |
| 184 | + $this->oValidator->notError($res, $aErrorOptions); | |
| 185 | + | |
| 186 | + // Thread and comment created correctly, commit to database | |
| 187 | + $this->commitTransaction(); | |
| 188 | + | |
| 189 | + $this->successRedirectTo('viewThread', "Reply posted", sprintf('fDocumentId=%d&fThreadId=%d', $this->oDocument->getId(), $oThread->getId())); | |
| 190 | + exit(0); | |
| 191 | + } | |
| 11 | 192 | } |
| 12 | 193 | $oKTActionRegistry->registerAction('documentaction', 'KTDocumentDiscussionAction', 'ktcore.actions.document.discussion'); |
| 13 | 194 | ... | ... |
presentation/lookAndFeel/knowledgeTree/discussions/addCommentBL.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * $Id$ | |
| 4 | - * | |
| 5 | - * Add a comment. | |
| 6 | - * | |
| 7 | - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com | |
| 8 | - * | |
| 9 | - * This program is free software; you can redistribute it and/or modify | |
| 10 | - * it under the terms of the GNU General Public License as published by | |
| 11 | - * the Free Software Foundation; either version 2 of the License, or | |
| 12 | - * (at your option) any later version. | |
| 13 | - * | |
| 14 | - * This program is distributed in the hope that it will be useful, | |
| 15 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 17 | - * GNU General Public License for more details. | |
| 18 | - * | |
| 19 | - * You should have received a copy of the GNU General Public License | |
| 20 | - * along with this program; if not, write to the Free Software | |
| 21 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 22 | - * | |
| 23 | - * @version $Revision$ | |
| 24 | - * @author Omar Rahbeeni, Jam Warehouse (Pty) Ltd, South Africa | |
| 25 | - * @package discussions | |
| 26 | - */ | |
| 27 | - | |
| 28 | -require_once("../../../../config/dmsDefaults.php"); | |
| 29 | - | |
| 30 | -KTUtil::extractGPC('fAddCommentSubmit', 'fComment', 'fCommentID', 'fDocumentID', 'fInReplyTo', 'fNewThread', 'fReplyComment', 'fSubject', 'fThreadID'); | |
| 31 | - | |
| 32 | -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCreate.inc"); | |
| 33 | -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternMainPage.inc"); | |
| 34 | -require_once("addCommentUI.inc"); //### | |
| 35 | -require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc"); | |
| 36 | -require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); | |
| 37 | -require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); | |
| 38 | -require_once("$default->fileSystemRoot/lib/users/User.inc"); | |
| 39 | -require_once("$default->fileSystemRoot/lib/security/Permission.inc"); | |
| 40 | -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); | |
| 41 | -require_once("$default->fileSystemRoot/lib/discussions/DiscussionThread.inc"); //### | |
| 42 | -require_once("$default->fileSystemRoot/lib/discussions/DiscussionComment.inc"); //### | |
| 43 | -require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/documentmanagement/documentUI.inc"); | |
| 44 | -require_once("$default->fileSystemRoot/presentation/Html.inc"); | |
| 45 | - | |
| 46 | -if(checkSession()) { | |
| 47 | - $oPatternCustom = & new PatternCustom(); | |
| 48 | - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | |
| 49 | - if (isset($fAddCommentSubmit)) { | |
| 50 | - $default->log->info("adding comment: subject=$fSubject; comment=$fComment"); | |
| 51 | - if ( (strlen($fSubject) > 0) && (strlen($fComment) > 0) ) { | |
| 52 | - // create a new thread, unless we're replying | |
| 53 | - if (isset($fNewThread)) { | |
| 54 | - $oThread = & new DiscussionThread(-1, $fDocumentID, $_SESSION["userID"]); | |
| 55 | - $oThread->create(); | |
| 56 | - $iThreadID = $oThread->getID(); | |
| 57 | - // if this is a new thread, then set inReplyTo to -1 | |
| 58 | - $fInReplyTo = -1; | |
| 59 | - } else { | |
| 60 | - // replying | |
| 61 | - // retrieve the thread id | |
| 62 | - //$iThreadID = DiscussionThread::getThreadIDforDoc($fDocumentID); | |
| 63 | - $default->log->info("adding comment: SEtting thread id: " . $fThreadID); | |
| 64 | - $iThreadID = $fThreadID; | |
| 65 | - } | |
| 66 | - if ($iThreadID) { | |
| 67 | - $default->log->info("addComment fInReplyTo=$fInReplyTo, threadID=$iThreadID"); | |
| 68 | - // Create the new comment | |
| 69 | - $oComment = & new DiscussionComment($fComment, $fSubject, $_SESSION["userID"], $iThreadID, $fInReplyTo); | |
| 70 | - $oComment->setThreadID($iThreadID); | |
| 71 | - $oComment->create(); | |
| 72 | - | |
| 73 | - if($oComment->getID() > 0) { | |
| 74 | - $oThread = DiscussionThread::get($iThreadID); | |
| 75 | - $oThread->setLastCommentID($oComment->getID()); | |
| 76 | - if ($oThread->getFirstCommentID() == -1){ // if it is a new Thread | |
| 77 | - $oThread->setFirstCommentID($oComment->getID()); | |
| 78 | - } | |
| 79 | - // Session variable is set to true if user views the thread | |
| 80 | - if ($_SESSION['Discussion' . $fDocumentID][0]->bViews != true ){ | |
| 81 | - $oThread->incrementNumberOfViews(); | |
| 82 | - $_SESSION['Discussion' . $fDocumentID][0]->bViews = true; | |
| 83 | - } | |
| 84 | - $oThread->incrementNumberOfReplies(); | |
| 85 | - | |
| 86 | - if ($oThread->Update()) { // | |
| 87 | - controllerRedirect("viewDiscussion", "fForDiscussion=1&fDocumentID=$fDocumentID"); | |
| 88 | - //$oPatternCustom->addHtml(getSubmitSuccessPage($fDocumentID)); | |
| 89 | - } else { | |
| 90 | - $main->setErrorMessage(_("Thread Object failed to update")); | |
| 91 | - } | |
| 92 | - } else { | |
| 93 | - $main->setErrorMessage(_("Comment Object failed in creation")); | |
| 94 | - } | |
| 95 | - } else { | |
| 96 | - $main->setErrorMessage(_("Could not create a new discussion thread.")); | |
| 97 | - } | |
| 98 | - } else { // the user has not entered BOTH a subject and a text body | |
| 99 | - $main->setErrorMessage(_("The subject line and/or body should not be empty.")); | |
| 100 | - $main->setFormAction($_SERVER['PHP_SELF'] . "?fAddCommentSubmit=1&fDocumentID=$fDocumentID"); | |
| 101 | - $oPatternCustom->addHtml(getAddComment($fDocumentID, $fSubject, $fComment, $fCommentID, 1, $fThreadID)); | |
| 102 | - } // end of IF for Subject and Body test | |
| 103 | - } else if (isset($fReplyComment)) { // if user is replying to existing comment | |
| 104 | - $main->setFormAction($_SERVER['PHP_SELF'] . "?fAddCommentSubmit=1&fDocumentID=$fDocumentID"); | |
| 105 | - | |
| 106 | - $oComment = DiscussionComment::get($fCommentID); | |
| 107 | - $oUser = User::get($oComment->getUserID()); | |
| 108 | - | |
| 109 | - $sReplyBody = $oComment->getBody(); | |
| 110 | - | |
| 111 | - $sReplyBodyHeader .= "\n\n> ------ Original Message ------"; | |
| 112 | - $sReplyBodyHeader .= "\n> User: " . $oUser->getName(); | |
| 113 | - $sReplyBodyHeader .= "\n> Date: " . $oComment->getDate(); | |
| 114 | - $sReplyBodyHeader .= "\n> Subject: " . $oComment->getSubject(); | |
| 115 | - $sReplyBodyHeader .= "\n> ---------------------------------------"; | |
| 116 | - $default->log->info("replyBody before=$sReplyBody; replyBodyAfter=" . str_replace("%0D%0A" ,"%0D%0A>", $sReplyBody)); | |
| 117 | - $sReplyBody = $sReplyBodyHeader . "\n>" . str_replace(">" ,"> >", $sReplyBody); // Put in ">" as indentation for the reply | |
| 118 | - //$sReplyBody = $sReplyBodyHeader . "\n>" . str_replace("%0D%0A" ,"%0D%0A>", $sReplyBody); // Put in ">" as indentation for the reply | |
| 119 | - | |
| 120 | - if (strpos($oComment->getSubject(), "Re:") != " "){ | |
| 121 | - $sReply = "Re: "; | |
| 122 | - } else { $sReply = ""; } | |
| 123 | - | |
| 124 | - $oPatternCustom->addHtml(getAddComment($fDocumentID, $sReply . $oComment->getSubject() , urldecode($sReplyBody), $fCommentID, "-1" , $fThreadID)); | |
| 125 | - | |
| 126 | - } else if (isset($fNewThread)){ // Start adding a new Thread | |
| 127 | - $main->setFormAction($_SERVER['PHP_SELF'] . "?fAddCommentSubmit=1&fDocumentID=$fDocumentID&fNewThread=1"); | |
| 128 | - $oPatternCustom->addHtml(getAddComment($fDocumentID, $CommentSubject ,$Comment, $fCommentID, "1", $fThreadID)); | |
| 129 | - } else { | |
| 130 | - // input validation | |
| 131 | - if (isset($fDocumentID)) { | |
| 132 | - $main->setFormAction($_SERVER['PHP_SELF'] . "?fAddCommentSubmit=1&fDocumentID=$fDocumentID"); | |
| 133 | - $oPatternCustom->setHtml(getAddComment($fDocumentID,$sSubject,$sBody, $fCommentID, 1, $fThreadID)); | |
| 134 | - } else { | |
| 135 | - $main->setErrorMessage(_("You did not specify a document to add a comment to.")); | |
| 136 | - } | |
| 137 | - } | |
| 138 | - $main->setCentralPayload($oPatternCustom); | |
| 139 | - $main->render(); | |
| 140 | -} | |
| 141 | -?> |
presentation/lookAndFeel/knowledgeTree/discussions/addCommentUI.inc deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * $Id$ | |
| 4 | - * | |
| 5 | - * Add a discussion comment UI functions. | |
| 6 | - * | |
| 7 | - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com | |
| 8 | - * | |
| 9 | - * This program is free software; you can redistribute it and/or modify | |
| 10 | - * it under the terms of the GNU General Public License as published by | |
| 11 | - * the Free Software Foundation; either version 2 of the License, or | |
| 12 | - * (at your option) any later version. | |
| 13 | - * | |
| 14 | - * This program is distributed in the hope that it will be useful, | |
| 15 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 17 | - * GNU General Public License for more details. | |
| 18 | - * | |
| 19 | - * You should have received a copy of the GNU General Public License | |
| 20 | - * along with this program; if not, write to the Free Software | |
| 21 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 22 | - * | |
| 23 | - * @version $Revision$ | |
| 24 | - * @author Omar Rahbeeni, Jam Warehouse (Pty) Ltd, South Africa | |
| 25 | - * @package discussions | |
| 26 | - */ | |
| 27 | - | |
| 28 | -/** | |
| 29 | - * Submission of comment SUCCESS page | |
| 30 | - * | |
| 31 | - * @param $iDocumentID -> a valid Document ID | |
| 32 | - */ | |
| 33 | -function getSubmitSuccessPage($iDocumentID){ | |
| 34 | - global $default; | |
| 35 | - $sMessage = _("Your submission has been successful."); | |
| 36 | - $sToRender .= "$sMessage<br><br><a href=\"" . generateControllerLink("viewDiscussion", "fDocumentID=" . $iDocumentID . "&fForDiscussion=1") . "\"><img src=\"" . KTHtml::getBackButton() . "\" border=\"0\" /></a>"; | |
| 37 | - | |
| 38 | - return $sToRender; | |
| 39 | -} | |
| 40 | - | |
| 41 | -/** | |
| 42 | - * Display the ADD COMMENT page | |
| 43 | - * | |
| 44 | - * @param $iDocumentID -> a valid Document ID | |
| 45 | - * @param $sSubject -> a Subject text | |
| 46 | - * @param $sBody -> a Body text | |
| 47 | - */ | |
| 48 | -function getAddComment($iDocumentID, $sSubject, $sBody, $iCommentID, $iNewComment = null, $iThreadID) { | |
| 49 | - global $default; | |
| 50 | - | |
| 51 | - $sHeading = _("Add a Comment"); | |
| 52 | - $sToRender .= renderHeading($sHeading); | |
| 53 | - $sToRender .= displayDocumentPath($iDocumentID); | |
| 54 | - $sToRender .= "<table width=\"100%\" border=\"0\" cellpadding=0 ><tr><td></td>\n"; | |
| 55 | - $sToRender .= "<td align=right width=500>"; | |
| 56 | - $sToRender .= " "; | |
| 57 | - $sToRender .= " "; | |
| 58 | - $sToRender .= "<input onmouseover=\"this.style.cursor='hand'\" type=\"image\" src=\"" . KTHtml::getSubmitButton() . "\" border=0></td>"; | |
| 59 | - if ($iNewComment>0) { // If user is creating a new comment | |
| 60 | - $sToRender .= "<td width=\"10\" valign=top><a href=\"" . generateControllerLink("viewDiscussion", "fForDiscussion=1&fDocumentID=$iDocumentID") . "\"><img src=\"" . KTHtml::getCancelButton() . "\" border=0 ></a></td></tr>\n"; | |
| 61 | - $sToRender .= "<input type=\"hidden\" name=\"fNewThread\" value=\"1\"/>"; | |
| 62 | - } else { // If the user is replying to a comment | |
| 63 | - $sToRender .= "<input type=\"hidden\" name=\"fInReplyTo\" value=\"$iCommentID\"/>"; | |
| 64 | - $sToRender .= "<input type=\"hidden\" name=\"fThreadID\" value=\"". $iThreadID . "\"/>"; | |
| 65 | - $sToRender .= "<td width=\"10\" valign=top><a href=\"" . generateControllerLink("viewComment", "fViewComment=1&fDocumentID=$iDocumentID&fCommentID=$iCommentID") . "\"><img src=\"" . KTHtml::getCancelButton() . "\" border=0 ></a></td></tr>\n"; | |
| 66 | - } | |
| 67 | - $sToRender .= "<br><tr><td valign=\"top\" width=10><b>Subject</b></td><td colspan=2>\n"; | |
| 68 | - $sToRender .= "<input type=\"text\" style=\"width:385\" name=\"fSubject\" value=\"$sSubject\"></td></tr>\n"; | |
| 69 | - $sToRender .= "<tr><td valign=\"top\"><b>Body</b></td><td colspan=2><textarea cols=60 rows=\"18\" name=\"fComment\" wrap=\"physical\">$sBody</textarea></td></tr></table>\n"; | |
| 70 | - return $sToRender; | |
| 71 | -} | |
| 72 | - | |
| 73 | -/** | |
| 74 | - * Display the comment: Body text included | |
| 75 | - * Prints out 1 comment | |
| 76 | - * User needs to call this function many times to list all comments | |
| 77 | - * | |
| 78 | - * @param $sCommentBody -> Some body text | |
| 79 | - * @param $iComment Subject -> Some subject text | |
| 80 | - * @param $dDate -> Date comment was created | |
| 81 | - * @param $iDocumentID -> a valid document ID | |
| 82 | - * @param $sUserName -> Name of creator of comment | |
| 83 | - */ | |
| 84 | -function getCommentBody($sCommentBody, $sCommentSubject,$dDate,$iDocumentID, $sUserName) { | |
| 85 | - global $default; | |
| 86 | - | |
| 87 | - $sHeading = _("Document Comment"); | |
| 88 | - | |
| 89 | - $sToRender .= renderHeading($sHeading); | |
| 90 | - $sToRender .= displayDocumentPath($iDocumentID); | |
| 91 | - $sToRender .= "<br> <b>Author: </b>$sUserName"; | |
| 92 | - $sToRender .= "<table width=\"96%\" border=\"1\"><tr>"; | |
| 93 | - $sToRender .= "<td width=\"1\" style=\"background-color:#F5F6EE;\" valign=\"top\"><b>" . _("Subject") . ": </b></td><td width=405 style=\"background-color:#F5F6EE;\"> <font color=#056DCE>$sCommentSubject</font></td>"; | |
| 94 | - $sToRender .= "<td><b>" . _("Date") . ": </b><font color=\"#056DCE\">$dDate</font></td></tr><tr><td colspan=3><br>$sCommentBody</a></td>"; | |
| 95 | - $sToRender .= "</tr></table>"; | |
| 96 | - return $sToRender; | |
| 97 | -} | |
| 98 | - | |
| 99 | -?> |
presentation/lookAndFeel/knowledgeTree/discussions/viewCommentBL.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * $Id$ | |
| 4 | - * | |
| 5 | - * Add a comment. | |
| 6 | - * | |
| 7 | - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com | |
| 8 | - * | |
| 9 | - * This program is free software; you can redistribute it and/or modify | |
| 10 | - * it under the terms of the GNU General Public License as published by | |
| 11 | - * the Free Software Foundation; either version 2 of the License, or | |
| 12 | - * (at your option) any later version. | |
| 13 | - * | |
| 14 | - * This program is distributed in the hope that it will be useful, | |
| 15 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 17 | - * GNU General Public License for more details. | |
| 18 | - * | |
| 19 | - * You should have received a copy of the GNU General Public License | |
| 20 | - * along with this program; if not, write to the Free Software | |
| 21 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 22 | - * | |
| 23 | - * @version $Revision$ | |
| 24 | - * @author Michael Joseph, Jam Warehouse (Pty) Ltd, South Africa | |
| 25 | - * @package discussions | |
| 26 | - */ | |
| 27 | - | |
| 28 | -require_once("../../../../config/dmsDefaults.php"); | |
| 29 | -require_once("viewCommentUI.inc"); | |
| 30 | -require_once("$default->fileSystemRoot/lib/users/User.inc"); | |
| 31 | -require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); | |
| 32 | -require_once("$default->fileSystemRoot/lib/security/Permission.inc"); | |
| 33 | -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); | |
| 34 | -require_once("$default->fileSystemRoot/lib/discussions/DiscussionThread.inc"); | |
| 35 | -require_once("$default->fileSystemRoot/lib/discussions/DiscussionComment.inc"); | |
| 36 | -require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/documentmanagement/documentUI.inc"); | |
| 37 | -require_once("$default->fileSystemRoot/presentation/Html.inc"); | |
| 38 | - | |
| 39 | -KTUtil::extractGPC('fCommentID', 'fDocumentID', 'fThreadID'); | |
| 40 | - | |
| 41 | -if (checkSession()) { | |
| 42 | - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | |
| 43 | - $oPatternCustom = & new PatternCustom(); | |
| 44 | - | |
| 45 | - // validate input parameters | |
| 46 | - if (isset($fCommentID) && isset($fDocumentID)) { | |
| 47 | - $oComment = DiscussionComment::get($fCommentID); | |
| 48 | - $oUser = User::get($oComment->getUserID()); | |
| 49 | - $main->setFormAction("$default->rootUrl/presentation/lookAndFeel/knowledgeTree/discussions/addCommentBL.php?fDocumentID=$iDocumentID&fCommentID=$iCommentID&fReplyComment=1"); | |
| 50 | - $oPatternCustom->setHtml(getCommentBody($oComment,$fDocumentID,$oUser,$fThreadID)); | |
| 51 | - } else { | |
| 52 | - $main->setErrorMessage(_("You didn't specify a comment to view")); | |
| 53 | - } | |
| 54 | - $main->setCentralPayload($oPatternCustom); | |
| 55 | - $main->render(); | |
| 56 | -} | |
| 57 | -?> |
presentation/lookAndFeel/knowledgeTree/discussions/viewCommentUI.inc deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * $Id$ | |
| 4 | - * | |
| 5 | - * Add a comment. | |
| 6 | - * | |
| 7 | - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com | |
| 8 | - * | |
| 9 | - * This program is free software; you can redistribute it and/or modify | |
| 10 | - * it under the terms of the GNU General Public License as published by | |
| 11 | - * the Free Software Foundation; either version 2 of the License, or | |
| 12 | - * (at your option) any later version. | |
| 13 | - * | |
| 14 | - * This program is distributed in the hope that it will be useful, | |
| 15 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 17 | - * GNU General Public License for more details. | |
| 18 | - * | |
| 19 | - * You should have received a copy of the GNU General Public License | |
| 20 | - * along with this program; if not, write to the Free Software | |
| 21 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 22 | - * | |
| 23 | - * @version $Revision$ | |
| 24 | - * @author Michael Joseph, Jam Warehouse (Pty) Ltd, South Africa | |
| 25 | - * @package discussions | |
| 26 | - */ | |
| 27 | - | |
| 28 | -/** | |
| 29 | - * Views a single thread comment with its text body | |
| 30 | - * | |
| 31 | - * @param $iDocumentID -> a valid Document ID | |
| 32 | - * @param $oComment -> a valid Comment Object | |
| 33 | - * @param $oUser -> a valid User Object (Logged in user) | |
| 34 | - * @param $iThreadID -> the ThreadID passed through | |
| 35 | - */ | |
| 36 | -function getCommentBody($oComment, $iDocumentID, $oUser, $iThreadID) { | |
| 37 | - global $default; | |
| 38 | - | |
| 39 | - $sHeading = _("Document Comment"); | |
| 40 | - | |
| 41 | - $sToRender .= renderHeading($sHeading); | |
| 42 | - $sToRender .= displayDocumentPath($iDocumentID); | |
| 43 | - $aBody = explode("\n",$oComment->getBody()); | |
| 44 | - $sBody = ""; | |
| 45 | - $numChars = 160; // number of chars in a line | |
| 46 | - | |
| 47 | - // Used for wrapping text that may be too long on one any line | |
| 48 | - for ($i=0; $i <= sizeof($aBody) ;$i++) { | |
| 49 | - if (strlen($aBody[$i]) >$numChars){ | |
| 50 | - $loop = (strlen($aBody[$i]) - (strlen($aBody[$i])) % $numChars)/$numChars +1; | |
| 51 | - | |
| 52 | - $j=$numChars; | |
| 53 | - for($j=0; $j < $loop; $j++ ) { | |
| 54 | - $sBody .= "<br>" . substr($aBody[$i],($j*$numChars), $numChars) . ""; | |
| 55 | - } | |
| 56 | - } else { $sBody .= "<br>" . $aBody[$i]; } | |
| 57 | - } | |
| 58 | - | |
| 59 | -// $sToRender .= "<td width=100><b>Views: </b> " . $oThread->getNumberOfViews() . "</td>"; | |
| 60 | -// $sToRender .= "<td width=20></td>"; | |
| 61 | -// $sToRender .= "<td><b>Replies: </b> " . $oThread->getNumberOfReplies() . "</td>"; | |
| 62 | - | |
| 63 | - $sToRender .= "<br><table width=100% border=0><tr ><td colspan=2><b>Author: </b>" . $oUser->getUserName() . "</td>\n"; | |
| 64 | - $sToRender .= "<td align=right>\n"; | |
| 65 | - $sToRender .= "<a href=\"" . generateControllerLink("addComment", "fDocumentID=" . $iDocumentID . "&fReplyComment=1&fCommentID=" . $oComment->getID()) . "&fThreadID=" . $iThreadID . "\"><img src=\"" . KTHtml::getReplyButton() . "\" border=\"0\" /></a>"; | |
| 66 | - $sToRender .= "</td><td width=30><a href=\"" . generateControllerLink("viewDiscussion", "fForDiscussion=1&fDocumentID=$iDocumentID") . "\"><img src=\"" . KTHtml::getBackButton() . "\" border=0 ><a></td></tr>\n"; | |
| 67 | - $sToRender .= "<tr><td width=\"1\" style=\"background-color:#F5F6EE;\" ><b>" . _("Subject") . ": </b></td><td width=405 style=\"background-color:#F5F6EE;\">"; | |
| 68 | - $sToRender .= $oComment->getSubject(); | |
| 69 | - $sToRender .= "</td><td colspan=2 nowrap style=\"background-color:#F5F6EE;\"><b>" . _("Date") . ": </b><font color=\"#056DCE\">" . $oComment->getDate() . "</font> </td></tr><tr><td colspan=4 valign=top>"; | |
| 70 | - $sToRender .= "<table border=0><tr><td>"; | |
| 71 | - $sToRender .= $sBody; | |
| 72 | - $sToRender .= "</td></tr></table>"; | |
| 73 | - $sToRender .= "</td>\n"; | |
| 74 | - | |
| 75 | - $sToRender .= "</tr></table> "; | |
| 76 | - | |
| 77 | - return $sToRender; | |
| 78 | -} | |
| 79 | -?> |
presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionBL.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * $Id$ | |
| 4 | - * | |
| 5 | - * View discussions. | |
| 6 | - * | |
| 7 | - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com | |
| 8 | - * | |
| 9 | - * This program is free software; you can redistribute it and/or modify | |
| 10 | - * it under the terms of the GNU General Public License as published by | |
| 11 | - * the Free Software Foundation; either version 2 of the License, or | |
| 12 | - * (at your option) any later version. | |
| 13 | - * | |
| 14 | - * This program is distributed in the hope that it will be useful, | |
| 15 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 17 | - * GNU General Public License for more details. | |
| 18 | - * | |
| 19 | - * You should have received a copy of the GNU General Public License | |
| 20 | - * along with this program; if not, write to the Free Software | |
| 21 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 22 | - * | |
| 23 | - * @version $Revision$ | |
| 24 | - * @author Omar Rahbeeni, Jam Warehouse (Pty) Ltd, South Africa | |
| 25 | - * @package discussions | |
| 26 | - */ | |
| 27 | - | |
| 28 | -require_once("../../../../config/dmsDefaults.php"); | |
| 29 | - | |
| 30 | -KTUtil::extractGPC('fDocumentID', 'fForDiscussion'); | |
| 31 | - | |
| 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/lib/visualpatterns/PatternCustom.inc"); | |
| 39 | -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternBrowsableSearchResults.inc"); | |
| 40 | -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListFromQuery.inc"); | |
| 41 | -require_once("$default->fileSystemRoot/lib/discussions/DiscussionThread.inc"); | |
| 42 | -require_once("$default->fileSystemRoot/lib/discussions/DiscussionComment.inc"); | |
| 43 | -require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/documentmanagement/documentUI.inc"); | |
| 44 | -require_once("$default->fileSystemRoot/presentation/Html.inc"); | |
| 45 | - | |
| 46 | -if (checkSession()) { | |
| 47 | - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | |
| 48 | - $oPatternCustom = & new PatternCustom(); | |
| 49 | - if (isset($fForDiscussion)) { | |
| 50 | - if (isset($fDocumentID)) { | |
| 51 | - $aDocumentThreads = DiscussionThread::getList(array("document_id = ? ORDER BY id", $fDocumentID));/*ok*/ | |
| 52 | - if (count($aDocumentThreads) > 0) { | |
| 53 | - // call the ui function to display the comments | |
| 54 | - $oPatternCustom->setHtml(getPage($fDocumentID, $aDocumentThreads)); | |
| 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(_("You did not specify a document.")); | |
| 61 | - } | |
| 62 | - } else { // If no discussion exists | |
| 63 | - $main->setErrorMessage(_("Invalid function. No such functionality exists for this page.")); | |
| 64 | - } | |
| 65 | - $main->setCentralPayload($oPatternCustom); | |
| 66 | - $main->render(); | |
| 67 | -} | |
| 68 | -?> |
presentation/lookAndFeel/knowledgeTree/discussions/viewDiscussionUI.inc deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * $Id$ | |
| 4 | - * | |
| 5 | - * View discussion UI functions. | |
| 6 | - * | |
| 7 | - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com | |
| 8 | - * | |
| 9 | - * This program is free software; you can redistribute it and/or modify | |
| 10 | - * it under the terms of the GNU General Public License as published by | |
| 11 | - * the Free Software Foundation; either version 2 of the License, or | |
| 12 | - * (at your option) any later version. | |
| 13 | - * | |
| 14 | - * This program is distributed in the hope that it will be useful, | |
| 15 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 17 | - * GNU General Public License for more details. | |
| 18 | - * | |
| 19 | - * You should have received a copy of the GNU General Public License | |
| 20 | - * along with this program; if not, write to the Free Software | |
| 21 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 22 | - * | |
| 23 | - * @version $Revision$ | |
| 24 | - * @author Omar Rahbeeni, Jam Warehouse (Pty) Ltd, South Africa | |
| 25 | - * @package discussions | |
| 26 | - */ | |
| 27 | - | |
| 28 | -function getPageButtons($iDocumentID){ | |
| 29 | - global $default; | |
| 30 | - $sToRender .= "<table width=100%><tr>\n"; | |
| 31 | - $sToRender .= "<td align=right width=100%><a href=\"" . generateControllerLink("addComment", "fDocumentID=$iDocumentID&fAddComment=1&fNewThread=1") . "\"><img src=\"" . KTHtml::getAddCommentButton() . "\" border=\"0\" /></a></td>\n"; | |
| 32 | - $sToRender .= "<td align=right width=10><a href=\"" . generateControllerLink("viewDocument", "fDocumentID=$iDocumentID&fAddComment=1") . "\"><img src=\"" . KTHtml::getBackButton() . "\" border=\"0\" /></a></td>\n"; | |
| 33 | - $sToRender .= "</tr></table>\n"; | |
| 34 | - return $sToRender; | |
| 35 | -} | |
| 36 | - | |
| 37 | -// If there are no threads to view for a document | |
| 38 | -function getViewFailPage($sMessage) { | |
| 39 | - global $default; | |
| 40 | - if ( strlen($sMessage)>0 ) { | |
| 41 | - $sToRender = $sMessage; | |
| 42 | - } else { | |
| 43 | - $sToRender = _("Current document has no discussion. Press the ADD button to start a discussion."); | |
| 44 | - } | |
| 45 | - return $sToRender; | |
| 46 | -} | |
| 47 | - | |
| 48 | -/** | |
| 49 | - * Page to create a new thread | |
| 50 | - * | |
| 51 | - * @param $iDocumentID -> a valid document ID | |
| 52 | - */ | |
| 53 | -function getNewThreadOption($iDocumentID) { | |
| 54 | - global $default; | |
| 55 | - $sToRender .= _("Would you like to create a new Discussion thread for this document?"); | |
| 56 | - $sToRender .= " "; | |
| 57 | - $sToRender .= "<a href=\"" . generateControllerLink("addComment", "fDocumentID=" . $iDocumentID . "&fNewThread=1") . "\"><img src=\"" . KTHtml::getNewButton() . "\" border=\"0\"></a>"; | |
| 58 | - $sToRender .= "<a href=\"" . generateControllerLink("viewDocument", "fDocumentID=" . $iDocumentID) . "\"><img src=\"" . KTHtml::getCancelButton() . "\" border=\"0\"></a>"; | |
| 59 | - return $sToRender; | |
| 60 | -} | |
| 61 | - | |
| 62 | -/** | |
| 63 | - * Views the list of comments for a document | |
| 64 | - * Prints out 1 comment | |
| 65 | - * User needs to call this function many times to list all comments | |
| 66 | - * | |
| 67 | - * @param $iNum -> its the iterative index of the current comment | |
| 68 | - * @param $iThread -> a valid Thread Object | |
| 69 | - * @param $oComment -> a valid Comment Object | |
| 70 | - */ | |
| 71 | -function getViewComment($iNum, $oThread, $oComment, $sIndent) { | |
| 72 | - global $default; | |
| 73 | - | |
| 74 | - $iSubjectChars = 59; | |
| 75 | - // If iNum is odd then highlight it | |
| 76 | - if (($iNum%2) == 1) $BGcolor = "#F5F6EE"; | |
| 77 | - if (($iNum%2) == 0) $UserBGcolor = "#F5F6EE"; | |
| 78 | - | |
| 79 | - $sUserName = ""; | |
| 80 | - $oUser = User::get($oComment->getUserID()); | |
| 81 | - if ($oUser) { | |
| 82 | - $sUserName = $oUser->getName(); | |
| 83 | - } | |
| 84 | - // If the Subject string is too long | |
| 85 | - if (strlen($oComment->getSubject())>$iSubjectChars ) $dotdot = " ..."; | |
| 86 | - | |
| 87 | - $sToRender .= "<tr>\n"; | |
| 88 | - $sToRender .= "\t<td style=\"background-color:$BGcolor\" width=450>\n"; | |
| 89 | - $sToRender .= "\t\t$sIndent<a href=\"" . generateControllerLink("viewComment", "fCommentID=" . $oComment->getID() . "&fDocumentID=" . $oThread->getDocumentID() . "&fThreadID=" . $oThread->getID()) . "\" title=\"" . $oComment->getSubject() . "\">\n"; | |
| 90 | - $sToRender .= substr($oComment->getSubject(),0,$iSubjectChars ) . $dotdot . "</a></td>\n"; | |
| 91 | - $sToRender .= "\t<td style=\"background-color:$UserBGcolor\" width=\"100\" title=\"$sUserName\">\n"; | |
| 92 | - $sToRender .= "\t\t$sUserName</td>\n"; | |
| 93 | - $sToRender .= "\t<td style=\"background-color:$BGcolor\" width=\"80\">" . $oComment->getDate() . "<td></tr>\n"; | |
| 94 | - | |
| 95 | - return $sToRender; | |
| 96 | -} | |
| 97 | - | |
| 98 | -/** | |
| 99 | - * Prints out the list of discussion comments | |
| 100 | - */ | |
| 101 | -function getPage($iDocumentID, $aDocumentThreads) { | |
| 102 | - global $default; | |
| 103 | - | |
| 104 | - $sToRender .= renderHeading(_("Document Discussion Comments")); | |
| 105 | - $sToRender .= displayDocumentPath($iDocumentID); | |
| 106 | - $sToRender .= getPageButtons($iDocumentID); | |
| 107 | - $sToRender .= "<table border=\"0\" width=\"100%\">\n"; | |
| 108 | - $sToRender .= "<tr>\n"; | |
| 109 | - $sToRender .= "<td><b>" . _("Subject") . "</b></td>\n"; | |
| 110 | - $sToRender .= "<td><b>" . _("Author") . "</b></td>\n"; | |
| 111 | - $sToRender .= "<td><b>" . _("Date") . "</b></td>\n"; | |
| 112 | - $sToRender .= "</tr>\n"; | |
| 113 | - | |
| 114 | - $iCount = 0; | |
| 115 | - // for each thread, retrieve all comments | |
| 116 | - for ($i=0; $i<count($aDocumentThreads); $i++) { | |
| 117 | - if ($aDocumentThreads[$i]) { | |
| 118 | - // get comment tree | |
| 119 | - $aCommentTree = getCommentTree($aDocumentThreads[$i]->getID(), -1); | |
| 120 | - // now loop through the comments, and indent comments that have the same reply_to at the same level .... ?? | |
| 121 | - for ($j=0; $j<count($aCommentTree); $j++) { | |
| 122 | - $default->log->info("commentTree[$j][comment]=" . arrayToString($aCommentTree[$j]["comment"])); | |
| 123 | - $sToRender .= getViewComment($iCount++, $aDocumentThreads[$i], $aCommentTree[$j]["comment"], getIndent($aCommentTree[$j]["level"])); | |
| 124 | - } | |
| 125 | - } | |
| 126 | - } | |
| 127 | - $sToRender .= "\n</table>\n\n"; | |
| 128 | - return $sToRender; | |
| 129 | -} | |
| 130 | -/** | |
| 131 | - * Returns the comments for a particular thread | |
| 132 | - */ | |
| 133 | -function getCommentTree($iThreadID, $iReplyTo, $iLevel = 0) { | |
| 134 | - global $default; | |
| 135 | - // find all comments for the specified thread and reply | |
| 136 | - $aWhereClause = array("thread_id = ? AND in_reply_to = ? ORDER BY id", array($iThreadID, $iReplyTo)); | |
| 137 | - $aComments = DiscussionComment::getList($aWhereClause);/*ok*/ | |
| 138 | - // loop through these and find their children | |
| 139 | - for ($i=0; $i<count($aComments); $i++) { | |
| 140 | - $aTree[] = array( "comment" => $aComments[$i], "level" => $iLevel); | |
| 141 | - $aChildren = getCommentTree($iThreadID, $aComments[$i]->getID(), $iLevel+1); | |
| 142 | - if (count($aChildren) > 0) { | |
| 143 | - $aTree = array_merge($aTree, $aChildren); | |
| 144 | - } | |
| 145 | - } | |
| 146 | - $default->log->debug("getCommentTree($iThreadID, $iReplyTo, $iLevel), returning " . arrayToString($aTree)); | |
| 147 | - return $aTree; | |
| 148 | -} | |
| 149 | - | |
| 150 | -/** | |
| 151 | - * Returns an indent string of appropriate length for the specified comment level | |
| 152 | - */ | |
| 153 | -function getIndent($iLevel) { | |
| 154 | - global $default; | |
| 155 | - $sToRender = ""; | |
| 156 | - for ($i=0; $i<$iLevel; $i++) { | |
| 157 | - $sToRender .= " "; | |
| 158 | - } | |
| 159 | - $default->log->info("indent($iLevel) = " . $sToRender); | |
| 160 | - return $sToRender; | |
| 161 | -} | |
| 162 | -?> |
templates/ktstandard/action/discussion.smarty
0 → 100644
| 1 | +{if $threads} | |
| 2 | +<h3>Existing threads</h3> | |
| 3 | +<table class="listing" cellspacing="0" cellpadding="0"> | |
| 4 | + <thead> | |
| 5 | + <tr> | |
| 6 | + <th>Subject</th> | |
| 7 | + <th>Creator</th> | |
| 8 | + <th>Views</th> | |
| 9 | + <th>Replies</th> | |
| 10 | + <th>Last activity</th> | |
| 11 | + </tr> | |
| 12 | + </thead> | |
| 13 | + <tbody> | |
| 14 | + {foreach from=$threads item=thread} | |
| 15 | + {$threadrenderer->render($context, $thread)} | |
| 16 | + {/foreach} | |
| 17 | + </tbody> | |
| 18 | +</table> | |
| 19 | +{else} | |
| 20 | + <p class="descriptiveText">There are no existing threads for this document</p> | |
| 21 | +{/if} | |
| 22 | + | |
| 23 | +<form method="POST" action="{$smarty.server.PHP_SELF}"> | |
| 24 | +<input type="hidden" name="action" value="newthread" /> | |
| 25 | +<input type="hidden" name="fDocumentId" value="{$context->oDocument->getId()}" /> | |
| 26 | +<fieldset><legend>Create a new thread</legend> | |
| 27 | +{foreach from=$fields item=oWidget} | |
| 28 | + {$oWidget->render()} | |
| 29 | +{/foreach} | |
| 30 | + | |
| 31 | +<div class="form_actions "> | |
| 32 | + <input type="submit" name="submit" value="Create a new thread"> | |
| 33 | +</div> | |
| 34 | +</fieldset> | |
| 35 | +</form> | ... | ... |
templates/ktstandard/action/discussion_comment_list_item.smarty
0 → 100644
| 1 | +{capture assign=sCSS}{literal} | |
| 2 | +dl.kt-discussion-comment > dt { | |
| 3 | + font-weight: bold; | |
| 4 | +} | |
| 5 | + | |
| 6 | +.kt-discussion-post-link { | |
| 7 | + font-size: smaller; | |
| 8 | +} | |
| 9 | +{/literal}{/capture} | |
| 10 | +{$context->oPage->requireCSSStandalone($sCSS)} | |
| 11 | + | |
| 12 | +<dl class="kt-discussion-comment"> | |
| 13 | + <dt>Posted</dt> | |
| 14 | + <dd>by {$creator->getName()} at {$comment->getDate()}</dd> | |
| 15 | + <dt>Subject</dt> | |
| 16 | + <dd>{$comment->getSubject()}</dd> | |
| 17 | + | |
| 18 | + <dt>Body</dt> | |
| 19 | + <dd>{$comment->getBody()}</dd> | |
| 20 | +</dl> | |
| 21 | + | |
| 22 | +<a class="kt-discussion-post-link" href="#kt-discussion-post">Post a reply</a> | ... | ... |
templates/ktstandard/action/discussion_thread.smarty
0 → 100644
| 1 | +{foreach from=$thread->getCommentsSortedByDate() item=oComment} | |
| 2 | + {$commentrenderer->render($context, $oComment)} | |
| 3 | +{/foreach} | |
| 4 | + | |
| 5 | +<form method="POST" action="{$smarty.server.PHP_SELF}"> | |
| 6 | +<input type="hidden" name="action" value="postreply" /> | |
| 7 | +<input type="hidden" name="fDocumentId" value="{$context->oDocument->getId()}" /> | |
| 8 | +<input type="hidden" name="fThreadId" value="{$thread->getId()}" /> | |
| 9 | +<fieldset><legend>Post a reply</legend> | |
| 10 | +<a name="kt-discussion-post"></a> | |
| 11 | +{foreach from=$fields item=oWidget} | |
| 12 | + {$oWidget->render()} | |
| 13 | +{/foreach} | |
| 14 | + | |
| 15 | +<div class="form_actions "> | |
| 16 | + <input type="submit" name="submit" value="Post a reply" /> | |
| 17 | +</div> | |
| 18 | +</fieldset> | |
| 19 | +</form> | ... | ... |
templates/ktstandard/action/discussion_thread_list_item.smarty
0 → 100644
| 1 | +<tr> | |
| 2 | + <td><a href="?action=viewThread&fDocumentId={$context->oDocument->getId()}&fThreadId={$thread->getId()}">{$first_comment->getSubject()}</a></td> | |
| 3 | + <td>{$creator->getName()}</td> | |
| 4 | + <td>{$thread->getNumberOfViews()}</td> | |
| 5 | + <td>{$thread->getNumberOfReplies()}</td> | |
| 6 | + <td>{$last_comment->getDate()}</td> | |
| 7 | +</tr> | ... | ... |