mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-11 20:21:16 +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()
|
||||
*
|
||||
* @param $userID
|
||||
* @return SeedDMS_Core_KeywordCategory[]|bool
|
||||
*/
|
||||
function getAllUserKeywordCategories($userID) { /* {{{ */
|
||||
$queryStr = "SELECT * FROM `tblKeywordCategories`";
|
||||
if ($userID != -1)
|
||||
$queryStr .= " WHERE `owner` = " . (int) $userID;
|
||||
|
||||
$resArr = $this->db->getResultArray($queryStr);
|
||||
if (is_bool($resArr) && !$resArr)
|
||||
if (!is_numeric($userID) || $userID < 1)
|
||||
return false;
|
||||
|
||||
$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;
|
||||
return self::getAllKeywordCategories([$userID]);
|
||||
} /* }}} */
|
||||
|
||||
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;
|
||||
}
|
||||
$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))
|
||||
return false;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user