36 var
$strata_order = array(
'DEFAULT',
'GLOBAL',
'FQDN_CREATOR',
'FQDN',
'CREATOR',
'MEMBER',
'DOMAIN');
46 $this->replace_array = array(
61 if (! is_array($son))
return $father;
62 foreach ($son as $k=>$v) {
87 if (
isset($_SERVER[
'HTTP_HOST'])) {
88 $host=$_SERVER[
'HTTP_HOST'];
122 if (
$uid != NULL ) {
130 foreach ( $this->strata_order as $strata) {
131 if (!
isset($arr_var[$strata]) || !is_array($arr_var[$strata]))
continue;
136 $variablesList = current($arr_var[
"DEFAULT"]);
143 if ( is_array($sub_infos) &&
isset($arr_var[
'FQDN_CREATOR'][$sub_infos[
'member_id']]) && is_array($arr_var[
'FQDN_CREATOR'][$sub_infos[
'member_id']])) {
148 if ( is_array($sub_infos) &&
isset($arr_var[
'FQDN'][$sub_infos[
'sub_id']]) && is_array($arr_var[
'FQDN'][$sub_infos[
'sub_id']])) {
158 if (
$uid &&
isset($arr_var[
'MEMBER'][
$uid]) && is_array($arr_var[
'MEMBER'][$uid])) {
171 if (!
isset($hh[
'value'])) {
174 $variables[$vv][
'value'] = strtr($hh[
'value'], $this->replace_array );
193 $this->cache_variable_list =
false;
213 function variable_get($name, $default = null, $createit_comment = null, $type=null) {
218 if (
isset($conf[$name])) {
219 return $conf[$name][
'value'];
220 } elseif (!is_null($createit_comment)) {
242 $err->log(
'variable',
'variable_update_or_create');
243 if ( strtolower($var_id) ==
'null' ) $var_id = null;
244 if ( strtolower($strata_id) ==
'null' ) $strata_id = null;
246 if (is_object($type) || is_array($type)) {
247 $type = serialize($type);
249 if (is_object($var_value) || is_array($var_value)) {
250 $var_value = serialize($var_value);
253 if ( ! is_null($var_id) ) {
254 $sql=
"UPDATE variable SET value='".mysql_real_escape_string($var_value).
"' WHERE id = ".intval($var_id);
256 if ( empty($strata) ) {
257 $err->raise(
'variables', _(
"Err: Missing strata when creating var"));
261 variable (name, value, strata, strata_id, comment, type)
263 '".mysql_real_escape_string($var_name).
"',
264 '".mysql_real_escape_string($var_value).
"',
265 '".mysql_real_escape_string($strata).
"',
266 ".( is_null($strata_id)?
'NULL':
"'".mysql_real_escape_string($strata_id).
"'").
",
267 '".mysql_real_escape_string($comment).
"',
268 '".mysql_real_escape_string($type).
"' );";
285 $result = $db->query(
"DELETE FROM `variable` WHERE id = '".intval($id).
"'");
302 $output .=
"<em>"._(
"Empty array").
"</em>";
305 foreach ( $v as $k=>$l) {
307 if (! is_numeric($k)) {
308 if (is_null($varname)) {
313 $output .= $this->
variables_list()[
'DEFAULT'][null][$varname][
'type'][$k][
'desc'];
318 $output .= $this->
variables_list()[
'DEFAULT'][null][$varname][
'type'][$k];
323 $output .= $this->
variables_list()[
'DEFAULT'][null][$varname][
'type'][$k][
'desc'];
328 foreach ($l as $m => $n ) {
330 if ( is_numeric($m)) {
333 $output .= $this->
variables_list()[
'DEFAULT'][null][$varname][
'type'][$k][$m][
'desc'];
346 }
else if (empty($v) && $v !=
'0') {
347 $output .=
"<em>"._(
"Empty").
"</em>";
369 if (
isset(
$tab[$strata][$id][$varname][
'value'])) {
370 $v =
$tab[$strata][$id][$varname][
'value'];
373 $output .=
"<em>"._(
"None defined").
"</em>";
390 $result = $db->query(
'SELECT name, comment FROM `variable` order by name');
392 while ($db->next_record($result)) {
393 $tname = $db->f(
'name');
395 if ( !
isset(
$t[$tname] ) || strlen(
$t[$tname]) < $db->f(
'comment') ) {
396 $t[$db->f(
'name')] = $db->f(
'comment');
410 if ( ! $this->cache_variable_list ) {
412 $result = $db->query(
'SELECT * FROM `variable`');
415 while ($db->next_record($result)) {
417 if ( (
$value = @unserialize($db->f(
'value'))) === FALSE) {
420 if ( ($type = @unserialize($db->f(
'type'))) === FALSE) {
421 $type=$db->f(
'type');
423 $arr_var[$db->f(
'strata')][$db->f(
'strata_id')][$db->f(
'name')] = array(
'id'=>$db->f(
'id') ,
'name'=>$db->f(
'name'),
'value'=>
$value,
'comment'=>$db->f(
'comment'),
'type'=>$type);
425 $this->cache_variable_list = $arr_var;