Commit 485c112b0ea148addc98b8822a9e034e432f0d41

Authored by Megan Watson
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
ktapi/KTAPIDocument.inc.php
@@ -1401,6 +1401,10 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1401,6 +1401,10 @@ class KTAPI_Document extends KTAPI_FolderItem
1401 { 1401 {
1402 $fieldname = $fieldinfo['name']; 1402 $fieldname = $fieldinfo['name'];
1403 $value = $fieldinfo['value']; 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 elseif ($fieldinfo instanceof stdClass) // is_a($fieldinfo, 'stdClass')) 1409 elseif ($fieldinfo instanceof stdClass) // is_a($fieldinfo, 'stdClass'))
1406 { 1410 {
@@ -2635,4 +2639,4 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -2635,4 +2639,4 @@ class KTAPI_Document extends KTAPI_FolderItem
2635 } 2639 }
2636 } 2640 }
2637 2641
2638 -?>  
2639 \ No newline at end of file 2642 \ No newline at end of file
  2643 +?>
lib/documentmanagement/documentutil.inc.php
@@ -641,6 +641,7 @@ $sourceDocument->getName(), @@ -641,6 +641,7 @@ $sourceDocument->getName(),
641 $aSimpleMetadata[$oField->getId()] = $sValue; 641 $aSimpleMetadata[$oField->getId()] = $sValue;
642 } 642 }
643 643
  644 + $MDPack = array();
644 foreach ($aFieldsets as $oFieldset) { 645 foreach ($aFieldsets as $oFieldset) {
645 $aFields =& $oFieldset->getFields(); 646 $aFields =& $oFieldset->getFields();
646 $aFieldValues = array(); 647 $aFieldValues = array();
@@ -694,6 +695,7 @@ $sourceDocument->getName(), @@ -694,6 +695,7 @@ $sourceDocument->getName(),
694 return $res; 695 return $res;
695 } 696 }
696 // XXX: Metadata refactor 697 // XXX: Metadata refactor
  698 + $aMetadata = (is_array($aMetadata)) ? $aMetadata : array();
697 foreach ($aMetadata as $aInfo) { 699 foreach ($aMetadata as $aInfo) {
698 list($oMetadata, $sValue) = $aInfo; 700 list($oMetadata, $sValue) = $aInfo;
699 if (is_null($oMetadata)) { 701 if (is_null($oMetadata)) {