Example #1
0
function buildVariableEnv($uid, $gid, $tid, &$vardisp, &$bounds, &$privilege, &$tree, &$condensed, &$autoDisplay)
{
    $result = sqlquery("SELECT view_row.name AS user_name, variable.name AS var_name, path, warning_bound, error_bound, alarm_order, view_row.filter as varfilter, view_table.filter as viewfilter, display, auto_display, view_row.vid AS vid " . "FROM variable, view_row, view_table " . "WHERE variable.command='variable' AND (view_table.uid='{$uid}' OR view_table.uid='{$gid}') AND view_table.tid='{$tid}' AND view_row.tid='{$tid}' AND variable.vid=view_row.vid ORDER BY view_row.ordering");
    while ($result && ($arr = sqlfetch($result))) {
        $vid = $arr["vid"];
        if (!hasAccessToVariable($vid)) {
            continue;
        }
        $path = $arr["path"];
        if ($arr["varfilter"] != "" && ($path = filterPath($path, $arr["varfilter"])) == "") {
            continue;
        }
        if ($arr["viewfilter"] != "" && ($path = filterPath($path, $arr["viewfilter"])) == "") {
            continue;
        }
        $condensed = $arr["display"] == "condensed";
        $autoDisplay = $arr["auto_display"] == "auto";
        $varName = getVarName($path);
        $vardisp[$varName] = $arr["user_name"];
        $bounds[$varName] = array($arr["warning_bound"], $arr["error_bound"], $arr["alarm_order"]);
        $privilege[$varName] = getVariableRight($vid);
        $address = explode(".", $path);
        //echo "add to tree address $path<br>\n";
        if (!isset($numsteps)) {
            $numsteps = count($address);
        }
        if ($numsteps != count($address)) {
            echo "Invalid table <b>{$tid}</b>, contains different variable path length (typically, mixed shard/server/service variables with entity variables)\n";
            return;
        }
        addToNode($tree, $address, 0);
    }
}
Example #2
0
 echo "<form method=post action='" . $_SERVER['PHP_SELF'] . "?tid={$tid}'><th><select name=sel_vgid onChange='submit()'>\n";
 foreach ($vargroups as $vargroup => $vgid) {
     echo "<option value='{$vgid}'" . ($sel_vgid == $vgid ? " selected" : "") . ">{$vargroup}\n";
 }
 echo "<option value='-1'" . (!isset($sel_vgid) || $sel_vgid == '-1' ? " selected" : "") . ">All Groups\n";
 echo "</select></th></form>\n";
 echo "<th>Path</th><th>State</th><th>Privilege</th></tr>\n";
 $result = sqlquery("SELECT command, variable.vid AS vid, variable.name AS name, path, state, variable.vgid AS vgid, variable_group.name AS group_name " . "FROM variable, variable_group " . "WHERE variable.vgid = variable_group.vgid" . (isset($sel_vgid) && $sel_vgid != "-1" ? " AND variable.vgid='{$sel_vgid}'" : "") . " ORDER BY variable.command, variable.vgid, variable.name");
 if (!$result) {
     die("variable select failed !");
 }
 $prevvgid = "";
 $prevvtype = "";
 while ($arr = mysql_fetch_array($result)) {
     $vid = $arr["vid"];
     if (!hasAccessToVariable($vid)) {
         continue;
     }
     $priv = getVariableRight($vid);
     if ($prevvtype != "" && $prevvtype != $arr["command"]) {
         echo "<tr height=15><td colspan=5></td></tr>\n";
         echo "<tr><th>Command</th><th>Group</th><th>Path</th><th>State</th><th>Privilege</th></tr>\n";
         $prevvgid = "";
     }
     if ($prevvgid != "" && $prevvgid != $arr["vgid"]) {
         echo "<tr height=5><td colspan=5></td></tr>\n";
     }
     $prevvgid = $arr["vgid"];
     $prevvtype = $arr["command"];
     echo "<tr><td><b><a href='" . $_SERVER['PHP_SELF'] . "?addToView={$vid}&tid={$tid}&sel_vgid={$sel_vgid}'>" . $arr["name"] . "</a></b></td>" . "<td>" . $arr["group_name"] . "</td>" . "<td>" . $arr["path"] . "</td>" . "<td>" . $arr["state"] . "</td>" . "<td>{$priv}</td></tr>\n";
 }