From 8fd00e2f7743b657a16d3786a2b93fd4aa27b4fa Mon Sep 17 00:00:00 2001 From: bshuttle Date: Wed, 13 Sep 2006 11:23:11 +0000 Subject: [PATCH] Fix for KTS-1336: Copy doesn't appear in transaction history. --- docs/VERSION.txt | 2 +- lib/documentmanagement/documentutil.inc.php | 14 +++++++++++++- plugins/ktcore/KTDocumentActions.php | 10 +++++----- sql/mysql/upgrade/3.1.6.6/copy_transaction.sql | 8 ++++++++ 4 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 sql/mysql/upgrade/3.1.6.6/copy_transaction.sql diff --git a/docs/VERSION.txt b/docs/VERSION.txt index 598264a..1e42fa4 100644 --- a/docs/VERSION.txt +++ b/docs/VERSION.txt @@ -1 +1 @@ -3.1.6.5 +3.1.6.6 diff --git a/lib/documentmanagement/documentutil.inc.php b/lib/documentmanagement/documentutil.inc.php index ffd96c6..f123f77 100644 --- a/lib/documentmanagement/documentutil.inc.php +++ b/lib/documentmanagement/documentutil.inc.php @@ -767,7 +767,7 @@ class KTDocumentUtil { } - function copy($oDocument, $oDestinationFolder) { + function copy($oDocument, $oDestinationFolder, $sReason = null) { // 1. generate a new triad of content, metadata and core objects. // 2. update the storage path. //print '--------------------------------- BEFORE'; @@ -852,6 +852,18 @@ class KTDocumentUtil { KTDocumentUtil::updateSearchableText($oNewDocument); KTPermissionUtil::updatePermissionLookup($oNewDocument); + if (is_null($sReason)) { + $sReason = ''; + } + + + $oDocumentTransaction = & new DocumentTransaction($oDocument, sprintf("Copied to folder \"%s\". %s", $oDestinationFolder->getName(), $sReason), 'ktcore.transactions.copy'); + $oDocumentTransaction->create(); + + $oSrcFolder = Folder::get($oDocument->getFolderID()); + $oDocumentTransaction = & new DocumentTransaction($oNewDocument, sprintf("Copied from original in folder \"%s\". %s", $oSrcFolder->getName(), $sReason), 'ktcore.transactions.copy'); + $oDocumentTransaction->create(); + return $oNewDocument; } diff --git a/plugins/ktcore/KTDocumentActions.php b/plugins/ktcore/KTDocumentActions.php index ee9545d..f70796a 100644 --- a/plugins/ktcore/KTDocumentActions.php +++ b/plugins/ktcore/KTDocumentActions.php @@ -605,7 +605,7 @@ class KTDocumentCancelCheckOutAction extends KTDocumentAction { 'action' => 'checkin', 'fail_action' => 'main', 'cancel_url' => KTBrowseUtil::getUrlForDocument($this->oDocument), - 'submit_label' => _kt("Cancel Checkin"), + 'submit_label' => _kt("Cancel Checkout"), 'context' => &$this, )); $oForm->setWidgets(array( @@ -1143,7 +1143,7 @@ class KTDocumentCopyAction extends KTDocumentAction { } } - $oNewDoc = KTDocumentUtil::copy($this->oDocument, $this->oFolder); + $oNewDoc = KTDocumentUtil::copy($this->oDocument, $this->oFolder, $sReason); if (PEAR::isError($oNewDoc)) { $this->errorRedirectTo("main", _kt("Failed to copy document: ") . $oNewDoc->getMessage(), sprintf("fDocumentId=%d&fFolderId=%d", $this->oDocument->getId(), $this->oFolder->getId())); exit(0); @@ -1179,9 +1179,9 @@ class KTDocumentCopyAction extends KTDocumentAction { $ret = $oTrigger->postValidate(); } - $aOptions = array('user' => $oUser); - $oDocumentTransaction = & new DocumentTransaction($oNewDoc, "Document copied from old version.", 'ktcore.transactions.create', $aOptions); - $res = $oDocumentTransaction->create(); + //$aOptions = array('user' => $oUser); + //$oDocumentTransaction = & new DocumentTransaction($oNewDoc, "Document copied from old version.", 'ktcore.transactions.create', $aOptions); + //$res = $oDocumentTransaction->create(); $_SESSION['KTInfoMessage'][] = _kt('Document copied.'); diff --git a/sql/mysql/upgrade/3.1.6.6/copy_transaction.sql b/sql/mysql/upgrade/3.1.6.6/copy_transaction.sql new file mode 100644 index 0000000..2791908 --- /dev/null +++ b/sql/mysql/upgrade/3.1.6.6/copy_transaction.sql @@ -0,0 +1,8 @@ +TRUNCATE `zseq_document_transaction_types_lookup`; +INSERT INTO `zseq_document_transaction_types_lookup` SELECT MAX(`id`) FROM `document_transaction_types_lookup`; +SELECT @foo:=id + 1 FROM `zseq_document_transaction_types_lookup`; + +INSERT INTO document_transaction_types_lookup VALUES (@foo, 'Copy', 'ktcore.transactions.copy'); + +TRUNCATE `zseq_document_transaction_types_lookup`; +INSERT INTO `zseq_document_transaction_types_lookup` SELECT MAX(`id`) FROM `document_transaction_types_lookup`; -- libgit2 0.21.4