From bc50f2f8b6e752b393683efc0066ebacf0e8764f Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Fri, 25 Jun 2021 09:34:54 +0200 Subject: [PATCH] add new method SeedDMS_Core_Document::hasCategory() --- SeedDMS_Core/Core/inc.ClassDocument.php | 20 ++++++++++++++++++++ SeedDMS_Core/package.xml | 1 + 2 files changed, 21 insertions(+) diff --git a/SeedDMS_Core/Core/inc.ClassDocument.php b/SeedDMS_Core/Core/inc.ClassDocument.php index ccb05979a..4d9c45a1b 100644 --- a/SeedDMS_Core/Core/inc.ClassDocument.php +++ b/SeedDMS_Core/Core/inc.ClassDocument.php @@ -429,6 +429,26 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ return true; } /* }}} */ + /** + * Check if document has a given category + * + * @param SeedDMS_Core_DocumentCategory $cat + * @return bool true if document has category, otherwise false + */ + function hasCategory($cat) { /* {{{ */ + $db = $this->_dms->getDB(); + + if(!$cat) + return false; + + $queryStr = "SELECT * FROM `tblDocumentCategory` WHERE `documentID` = ".$this->_id." AND `categoryID`=".$cat->getId(); + $resArr = $db->getResultArray($queryStr); + if (!$resArr) + return false; + + return true; + } /* }}} */ + /** * Retrieve a list of all categories this document belongs to * diff --git a/SeedDMS_Core/package.xml b/SeedDMS_Core/package.xml index f93729797..e1d424d98 100644 --- a/SeedDMS_Core/package.xml +++ b/SeedDMS_Core/package.xml @@ -29,6 +29,7 @@ - add methods SeedDMS_Core_DocumentContent::getApproveLog() and SeedDMS_Core_DocumentContent::getReviewLog() - better handling of document with an empty workflow state - fix checking of email addresses by using filter_var instead of regex +- add new method SeedDMS_Core_Document::hasCategory()