Commit 9964778245bef0871b10d23372153237794355b2
1 parent
580779ff
KTS-2895
"DocumentUtil::saveMetadata clears metadata when novalidation option is set" Fixed. Committed By: Conrad Vermeulen Reviewed By: Megan Watson git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7976 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
14 additions
and
20 deletions
lib/documentmanagement/documentutil.inc.php
| ... | ... | @@ -256,20 +256,12 @@ class KTDocumentUtil { |
| 256 | 256 | 'documenttypeid' => $iDocumentTypeId, |
| 257 | 257 | )); |
| 258 | 258 | |
| 259 | -// if (is_null($oContents)) { | |
| 260 | -// $res = KTDocumentUtil::setIncomplete($oDocument, 'contents'); | |
| 261 | -// if (PEAR::isError($res)) { | |
| 262 | -// $oDocument->delete(); | |
| 263 | -// return $res; | |
| 264 | -// } | |
| 265 | -// } else { | |
| 266 | - // $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('Storing contents'))); | |
| 267 | - $res = KTDocumentUtil::storeContents($oDocument, '', $aOptions); | |
| 268 | - if (PEAR::isError($res)) { | |
| 269 | - $oDocument->delete(); | |
| 270 | - return $res; | |
| 271 | - } | |
| 272 | -// } | |
| 259 | + $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('Storing contents'))); | |
| 260 | + $res = KTDocumentUtil::storeContents($oDocument, '', $aOptions); | |
| 261 | + if (PEAR::isError($res)) { | |
| 262 | + $oDocument->delete(); | |
| 263 | + return $res; | |
| 264 | + } | |
| 273 | 265 | |
| 274 | 266 | if (is_null($aMetadata)) { |
| 275 | 267 | $res = KTDocumentUtil::setIncomplete($oDocument, 'metadata'); |
| ... | ... | @@ -278,7 +270,7 @@ class KTDocumentUtil { |
| 278 | 270 | return $res; |
| 279 | 271 | } |
| 280 | 272 | } else { |
| 281 | - // $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('Saving metadata'))); | |
| 273 | + $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('Saving metadata'))); | |
| 282 | 274 | $res = KTDocumentUtil::saveMetadata($oDocument, $aMetadata, $aOptions); |
| 283 | 275 | if (PEAR::isError($res)) { |
| 284 | 276 | $oDocument->delete(); |
| ... | ... | @@ -420,13 +412,15 @@ class KTDocumentUtil { |
| 420 | 412 | function saveMetadata(&$oDocument, $aMetadata, $aOptions = null) { |
| 421 | 413 | $table = 'document_fields_link'; |
| 422 | 414 | $bNoValidate = KTUtil::arrayGet($aOptions, 'novalidate', false); |
| 423 | - if ($bNoValidate !== true) { | |
| 415 | + if ($bNoValidate !== true) | |
| 416 | + { | |
| 424 | 417 | $res = KTDocumentUtil::validateMetadata($oDocument, $aMetadata); |
| 418 | + if (PEAR::isError($res)) | |
| 419 | + { | |
| 420 | + return $res; | |
| 421 | + } | |
| 422 | + $aMetadata = empty($res)?array():$res; | |
| 425 | 423 | } |
| 426 | - if (PEAR::isError($res)) { | |
| 427 | - return $res; | |
| 428 | - } | |
| 429 | - $aMetadata = empty($res)?array():$res; | |
| 430 | 424 | |
| 431 | 425 | $iMetadataVersionId = $oDocument->getMetadataVersionId(); |
| 432 | 426 | $res = DBUtil::runQuery(array("DELETE FROM $table WHERE metadata_version_id = ?", array($iMetadataVersionId))); | ... | ... |