Commit 485c112b0ea148addc98b8822a9e034e432f0d41
1 parent
4484c282
Initialised packed metadata as an array. Checked that values are set to n/a befo…
…re setting them to an empty string. Committed by: Megan Watson Conflicts: ktapi/KTAPIDocument.inc.php
Showing
2 changed files
with
7 additions
and
1 deletions
ktapi/KTAPIDocument.inc.php
| ... | ... | @@ -1401,6 +1401,10 @@ class KTAPI_Document extends KTAPI_FolderItem |
| 1401 | 1401 | { |
| 1402 | 1402 | $fieldname = $fieldinfo['name']; |
| 1403 | 1403 | $value = $fieldinfo['value']; |
| 1404 | + // if the 'blankvalue' argument was set to 1 (true) then do not use the current value; | |
| 1405 | + // this prevents the 'n/a' values set for blank fields on get_metadata from being saved as such | |
| 1406 | + // while allowing user entered values of 'n/a' to be saved | |
| 1407 | + $value = ($fieldinfo['value'] == 'n/a' && $fieldinfo['blankvalue']) ? '' : $fieldinfo['value']; | |
| 1404 | 1408 | } |
| 1405 | 1409 | elseif ($fieldinfo instanceof stdClass) // is_a($fieldinfo, 'stdClass')) |
| 1406 | 1410 | { |
| ... | ... | @@ -2635,4 +2639,4 @@ class KTAPI_Document extends KTAPI_FolderItem |
| 2635 | 2639 | } |
| 2636 | 2640 | } |
| 2637 | 2641 | |
| 2638 | -?> | |
| 2639 | 2642 | \ No newline at end of file |
| 2643 | +?> | ... | ... |
lib/documentmanagement/documentutil.inc.php
| ... | ... | @@ -641,6 +641,7 @@ $sourceDocument->getName(), |
| 641 | 641 | $aSimpleMetadata[$oField->getId()] = $sValue; |
| 642 | 642 | } |
| 643 | 643 | |
| 644 | + $MDPack = array(); | |
| 644 | 645 | foreach ($aFieldsets as $oFieldset) { |
| 645 | 646 | $aFields =& $oFieldset->getFields(); |
| 646 | 647 | $aFieldValues = array(); |
| ... | ... | @@ -694,6 +695,7 @@ $sourceDocument->getName(), |
| 694 | 695 | return $res; |
| 695 | 696 | } |
| 696 | 697 | // XXX: Metadata refactor |
| 698 | + $aMetadata = (is_array($aMetadata)) ? $aMetadata : array(); | |
| 697 | 699 | foreach ($aMetadata as $aInfo) { |
| 698 | 700 | list($oMetadata, $sValue) = $aInfo; |
| 699 | 701 | if (is_null($oMetadata)) { | ... | ... |