mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-14 13:42:04 +00:00
getAllUserKeywordCategories() calls getAllKeywordCategories(), better checking of parameters pass to addDocumentCategory()
This commit is contained in:
parent
2ee30ccd5b
commit
e809297cfd
|
@ -2339,33 +2339,25 @@ class SeedDMS_Core_DMS {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function should be replaced by getAllKeywordCategories()
|
* This function should be replaced by getAllKeywordCategories()
|
||||||
|
*
|
||||||
* @param $userID
|
* @param $userID
|
||||||
* @return SeedDMS_Core_KeywordCategory[]|bool
|
* @return SeedDMS_Core_KeywordCategory[]|bool
|
||||||
*/
|
*/
|
||||||
function getAllUserKeywordCategories($userID) { /* {{{ */
|
function getAllUserKeywordCategories($userID) { /* {{{ */
|
||||||
$queryStr = "SELECT * FROM `tblKeywordCategories`";
|
if (!is_numeric($userID) || $userID < 1)
|
||||||
if ($userID != -1)
|
|
||||||
$queryStr .= " WHERE `owner` = " . (int) $userID;
|
|
||||||
|
|
||||||
$resArr = $this->db->getResultArray($queryStr);
|
|
||||||
if (is_bool($resArr) && !$resArr)
|
|
||||||
return false;
|
return false;
|
||||||
|
return self::getAllKeywordCategories([$userID]);
|
||||||
$categories = array();
|
|
||||||
foreach ($resArr as $row) {
|
|
||||||
$cat = new SeedDMS_Core_KeywordCategory($row["id"], $row["owner"], $row["name"]);
|
|
||||||
$cat->setDMS($this);
|
|
||||||
array_push($categories, $cat);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $categories;
|
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function addKeywordCategory($userID, $name) { /* {{{ */
|
function addKeywordCategory($userID, $name) { /* {{{ */
|
||||||
if (is_object($this->getKeywordCategoryByName($name, $userID))) {
|
if (!is_numeric($userID) || $userID < 1)
|
||||||
|
return false;
|
||||||
|
if(!trim($name))
|
||||||
|
return false;
|
||||||
|
if (is_object($this->getKeywordCategoryByName(trim($name), $userID))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$queryStr = "INSERT INTO `tblKeywordCategories` (`owner`, `name`) VALUES (".(int) $userID.", ".$this->db->qstr($name).")";
|
$queryStr = "INSERT INTO `tblKeywordCategories` (`owner`, `name`) VALUES (".(int) $userID.", ".$this->db->qstr(trim($name)).")";
|
||||||
if (!$this->db->getResult($queryStr))
|
if (!$this->db->getResult($queryStr))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user