diff --git a/SeedDMS_Core/Core/inc.ClassDMS.php b/SeedDMS_Core/Core/inc.ClassDMS.php index 58720b1a7..ed6e10995 100644 --- a/SeedDMS_Core/Core/inc.ClassDMS.php +++ b/SeedDMS_Core/Core/inc.ClassDMS.php @@ -3567,6 +3567,46 @@ class SeedDMS_Core_DMS { } /* }}} */ + /** + * Returns document content which has the incorrect file type + * + * This method is for finding document content with an incorrect + * or missing file type. It just checks documents contents + * with a certain mime type. + * @return bool|SeedDMS_Core_Document[] + */ + function getWrongFiletypeDocumentContent() { /* {{{ */ + $queryStr = "SELECT * FROM `tblDocumentContent` WHERE `mimeType` in ('application/pdf', 'image/png', 'image/gif', 'image/jpg')"; + $resArr = $this->db->getResultArray($queryStr); + if ($resArr === false) + return false; + + /** @var SeedDMS_Core_Document[] $versions */ + $versions = array(); + foreach($resArr as $row) { + $expect = ''; + switch($row['mimeType']) { + case "application/pdf": + case "image/png": + case "image/gif": + case "image/jpg": + $expect = substr($row['mimeType'], -3, 3); + break; + } + if($expect) { + if($row['fileType'] != '.'.$expect) { + /** @var SeedDMS_Core_Document $document */ + $document = new $this->classnames['document']($row['document'], '', '', '', '', '', '', '', '', '', '', ''); + $document->setDMS($this); + $version = new $this->classnames['documentcontent']($row['id'], $document, $row['version'], $row['comment'], $row['date'], $row['createdBy'], $row['dir'], $row['orgFileName'], $row['fileType'], $row['mimeType'], $row['fileSize'], $row['checksum']); + $versions[] = $version; + } + } + } + return $versions; + + } /* }}} */ + /** * Returns document content which is duplicated *