From d284ecdd02a4591ec06610663926590f4c647ead Mon Sep 17 00:00:00 2001 From: Neil Blakey-Milner Date: Mon, 28 Nov 2005 20:27:13 +0000 Subject: [PATCH] Grab document type and set it at createFromArray-time. --- lib/documentmanagement/documentutil.inc.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/documentmanagement/documentutil.inc.php b/lib/documentmanagement/documentutil.inc.php index 05262aa..4379ec9 100644 --- a/lib/documentmanagement/documentutil.inc.php +++ b/lib/documentmanagement/documentutil.inc.php @@ -154,24 +154,24 @@ class KTDocumentUtil { $aMetadata = KTUtil::arrayGet($aOptions, 'metadata'); $oDocumentType = KTUtil::arrayGet($aOptions, 'documenttype'); $sDescription = KTUtil::arrayGet($aOptions, 'description', $sFilename); + + if ($oDocumentType) { + $iDocumentTypeId = KTUtil::getId($oDocumentType); + } else { + $iDocumentTypeId = 1; + } $oDocument =& Document::createFromArray(array( 'name' => $sDescription, 'description' => $sDescription, 'filename' => $sFilename, 'folderid' => $oFolder->getID(), 'creatorid' => $oUser->getID(), + 'documenttypeid' => $iDocumentTypeId, )); if (PEAR::isError($oDocument)) { return $oDocument; } - if (!is_null($oDocumentType)) { - $oDocument->setDocumentTypeID($oDocumentType->getID()); - } else { - // XXX: Ug... - $oDocument->setDocumentTypeID(1); - } - if (is_null($oContents)) { $res = KTDocumentUtil::setIncomplete($oDocument, "contents"); if (PEAR::isError($res)) { -- libgit2 0.21.4