mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-11 17:44:56 +00:00
add new method hasSubFolderByName(), fix hasDocumetByName()
hasDocumetByName() returned a positiv integer if documents of the folder has been loaded before.
This commit is contained in:
parent
3d9e752694
commit
164282cfb9
|
@ -520,6 +520,26 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
|||
return $resArr[0]['c'];
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Check if folder has as subfolder with given name
|
||||
*
|
||||
* @param string $name
|
||||
* @return bool true if subfolder exists, false if not or in case
|
||||
* of an error
|
||||
*/
|
||||
function hasSubFolderByName($name) { /* {{{ */
|
||||
$db = $this->_dms->getDB();
|
||||
/* Always check the database instead of iterating over $this->_documents, because
|
||||
* it is probably not slower
|
||||
*/
|
||||
$queryStr = "SELECT count(*) as c FROM `tblFolders` WHERE `parent` = " . $this->_id . " AND `name` = ".$db->qstr($name);
|
||||
$resArr = $db->getResultArray($queryStr);
|
||||
if (is_bool($resArr) && !$resArr)
|
||||
return false;
|
||||
|
||||
return ($resArr[0]['c'] > 0);
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Returns a list of subfolders
|
||||
* This function does not check for access rights. Use
|
||||
|
@ -713,10 +733,9 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
|||
*/
|
||||
function hasDocumentByName($name) { /* {{{ */
|
||||
$db = $this->_dms->getDB();
|
||||
if (isset($this->_documents)) {
|
||||
/** @noinspection PhpUndefinedFieldInspection */ /** @todo not $this->_documents? */
|
||||
return count($this->documents);
|
||||
}
|
||||
/* Always check the database instead of iterating over $this->_documents, because
|
||||
* it is probably not slower
|
||||
*/
|
||||
$queryStr = "SELECT count(*) as c FROM `tblDocuments` WHERE `folder` = " . $this->_id . " AND `name` = ".$db->qstr($name);
|
||||
$resArr = $db->getResultArray($queryStr);
|
||||
if (is_bool($resArr) && !$resArr)
|
||||
|
|
Loading…
Reference in New Issue
Block a user