Commit 55f36a0a60641b10ee5a8bd8f491e303f08f182f

Authored by megan_w
1 parent 35bdabf8

KTS-3388

"Warning on checkin from mime.inc.php on line 146"
Fixed. Moved the mime type check to the top of the checkin function.

Committed by: Megan Watson
Reviewed by: Jonathan Byrne



git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/branches/3.5.3-Branch@8525 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/documentmanagement/documentutil.inc.php
... ... @@ -11,31 +11,31 @@
11 11 * Document Management Made Simple
12 12 * Copyright (C) 2008 KnowledgeTree Inc.
13 13 * Portions copyright The Jam Warehouse Software (Pty) Limited
14   - *
  14 + *
15 15 * This program is free software; you can redistribute it and/or modify it under
16 16 * the terms of the GNU General Public License version 3 as published by the
17 17 * Free Software Foundation.
18   - *
  18 + *
19 19 * This program is distributed in the hope that it will be useful, but WITHOUT
20 20 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
21 21 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
22 22 * details.
23   - *
  23 + *
24 24 * You should have received a copy of the GNU General Public License
25 25 * along with this program. If not, see <http://www.gnu.org/licenses/>.
26   - *
27   - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
  26 + *
  27 + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
28 28 * California 94120-7775, or email info@knowledgetree.com.
29   - *
  29 + *
30 30 * The interactive user interfaces in modified source and object code versions
31 31 * of this program must display Appropriate Legal Notices, as required under
32 32 * Section 5 of the GNU General Public License version 3.
33   - *
  33 + *
34 34 * In accordance with Section 7(b) of the GNU General Public License version 3,
35 35 * these Appropriate Legal Notices must retain the display of the "Powered by
36   - * KnowledgeTree" logo and retain the original copyright notice. If the display of the
  36 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
37 37 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
38   - * must display the words "Powered by KnowledgeTree" and retain the original
  38 + * must display the words "Powered by KnowledgeTree" and retain the original
39 39 * copyright notice.
40 40 * Contributor( s): ______________________________________
41 41 */
... ... @@ -62,6 +62,10 @@ require_once(KT_LIB_DIR . &#39;/workflow/workflowutil.inc.php&#39;);
62 62 class KTDocumentUtil {
63 63 function checkin($oDocument, $sFilename, $sCheckInComment, $oUser, $aOptions = false) {
64 64 $oStorage =& KTStorageManagerUtil::getSingleton();
  65 +
  66 + $sType = KTMime::getMimeTypeFromFile($sFilename);
  67 + $iMimeTypeId = KTMime::getMimeTypeID($sType, $oDocument->getFileName());
  68 +
65 69 $iFileSize = filesize($sFilename);
66 70  
67 71 $iPreviousMetadataVersion = $oDocument->getMetadataVersionId();
... ... @@ -72,7 +76,7 @@ class KTDocumentUtil {
72 76 }
73 77  
74 78 KTDocumentUtil::copyMetadata($oDocument, $iPreviousMetadataVersion);
75   -
  79 +
76 80 $md5hash = md5_file($sFilename);
77 81 $content = $oDocument->_oDocumentContentVersion;
78 82 $content->setStorageHash($md5hash);
... ... @@ -80,7 +84,7 @@ class KTDocumentUtil {
80 84  
81 85 if (empty($aOptions)) $aOptions = array();
82 86 $aOptions['md5hash'] = $md5hash;
83   -
  87 +
84 88 if (!$oStorage->upload($oDocument, $sFilename, $aOptions)) {
85 89 return PEAR::raiseError(_kt('An error occurred while storing the new file'));
86 90 }
... ... @@ -108,8 +112,6 @@ class KTDocumentUtil {
108 112 }
109 113 }
110 114  
111   - $sType = KTMime::getMimeTypeFromFile($sFilename);
112   - $iMimeTypeId = KTMime::getMimeTypeID($sType, $oDocument->getFileName());
113 115 $oDocument->setMimeTypeId($iMimeTypeId);
114 116  
115 117 $bSuccess = $oDocument->update();
... ...