Commit 91094d39ce89b1bed1c0bfc5ae176a1013f2ce4e

Authored by nbm
1 parent 9e439708

If given a KTDocumentCore object, get the Document object instead.

Copy the metadata when creating a new metadata version.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5300 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/workflow/workflowutil.inc.php
... ... @@ -122,7 +122,9 @@ class KTWorkflowUtil {
122 122  
123 123 $oUser = User::get($_SESSION['userID']);
124 124  
  125 + $iPreviousMetadataVersion = $oDocument->getMetadataVersionId();
125 126 $oDocument->startNewMetadataVersion($oUser);
  127 + KTDocumentUtil::copyMetadata($oDocument, $iPreviousMetadataVersion);
126 128  
127 129 if (!empty($oWorkflow)) {
128 130 $oWorkflow =& KTUtil::getObject('KTWorkflow', $oWorkflow);
... ... @@ -323,6 +325,10 @@ class KTWorkflowUtil {
323 325 */
324 326 function getWorkflowForDocument ($oDocument, $aOptions = null) {
325 327 $ids = KTUtil::arrayGet($aOptions, 'ids', false);
  328 +
  329 + if (is_a($oDocument, 'KTDocumentCore')) {
  330 + $oDocument = $oDocument->getId();
  331 + }
326 332  
327 333 $oDocument = KTUtil::getObject('Document', $oDocument);
328 334 $iWorkflowId = $oDocument->getWorkflowId();
... ... @@ -352,6 +358,10 @@ class KTWorkflowUtil {
352 358  
353 359 $ids = KTUtil::arrayGet($aOptions, 'ids', false);
354 360  
  361 + if (is_a($oDocument, 'KTDocumentCore')) {
  362 + $oDocument = $oDocument->getId();
  363 + }
  364 +
355 365 $oDocument = KTUtil::getObject('Document', $oDocument);
356 366 $iWorkflowStateId = $oDocument->getWorkflowStateId();
357 367  
... ... @@ -448,7 +458,9 @@ class KTWorkflowUtil {
448 458 }
449 459 $oSourceState =& KTWorkflowUtil::getWorkflowStateForDocument($oDocument);
450 460  
  461 + $iPreviousMetadataVersion = $oDocument->getMetadataVersionId();
451 462 $oDocument->startNewMetadataVersion($oUser);
  463 + KTDocumentUtil::copyMetadata($oDocument, $iPreviousMetadataVersion);
452 464  
453 465 $iStateId = $oTransition->getTargetStateId();
454 466  
... ...