NetworkPort::showForm PHP Method

showForm() public method

public showForm ( $ID, $options = [] )
    function showForm($ID, $options = array())
    {
        global $CFG_GLPI;
        if (!isset($options['several'])) {
            $options['several'] = false;
        }
        if (!self::canView()) {
            return false;
        }
        $this->initForm($ID, $options);
        $recursiveItems = $this->recursivelyGetItems();
        if (count($recursiveItems) > 0) {
            $lastItem = $recursiveItems[count($recursiveItems) - 1];
            $lastItem_entities_id = $lastItem->getField('entities_id');
        } else {
            $lastItem_entities_id = $_SESSION['glpiactive_entity'];
        }
        $options['entities_id'] = $lastItem_entities_id;
        $this->showFormHeader($options);
        echo "<tr class='tab_bg_1'><td>";
        $this->displayRecursiveItems($recursiveItems, 'Type');
        echo "&nbsp;:</td>\n<td>";
        // Need these to update information
        echo "<input type='hidden' name='items_id' value='" . $this->fields["items_id"] . "'>\n";
        echo "<input type='hidden' name='itemtype' value='" . $this->fields["itemtype"] . "'>\n";
        echo "<input type='hidden' name='_create_children' value='1'>\n";
        echo "<input type='hidden' name='instantiation_type' value='" . $this->fields["instantiation_type"] . "'>\n";
        $this->displayRecursiveItems($recursiveItems, "Link");
        echo "</td>\n";
        $colspan = 2;
        if (!$options['several']) {
            $colspan++;
        }
        echo "<td rowspan='{$colspan}'>" . __('Comments') . "</td>";
        echo "<td rowspan='{$colspan}' class='middle'>";
        echo "<textarea cols='45' rows='{$colspan}' name='comment' >" . $this->fields["comment"] . "</textarea>";
        echo "</td></tr>\n";
        if (!$options['several']) {
            echo "<tr class='tab_bg_1'><td>" . _n('Port number', 'Ports number', 1) . "</td>\n";
            echo "<td>";
            Html::autocompletionTextField($this, "logical_number", array('size' => 5));
            echo "</td></tr>\n";
        } else {
            echo "<tr class='tab_bg_1'><td>" . _n('Port number', 'Port numbers', Session::getPluralNumber()) . "</td>\n";
            echo "<td>";
            echo "<input type='hidden' name='several' value='yes'>";
            echo "<input type='hidden' name='logical_number' value=''>\n";
            echo __('from') . "&nbsp;";
            Dropdown::showNumber('from_logical_number', array('value' => 0));
            echo "&nbsp;" . __('to') . "&nbsp;";
            Dropdown::showNumber('to_logical_number', array('value' => 0));
            echo "</td></tr>\n";
        }
        echo "<tr class='tab_bg_1'><td>" . __('Name') . "</td>\n";
        echo "<td>";
        Html::autocompletionTextField($this, "name");
        echo "</td></tr>\n";
        $instantiation = $this->getInstantiation();
        if ($instantiation !== false) {
            echo "<tr class='tab_bg_1'><th colspan='4'>" . $instantiation->getTypeName(1) . "</th></tr>\n";
            $instantiation->showInstantiationForm($this, $options, $recursiveItems);
            unset($instantiation);
        }
        if (!$options['several']) {
            NetworkName::showFormForNetworkPort($this->getID());
        }
        $this->showFormButtons($options);
    }

Usage Example

Example #1
0
            $np->updateDependencies(1);
            Event::log($_POST["id"], "networkport", 4, "inventory", sprintf(__('%s updates an item'), $_SESSION["glpiname"]));
            Html::back();
        } else {
            if (isset($_POST["disconnect"])) {
                $nn->check($_POST['id'], 'd');
                if (isset($_POST["id"])) {
                    $nn->delete($_POST);
                }
                Html::back();
            } else {
                if (empty($_GET["items_id"])) {
                    $_GET["items_id"] = "";
                }
                if (empty($_GET["itemtype"])) {
                    $_GET["itemtype"] = "";
                }
                if (empty($_GET["several"])) {
                    $_GET["several"] = "";
                }
                if (empty($_GET["instantiation_type"])) {
                    $_GET["instantiation_type"] = "";
                }
                Session::checkRight("networking", "w");
                Html::header(NetworkPort::getTypeName(2), $_SERVER['PHP_SELF'], 'inventory');
                $np->showForm($_GET["id"], $_GET);
                Html::footer();
            }
        }
    }
}