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