Retro compatibilite

This commit is contained in:
Alan Garcia 2014-01-21 16:33:52 +00:00
parent 53eabe7596
commit e61e8d49a9
1 changed files with 5 additions and 7 deletions

View File

@ -157,14 +157,13 @@ class m_variables {
*/
function variable_get($name, $default = null, $createit_comment = null) {
global $conf;
$name=str_replace('.', '_', $name); // Php can't handle POST var with a '.'
$this->variable_init_maybe();
if (isset($conf[$name])) {
return $conf[$name]['value'];
} elseif (!is_null($createit_comment)) {
$this->variable_set($name, $default, $createit_comment);
$this->variable_update_or_create($name, $value, 'DEFAULT', null, null, $createit_comment);
}
return $default;
}
@ -182,8 +181,6 @@ class m_variables {
global $conf, $db, $err;
$err->log('variable', 'variable_set', '+'.serialize($value).'+'.$comment.'+');
$name=str_replace('.', '_', $name); // Php can't handle POST var with a '.'
$conf[$name] = $value;
if (is_object($value) || is_array($value)) {
$value = serialize($value);
@ -202,7 +199,7 @@ class m_variables {
$this->variable_init();
}
function variable_update_or_create($var_name, $var_value, $strata=null, $strata_id=null, $var_id=null) {
function variable_update_or_create($var_name, $var_value, $strata=null, $strata_id=null, $var_id=null, $comment=null) {
global $db, $err;
$err->log('variable', 'variable_update_or_create');
@ -214,12 +211,13 @@ class m_variables {
return false;
}
$sql="INSERT INTO
variable (name, value, strata, strata_id)
variable (name, value, strata, strata_id, comment)
VALUES (
'".mysql_real_escape_string($var_name)."',
'".mysql_real_escape_string($var_value)."',
'".mysql_real_escape_string($strata)."',
'".mysql_real_escape_string($strata_id)."' );";
'".mysql_real_escape_string($strata_id)."',
'".mysql_real_escape_string($comment)."' );";
}
$db->query("$sql");