diff --git a/edit.php b/edit.php index a3a74a8..76698e1 100644 --- a/edit.php +++ b/edit.php @@ -83,9 +83,18 @@ class KTEditDocumentDispatcher extends KTStandardDispatcher { $this->addBreadcrumbs(); $this->oPage->setBreadcrumbDetails(_('Change Document Type')); - $oDocumentType = DocumentType::get($oDocument->getDocumentTypeID()); $aDocTypes = DocumentType::getList(); - + + + $aDocTypes = array(); + foreach (DocumentType::getList() as $oDocumentType) { + if(!$oDocumentType->getDisabled()) { + $aDocTypes[] = $oDocumentType; + } + } + + $oDocumentType = DocumentType::get($oDocument->getDocumentTypeID()); + $oTemplating =& KTTemplating::getSingleton(); $oTemplate =& $oTemplating->loadTemplate("ktcore/document/change_type"); $aTemplateData = array( diff --git a/lib/dashboard/Notification.inc.php b/lib/dashboard/Notification.inc.php index 55c7f17..b861066 100644 --- a/lib/dashboard/Notification.inc.php +++ b/lib/dashboard/Notification.inc.php @@ -201,6 +201,7 @@ class KTSubscriptionNotification extends KTNotificationHandler { // resolve the object type based on the alert type. function _getEventObject($sAlertType, $id) { $t = KTUtil::arrayGet($this->_eventObjectMap, $sAlertType ,''); + if ($t == 'document') { $o = Document::get($id); if (PEAR::isError($o) || ($o == false)) { return null; @@ -283,6 +284,7 @@ class KTSubscriptionNotification extends KTNotificationHandler { $info = $this->_getSubscriptionData($oKTNotification); $object_type = $this->_getEventObjectType($info['event_type']); + if ($object_type == '') { $_SESSION['KTErrorMessage'][] = 'This notification has no "target". Please report as a bug that this subscription should only have a clear action.' . $object_type; exit(redirect(generateControllerLink('dashboard'))); diff --git a/lib/documentmanagement/DocumentType.inc b/lib/documentmanagement/DocumentType.inc index d919492..f8f611f 100644 --- a/lib/documentmanagement/DocumentType.inc +++ b/lib/documentmanagement/DocumentType.inc @@ -30,10 +30,13 @@ class DocumentType extends KTEntity { var $iId; /** document type name */ var $sName; + /** disabled boolean */ + var $bDisabled; var $_aFieldToSelect = array( 'iId' => 'id', 'sName' => 'name', + 'bDisabled' => 'disabled' ); /** @@ -47,6 +50,7 @@ class DocumentType extends KTEntity { //object not created yet $this->iId = -1; $this->sName = $sNewName; + $this->bDisabled = false; } /** @@ -79,9 +83,36 @@ class DocumentType extends KTEntity { $this->sName = $sNewValue; } + + + /** + * Get the document type's disabled status + * + * @return Boolean document type's disabled status + * + */ + function getDisabled() { + return $this->bDisabled; + } + + /** + * Set the document type's disabled status + * + * @param document type's new disabled status + * + */ + function setDisabled($bNewValue) { + $this->bDisabled = ($bNewValue) ? true : false; + } + + + + + function _fieldValues () { return array( 'name' => $this->sName, + 'disabled' => $this->bDisabled, ); } @@ -155,6 +186,7 @@ class DocumentType extends KTEntity { if ($sql->next_record()) { $oDocumentType = & new DocumentType($sql->f("name")); $oDocumentType->iId = $sql->f("id"); + $oDocumentType->bDisabled = $sql->f("disabled"); return $oDocumentType; } $_SESSION["errorMessage"] = $lang_err_object_not_exist . "id = " . $iDocumentID . " table = document_types"; diff --git a/lib/subscriptions/subscriptions.inc.php b/lib/subscriptions/subscriptions.inc.php index 38560f7..cbe08f5 100644 --- a/lib/subscriptions/subscriptions.inc.php +++ b/lib/subscriptions/subscriptions.inc.php @@ -291,7 +291,7 @@ class SubscriptionEvent { } } } - function CheckinDocument($oModifiedDocument, $oParentFolder) { + function CheckInDocument($oModifiedDocument, $oParentFolder) { $content = new SubscriptionContent(); // needed for i18n // OK: two actions: document registrants, folder registrants. $aUsers = $this->_getSubscribers($oModifiedDocument->getId(), $this->subscriptionTypes["Document"]); @@ -305,7 +305,7 @@ class SubscriptionEvent { $aNotificationOptions['target_name'] = $oModifiedDocument->getName(); $aNotificationOptions['location_name'] = $oParentFolder->getName(); $aNotificationOptions['object_id'] = $oModifiedDocument->getId(); // parent folder_id, in this case. - $aNotificationOptions['event_type'] = "CheckinDocument"; + $aNotificationOptions['event_type'] = "CheckInDocument"; $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); // now the email content. @@ -330,7 +330,7 @@ class SubscriptionEvent { $aNotificationOptions['target_name'] = $oModifiedDocument->getName(); $aNotificationOptions['location_name'] = $oParentFolder->getName(); $aNotificationOptions['object_id'] = $oModifiedDocument->getId(); // parent folder_id, in this case. - $aNotificationOptions['event_type'] = "CheckinDocument"; + $aNotificationOptions['event_type'] = "CheckInDocument"; $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); // now the email content. @@ -344,7 +344,7 @@ class SubscriptionEvent { } } } - function CheckoutDocument($oModifiedDocument, $oParentFolder) { + function CheckOutDocument($oModifiedDocument, $oParentFolder) { $content = new SubscriptionContent(); // needed for i18n // OK: two actions: document registrants, folder registrants. $aUsers = $this->_getSubscribers($oModifiedDocument->getId(), $this->subscriptionTypes["Document"]); @@ -358,7 +358,7 @@ class SubscriptionEvent { $aNotificationOptions['target_name'] = $oModifiedDocument->getName(); $aNotificationOptions['location_name'] = $oParentFolder->getName(); $aNotificationOptions['object_id'] = $oModifiedDocument->getId(); // parent folder_id, in this case. - $aNotificationOptions['event_type'] = "CheckoutDocument"; + $aNotificationOptions['event_type'] = "CheckOutDocument"; $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); // now the email content. @@ -383,7 +383,7 @@ class SubscriptionEvent { $aNotificationOptions['target_name'] = $oModifiedDocument->getName(); $aNotificationOptions['location_name'] = $oParentFolder->getName(); $aNotificationOptions['object_id'] = $oModifiedDocument->getId(); // parent folder_id, in this case. - $aNotificationOptions['event_type'] = "CheckoutDocument"; + $aNotificationOptions['event_type'] = "CheckOutDocument"; $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); // now the email content. diff --git a/lib/validation/dispatchervalidation.inc.php b/lib/validation/dispatchervalidation.inc.php index 94c4338..00b7ef0 100644 --- a/lib/validation/dispatchervalidation.inc.php +++ b/lib/validation/dispatchervalidation.inc.php @@ -40,7 +40,8 @@ class KTDispatcherValidation { $aFunc = array($entity_name, KTUtil::arrayGet($aOptions, 'method', 'get')); $oEntity =& call_user_func($aFunc, $iId); if (PEAR::isError($oEntity) || ($oEntity === false)) { - $this->oDispatcher->errorPage(sprintf(_("Invalid identifier provided for: %s"), $entity_name)); + $aOptions['message'] = KTUtil::arrayGet($aOptions, 'message', sprintf(_("Invalid identifier provided for: %s"), $entity_name)); + $this->handleError($aOptions); } return $oEntity; } diff --git a/plugins/ktcore/admin/documentTypes.php b/plugins/ktcore/admin/documentTypes.php index b3e1b00..5187fcc 100755 --- a/plugins/ktcore/admin/documentTypes.php +++ b/plugins/ktcore/admin/documentTypes.php @@ -62,6 +62,36 @@ class KTDocumentTypeDispatcher extends KTAdminDispatcher { exit(0); } + function do_disable() { + $oDocumentType =& DocumentType::get($_REQUEST['fDocumentTypeId']); + + $oDocumentType->setDisabled(true); + $res = $oDocumentType->update(); + + if (PEAR::isError($res) || ($res === false)) { + $this->errorRedirectTo('main', _('Could not disable document type'), 'fDocumentTypeId=' . $oDocumentType->getId()); + exit(0); + } + + $this->successRedirectToMain(_('Document type disabled')); + exit(0); + } + + function do_enable() { + $oDocumentType =& DocumentType::get($_REQUEST['fDocumentTypeId']); + + $oDocumentType->setDisabled(false); + $res = $oDocumentType->update(); + + if (PEAR::isError($res) || ($res === false)) { + $this->errorRedirectTo('main', _('Could not enable document type'), 'fDocumentTypeId=' . $oDocumentType->getId()); + exit(0); + } + + $this->successRedirectToMain(_('Document type enabled')); + exit(0); + } + function do_edit() { $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _('Document Type Management')); diff --git a/plugins/ktcore/folder/BulkImport.php b/plugins/ktcore/folder/BulkImport.php index 5f8fe7e..75b288f 100644 --- a/plugins/ktcore/folder/BulkImport.php +++ b/plugins/ktcore/folder/BulkImport.php @@ -25,10 +25,13 @@ class KTBulkImportFolderAction extends KTFolderAction { $add_fields = array(); $add_fields[] = new KTStringWidget(_('Path'), _('The path containing the documents to be added to the document management system.'), 'path', "", $this->oPage, true); - $aVocab = array(); + $aVocab = array('' => _('<Please select a document type>')); foreach (DocumentType::getList() as $oDocumentType) { - $aVocab[$oDocumentType->getId()] = $oDocumentType->getName(); + if(!$oDocumentType->getDisabled()) { + $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); diff --git a/plugins/ktcore/folder/BulkUpload.php b/plugins/ktcore/folder/BulkUpload.php index eec552d..63662c1 100644 --- a/plugins/ktcore/folder/BulkUpload.php +++ b/plugins/ktcore/folder/BulkUpload.php @@ -40,9 +40,11 @@ class KTBulkUploadFolderAction extends KTFolderAction { $add_fields = array(); $add_fields[] = new KTFileUploadWidget(_('Archive file'), _('The archive file containing the documents you wish to add to the document management system.'), 'file', "", $this->oPage, true); - $aVocab = array(); + $aVocab = array('' => _('<Please select a document type>')); foreach (DocumentType::getList() as $oDocumentType) { - $aVocab[$oDocumentType->getId()] = $oDocumentType->getName(); + if(!$oDocumentType->getDisabled()) { + $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); diff --git a/plugins/ktcore/folder/addDocument.php b/plugins/ktcore/folder/addDocument.php index 0a657aa..171e636 100644 --- a/plugins/ktcore/folder/addDocument.php +++ b/plugins/ktcore/folder/addDocument.php @@ -44,10 +44,13 @@ class KTFolderAddDocumentAction extends KTFolderAction { $add_fields[] = new KTStringWidget(_('Title'), _('The document title is used as the main name of a document throughout KnowledgeTree.'), 'title', "", $this->oPage, true); - $aVocab = array(); + $aVocab = array('' => _('<Please select a document type>')); foreach (DocumentType::getList() as $oDocumentType) { - $aVocab[$oDocumentType->getId()] = $oDocumentType->getName(); + if(!$oDocumentType->getDisabled()) { + $aVocab[$oDocumentType->getId()] = $oDocumentType->getName(); + } } + $fieldOptions = array("vocab" => $aVocab); $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); @@ -96,7 +99,8 @@ class KTFolderAddDocumentAction extends KTFolderAction { } } - $this->oDocumentType = $this->oValidator->validateDocumentType($_REQUEST['fDocumentTypeId']); + $aErrorOptions['message'] = _("Please select a valid document type"); + $this->oDocumentType = $this->oValidator->validateDocumentType($_REQUEST['fDocumentTypeId'], $aErrorOptions); $aOptions = array( 'contents' => new KTFSFileLike($aFile['tmp_name']), diff --git a/plugins/ktstandard/KTDiscussion.php b/plugins/ktstandard/KTDiscussion.php index 3af7769..7cc8b06 100644 --- a/plugins/ktstandard/KTDiscussion.php +++ b/plugins/ktstandard/KTDiscussion.php @@ -130,6 +130,7 @@ class KTDocumentDiscussionAction extends KTDocumentAction { $iCommentId = $oThread->getFirstCommentId(); $oComment = DiscussionComment::get($iCommentId); + // breadcrumbs... $this->aBreadcrumbs[] = array( 'name' => _('discussion'), 'url' => $_SERVER['PHP_SELF'] . sprintf('?fDocumentId=%d', $this->oDocument->getId()), @@ -138,6 +139,7 @@ class KTDocumentDiscussionAction extends KTDocumentAction { 'name' => $oComment->getSubject(), ); $this->oPage->setBreadcrumbDetails(_("viewing comments")); + $oTemplate =& $this->oValidator->validateTemplate('ktstandard/action/discussion_thread'); // Fields for new thread creation @@ -153,6 +155,10 @@ class KTDocumentDiscussionAction extends KTDocumentAction { 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)); } + + // increment views + $oThread->incrementNumberOfViews(); + $oThread->update(); $aTemplateData = array( 'context' => &$this, @@ -190,6 +196,7 @@ class KTDocumentDiscussionAction extends KTDocumentAction { // Start the transaction comment creation $this->startTransaction(); + // Create comment $oComment = DiscussionComment::createFromArray(array( 'threadid' => $oThread->getId(), 'userid' => $this->oUser->getId(), @@ -199,11 +206,17 @@ class KTDocumentDiscussionAction extends KTDocumentAction { $aErrorOptions['message'] = _("There was an error adding the comment to the thread"); $this->oValidator->notError($oComment, $aErrorOptions); + // Update thread $oThread->setLastCommentId($oComment->getId()); + $oThread->incrementNumberOfReplies(); + $res = $oThread->update(); + $aErrorOptions['message'] = _("There was an error updating the thread with the new comment"); $this->oValidator->notError($res, $aErrorOptions); + + // Thread and comment created correctly, commit to database $this->commitTransaction(); diff --git a/resources/css/kt-framing.css b/resources/css/kt-framing.css index 921cd93..91eee64 100644 --- a/resources/css/kt-framing.css +++ b/resources/css/kt-framing.css @@ -341,6 +341,24 @@ a.main_nav_item { font-weight: normal; } +#content a.ktCancelLink { + border: 1px solid #888; + background: #eee; + color: black; + font-weight: normal; + font-size: 90%; + padding: 2px 0.65em 1px 0.65em; + text-transform: lowercase; + text-decoration: none; +} + +#content a.ktCancelLink:hover { + color: black; + text-decoration: none; + border: 1px solid #888; + cursor: default; +} + #content .field { margin-bottom: 1.5em; @@ -656,7 +674,8 @@ The text will be hidden for screen view. The generic fahrner-ish approach comes width: 16px; cursor: pointer; } - + + /* FIXME when available icon-naming-conformant sets have better coverage, make these more accurate. */ .ktAction.ktDelete { background: transparent url(../../thirdparty/icon-theme/16x16/mimetypes/x-directory-trash.png) top left no-repeat; } .ktAction.ktEdit { background: transparent url(../../thirdparty/icon-theme/16x16/actions/document-properties.png) top left no-repeat; } diff --git a/sql/mysql/install/structure.sql b/sql/mysql/install/structure.sql index 6078817..7bbeef6 100644 --- a/sql/mysql/install/structure.sql +++ b/sql/mysql/install/structure.sql @@ -414,6 +414,7 @@ CREATE TABLE `document_type_fieldsets_link` ( CREATE TABLE `document_types_lookup` ( `id` int(11) NOT NULL default '0', `name` char(100) default NULL, + `disabled` int(1) NOT NULL default '0', UNIQUE KEY `id` (`id`), UNIQUE KEY `name` (`name`) ) TYPE=InnoDB; diff --git a/templates/kt3/notifications/subscriptions.CheckinDocument.smarty b/templates/kt3/notifications/subscriptions.CheckInDocument.smarty index 97de650..97de650 100644 --- a/templates/kt3/notifications/subscriptions.CheckinDocument.smarty +++ b/templates/kt3/notifications/subscriptions.CheckInDocument.smarty diff --git a/templates/kt3/notifications/subscriptions.CheckoutDocument.smarty b/templates/kt3/notifications/subscriptions.CheckOutDocument.smarty index b18484b..b18484b 100644 --- a/templates/kt3/notifications/subscriptions.CheckoutDocument.smarty +++ b/templates/kt3/notifications/subscriptions.CheckOutDocument.smarty diff --git a/templates/ktcore/document/admin/deletedlist.smarty b/templates/ktcore/document/admin/deletedlist.smarty index 061f262..0b16ba3 100644 --- a/templates/ktcore/document/admin/deletedlist.smarty +++ b/templates/ktcore/document/admin/deletedlist.smarty @@ -1,3 +1,9 @@ +{$context->oPage->requireJSResource('thirdpartyjs/MochiKit/Base.js')} +{$context->oPage->requireJSResource('thirdpartyjs/MochiKit/Iter.js')} +{$context->oPage->requireJSResource('thirdpartyjs/MochiKit/DOM.js')} + +{$context->oPage->requireJSResource('resources/js/toggleselect.js')} +
{i18n}Documents which are deleted by users are hidden from view @@ -5,10 +11,6 @@ but still available for restoration. Since "soft deletes" consume system resour is possible to expunge these documents. Alternatively, you can restore them as necessary.{/i18n}
-FIXME its probably very useful to add -more information about the documents below - e.g. when was it deleted (last modified?)
- -FIXME Have a "select all" toggler here.
{if (!empty($documents))} @@ -16,18 +18,20 @@ more information about the documents below - e.g. when was it deleted (last modi -| + | {i18n}Document Name{/i18n} | +{i18n}Last Modification{/i18n} | ||
|---|---|---|---|---|
| {$oDoc->getName()} | +{$oDoc->getLastModifiedDate()} | |||
| {i18n}Document Type{/i18n} | +{i18n}Document Type{/i18n} | |||
|---|---|---|---|---|
| -{ if $oDocumentType->isUsed() } - -{ else } -{i18n}Delete Type{/i18n} -{/if} + | ||||
| + { $oDocumentType->getName() } + | +- { $oDocumentType->getName() } - - | +{if $oDocumentType->getDisabled()} + {i18n}Enable{/i18n} +{else} + {i18n}Disable{/i18n} +{/if} + | + + + {/foreach}||