Commit 12b1e16270f8cabac4e880a71e5ea2d8b8507d76

Authored by megan_w
1 parent ce00e2b7

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.

Committed by: Megan Watson
Reviewed by: Conrad Vermeulen



git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7318 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/documentmanagement/documentutil.inc.php
@@ -898,7 +898,6 @@ class KTDocumentUtil { @@ -898,7 +898,6 @@ class KTDocumentUtil {
898 $sReason = ''; 898 $sReason = '';
899 } 899 }
900 900
901 -  
902 $oDocumentTransaction = new DocumentTransaction($oDocument, sprintf(_kt("Copied to folder \"%s\". %s"), $oDestinationFolder->getName(), $sReason), 'ktcore.transactions.copy'); 901 $oDocumentTransaction = new DocumentTransaction($oDocument, sprintf(_kt("Copied to folder \"%s\". %s"), $oDestinationFolder->getName(), $sReason), 'ktcore.transactions.copy');
903 $oDocumentTransaction->create(); 902 $oDocumentTransaction->create();
904 903
@@ -906,6 +905,24 @@ class KTDocumentUtil { @@ -906,6 +905,24 @@ class KTDocumentUtil {
906 $oDocumentTransaction = new DocumentTransaction($oNewDocument, sprintf(_kt("Copied from original in folder \"%s\". %s"), $oSrcFolder->getName(), $sReason), 'ktcore.transactions.copy'); 905 $oDocumentTransaction = new DocumentTransaction($oNewDocument, sprintf(_kt("Copied from original in folder \"%s\". %s"), $oSrcFolder->getName(), $sReason), 'ktcore.transactions.copy');
907 $oDocumentTransaction->create(); 906 $oDocumentTransaction->create();
908 907
  908 +
  909 + $oKTTriggerRegistry = KTTriggerRegistry::getSingleton();
  910 + $aTriggers = $oKTTriggerRegistry->getTriggers('copyDocument', 'postValidate');
  911 + foreach ($aTriggers as $aTrigger) {
  912 + $sTrigger = $aTrigger[0];
  913 + $oTrigger = new $sTrigger;
  914 + $aInfo = array(
  915 + 'document' => $oNewDocument,
  916 + 'old_folder' => $oSrcFolder,
  917 + 'new_folder' => $oDestinationFolder,
  918 + );
  919 + $oTrigger->setInfo($aInfo);
  920 + $ret = $oTrigger->postValidate();
  921 + if (PEAR::isError($ret)) {
  922 + return $ret;
  923 + }
  924 + }
  925 +
909 return $oNewDocument; 926 return $oNewDocument;
910 } 927 }
911 928
@@ -1013,15 +1030,15 @@ class KTDocumentUtil { @@ -1013,15 +1030,15 @@ class KTDocumentUtil {
1013 1030
1014 return KTPermissionUtil::updatePermissionLookup($oDocument); 1031 return KTPermissionUtil::updatePermissionLookup($oDocument);
1015 } 1032 }
1016 - 1033 +
1017 /** 1034 /**
1018 * Delete a selected version of the document. 1035 * Delete a selected version of the document.
1019 */ 1036 */
1020 function deleteVersion($oDocument, $iVersionID, $sReason){ 1037 function deleteVersion($oDocument, $iVersionID, $sReason){
1021 - 1038 +
1022 $oDocument =& KTUtil::getObject('Document', $oDocument); 1039 $oDocument =& KTUtil::getObject('Document', $oDocument);
1023 $oVersion =& KTDocumentMetadataVersion::get($iVersionID); 1040 $oVersion =& KTDocumentMetadataVersion::get($iVersionID);
1024 - 1041 +
1025 $oStorageManager =& KTStorageManagerUtil::getSingleton(); 1042 $oStorageManager =& KTStorageManagerUtil::getSingleton();
1026 1043
1027 global $default; 1044 global $default;
@@ -1037,17 +1054,17 @@ class KTDocumentUtil { @@ -1037,17 +1054,17 @@ class KTDocumentUtil {
1037 if (PEAR::isError($oVersion) || ($oVersion == false)) { 1054 if (PEAR::isError($oVersion) || ($oVersion == false)) {
1038 return PEAR::raiseError(_kt('Invalid document version object.')); 1055 return PEAR::raiseError(_kt('Invalid document version object.'));
1039 } 1056 }
1040 - 1057 +
1041 $iContentId = $oVersion->getContentVersionId(); 1058 $iContentId = $oVersion->getContentVersionId();
1042 $oContentVersion = KTDocumentContentVersion::get($iContentId); 1059 $oContentVersion = KTDocumentContentVersion::get($iContentId);
1043 - 1060 +
1044 if (PEAR::isError($oContentVersion) || ($oContentVersion == false)) { 1061 if (PEAR::isError($oContentVersion) || ($oContentVersion == false)) {
1045 DBUtil::rollback(); 1062 DBUtil::rollback();
1046 return PEAR::raiseError(_kt('Invalid document content version object.')); 1063 return PEAR::raiseError(_kt('Invalid document content version object.'));
1047 } 1064 }
1048 1065
1049 DBUtil::startTransaction(); 1066 DBUtil::startTransaction();
1050 - 1067 +
1051 // now delete the document version 1068 // now delete the document version
1052 $res = $oStorageManager->deleteVersion($oVersion); 1069 $res = $oStorageManager->deleteVersion($oVersion);
1053 if (PEAR::isError($res) || ($res == false)) { 1070 if (PEAR::isError($res) || ($res == false)) {
@@ -1064,11 +1081,11 @@ class KTDocumentUtil { @@ -1064,11 +1081,11 @@ class KTDocumentUtil {
1064 1081
1065 return PEAR::raiseError(_kt('There was a problem deleting the document from storage.')); 1082 return PEAR::raiseError(_kt('There was a problem deleting the document from storage.'));
1066 } 1083 }
1067 - 1084 +
1068 // change status for the metadata version 1085 // change status for the metadata version
1069 $oVersion->setStatusId(VERSION_DELETED); 1086 $oVersion->setStatusId(VERSION_DELETED);
1070 $oVersion->update(); 1087 $oVersion->update();
1071 - 1088 +
1072 // set the storage path to empty 1089 // set the storage path to empty
1073 // $oContentVersion->setStoragePath(''); 1090 // $oContentVersion->setStoragePath('');
1074 1091
plugins/ktcore/KTDocumentActions.php
@@ -1242,25 +1242,6 @@ class KTDocumentCopyAction extends KTDocumentAction { @@ -1242,25 +1242,6 @@ class KTDocumentCopyAction extends KTDocumentAction {
1242 1242
1243 $this->commitTransaction(); 1243 $this->commitTransaction();
1244 1244
1245 - // FIXME do we need to refactor all trigger usage into the util function?  
1246 - $oKTTriggerRegistry = KTTriggerRegistry::getSingleton();  
1247 - $aTriggers = $oKTTriggerRegistry->getTriggers('copyDocument', 'postValidate');  
1248 - foreach ($aTriggers as $aTrigger) {  
1249 - $sTrigger = $aTrigger[0];  
1250 - $oTrigger = new $sTrigger;  
1251 - $aInfo = array(  
1252 - 'document' => $oNewDoc,  
1253 - 'old_folder' => $this->oDocumentFolder,  
1254 - 'new_folder' => $data['browse'],  
1255 - );  
1256 - $oTrigger->setInfo($aInfo);  
1257 - $ret = $oTrigger->postValidate();  
1258 - }  
1259 -  
1260 - //$aOptions = array('user' => $oUser);  
1261 - //$oDocumentTransaction = & new DocumentTransaction($oNewDoc, 'Document copied from old version.', 'ktcore.transactions.create', $aOptions);  
1262 - //$res = $oDocumentTransaction->create();  
1263 -  
1264 $_SESSION['KTInfoMessage'][] = _kt('Document copied.'); 1245 $_SESSION['KTInfoMessage'][] = _kt('Document copied.');
1265 1246
1266 controllerRedirect('viewDocument', 'fDocumentId=' . $oNewDoc->getId()); 1247 controllerRedirect('viewDocument', 'fDocumentId=' . $oNewDoc->getId());