Commit d284ecdd02a4591ec06610663926590f4c647ead

Authored by Neil Blakey-Milner
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
lib/documentmanagement/documentutil.inc.php
@@ -154,24 +154,24 @@ class KTDocumentUtil { @@ -154,24 +154,24 @@ class KTDocumentUtil {
154 $aMetadata = KTUtil::arrayGet($aOptions, 'metadata'); 154 $aMetadata = KTUtil::arrayGet($aOptions, 'metadata');
155 $oDocumentType = KTUtil::arrayGet($aOptions, 'documenttype'); 155 $oDocumentType = KTUtil::arrayGet($aOptions, 'documenttype');
156 $sDescription = KTUtil::arrayGet($aOptions, 'description', $sFilename); 156 $sDescription = KTUtil::arrayGet($aOptions, 'description', $sFilename);
  157 +
  158 + if ($oDocumentType) {
  159 + $iDocumentTypeId = KTUtil::getId($oDocumentType);
  160 + } else {
  161 + $iDocumentTypeId = 1;
  162 + }
157 $oDocument =& Document::createFromArray(array( 163 $oDocument =& Document::createFromArray(array(
158 'name' => $sDescription, 164 'name' => $sDescription,
159 'description' => $sDescription, 165 'description' => $sDescription,
160 'filename' => $sFilename, 166 'filename' => $sFilename,
161 'folderid' => $oFolder->getID(), 167 'folderid' => $oFolder->getID(),
162 'creatorid' => $oUser->getID(), 168 'creatorid' => $oUser->getID(),
  169 + 'documenttypeid' => $iDocumentTypeId,
163 )); 170 ));
164 if (PEAR::isError($oDocument)) { 171 if (PEAR::isError($oDocument)) {
165 return $oDocument; 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 if (is_null($oContents)) { 175 if (is_null($oContents)) {
176 $res = KTDocumentUtil::setIncomplete($oDocument, "contents"); 176 $res = KTDocumentUtil::setIncomplete($oDocument, "contents");
177 if (PEAR::isError($res)) { 177 if (PEAR::isError($res)) {