Example #1
0
 https://forge.indepnet.net/projects/archires
 -------------------------------------------------------------------------

 LICENSE

 This file is part of archires.

 Archires is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 Archires is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with Archires. If not, see <http://www.gnu.org/licenses/>.
 --------------------------------------------------------------------------
*/
include "../../../inc/includes.php";
Html::header(PluginArchiresArchires::getTypeName() . " " . PluginAppliancesAppliance::getTypeName(), '', "plugins", "archires", "appliance");
$PluginArchiresApplianceQuery = new PluginArchiresApplianceQuery();
if ($PluginArchiresApplianceQuery->canView() || Session::haveRight("config", "w")) {
    Search::show("PluginArchiresApplianceQuery");
} else {
    Html::displayRightError();
}
Html::footer();
Example #2
0
 function createGraph($format, $obj, $plugin_archires_views_id)
 {
     global $DB, $CFG_GLPI;
     $type = get_class($obj);
     $ID = $obj->fields["id"];
     $object_view = $obj->fields["plugin_archires_views_id"];
     if (!isset($plugin_archires_views_id)) {
         $plugin_archires_views_id = $object_view;
     }
     $PluginArchiresView = new PluginArchiresView();
     $plugin = new Plugin();
     if ($plugin->isActivated("appliances")) {
         $PluginArchiresApplianceQuery = new PluginArchiresApplianceQuery();
     }
     $PluginArchiresLocationQuery = new PluginArchiresLocationQuery();
     $PluginArchiresNetworkEquipmentQuery = new PluginArchiresNetworkEquipmentQuery();
     $PluginArchiresImageItem = new PluginArchiresImageItem();
     $PluginArchiresView->getFromDB($plugin_archires_views_id);
     $devices = array();
     $ports = array();
     if ($type == 'PluginArchiresLocationQuery') {
         $devices = $PluginArchiresLocationQuery->Query($ID, $PluginArchiresView, true);
         $ports = $PluginArchiresLocationQuery->Query($ID, $PluginArchiresView, false);
     } else {
         if ($type == 'PluginArchiresNetworkEquipmentQuery') {
             $devices = $PluginArchiresNetworkEquipmentQuery->Query($ID, $PluginArchiresView, true);
             $ports = $PluginArchiresNetworkEquipmentQuery->Query($ID, $PluginArchiresView, false);
         } else {
             if ($type == 'PluginArchiresApplianceQuery') {
                 $devices = $PluginArchiresApplianceQuery->Query($ID, $PluginArchiresView, true);
                 $ports = $PluginArchiresApplianceQuery->Query($ID, $PluginArchiresView, false);
             }
         }
     }
     $wires = array();
     $query = "SELECT `id`, `networkports_id_1`, `networkports_id_2`\n                FROM `glpi_networkports_networkports`";
     if ($result = $DB->query($query)) {
         while ($data = $DB->fetch_array($result)) {
             $wires[$data["id"]]["networkports_id_1"] = $data["networkports_id_1"];
             $wires[$data["id"]]["networkports_id_2"] = $data["networkports_id_2"];
         }
     }
     $graph = "graph G {\n";
     $graph .= "overlap=false;\n";
     $graph .= "bgcolor=white;\n";
     //items
     $graph .= "node [shape=polygon, sides=6, fontname=\"Verdana\", fontsize=\"5\"];\n";
     foreach ($devices as $itemtype => $typed_devices) {
         foreach ($typed_devices as $device_id => $device) {
             $image_name = $PluginArchiresImageItem->displayItemImage($device["type"], $itemtype, false);
             $link = Toolbox::getItemTypeFormURL($itemtype);
             $url = $link . "?id=" . $device_id;
             $graph .= $this->graphItems($device, $device_id, $itemtype, $format, $image_name, $url, $PluginArchiresView);
         }
     }
     foreach ($wires as $wire) {
         if (!empty($ports[$wire["networkports_id_1"]]) && !empty($ports[$wire["networkports_id_2"]]) && isset($ports[$wire["networkports_id_1"]]) && isset($ports[$wire["networkports_id_2"]])) {
             $graph .= $this->graphPorts($devices, $ports, $wire, $format, $PluginArchiresView);
         }
     }
     $graph .= "}\n";
     return $this->generateGraphviz($graph, $format, $PluginArchiresView);
 }
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Archires. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
include "../../../inc/includes.php";
if (!isset($_GET["id"])) {
    $_GET["id"] = "";
}
if (isset($_GET["start"])) {
    $start = $_GET["start"];
} else {
    $start = 0;
}
$PluginArchiresApplianceQuery = new PluginArchiresApplianceQuery();
$PluginArchiresQueryType = new PluginArchiresQueryType();
if (isset($_POST["add"])) {
    $PluginArchiresApplianceQuery->check(-1, 'w', $_POST);
    $PluginArchiresApplianceQuery->add($_POST);
    Html::back();
} else {
    if (isset($_POST["delete"])) {
        $PluginArchiresApplianceQuery->check($_POST['id'], 'w');
        $PluginArchiresApplianceQuery->delete($_POST);
        Html::redirect(Toolbox::getItemTypeSearchURL('PluginArchiresApplianceQuery'));
    } else {
        if (isset($_POST["restore"])) {
            $PluginArchiresApplianceQuery->check($_POST['id'], 'w');
            $PluginArchiresApplianceQuery->restore($_POST);
            Html::redirect(Toolbox::getItemTypeSearchURL('PluginArchiresApplianceQuery'));