/**
 * Returns an HTML description of a single object array.
 * @param $obj_id (int) Object ID.
 * @param $objdata (array) Object data array.
 * @param $tempfields (array) Array of template fields.
 * @param $tfkeys (array) Array of template fields keys.
 * @param $level (int) Count nesting level of child objects.
 * @return string Object data.
 */
function F_get_object_info($obj_id, $objdata, $tempfields, $tfkeys, $level = 0)
{
    global $l, $db;
    require_once '../config/tce_config.php';
    require_once 'tce_functions_group_permissions.php';
    $ret = '';
    // list parent objects of virtual object
    if (isset($objdata['obj_parents']) and !empty($objdata['obj_parents'])) {
        $ret .= getFormDescriptionLine($l['w_child_of'], '', $objdata['obj_parents']);
    }
    // manufacturer
    if (isset($objdata['obj_mnf']) and !empty($objdata['obj_mnf'])) {
        $ret .= getFormDescriptionLine($l['w_manufacturer'], '', htmlspecialchars($objdata['obj_mnf'], ENT_COMPAT, $l['a_meta_charset']));
    }
    // owner
    if (isset($objdata['obj_owner']) and !empty($objdata['obj_owner'])) {
        $ret .= getFormDescriptionLine($l['w_owner'], '', htmlspecialchars($objdata['obj_owner'], ENT_COMPAT, $l['a_meta_charset']));
    }
    // tenant
    if (isset($objdata['obj_tenant']) and !empty($objdata['obj_tenant'])) {
        $ret .= getFormDescriptionLine($l['w_tenant'], '', htmlspecialchars($objdata['obj_tenant'], ENT_COMPAT, $l['a_meta_charset']));
    }
    // label
    if (isset($objdata['obj_label']) and !empty($objdata['obj_label'])) {
        $ret .= getFormDescriptionLine($l['w_label'], $l['h_ojbect_label'], htmlspecialchars($objdata['obj_label'], ENT_COMPAT, $l['a_meta_charset']));
    }
    // tag
    if (isset($objdata['obj_tag']) and !empty($objdata['obj_tag'])) {
        $ret .= getFormDescriptionLine($l['w_tag'], $l['h_ojbect_tag'], htmlspecialchars($objdata['obj_tag'], ENT_COMPAT, $l['a_meta_charset']));
    }
    // description
    if (isset($objdata['obj_description']) and !empty($objdata['obj_description'])) {
        $ret .= getFormDescriptionLine($l['w_description'], $l['h_object_description'], htmlspecialchars($objdata['obj_description'], ENT_COMPAT, $l['a_meta_charset']));
    }
    // attributes
    if (isset($objdata['attribute']) and !empty($objdata['attribute'])) {
        foreach ($objdata['attribute'] as $atb_name => $atb_value) {
            if (!empty($atb_value)) {
                $val = htmlspecialchars($atb_value, ENT_COMPAT, $l['a_meta_charset']);
                if ($atb_name == 'IP' or $atb_name == 'IPv4' or $atb_name == 'IPv6') {
                    $ret .= getFormDescriptionLine($atb_name, '', '<a href="http://' . $val . '" title="IP" onclick="pdfWindow=window.open(\'http://' . $val . '\',\'pdfWindow\',\'dependent,menubar=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=yes\'); return false;">' . $val . '</a>');
                } else {
                    // replace template tokens on attribute value (if any)
                    $tmpval = $val;
                    // search #~...~# pattern on $val
                    preg_match_all('/([#][~][^~]+[~][#])/U', $val, $matches, PREG_SET_ORDER);
                    foreach ($matches as $v) {
                        if (isset($v[1])) {
                            $pattern = str_replace('*', '[A-Z0-9]', $v[1]);
                            if (preg_match('/' . $pattern . '/U', $tfkeys, $mk) > 0) {
                                if (isset($mk[0]) and !empty($mk[0]) and isset($tempfields[$mk[0]])) {
                                    $tmpval = str_replace($v[1], $tempfields[$mk[0]], $tmpval);
                                }
                            }
                        }
                    }
                    $val = $tmpval;
                    // check for link type
                    if (F_isURL($val)) {
                        // the attribute is a link
                        $val = '<a href="' . $val . '" title="' . $atb_name . '">' . $val . '</a>';
                    }
                    $ret .= getFormDescriptionLine($atb_name, '', $val);
                }
            }
        }
    }
    // Permissions
    if ($level == 0) {
        // print permissions only for parent objects
        $ret .= '<div class="row">' . K_NEWLINE;
        $ret .= '<span class="label">' . K_NEWLINE;
        $ret .= $l['w_permissions'] . ':' . K_NEWLINE;
        $ret .= '</span>' . K_NEWLINE;
        $ret .= '<div class="value">';
        $ret .= F_groupsPermsSelector($objdata['permissions'], true, true);
        $ret .= '</div>' . K_NEWLINE;
        $ret .= '</div>' . K_NEWLINE;
    }
    // list connections
    $connections = F_get_object_connections($obj_id);
    if (!empty($connections)) {
        $ret .= getFormDescriptionLine($l['w_connected_to'], '', $connections);
    }
    // *** list child ojbects (if any)
    if (isset($objdata['child']) and !empty($objdata['child'])) {
        $ret .= '<div class="row">' . K_NEWLINE;
        $ret .= '<span class="label">' . K_NEWLINE;
        $ret .= $l['w_child_objects'] . ':' . K_NEWLINE;
        $ret .= '</span>' . K_NEWLINE;
        $ret .= '<br /><div class="value">';
        foreach ($objdata['child'] as $name => $data) {
            $ret .= '<div style="background-color:#ffff99;font-weight:bold;">';
            $ret .= '<a href="tce_edit_objects.php?obj_id=' . $data['obj_id'] . '" title="' . $l['t_object_editor'] . ': ' . $data['obj_name'] . '">';
            if ($data['obj_obt_virtual']) {
                $ret .= '&otimes; ';
            }
            $ret .= htmlspecialchars($data['obj_name'], ENT_NOQUOTES, $l['a_meta_charset']);
            $ret .= '</a>';
            $ret .= '</div>';
            $ret .= F_get_object_info($data['obj_id'], $data, $tempfields, $tfkeys, ++$level);
        }
        $ret .= '</div>' . K_NEWLINE;
        $ret .= '</div>' . K_NEWLINE;
    }
    $ret .= '<div style="clear:both;margin:0;padding:0;height:0;font-size:0;">&nbsp;</div>' . K_NEWLINE;
    return $ret;
}
Example #2
0
echo '<div class="container">' . K_NEWLINE;
echo '<div class="tceformbox">' . K_NEWLINE;
echo '<form action="' . $_SERVER['SCRIPT_NAME'] . '" method="post" enctype="multipart/form-data" id="form_editor">' . K_NEWLINE;
echo F_select_datacenter($dcn_id, $datacenter_data, false);
echo F_select_suite($dcn_id, $sts_id, $suite_data, true);
echo '<div class="row"><hr /></div>' . K_NEWLINE;
echo getFormRowTextInput('sts_name', $l['w_name'], $l['h_suite_name'], '', $sts_name, '', 255, false, false, false, '');
echo getFormRowTextBox('sts_description', $l['w_description'], $l['h_suite_description'], $sts_description, false, '');
echo getFormRowTextInput('sts_floor', $l['w_floor'], $l['h_suite_floor'], '', $sts_floor, '', 255, false, false, false, '');
echo getFormRowTextInput('sts_width', $l['w_width'], $l['h_suite_width'], '[# ' . $l['w_racks'] . ']', $sts_width, '', 255, false, false, false, '');
echo getFormRowTextInput('sts_height', $l['w_height'], $l['h_suite_height'], '[# ' . $l['w_racks'] . ']', $sts_height, '', 255, false, false, false, '');
// -----------------------------------------------------------------------------
// group permissions
echo '<fieldset class="subset" style="text-align:left;">' . K_NEWLINE;
echo '<legend>' . $l['t_permissions'] . '</legend>' . K_NEWLINE;
echo F_groupsPermsSelector($perms, false);
echo '</fieldset>' . K_NEWLINE;
// -----------------------------------------------------------------------------
echo '<div class="row">' . K_NEWLINE;
// show buttons by case
if (isset($sts_id) and $sts_id > 0) {
    if ($userlevel >= K_AUTH_ADMINISTRATOR or ($perms & 4) > 0) {
        echo '<span style="background-color:#999999;">';
        echo '<input type="checkbox" name="confirmupdate" id="confirmupdate" value="1" title="confirm &rarr; update" />';
        F_submit_button('update', $l['w_update'], $l['h_update']);
        echo '</span>';
    }
    if ($userlevel >= K_AUTH_ADMINISTRATOR or ($perms & 8) > 0) {
        F_submit_button('delete', $l['w_delete'], $l['h_delete']);
    }
} else {
//end of switch
// -----------------------------------------------------------------------------
echo '<div class="container">' . K_NEWLINE;
echo '<div class="tceformbox">' . K_NEWLINE;
echo '<form action="' . $_SERVER['SCRIPT_NAME'] . '" method="post" enctype="multipart/form-data" id="form_editor">' . K_NEWLINE;
// *** selection filter ***
echo F_getDataFilter($dcn_id, $sts_id, $rck_id, $obt_id, $obj_owner_id, $obj_tenant_id, $keywords);
// display selected objects with checkboxes for selection
if ($filtered === true) {
    echo F_getSelectedObject($dcn_id, $sts_id, $rck_id, $obt_id, $obj_owner_id, $obj_tenant_id, $keywords);
    // *** user groups ***
    // -----------------------------------------------------------------------------
    // group permissions
    echo '<fieldset class="subset" style="text-align:left;">' . K_NEWLINE;
    echo '<legend>' . $l['t_permissions'] . '</legend>' . K_NEWLINE;
    echo F_groupsPermsSelector($perms, true);
    echo '</fieldset>' . K_NEWLINE;
    // -----------------------------------------------------------------------------
    echo getFormRowCheckBox('sshkey_overwrite', $l['w_overwrite'], $l['h_sshkey_overwrite'], '', '1', $sshkey_overwrite, false, '');
    // generate button
    echo '<div class="row">' . K_NEWLINE;
    F_submit_button('update', $l['w_update'], $l['h_update']);
    if ($userlevel >= K_AUTH_ADMINISTRATOR) {
        F_submit_button('updatessh', $l['w_update_ssh'], $l['h_update_ssh']);
    }
    echo '</div>' . K_NEWLINE;
}
echo '<div class="row">' . K_NEWLINE;
echo '&nbsp;' . K_NEWLINE;
// comma separated list of required fields
echo '<input type="hidden" name="ff_required" id="ff_required" value="" />' . K_NEWLINE;
Example #4
0
    echo F_object_selector($cab_a_obj_id, 'cab_a_obj_id', $l['w_object'], true, false, true, true);
    echo F_select_connection_type($cab_a_cbt_id, false, false, 'cab_a_cbt_id');
    echo F_select_color($cab_a_color, 'cab_a_color', $l['w_color'], $l['h_cable_color']);
    echo '</fieldset>' . K_NEWLINE;
    echo '<fieldset class="subset" style="text-align:left;margin:10px;width:98%;">' . K_NEWLINE;
    echo '<legend>' . $l['w_connection_second'] . '</legend>' . K_NEWLINE;
    echo F_object_selector($cab_b_obj_id, 'cab_b_obj_id', $l['w_object'], true, false, true, true);
    echo F_select_connection_type($cab_b_cbt_id, false, false, 'cab_b_cbt_id');
    echo F_select_color($cab_b_color, 'cab_b_color', $l['w_color'], $l['h_cable_color']);
    echo '</fieldset>' . K_NEWLINE;
    echo '</fieldset>' . K_NEWLINE;
    // -----------------------------------------------------------------------------
    // group permissions
    echo '<fieldset class="subset" style="text-align:left;">' . K_NEWLINE;
    echo '<legend>' . $l['t_permissions'] . '</legend>' . K_NEWLINE;
    echo F_groupsPermsSelector($perms, $num_perms > 4);
    echo '</fieldset>' . K_NEWLINE;
    // -----------------------------------------------------------------------------
}
echo '<div class="row">' . K_NEWLINE;
// show buttons by case
if (isset($obj_id) and $obj_id > 0) {
    if ($userlevel >= K_AUTH_ADMINISTRATOR or ($perms & 4) > 0) {
        echo '<span style="background-color:#999999;">';
        echo '<input type="checkbox" name="confirmupdate" id="confirmupdate" value="1" title="confirm &rarr; update" />';
        F_submit_button('update', $l['w_update'], $l['h_update']);
        if ($userlevel >= K_AUTH_ADMINISTRATOR) {
            F_submit_button('updatessh', $l['w_update_ssh'], $l['h_update_ssh']);
        }
        echo '</span>';
    }