<commit_before><?php
/*"******************************************************************************************************
*   (c) 2004-2006 by MulchProductions, www.mulchprod.de                                                 *
*   (c) 2007-2011 by Kajona, www.kajona.de                                                              *
*       Published under the GNU LGPL v2.1, see /system/licence_lgpl.txt                                 *
*-------------------------------------------------------------------------------------------------------*
*	$Id$                               *
********************************************************************************************************/

/**
 * Model for a single system-setting
 * Setting are not represented by a record in the system-table
 *
 * @package modul_system
 */
class class_modul_system_setting extends class_model implements interface_model  {

    //0 = bool, 1 = int, 2 = string, 3 = page
    //use ONLY the following static vars to assign a type to your constant.
    //integer values may change without warnings!
    /**
     * Used for bool values = 0
     *
     * @var int
     */
    public static $int_TYPE_BOOL = 0;

    /**
     * Used for integer values = 1
     *
     * @var int
     */
    public static $int_TYPE_INT = 1;

    /**
     * Used for string values = 2
     *
     * @var int
     */
    public static $int_TYPE_STRING = 2;

    /**
     * Used for pages = 3
     *
     * @var int
     */
    public static $int_TYPE_PAGE = 3;

    private $strName = "";
    private $strValue = "";
    private $intType = 0;
    private $intModule = 0;

    /**
     * Constructor to create a valid object
     *
     * @param string $strSystemid (use "" on new objects)
     */
    public function __construct($strSystemid = "") {
        $arrModul = array();
        $arrModul["name"] 				= "modul_system";
		$arrModul["author"] 			= "<EMAIL>";
		$arrModul["moduleId"] 			= _system_modul_id_;
		$arrModul["table"]       		= _dbprefix_."system_config";
		$arrModul["modul"]				= "system";

		//base class
		parent::__construct($arrModul, $strSystemid);

		//init current object
		if($strSystemid != "")
		    $this->initObject();
    }

    /**
     * Initalises the current object, if a systemid was given
     *
     */
    public function initObject() {
        $strQuery = "SELECT * FROM ".$this->arrModule["table"]." WHERE system_config_id = '".$this->objDB->dbsafeString($this->getSystemid())."'";
        $arrRow = $this->objDB->getRow($strQuery);

        $this->setStrName($arrRow["system_config_name"]);
        $this->setStrValue($arrRow["system_config_value"]);
        $this->setIntType($arrRow["system_config_type"]);
        $this->setIntModule($arrRow["system_config_module"]);
    }

    /**
     * Updates the current object to the database.
     * Only the value is updated!!!
     *
     * @return bool
     */
    public function updateObjectToDb($strPrevId = false) {

        if(!class_modul_system_setting::checkConfigExisting($this->getStrName())) {
            class_logger::getInstance()->addLogRow("new constant ".$this->getStrName() ." with value ".$this->getStrValue(), class_logger::$levelInfo);

            $strQuery = "INSERT INTO "._dbprefix_."system_config
                        (system_config_id, system_config_name, system_config_value, system_config_type, system_config_module) VALUES
                        ('".$this->objDB->dbsafeString($this->generateSystemid())."', '".$this->objDB->dbsafeString($this->getStrName())."',
                         '".$this->objDB->dbsafeString($this->getStrValue())."', '".(int)$this->getIntType()."', '".(int)$this->getIntModule()."')";
            return $this->objDB->_query($strQuery);
        }
        else {

            class_logger::getInstance()->addLogRow("updated constant ".$this->getStrName() ." to value ".$this->getStrValue(), class_logger::$levelInfo);
            $strQuery = "UPDATE "._dbprefix_."system_config
                        SET system_config_value = '".$this->objDB->dbsafeString($this->getStrValue())."'
                      WHERE system_config_name = '".$this->objDB->dbsafeString($this->getStrName())."'";
            return $this->objDB->_query($strQuery);
        }
    }
    
    
    /**
     * Renames a constant in the database.
     * @param string $strNewName
     * @return bool
     */
    public function renameConstant($strNewName) {
    	class_logger::getInstance()->addLogRow("renamed constant ".$this->getStrName() ." to ".$strNewName, class_logger::$levelInfo);
        
    	
        $strQuery = "UPDATE "._dbprefix_."system_config
                    SET system_config_name = '".$this->objDB->dbsafeString($strNewName)."' WHERE system_config_name = '".$this->objDB->dbsafeString($this->getStrName())."'";<commit_msg>NEW: changing a setting generates a log-entry leveled as a warning instead of an info<commit_after><?php
/*"******************************************************************************************************
*   (c) 2004-2006 by MulchProductions, www.mulchprod.de                                                 *
*   (c) 2007-2011 by Kajona, www.kajona.de                                                              *
*       Published under the GNU LGPL v2.1, see /system/licence_lgpl.txt                                 *
*-------------------------------------------------------------------------------------------------------*
*	$Id$                               *
********************************************************************************************************/

/**
 * Model for a single system-setting
 * Setting are not represented by a record in the system-table
 *
 * @package modul_system
 */
class class_modul_system_setting extends class_model implements interface_model  {

    //0 = bool, 1 = int, 2 = string, 3 = page
    //use ONLY the following static vars to assign a type to your constant.
    //integer values may change without warnings!
    /**
     * Used for bool values = 0
     *
     * @var int
     */
    public static $int_TYPE_BOOL = 0;

    /**
     * Used for integer values = 1
     *
     * @var int
     */
    public static $int_TYPE_INT = 1;

    /**
     * Used for string values = 2
     *
     * @var int
     */
    public static $int_TYPE_STRING = 2;

    /**
     * Used for pages = 3
     *
     * @var int
     */
    public static $int_TYPE_PAGE = 3;

    private $strName = "";
    private $strValue = "";
    private $intType = 0;
    private $intModule = 0;

    /**
     * Constructor to create a valid object
     *
     * @param string $strSystemid (use "" on new objects)
     */
    public function __construct($strSystemid = "") {
        $arrModul = array();
        $arrModul["name"] 				= "modul_system";
		$arrModul["author"] 			= "<EMAIL>";
		$arrModul["moduleId"] 			= _system_modul_id_;
		$arrModul["table"]       		= _dbprefix_."system_config";
		$arrModul["modul"]				= "system";

		//base class
		parent::__construct($arrModul, $strSystemid);

		//init current object
		if($strSystemid != "")
		    $this->initObject();
    }

    /**
     * Initalises the current object, if a systemid was given
     *
     */
    public function initObject() {
        $strQuery = "SELECT * FROM ".$this->arrModule["table"]." WHERE system_config_id = '".$this->objDB->dbsafeString($this->getSystemid())."'";
        $arrRow = $this->objDB->getRow($strQuery);

        $this->setStrName($arrRow["system_config_name"]);
        $this->setStrValue($arrRow["system_config_value"]);
        $this->setIntType($arrRow["system_config_type"]);
        $this->setIntModule($arrRow["system_config_module"]);
    }

    /**
     * Updates the current object to the database.
     * Only the value is updated!!!
     *
     * @return bool
     */
    public function updateObjectToDb($strPrevId = false) {

        if(!class_modul_system_setting::checkConfigExisting($this->getStrName())) {
            class_logger::getInstance()->addLogRow("new constant ".$this->getStrName() ." with value ".$this->getStrValue(), class_logger::$levelWarning);

            $strQuery = "INSERT INTO "._dbprefix_."system_config
                        (system_config_id, system_config_name, system_config_value, system_config_type, system_config_module) VALUES
                        ('".$this->objDB->dbsafeString($this->generateSystemid())."', '".$this->objDB->dbsafeString($this->getStrName())."',
                         '".$this->objDB->dbsafeString($this->getStrValue())."', '".(int)$this->getIntType()."', '".(int)$this->getIntModule()."')";
            return $this->objDB->_query($strQuery);
        }
        else {

            class_logger::getInstance()->addLogRow("updated constant ".$this->getStrName() ." to value ".$this->getStrValue(), class_logger::$levelWarning);
            $strQuery = "UPDATE "._dbprefix_."system_config
                        SET system_config_value = '".$this->objDB->dbsafeString($this->getStrValue())."'
                      WHERE system_config_name = '".$this->objDB->dbsafeString($this->getStrName())."'";
            return $this->objDB->_query($strQuery);
        }
    }
    
    
    /**
     * Renames a constant in the database.
     * @param string $strNewName
     * @return bool
     */
    public function renameConstant($strNewName) {
    	class_logger::getInstance()->addLogRow("renamed constant ".$this->getStrName() ." to ".$strNewName, class_logger::$levelInfo);
        
    	
        $strQuery = "UPDATE "._dbprefix_."system_config
                    SET system_config_name = '".$this->objDB->dbsafeString($strNewName)."' WHERE system_config_name = '".$this->objDB->dbsafeString($this->getStrName())."'";
{'fraction_non_alphanumeric': 0.2036542804352289, 'fraction_numerical': 0.006569492917265448, 'mean_word_length': 2.2871120107962213, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 97, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4620842', 'n_tokens_mistral': 2897, 'n_tokens_neox': 2730, 'n_words': 565}