Alternc  3.2
Alternc logiel libre pour l'h├ębergement
 All Data Structures Namespaces Files Functions Variables Pages
adm_var_edit.php File Reference

Go to the source code of this file.

Functions

 var_input ($infotype, $name, $value='')
 edit_var ($var_arr)
 add_var ($stratatata, $stratatata_arr=null)

Variables

 $fields
if(empty($var)) $var_v = null
if($var_id &&$delete) else if($strata
&&$var_name &&$var_v) else 
if ($var_id &&$var_v)
 $members = $admin->get_list()
 $panel_url = $fqdn=$dom->get_panel_url_list()
 $allvars = $variables->variables_list()
 $members_list = array()
foreach($admin->get_list() as
$mid=> $mlogin) 
$creators_list = array()
 foreach ($admin->get_creator_list() as $mid=> $mlogin)

Function Documentation

add_var (   $stratatata,
  $stratatata_arr = null 
)

Definition at line 186 of file adm_var_edit.php.

References $allvars, ehe(), eoption(), isset, and var_input().

{
global $var, $allvars;
echo "<div id='add_var_div_$stratatata'><form method=post>";
echo "<input type='hidden' name='strata' value='";ehe($stratatata);echo "' />";
echo "<input type='hidden' name='var_name' value='";ehe($var);echo "' />";
if (is_array($stratatata_arr)) {
echo "<select name='strata_id'>";
eoption($stratatata_arr, null);
echo "</select> ";
}
$infotype = $allvars['DEFAULT'][null][$var]['type'];
if (is_array( $infotype )) {
echo "<ul>";
foreach ($allvars['DEFAULT'][null][$var]['type'] as $kk => $vv) {
echo "<li>";
if ( is_array($vv) && ! (isset($vv['desc']) && isset($vv['type'])) ) { // if is an array but not the last array, used to contain DESC and TYPE
echo $kk;
echo "<ul>";
foreach ($vv as $ll => $mm ) {
echo "<li>";
var_input($infotype[$kk][$ll], "var_value_arr[$kk][$ll]" );
echo "</li>";
}
echo "</ul>";
} else {
var_input($infotype[$kk], "var_value_arr[$kk]" );
}
echo "</li>";
}
echo "</ul>";
} else {
echo "<input type='text' class='int' name='var_value' value='' size='30' />";
}
echo "<br/>";
echo "<input type='button' class='inb cancel' name='cancel' value='"._('Cancel')."' onclick=\"$('#add_var_div_$stratatata').toggle();\" />";
echo "<input type='submit' class='inb ok' value='"._("Apply")."'/>";
echo "</form></div>";
echo "<script type='text/javascript'>$('#add_var_div_$stratatata').toggle();</script>";
}
echo "<table class='tlist'>";
foreach ( $variables->strata_order as $strata) {
echo "<tr class='lst'>";
echo "<td>"; __($strata); echo "</td>";
switch($strata) {
case 'DEFAULT':
echo "<td>"; $variables->display_value_html($allvars, 'DEFAULT', null, $var); echo "</td>";
break;
case 'GLOBAL':
echo "<td>";
if ( isset($allvars['GLOBAL'][null][$var]) && is_array($allvars['GLOBAL'][null][$var])){
echo "<a href='javascript:edit_var(".$allvars['GLOBAL'][null][$var]['id'].");'>"; $variables->display_value_html($allvars, 'GLOBAL', null, $var); echo "</a>";
edit_var($allvars['GLOBAL'][null][$var]);
} else {
echo "<a href='javascript:add_var(\"$strata\");'>"._("Add")."</a>";
add_var($strata);
}
echo "</td>";
break;
case 'FQDN_CREATOR':
echo "<td>";
if (isset($allvars['FQDN_CREATOR']) && is_array($allvars['FQDN_CREATOR'])) {
foreach ($allvars['FQDN_CREATOR'] as $ttk => $ttv ) {
if ( isset($ttv[$var]) && is_array( $ttv[$var])) {
echo sprintf(_("Overwritted by %s"), $members[$ttk]['login'])." &rarr; ";
echo "<a href='javascript:edit_var(".$ttv[$var]['id'].");'>"; echo $variables->display_valueraw_html($ttv[$var]['value'], $var);echo "</a>";
edit_var($ttv[$var]);
}
echo "<br/>";
}
} // isset
echo "<a href='javascript:add_var(\"$strata\");'>"._("Add")."</a>";
echo "</td>";
break;
case 'FQDN':
echo "<td>";
if ( isset($allvars['FQDN']) && is_array($allvars['FQDN'])) {
foreach ($allvars['FQDN'] as $ttk => $ttv ) {
if ( isset($ttv[$var]) && is_array( $ttv[$var])) {
echo sprintf(_("Overwritted by %s"), $panel_url[$ttk])." &rarr; ";
echo "<a href='javascript:edit_var(".$ttv[$var]['id'].");'>"; echo $variables->display_valueraw_html($ttv[$var]['value'], $var);echo "</a>";
edit_var($ttv[$var]);
}
echo "<br/>";
}
} //isset
echo "<a href='javascript:add_var(\"$strata\");'>"._("Add")."</a>";
add_var($strata, $panel_url);
echo "</td>";
break;
case 'CREATOR':
echo "<td>";
if (isset($allvars['CREATOR']) && is_array($allvars['CREATOR'])) {
foreach ($allvars['CREATOR'] as $ttk => $ttv ) {
if ( isset($ttv[$var]) && is_array( $ttv[$var])) {
echo sprintf(_("Overwritted by %s"), $members[$ttk]['login'])." &rarr; ";
echo "<a href='javascript:edit_var(".$ttv[$var]['id'].");'>"; echo $variables->display_valueraw_html($ttv[$var]['value'], $var);echo "</a>";
edit_var($ttv[$var]);
}
echo "<br/>";
}
} //isset
echo "<a href='javascript:add_var(\"$strata\");'>"._("Add")."</a>";
add_var($strata, $creators_list );
echo "</td>";
break;
case 'MEMBER':
echo "<td>";
if (isset($allvars['MEMBER']) && is_array($allvars['MEMBER'])) {
foreach ($allvars['MEMBER'] as $ttk => $ttv ) {
if ( isset($ttv[$var]) && is_array( $ttv[$var])) {
echo sprintf(_("Overwritted by %s"), $members[$ttk]['login'])." &rarr; ";
echo "<a href='javascript:edit_var(".$ttv[$var]['id'].");'>"; echo $variables->display_valueraw_html($ttv[$var]['value'], $var);echo "</a>";
edit_var($ttv[$var]);
}
echo "<br/>";
}
} //isset
echo "<a href='javascript:add_var(\"$strata\");'>"._("Add")."</a>";
echo "</td>";
break;
case 'DOMAIN':
//FIXME TODO
echo "<td>Todo.</td>";
break;
} //switch
echo "</tr>";
} //foreach
edit_var (   $var_arr)

Definition at line 148 of file adm_var_edit.php.

References $allvars, ehe(), and var_input().

{
global $allvars;
echo "<div id='edit_var_div_{$var_arr['id']}'><form method=post>";
echo "<input type='hidden' name='var_id' value='";ehe($var_arr['id']);echo "' />";
if (is_array( $allvars['DEFAULT'][null][$var_arr['name']]['type'] )) {
echo "<ul>";
$infotype = $allvars['DEFAULT'][null][$var_arr['name']]['type'];
//foreach ($allvars['DEFAULT'][null][$var_arr['name']]['type'] as $kk => $vv) {
foreach ($var_arr['value'] as $kk => $vv) {
echo "<li>";
if ( is_array($vv)) {
echo $kk;
echo "<ul>";
foreach ($vv as $ll => $mm ) {
echo "<li>";
var_input($infotype[$kk][$ll], "var_value_arr[$kk][$ll]", $var_arr['value'][$kk][$ll] );
echo "</li>";
}
echo "</ul>";
} else {
var_input($infotype[$kk], "var_value_arr[$kk]", $var_arr['value'][$kk]);
}
echo "</li>";
}
echo "</ul>";
} else {
echo "<input type='text' class='int' name='var_value' value='";ehe($var_arr['value']); echo "' size='30' />";
}
echo "<br/>";
echo "<input type='button' class='inb cancel' name='cancel' value='"._('Cancel')."' onclick=\"$('#edit_var_div_{$var_arr['id']}').toggle();\" />";
echo "<input type='submit' class='inb ok' value='"._("Apply")."'/>";
echo "<input type='submit' class='inb delete' name='delete' value='"._("Delete")."' onclick=\"return confirm('"; ehe(_("Are you sure you want to delete it.")); echo "')\" />";
echo "</form></div>";
echo "<script type='text/javascript'>$('#edit_var_div_{$var_arr['id']}').toggle();</script>";
}
var_input (   $infotype,
  $name,
  $value = '' 
)

Definition at line 122 of file adm_var_edit.php.

References $value, cbox(), and ehe().

Referenced by add_var(), and edit_var().

{
$id = rand();
echo "<label for='add_$id'>".$infotype['desc']."</label>";
switch(strtolower($infotype['type'])) {
case "string":
echo "<input type='text' class='int' id='add_$id' name='$name' value='";ehe($value); echo "' size='30' />&nbsp;";
echo "<em>"._("Value expected: string")."</em>";
break;
case "integer":
echo "<input type='text' class='int' id='add_$id' name='$name' value='";ehe($value); echo "' size='10' pattern='[0-9]+'/>&nbsp;";
echo "<em>"._("Value expected: integer")."</em>";
break;
case "ip":
echo "<input type='text' class='int' id='add_$id' name='$name' value='";ehe($value); echo "' size='15' pattern='[0-9\.:]+' />&nbsp;";
echo "<em>"._("Value expected: IP address")."</em>";
break;
case "boolean":
echo "<input type='hidden' name='$name' value='0' />"; // This way, there is allways something send, even if checkbox is unchecked
echo "<input type='checkbox' id='add_$id' name='$name' value='1' ";cbox($value);echo " />";
break;
default:
echo "WTF ? Dunno what to do with a ".$infotype['type'];
break;
}
}

Variable Documentation

$allvars = $variables->variables_list()

Definition at line 104 of file adm_var_edit.php.

Referenced by add_var(), and edit_var().

foreach ($admin->get_list() as $mid=> $mlogin) $creators_list = array()

Definition at line 111 of file adm_var_edit.php.

$fields
Initial value:
array (
"var" => array ("get", "string", null),
"var_id" => array ("post", "integer", null),
"var_value" => array ("post", "string", null),
"var_value_arr" => array ("post", "array", null),
"var_name" => array ("post", "string", null),
"strata" => array ("post", "string", null),
"strata_id" => array ("post", "integer", null),
"delete" => array ("post", "boolean", false),
)

Definition at line 12 of file adm_var_edit.php.

$members = $admin->get_list()

Definition at line 101 of file adm_var_edit.php.

Referenced by checkfqdn().

$members_list = array()

Definition at line 106 of file adm_var_edit.php.

$panel_url = $fqdn=$dom->get_panel_url_list()

Definition at line 102 of file adm_var_edit.php.

if (empty($var)) $var_v = null

Definition at line 86 of file adm_var_edit.php.

foreach($variables->strata_order as $strata)

Definition at line 112 of file adm_var_edit.php.

if ($var_id &&$delete) else if ($strata &&$var_name &&$var_v) else if($var_id &&$var_v)

Definition at line 95 of file adm_var_edit.php.