<?php
/*
* Free IT Foundation
* Free Technology Serving Knowledge
* http://www.free-it-foundation.org
*
* This file is part of Knowledge Box.
*
* Knowledge Box is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Knowledge Box is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Knowledge Box. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* class
* KBModuleConfig
*/
class KBModuleConfig extends CDpObject
{
var $base_id = 0;
var $property = 0;
var $value = "";
/*
* constructor
*/
function KBModuleConfig ()
{
// void
}
/*
* getBaseId ()
*/
function getBaseId ()
{
return $this->base_id;
}
/*
* setBaseId ()
*/
function setBaseId ($base_id)
{
$this->base_id = (int) $base_id;
}
/*
* getProperty ()
*/
function getProperty ()
{
return $this->property;
}
/*
* setProperty ()
*/
function setProperty ($property)
{
$this->property = (int) $property;
}
/*
* getValue ()
*/
function getValue ()
{
return $this->getStringValue ();
}
/*
* setValue ()
*/
function setValue ($value)
{
$this->setStringValue ($value);
}
/*
* getStringValue ()
*/
function getStringValue ()
{
return (string) $this->value;
}
/*
* setStringValue ()
*/
function setStringValue ($value)
{
$this->value = (string) $value;
}
/*
* getIntValue ()
*/
function getIntValue ()
{
return (int) $this->value;
}
/*
* setIntValue ()
*/
function setIntValue ($value)
{
$this->value = (int) $value;
}
/*
* store ()
*/
function store ()
{
// free
$this->delete ();
// insert
$sql = "INSERT INTO `" . KB_TABLE_CONFIGS . "`";
$sql .= " ( `base_id` , `property` , `value` )";
$sql .= " VALUES (";
$sql .= " '" . $this->base_id . "',";
$sql .= " '" . $this->property . "',";
$sql .= " '" . addslashes ($this->value) . "'";
$sql .= ")";
// execute
db_exec ($sql);
}
/*
* delete ()
*/
function delete ()
{
// sql
$sql = "DELETE FROM " . KB_TABLE_CONFIGS;
$sql .= " WHERE base_id = " . $this->base_id;
$sql .= " AND property = " . $this->property;
// execute
db_exec ($sql);
}
/*
* getConfigsByBase ()
*/
function getConfigsByBase ($base_id)
{
$r = array ();
// sql
$sql = "SELECT * FROM " . KB_TABLE_CONFIGS;
$sql .= " WHERE base_id = " . $base_id;
// load
$hash = db_loadList ($sql);
// bind
foreach ($hash as $row)
{
$obj = new KBModuleConfig ();
bindHashToObject ($row, $obj);
$r [] = $obj;
}
// return
return $r;
}
/*
* getConfig ()
*/
function getConfig ($base_id, $property)
{
// sql
$sql = "SELECT * FROM " . KB_TABLE_CONFIGS;
$sql .= " WHERE base_id = '" . (int) $base_id . "'";
$sql .= " AND property = '" . (int) $property . "'";
// load
$obj = new KBModuleConfig ();
// bind
db_loadObject ($sql, $obj);
// return
return $obj;
}
}
?>