Commit d284ecdd02a4591ec06610663926590f4c647ead
1 parent
d25707e1
Grab document type and set it at createFromArray-time.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4236 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
7 additions
and
7 deletions
lib/documentmanagement/documentutil.inc.php
| ... | ... | @@ -154,24 +154,24 @@ class KTDocumentUtil { |
| 154 | 154 | $aMetadata = KTUtil::arrayGet($aOptions, 'metadata'); |
| 155 | 155 | $oDocumentType = KTUtil::arrayGet($aOptions, 'documenttype'); |
| 156 | 156 | $sDescription = KTUtil::arrayGet($aOptions, 'description', $sFilename); |
| 157 | + | |
| 158 | + if ($oDocumentType) { | |
| 159 | + $iDocumentTypeId = KTUtil::getId($oDocumentType); | |
| 160 | + } else { | |
| 161 | + $iDocumentTypeId = 1; | |
| 162 | + } | |
| 157 | 163 | $oDocument =& Document::createFromArray(array( |
| 158 | 164 | 'name' => $sDescription, |
| 159 | 165 | 'description' => $sDescription, |
| 160 | 166 | 'filename' => $sFilename, |
| 161 | 167 | 'folderid' => $oFolder->getID(), |
| 162 | 168 | 'creatorid' => $oUser->getID(), |
| 169 | + 'documenttypeid' => $iDocumentTypeId, | |
| 163 | 170 | )); |
| 164 | 171 | if (PEAR::isError($oDocument)) { |
| 165 | 172 | return $oDocument; |
| 166 | 173 | } |
| 167 | 174 | |
| 168 | - if (!is_null($oDocumentType)) { | |
| 169 | - $oDocument->setDocumentTypeID($oDocumentType->getID()); | |
| 170 | - } else { | |
| 171 | - // XXX: Ug... | |
| 172 | - $oDocument->setDocumentTypeID(1); | |
| 173 | - } | |
| 174 | - | |
| 175 | 175 | if (is_null($oContents)) { |
| 176 | 176 | $res = KTDocumentUtil::setIncomplete($oDocument, "contents"); |
| 177 | 177 | if (PEAR::isError($res)) { | ... | ... |