예제 #1
0
 function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
 {
     if ($item->getType() == 'Profile' && $item->getField('interface') != 'helpdesk') {
         return PluginRoutetablesRoutetable::getTypeName(2);
     }
     return '';
 }
예제 #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();
예제 #3
0
 /**
  * Show items links to a routetables
  *
  * @since version 0.84
  *
  * @param $routetable PluginRoutetablesRoutetable object
  *
  * @return nothing (HTML display)
  * */
 public static function showForRoutetables(PluginRoutetablesRoutetable $routetable)
 {
     global $DB;
     $instID = $routetable->fields['id'];
     if (!$routetable->can($instID, 'r')) {
         return false;
     }
     $rand = mt_rand();
     $canedit = $routetable->can($instID, 'w');
     $query = "SELECT DISTINCT `itemtype`\n             FROM `glpi_plugin_routetables_routetables_items`\n             WHERE `plugin_routetables_routetables_id` = '{$instID}'\n             ORDER BY `itemtype`\n             LIMIT " . count(PluginRoutetablesRoutetable::getTypes(true));
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     if (Session::isMultiEntitiesMode()) {
         $colsup = 1;
     } else {
         $colsup = 0;
     }
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form method='post' name='routetable_form{$rand}' id='routetable_form{$rand}'\n         action='" . Toolbox::getItemTypeFormURL("PluginRoutetablesRoutetable") . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2'><th colspan='" . ($canedit ? 5 + $colsup : 4 + $colsup) . "'>" . __('Add an item') . "</th></tr>";
         echo "<tr class='tab_bg_1'><td colspan='" . (3 + $colsup) . "' class='center'>";
         echo "<input type='hidden' name='plugin_routetables_routetables_id' value='{$instID}'>";
         Dropdown::showAllItems("items_id", 0, 0, -1, PluginRoutetablesRoutetable::getTypes());
         echo "</td>";
         echo "<td colspan='2' class='tab_bg_2'>";
         echo "<input type='submit' name='additem' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $number) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array();
         Html::showMassiveActions(__CLASS__, $massiveactionparams);
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     if ($canedit && $number) {
         echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
     }
     echo "<th>" . __('Type') . "</th>";
     echo "<th>" . __('Name') . "</th>";
     if (Session::isMultiEntitiesMode()) {
         echo "<th>" . __('Entity') . "</th>";
     }
     echo "<th>" . __('Serial number') . "</th>";
     echo "<th>" . __('Inventory number') . "</th>";
     echo "</tr>";
     for ($i = 0; $i < $number; $i++) {
         $itemType = $DB->result($result, $i, "itemtype");
         if (!($item = getItemForItemtype($itemType))) {
             continue;
         }
         if ($item->canView()) {
             $column = "name";
             $itemTable = getTableForItemType($itemType);
             $query = "SELECT `" . $itemTable . "`.*,\n                             `glpi_plugin_routetables_routetables_items`.`id` AS items_id,\n                             `glpi_entities`.`id` AS entity " . " FROM `glpi_plugin_routetables_routetables_items`, `" . $itemTable . "` LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `" . $itemTable . "`.`entities_id`) " . " WHERE `" . $itemTable . "`.`id` = `glpi_plugin_routetables_routetables_items`.`items_id`\n                AND `glpi_plugin_routetables_routetables_items`.`itemtype` = '{$itemType}'\n                AND `glpi_plugin_routetables_routetables_items`.`plugin_routetables_routetables_id` = '{$instID}' " . getEntitiesRestrictRequest(" AND ", $itemTable, '', '', $item->maybeRecursive());
             if ($item->maybeTemplate()) {
                 $query .= " AND `" . $itemTable . "`.`is_template` = '0'";
             }
             $query .= " ORDER BY `glpi_entities`.`completename`, `" . $itemTable . "`.`{$column}`";
             if ($result_linked = $DB->query($query)) {
                 if ($DB->numrows($result_linked)) {
                     Session::initNavigateListItems($itemType, PluginRoutetablesRoutetable::getTypeName(2) . " = " . $routetable->fields['name']);
                     while ($data = $DB->fetch_assoc($result_linked)) {
                         $item->getFromDB($data["id"]);
                         Session::addToNavigateListItems($itemType, $data["id"]);
                         $ID = "";
                         if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
                             $ID = " (" . $data["id"] . ")";
                         }
                         $link = Toolbox::getItemTypeFormURL($itemType);
                         $name = "<a href=\"" . $link . "?id=" . $data["id"] . "\">" . $data["name"] . "{$ID}</a>";
                         echo "<tr class='tab_bg_1'>";
                         if ($canedit) {
                             echo "<td width='10'>";
                             Html::showMassiveActionCheckBox(__CLASS__, $data["items_id"]);
                             echo "</td>";
                         }
                         echo "<td class='center'>" . $item::getTypeName(1) . "</td>";
                         echo "<td class='center' " . (isset($data['is_deleted']) && $data['is_deleted'] ? "class='tab_bg_2_2'" : "") . ">" . $name . "</td>";
                         if (Session::isMultiEntitiesMode()) {
                             echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entity']) . "</td>";
                         }
                         echo "<td class='center'>" . (isset($data["serial"]) ? "" . $data["serial"] . "" : "-") . "</td>";
                         echo "<td class='center'>" . (isset($data["otherserial"]) ? "" . $data["otherserial"] . "" : "-") . "</td>";
                         echo "</tr>";
                     }
                 }
             }
         }
     }
     echo "</table>";
     if ($canedit && $number) {
         $paramsma['ontop'] = false;
         Html::showMassiveActions(__CLASS__, $paramsma);
         Html::closeForm();
     }
     echo "</div>";
 }
예제 #4
0
파일: hook.php 프로젝트: geldarr/hack-space
function plugin_routetables_getAddSearchOptions($itemtype)
{
    $sopt = array();
    if (in_array($itemtype, PluginRoutetablesRoutetable::getTypes(true))) {
        if (plugin_routetables_haveRight("routetables", "r")) {
            $sopt[5110]['table'] = 'glpi_plugin_routetables_routetables';
            $sopt[5110]['field'] = 'name';
            $sopt[5110]['name'] = PluginRoutetablesRoutetable::getTypeName(2) . " - " . __('Name');
            $sopt[5110]['forcegroupby'] = true;
            $sopt[5110]['massiveaction'] = false;
            $sopt[5110]['datatype'] = 'itemlink';
            $sopt[5110]['itemlink_type'] = 'PluginRoutetablesRoutetable';
            $sopt[5110]['joinparams'] = array('beforejoin' => array('table' => 'glpi_plugin_routetables_routetables_items', 'joinparams' => array('jointype' => 'itemtype_item')));
            $sopt[5111]['table'] = 'glpi_plugin_routetables_routetables';
            $sopt[5111]['field'] = 'destination';
            $sopt[5111]['name'] = PluginRoutetablesRoutetable::getTypeName(2) . " - " . __('Network');
            $sopt[5111]['forcegroupby'] = true;
            $sopt[5111]['massiveaction'] = false;
            $sopt[5111]['joinparams'] = array('beforejoin' => array('table' => 'glpi_plugin_routetables_routetables_items', 'joinparams' => array('jointype' => 'itemtype_item')));
            $sopt[5112]['table'] = 'glpi_plugin_routetables_routetables';
            $sopt[5112]['field'] = 'gateway';
            $sopt[5112]['name'] = PluginRoutetablesRoutetable::getTypeName(2) . " - " . __('Gateway');
            $sopt[5112]['forcegroupby'] = true;
            $sopt[5112]['massiveaction'] = false;
            $sopt[5112]['joinparams'] = array('beforejoin' => array('table' => 'glpi_plugin_routetables_routetables_items', 'joinparams' => array('jointype' => 'itemtype_item')));
        }
    }
    return $sopt;
}