add property color to document categories

This commit is contained in:
Uwe Steinmann 2021-05-13 16:14:40 +02:00
parent 012054c731
commit 83dc876ac4
4 changed files with 28 additions and 7 deletions

View File

@ -3180,7 +3180,7 @@ class SeedDMS_Core_DMS {
return false;
$resArr = $resArr[0];
$cat = new SeedDMS_Core_DocumentCategory($resArr["id"], $resArr["name"]);
$cat = new SeedDMS_Core_DocumentCategory($resArr["id"], $resArr["name"], $resArr['color']);
$cat->setDMS($this);
return $cat;
} /* }}} */
@ -3194,7 +3194,7 @@ class SeedDMS_Core_DMS {
$categories = array();
foreach ($resArr as $row) {
$cat = new SeedDMS_Core_DocumentCategory($row["id"], $row["name"]);
$cat = new SeedDMS_Core_DocumentCategory($row["id"], $row["name"], $row['color']);
$cat->setDMS($this);
array_push($categories, $cat);
}
@ -3219,17 +3219,17 @@ class SeedDMS_Core_DMS {
return false;
$row = $resArr[0];
$cat = new SeedDMS_Core_DocumentCategory($row["id"], $row["name"]);
$cat = new SeedDMS_Core_DocumentCategory($row["id"], $row["name"], $row['color']);
$cat->setDMS($this);
return $cat;
} /* }}} */
function addDocumentCategory($name) { /* {{{ */
function addDocumentCategory($name, $color) { /* {{{ */
if (is_object($this->getDocumentCategoryByName($name))) {
return false;
}
$queryStr = "INSERT INTO `tblCategory` (`name`) VALUES (".$this->db->qstr($name).")";
$queryStr = "INSERT INTO `tblCategory` (`name`, `color`) VALUES (".$this->db->qstr($name).", ".$this->db->qstr($color).")";
if (!$this->db->getResult($queryStr))
return false;

View File

@ -471,7 +471,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
return false;
foreach ($resArr as $row) {
$cat = new SeedDMS_Core_DocumentCategory($row['id'], $row['name']);
$cat = new SeedDMS_Core_DocumentCategory($row['id'], $row['name'], $row['color']);
$cat->setDMS($this->_dms);
$this->_categories[] = $cat;
}

View File

@ -33,15 +33,22 @@ class SeedDMS_Core_DocumentCategory {
*/
protected $_name;
/**
* @var string $_color color of category in html notation
* @access protected
*/
protected $_color;
/**
* @var object $_dms reference to dms this category belongs to
* @access protected
*/
protected $_dms;
function __construct($id, $name) { /* {{{ */
function __construct($id, $name, $color) { /* {{{ */
$this->_id = $id;
$this->_name = $name;
$this->_color = $color;
$this->_dms = null;
} /* }}} */
@ -64,6 +71,19 @@ class SeedDMS_Core_DocumentCategory {
return true;
} /* }}} */
function getColor() { return $this->_color; }
function setColor($newColor) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblCategory` SET `color` = ".$db->qstr($newColor)." WHERE `id` = ". $this->_id;
if (!$db->getResult($queryStr))
return false;
$this->_color = $newColor;
return true;
} /* }}} */
function isUsed() { /* {{{ */
$db = $this->_dms->getDB();

View File

@ -25,6 +25,7 @@
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes>
add class SeedDMS_Core_ApiKey
add property color to SeedDMS_Document_Category
</notes>
<contents>
<dir baseinstalldir="SeedDMS" name="/">