Beispiel #1
0
 function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
 {
     if ($item->getType() == 'Profile' && $item->getField('interface') != 'helpdesk') {
         return PluginRoutetablesRoutetable::getTypeName(2);
     }
     return '';
 }
Beispiel #2
0
 https://forge.indepnet.net/projects/routetables
 -------------------------------------------------------------------------

 LICENSE

 This file is part of Routetables.

 Routetables 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.

 Routetables 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 Routetables. If not, see <http://www.gnu.org/licenses/>.
 --------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
Html::Header(PluginRoutetablesRoutetable::getTypeName(2), '', "plugins", "routetables");
$route = new PluginRoutetablesRoutetable();
if ($route->canView() || Session::haveRight("config", "w")) {
    Search::show("PluginRoutetablesRoutetable");
} else {
    Html::displayRightError();
}
Html::footer();
 /**
  * Show routetables associated to an item
  *
  * @since version 0.84
  *
  * @param $item            CommonDBTM object for which associated routetables must be displayed
  * @param $withtemplate    (default '')
  * */
 static function showForItem(CommonDBTM $item, $withtemplate = '')
 {
     global $DB, $CFG_GLPI;
     $ID = $item->getField('id');
     if ($item->isNewID($ID)) {
         return false;
     }
     if (!plugin_routetables_haveRight('routetables', 'r')) {
         return false;
     }
     if (!$item->can($item->fields['id'], 'r')) {
         return false;
     }
     if (empty($withtemplate)) {
         $withtemplate = 0;
     }
     $canedit = $item->canadditem('PluginRoutetablesRoutetable');
     $rand = mt_rand();
     $is_recursive = $item->isRecursive();
     $query = "SELECT `glpi_plugin_routetables_routetables_items`.`id` AS assocID,\n                       `glpi_entities`.`id` AS entity,\n                       `glpi_plugin_routetables_routetables`.`name` AS assocName,\n                       `glpi_plugin_routetables_routetables`.*\n                FROM `glpi_plugin_routetables_routetables_items`\n                LEFT JOIN `glpi_plugin_routetables_routetables`\n                 ON (`glpi_plugin_routetables_routetables_items`.`plugin_routetables_routetables_id`=`glpi_plugin_routetables_routetables`.`id`)\n                LEFT JOIN `glpi_entities` ON (`glpi_plugin_routetables_routetables`.`entities_id`=`glpi_entities`.`id`)\n                WHERE `glpi_plugin_routetables_routetables_items`.`items_id` = '{$ID}'\n                      AND `glpi_plugin_routetables_routetables_items`.`itemtype` = '" . $item->getType() . "' ";
     $query .= getEntitiesRestrictRequest(" AND", "glpi_plugin_routetables_routetables", '', '', false);
     $query .= " ORDER BY `assocName`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $i = 0;
     $routetables = array();
     $routetable = new PluginRoutetablesRoutetable();
     $used = array();
     if ($numrows = $DB->numrows($result)) {
         while ($data = $DB->fetch_assoc($result)) {
             $routetables[$data['id']] = $data;
             $used[$data['id']] = $data['id'];
         }
     }
     if ($canedit && $withtemplate < 2) {
         // Restrict entity for knowbase
         $entities = "";
         $entity = $_SESSION["glpiactive_entity"];
         if ($item->isEntityAssign()) {
             /// Case of personal items : entity = -1 : create on active entity (Reminder case))
             if ($item->getEntityID() >= 0) {
                 $entity = $item->getEntityID();
             }
             if ($item->isRecursive()) {
                 $entities = getSonsOf('glpi_entities', $entity);
             } else {
                 $entities = $entity;
             }
         }
         $limit = getEntitiesRestrictRequest(" AND ", "glpi_plugin_routetables_routetables", '', $entities, false);
         $q = "SELECT COUNT(*)\n               FROM `glpi_plugin_routetables_routetables`\n               WHERE `is_deleted` = '0'\n               {$limit}";
         $result = $DB->query($q);
         $nb = $DB->result($result, 0, 0);
         echo "<div class='firstbloc'>";
         if (plugin_routetables_haveRight('routetables', 'r') && $nb > count($used)) {
             echo "<form name='routetable_form{$rand}' id='routetable_form{$rand}' method='post'\n                   action='" . Toolbox::getItemTypeFormURL('PluginRoutetablesRoutetable') . "'>";
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr class='tab_bg_1'>";
             echo "<td colspan='4' class='center'>";
             echo "<input type='hidden' name='entities_id' value='{$entity}'>";
             echo "<input type='hidden' name='is_recursive' value='{$is_recursive}'>";
             echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
             echo "<input type='hidden' name='items_id' value='{$ID}'>";
             if ($item->getType() == 'Ticket') {
                 echo "<input type='hidden' name='tickets_id' value='{$ID}'>";
             }
             $routetable->dropdownRouteTables("plugin_routetables_routetables_id", $entities, $used);
             echo "</td><td class='center' width='20%'>";
             echo "<input type='submit' name='additem' value=\"" . _sx('button', 'Associate a routing table', 'routetables') . "\" class='submit'>";
             echo "</td>";
             echo "</tr>";
             echo "</table>";
             Html::closeForm();
         }
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $number && $withtemplate < 2) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => $number);
         Html::showMassiveActions(__CLASS__, $massiveactionparams);
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     if ($canedit && $number && $withtemplate < 2) {
         echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
     }
     echo "<th>" . __('Name') . "</th>";
     if (Session::isMultiEntitiesMode()) {
         echo "<th>" . __('Entity') . "</th>";
     }
     echo "<th>" . __('Network') . "</th>";
     echo "<th>" . __('Subnet mask') . "</th>";
     echo "<th>" . __('Gateway') . "</th>";
     echo "<th>" . __('Metric', 'routetables') . "</th>";
     echo "<th>" . __('Interface') . "</th>";
     echo "<th>" . __('Persistance', 'routetables') . "</th>";
     echo "<th>" . __('Comments') . "</th>";
     echo "</tr>";
     $used = array();
     if ($number) {
         Session::initNavigateListItems('PluginRoutetablesRoutetable', sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
         foreach ($routetables as $data) {
             $routetableID = $data["id"];
             $link = NOT_AVAILABLE;
             if ($routetable->getFromDB($routetableID)) {
                 $link = $routetable->getLink();
             }
             Session::addToNavigateListItems('PluginRoutetablesRoutetable', $routetable);
             $used[$routetableID] = $routetableID;
             $assocID = $data["assocID"];
             echo "<tr class='tab_bg_1" . ($data["is_deleted"] ? "_2" : "") . "'>";
             if ($canedit && $withtemplate < 2) {
                 echo "<td width='10'>";
                 Html::showMassiveActionCheckBox(__CLASS__, $data["assocID"]);
                 echo "</td>";
             }
             echo "<td class='center'>{$link}</td>";
             if (Session::isMultiEntitiesMode()) {
                 echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entities_id']) . "</td>";
             }
             echo "<td class='center'>" . $data["destination"] . "</td>";
             echo "<td class='center'>" . $data["netmask"] . "</td>";
             echo "<td class='center'>" . $data["gateway"] . "</td>";
             echo "<td class='center'>" . $data["metric"] . "</td>";
             echo "<td class='center'>" . $data["interface"] . "</td>";
             echo "<td class='center'>" . Dropdown::getYesNo($data["persistence"]) . "</td>";
             echo "<td class='center'>" . $data["comment"] . "</td>";
             echo "</tr>";
             $i++;
         }
     }
     echo "</table>";
     if ($canedit && $number && $withtemplate < 2) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions(__CLASS__, $massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
Beispiel #4
0
function plugin_routetables_MassiveActionsDisplay($options = array())
{
    $route = new PluginRoutetablesRoutetable();
    if (in_array($options['itemtype'], PluginRoutetablesRoutetable::getTypes(true))) {
        $route->dropdownRouteTables("plugin_routetables_routetables_id");
        echo "<input type=\"submit\" name=\"massiveaction\" class=\"submit\" value=\"" . __('Post') . "\" >";
    }
    return "";
}
Beispiel #5
0
 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 Routetables. If not, see <http://www.gnu.org/licenses/>.
 --------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
if (!isset($_GET["id"])) {
    $_GET["id"] = "";
}
if (!isset($_GET["withtemplate"])) {
    $_GET["withtemplate"] = "";
}
$route = new PluginRoutetablesRoutetable();
$route_item = new PluginRoutetablesRoutetable_Item();
if (isset($_POST["add"])) {
    $route->check(-1, 'w', $_POST);
    $newID = $route->add($_POST);
    Html::back();
} else {
    if (isset($_POST["delete"])) {
        $route->check($_POST['id'], 'w');
        $route->delete($_POST);
        $route->redirectToList();
    } else {
        if (isset($_POST["restore"])) {
            $route->check($_POST['id'], 'w');
            $route->restore($_POST);
            $route->redirectToList();