From 789d7e189ab2dd5033c47dc0182608a92aec6aae Mon Sep 17 00:00:00 2001 From: Megan Watson Date: Fri, 19 Mar 2010 19:29:47 +0200 Subject: [PATCH] Initialised packed metadata as an array. Checked that values are set to n/a before setting them to an empty string. --- ktapi/KTAPIDocument.inc.php | 6 +++--- lib/documentmanagement/documentutil.inc.php | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ktapi/KTAPIDocument.inc.php b/ktapi/KTAPIDocument.inc.php index 5aa2504..df49ea1 100644 --- a/ktapi/KTAPIDocument.inc.php +++ b/ktapi/KTAPIDocument.inc.php @@ -1405,7 +1405,7 @@ class KTAPI_Document extends KTAPI_FolderItem // if the 'blankvalue' argument was set to 1 (true) then do not use the current value; // this prevents the 'n/a' values set for blank fields on get_metadata from being saved as such // while allowing user entered values of 'n/a' to be saved - $value = $fieldinfo['blankvalue'] ? '' : $fieldinfo['value']; + $value = ($fieldinfo['value'] == 'n/a' && $fieldinfo['blankvalue']) ? '' : $fieldinfo['value']; } elseif ($fieldinfo instanceof stdClass) // is_a($fieldinfo, 'stdClass')) { @@ -2156,7 +2156,7 @@ class KTAPI_Document extends KTAPI_FolderItem { return $this->document->getContentVersionId(); } - + /** * Gets the url which can be used to download the document. * @@ -2622,7 +2622,7 @@ class KTAPI_Document extends KTAPI_FolderItem if (KTPluginUtil::pluginIsActive('brad.UserHistory.plugin')) { $path = KTPluginUtil::getPluginPath('brad.UserHistory.plugin'); require_once($path . 'UserHistoryActions.php'); - + $docAction = new UserHistoryDocumentAction($this->document, $this->ktapi->get_user()); $docAction->_show(); } diff --git a/lib/documentmanagement/documentutil.inc.php b/lib/documentmanagement/documentutil.inc.php index 3de4244..bf5f763 100644 --- a/lib/documentmanagement/documentutil.inc.php +++ b/lib/documentmanagement/documentutil.inc.php @@ -641,6 +641,7 @@ $sourceDocument->getName(), $aSimpleMetadata[$oField->getId()] = $sValue; } + $MDPack = array(); foreach ($aFieldsets as $oFieldset) { $aFields =& $oFieldset->getFields(); $aFieldValues = array(); @@ -694,6 +695,7 @@ $sourceDocument->getName(), return $res; } // XXX: Metadata refactor + $aMetadata = (is_array($aMetadata)) ? $aMetadata : array(); foreach ($aMetadata as $aInfo) { list($oMetadata, $sValue) = $aInfo; if (is_null($oMetadata)) { -- libgit2 0.21.4