From 12b1e16270f8cabac4e880a71e5ea2d8b8507d76 Mon Sep 17 00:00:00 2001 From: megan_w Date: Wed, 10 Oct 2007 06:53:53 +0000 Subject: [PATCH] BBS-1011 "Auto Workflow Assignment: When a document is move from within KTE to the assigned linked folder the correct worklfow is not initiated." Moved the triggers into the document util copy action, fixes both webdav and KT tools. --- lib/documentmanagement/documentutil.inc.php | 35 ++++++++++++++++++++++++++--------- plugins/ktcore/KTDocumentActions.php | 19 ------------------- 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/lib/documentmanagement/documentutil.inc.php b/lib/documentmanagement/documentutil.inc.php index 493977d..90d3ba8 100644 --- a/lib/documentmanagement/documentutil.inc.php +++ b/lib/documentmanagement/documentutil.inc.php @@ -898,7 +898,6 @@ class KTDocumentUtil { $sReason = ''; } - $oDocumentTransaction = new DocumentTransaction($oDocument, sprintf(_kt("Copied to folder \"%s\". %s"), $oDestinationFolder->getName(), $sReason), 'ktcore.transactions.copy'); $oDocumentTransaction->create(); @@ -906,6 +905,24 @@ class KTDocumentUtil { $oDocumentTransaction = new DocumentTransaction($oNewDocument, sprintf(_kt("Copied from original in folder \"%s\". %s"), $oSrcFolder->getName(), $sReason), 'ktcore.transactions.copy'); $oDocumentTransaction->create(); + + $oKTTriggerRegistry = KTTriggerRegistry::getSingleton(); + $aTriggers = $oKTTriggerRegistry->getTriggers('copyDocument', 'postValidate'); + foreach ($aTriggers as $aTrigger) { + $sTrigger = $aTrigger[0]; + $oTrigger = new $sTrigger; + $aInfo = array( + 'document' => $oNewDocument, + 'old_folder' => $oSrcFolder, + 'new_folder' => $oDestinationFolder, + ); + $oTrigger->setInfo($aInfo); + $ret = $oTrigger->postValidate(); + if (PEAR::isError($ret)) { + return $ret; + } + } + return $oNewDocument; } @@ -1013,15 +1030,15 @@ class KTDocumentUtil { return KTPermissionUtil::updatePermissionLookup($oDocument); } - + /** * Delete a selected version of the document. */ function deleteVersion($oDocument, $iVersionID, $sReason){ - + $oDocument =& KTUtil::getObject('Document', $oDocument); $oVersion =& KTDocumentMetadataVersion::get($iVersionID); - + $oStorageManager =& KTStorageManagerUtil::getSingleton(); global $default; @@ -1037,17 +1054,17 @@ class KTDocumentUtil { if (PEAR::isError($oVersion) || ($oVersion == false)) { return PEAR::raiseError(_kt('Invalid document version object.')); } - + $iContentId = $oVersion->getContentVersionId(); $oContentVersion = KTDocumentContentVersion::get($iContentId); - + if (PEAR::isError($oContentVersion) || ($oContentVersion == false)) { DBUtil::rollback(); return PEAR::raiseError(_kt('Invalid document content version object.')); } DBUtil::startTransaction(); - + // now delete the document version $res = $oStorageManager->deleteVersion($oVersion); if (PEAR::isError($res) || ($res == false)) { @@ -1064,11 +1081,11 @@ class KTDocumentUtil { return PEAR::raiseError(_kt('There was a problem deleting the document from storage.')); } - + // change status for the metadata version $oVersion->setStatusId(VERSION_DELETED); $oVersion->update(); - + // set the storage path to empty // $oContentVersion->setStoragePath(''); diff --git a/plugins/ktcore/KTDocumentActions.php b/plugins/ktcore/KTDocumentActions.php index bb18ced..a1735fa 100644 --- a/plugins/ktcore/KTDocumentActions.php +++ b/plugins/ktcore/KTDocumentActions.php @@ -1242,25 +1242,6 @@ class KTDocumentCopyAction extends KTDocumentAction { $this->commitTransaction(); - // FIXME do we need to refactor all trigger usage into the util function? - $oKTTriggerRegistry = KTTriggerRegistry::getSingleton(); - $aTriggers = $oKTTriggerRegistry->getTriggers('copyDocument', 'postValidate'); - foreach ($aTriggers as $aTrigger) { - $sTrigger = $aTrigger[0]; - $oTrigger = new $sTrigger; - $aInfo = array( - 'document' => $oNewDoc, - 'old_folder' => $this->oDocumentFolder, - 'new_folder' => $data['browse'], - ); - $oTrigger->setInfo($aInfo); - $ret = $oTrigger->postValidate(); - } - - //$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.'); controllerRedirect('viewDocument', 'fDocumentId=' . $oNewDoc->getId()); -- libgit2 0.21.4