diff --git a/lib/discussions/DiscussionThread.inc b/lib/discussions/DiscussionThread.inc index 15865ec..d39d2ca 100644 --- a/lib/discussions/DiscussionThread.inc +++ b/lib/discussions/DiscussionThread.inc @@ -32,6 +32,9 @@ class DiscussionThread extends KTEntity{ var $iLastCommentId = -1; var $iNumberOfViews = 0; var $iNumberOfReplies = 0; + var $iState = 0; + var $iCloseMetadataVersion = 0; + var $sCloseReason = ""; var $iCreatorId; var $_aFieldToSelect = array( @@ -41,6 +44,9 @@ class DiscussionThread extends KTEntity{ 'iLastCommentId' => 'last_comment_id', 'iNumberOfViews' => 'views', 'iNumberOfReplies' => 'replies', + 'iState' => 'state', + 'iCloseMetadataVersion' => 'close_metadata_version', + 'sCloseReason' => 'close_reason', 'iCreatorId' => 'creator_id', ); @@ -71,7 +77,14 @@ class DiscussionThread extends KTEntity{ function getNumberOfReplies(){ return $this->iNumberOfReplies; } function incrementNumberOfReplies(){ $this->iNumberOfReplies += 1; } function setNumberOfReplies($iValue){ $this->iNumberOfReplies = $iValue; } - + function getState(){ return $this->iState; } + function setState($iValue){ $this->iState = $iValue; } + function getCloseMetadataVersion(){ return $this->iCloseMetadataVersion; } + function setCloseMetadataVersion($iValue){ $this->iCloseMetadataVersion = $iValue; } + function getCloseReason(){ return $this->sCloseReason; } + function setCloseReason($sValue){ $this->sCloseReason = $sValue; } + + /** * Get a All commentId's seperated by a comma "," */ diff --git a/plugins/ktcore/folder/addDocument.php b/plugins/ktcore/folder/addDocument.php index a3a4a11..0a657aa 100644 --- a/plugins/ktcore/folder/addDocument.php +++ b/plugins/ktcore/folder/addDocument.php @@ -49,7 +49,7 @@ class KTFolderAddDocumentAction extends KTFolderAction { $aVocab[$oDocumentType->getId()] = $oDocumentType->getName(); } $fieldOptions = array("vocab" => $aVocab); - $add_fields[] = new KTLookupWidget(_('Document Type'), 'FIXME', 'fDocumentTypeId', null, $this->oPage, true, "add-document-type", $fieldErrors, $fieldOptions); + $add_fields[] = new KTLookupWidget(_('Document Type'), _('Document Types, defined by the administrator, are used to categorise documents. Please select a Document Type from the list below.'), 'fDocumentTypeId', null, $this->oPage, true, "add-document-type", $fieldErrors, $fieldOptions); $fieldsets = array(); $fieldsetDisplayReg =& KTFieldsetDisplayRegistry::getSingleton(); diff --git a/plugins/ktstandard/KTDiscussion.php b/plugins/ktstandard/KTDiscussion.php index 16303be..3af7769 100644 --- a/plugins/ktstandard/KTDiscussion.php +++ b/plugins/ktstandard/KTDiscussion.php @@ -40,12 +40,13 @@ class KTDiscussionThreadListRenderer { } class KTCommentListRenderer { - function render($context, $oComment) { + function render($context, $oComment, $oThread) { $this->oComment = $oComment; $oTemplate = $context->oValidator->validateTemplate('ktstandard/action/discussion_comment_list_item'); $oCreator = User::get($oComment->getUserId()); $oTemplate->setData(array( 'comment' => $oComment, + 'state' => $oThread->getState(), 'creator' => $oCreator, 'context' => $context, )); @@ -138,17 +139,29 @@ class KTDocumentDiscussionAction extends KTDocumentAction { ); $this->oPage->setBreadcrumbDetails(_("viewing comments")); $oTemplate =& $this->oValidator->validateTemplate('ktstandard/action/discussion_thread'); + // Fields for new thread creation - $fields = array(); - $fields[] = new KTStringWidget(_("Subject"), _("The topic of discussion in this thread"), "subject", "", $this->oPage, true); - $fields[] = new KTTextWidget(_("Body"), _("Your contribution to the discussion in this thread"), "body", "", $this->oPage, true, null, null, array("cols" => 50, "rows" => 10)); + $replyFields = array(); + $replyFields[] = new KTStringWidget(_("Subject"), _("The topic of discussion in this thread"), "subject", "", $this->oPage, true); + $replyFields[] = new KTTextWidget(_("Body"), _("Your contribution to the discussion in this thread"), "body", "", $this->oPage, true, null, null, array("cols" => 50, "rows" => 10)); + + // Fields for closing thread (if user has write permission) + $closeFields = array(); + + $oPermission =& KTPermission::getByName('ktcore.permissions.write'); + if (PEAR::isError($oPermission) || + KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPermission, $this->oDocument)) { + $closeFields[] = new KTTextWidget(_("Reason"), _("Describe the reason for closing this thread"), "reason", "", $this->oPage, true, null, null, array("cols" => 50, "rows" => 5)); + } $aTemplateData = array( 'context' => &$this, - 'fields' => $fields, + 'replyfields' => $replyFields, + 'closefields' => $closeFields, 'thread' => $oThread, 'commentrenderer' => new KTCommentListRenderer(), ); + return $oTemplate->render($aTemplateData); } @@ -197,4 +210,50 @@ class KTDocumentDiscussionAction extends KTDocumentAction { $this->successRedirectTo('viewThread', _("Reply posted"), sprintf('fDocumentId=%d&fThreadId=%d', $this->oDocument->getId(), $oThread->getId())); exit(0); } + + function do_closethread() { + $aErrorOptions = array( + 'redirect_to' => array('main', sprintf('fDocumentId=%d', $this->oDocument->getId())), + ); + + $iThreadId = KTUtil::arrayGet($_REQUEST, 'fThreadId'); + $oThread = DiscussionThread::get($iThreadId); + + $this->oValidator->notError($oThread, $aErrorOptions); + + $aErrorOptions = array( + 'redirect_to' => array('viewthread', sprintf('fDocumentId=%d&fThreadId=%d', $this->oDocument->getId(), $oThread->getId())), + ); + + $oPermission =& KTPermission::getByName('ktcore.permissions.write'); + + if (PEAR::isError($oPermission)) { + $this->errorRedirectTo(implode('&', $aErrorOptions['redirect_to']), _("Error getting permission")); + } + if (!KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPermission, $this->oDocument)) { + $this->errorRedirectTo(implode('&', $aErrorOptions['redirect_to']), _("You do not have permission to close this thread")); + } + + $aErrorOptions['message'] = _("No reason provided"); + $sReason = KTUtil::arrayGet($_REQUEST, 'reason'); + $sReason = $this->oValidator->validateString($sReason, $aErrorOptions); + + // Start the transaction comment creation + $this->startTransaction(); + + $oThread->setState(1); + $oThread->setCloseMetadataVersion($this->oDocument->getMetadataVersion()); + $oThread->setCloseReason($sReason); + $res = $oThread->update(); + + $aErrorOptions['message'] = _("There was an error updating the thread with the new comment"); + $this->oValidator->notError($res, $aErrorOptions); + + // Thread closed correctly, so commit + $this->commitTransaction(); + + $this->successRedirectTo('viewThread', _("Thread closed"), sprintf('fDocumentId=%d&fThreadId=%d', $this->oDocument->getId(), $oThread->getId())); + exit(0); + } + } diff --git a/preferences.php b/preferences.php index acce037..8b06a9d 100644 --- a/preferences.php +++ b/preferences.php @@ -75,9 +75,9 @@ class PreferencesDispatcher extends KTStandardDispatcher { $confirm_password = KTUtil::arrayGet($_REQUEST, 'confirm_password'); if (empty($password)) { - $this->errorRedirect("setPassword", _("You must specify a password.")); + $this->errorRedirectTo("setPassword", _("You must specify a password.")); } else if ($password !== $confirm_password) { - $this->errorRedirect("setPassword", _("The passwords you specified do not match.")); + $this->errorRedirectTo("setPassword", _("The passwords you specified do not match.")); } $KTConfig =& KTConfig::getSingleton(); diff --git a/sql/mysql/install/structure.sql b/sql/mysql/install/structure.sql index a54a7e8..a3bf9b1 100644 --- a/sql/mysql/install/structure.sql +++ b/sql/mysql/install/structure.sql @@ -190,6 +190,9 @@ CREATE TABLE `discussion_threads` ( `last_comment_id` int(11) NOT NULL default '0', `views` int(11) NOT NULL default '0', `replies` int(11) NOT NULL default '0', + `state` int(1) NOT NULL default '0', + `close_metadata_version` int(11) NOT NULL default '0', + `close_reason` text NOT NULL default '', `creator_id` int(11) NOT NULL default '0', UNIQUE KEY `id` (`id`) ) TYPE=InnoDB ; @@ -431,7 +434,7 @@ CREATE TABLE `documents` ( `description` varchar(200) NOT NULL default '', `security` int(11) NOT NULL default '0', `mime_id` int(11) NOT NULL default '0', - `folder_id` int(11) NOT NULL default '0', + `folder_id` int(11) default '1', `major_version` int(11) NOT NULL default '0', `minor_version` int(11) NOT NULL default '0', `is_checked_out` tinyint(1) NOT NULL default '0', @@ -841,6 +844,18 @@ CREATE TABLE `organisations_lookup` ( -- -------------------------------------------------------- +CREATE TABLE `plugins` ( + `id` int(11) NOT NULL default '0', + `namespace` varchar(255) NOT NULL default '', + `path` varchar(255) NOT NULL default '', + `version` int(11) NOT NULL default '0', + `disabled` tinyint(1) NOT NULL default '0', + `data` text, + PRIMARY KEY (`id`), + KEY `name` (`namespace`) +) ENGINE=InnoDB; + + -- -- Table structure for table `permission_assignments` -- @@ -2135,6 +2150,15 @@ CREATE TABLE `zseq_workflows` ( PRIMARY KEY (`id`) ) TYPE=MyISAM ; + +CREATE TABLE `zseq_plugins` ( + `id` int(10) unsigned NOT NULL auto_increment, + PRIMARY KEY (`id`) +) ENGINE=MyISAM; + + + + -- -- Constraints for dumped tables -- diff --git a/templates/ktstandard/action/discussion.smarty b/templates/ktstandard/action/discussion.smarty index 6ec5912..134c0ad 100644 --- a/templates/ktstandard/action/discussion.smarty +++ b/templates/ktstandard/action/discussion.smarty @@ -8,6 +8,7 @@