mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-13 21:21:27 +00:00
add new method setFileType()
This commit is contained in:
parent
efec0c36bf
commit
9b24827598
|
@ -3491,6 +3491,40 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
return true;
|
return true;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set file type by evaluating the mime type
|
||||||
|
*/
|
||||||
|
function setFileType() { /* {{{ */
|
||||||
|
$mimetype = $this->getMimeType();
|
||||||
|
|
||||||
|
switch($this->_mimeType) {
|
||||||
|
case "application/pdf":
|
||||||
|
case "image/png":
|
||||||
|
case "image/gif":
|
||||||
|
case "image/jpg":
|
||||||
|
$expect = substr($this->_mimeType, -3, 3);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if($expect && '.'.$expect != $this->_fileType) {
|
||||||
|
$db = $this->_document->getDMS()->getDB();
|
||||||
|
$db->startTransaction();
|
||||||
|
$queryStr = "UPDATE `tblDocumentContent` SET `fileType`='.".$expect."' WHERE `id` = ". $this->_id;
|
||||||
|
$res = $db->getResult($queryStr);
|
||||||
|
if ($res) {
|
||||||
|
if(!SeedDMS_Core_File::renameFile($this->_dms->contentDir.$this->_document->getDir() . $this->_version . $this->_fileType, $this->_dms->contentDir.$this->_document->getDir() . $this->_version . '.' . $expect)) {
|
||||||
|
$db->rollbackTransaction();
|
||||||
|
} else {
|
||||||
|
$db->commitTransaction();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$db->rollbackTransaction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
function setComment($newComment) { /* {{{ */
|
function setComment($newComment) { /* {{{ */
|
||||||
$db = $this->_document->getDMS()->getDB();
|
$db = $this->_document->getDMS()->getDB();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user