/**
  * Show the aliases contained by the alias
  *
  * @param $item                     the FQDN owning the aliases
  * @param $withtemplate  integer    withtemplate param
  **/
 static function showForFQDN(CommonGLPI $item, $withtemplate)
 {
     global $DB;
     $alias = new self();
     $address = new NetworkName();
     $item->check($item->getID(), READ);
     $canedit = $item->canEdit($item->getID());
     if (isset($_GET["start"])) {
         $start = $_GET["start"];
     } else {
         $start = 0;
     }
     if (!empty($_GET["order"])) {
         $order = $_GET["order"];
     } else {
         $order = "alias";
     }
     $number = countElementsInTable($alias->getTable(), "`fqdns_id`='" . $item->getID() . "'");
     echo "<br><div class='center'>";
     if ($number < 1) {
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th>" . self::getTypeName(1) . "</th><th>" . __('No item found') . "</th></tr>";
         echo "</table>\n";
     } else {
         Html::printAjaxPager(self::getTypeName($number), $start, $number);
         echo "<table class='tab_cadre_fixe'><tr>";
         echo "<th><a href='javascript:reloadTab(\"order=alias\");'>" . self::getTypeName(1) . "</a></th>";
         // Alias
         echo "<th><a href='javascript:reloadTab(\"order=realname\");'>" . __("Computer's name") . "</a></th>";
         echo "<th>" . __('Comments') . "</th>";
         echo "</tr>\n";
         Session::initNavigateListItems($item->getType(), sprintf(__('%1$s = %2$s'), self::getTypeName(1), $item->fields['name']));
         $query = "SELECT `glpi_networkaliases`.`id` AS alias_id,\n                          `glpi_networkaliases`.`name` AS alias,\n                          `glpi_networknames`.`id` AS address_id,\n                          `glpi_networkaliases`.`comment` AS comment\n                   FROM `glpi_networkaliases`, `glpi_networknames`\n                   WHERE `glpi_networkaliases`.`fqdns_id` = '" . $item->getID() . "'\n                         AND  `glpi_networknames`.`id` = `glpi_networkaliases`.`networknames_id`\n                   ORDER BY `{$order}`\n                   LIMIT " . $_SESSION['glpilist_limit'] . "\n                   OFFSET {$start}";
         foreach ($DB->request($query) as $data) {
             Session::addToNavigateListItems($alias->getType(), $data["alias_id"]);
             if ($address->getFromDB($data["address_id"])) {
                 echo "<tr class='tab_bg_1'>";
                 echo "<td><a href='" . $alias->getFormURL() . '?id=' . $data['alias_id'] . "'>" . $data['alias'] . "</a></td>";
                 echo "<td><a href='" . $address->getLinkURL() . "'>" . $address->getInternetName() . "</a></td>";
                 echo "<td>" . $data['comment'] . "</td>";
                 echo "</tr>\n";
             }
         }
         echo "</table>\n";
         Html::printAjaxPager(self::getTypeName($number), $start, $number);
     }
     echo "</div>\n";
 }
示例#2
0
 static function showForItem(CommonGLPI $item, $withtemplate = 0)
 {
     global $CFG_GLPI;
     $is_device = $item instanceof CommonDevice;
     $ID = $item->getField('id');
     if (!$item->can($ID, READ)) {
         return false;
     }
     $canedit = $withtemplate != 2 && $item->canEdit($ID) && Session::haveRightsOr('device', array(UPDATE, PURGE));
     echo "<div class='spaced'>";
     $rand = mt_rand();
     if ($canedit) {
         echo "\n<form id='form_device_add{$rand}' name='form_device_add{$rand}'\n                  action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "' method='post'>\n";
         echo "\t<input type='hidden' name='items_id' value='{$ID}'>\n";
         echo "\t<input type='hidden' name='itemtype' value='" . $item->getType() . "'>\n";
     }
     $table = new HTMLTableMain();
     $table->setTitle(_n('Component', 'Components', Session::getPluralNumber()));
     if ($canedit) {
         $delete_all_column = $table->addHeader('delete all', Html::getCheckAllAsCheckbox("form_device_action{$rand}", '__RAND__'));
         $delete_all_column->setHTMLClass('center');
     } else {
         $delete_all_column = NULL;
     }
     $column_label = $is_device ? _n('Item', 'Items', Session::getPluralNumber()) : __('Type of component');
     $common_column = $table->addHeader('common', $column_label);
     $specific_column = $table->addHeader('specificities', __('Specificities'));
     $specific_column->setHTMLClass('center');
     $dynamic_column = '';
     if ($item->isDynamic()) {
         $dynamic_column = $table->addHeader('is_dynamic', __('Automatic inventory'));
         $dynamic_column->setHTMLClass('center');
     }
     if ($canedit) {
         $massiveactionparams = array('container' => "form_device_action{$rand}", 'fixed' => false, 'display_arrow' => false);
         $content = array(array('function' => 'Html::showMassiveActions', 'parameters' => array($massiveactionparams)));
         $delete_column = $table->addHeader('delete one', $content);
         $delete_column->setHTMLClass('center');
     } else {
         $delete_column = NULL;
     }
     $table_options = array('canedit' => $canedit, 'rand' => $rand);
     if ($is_device) {
         Session::initNavigateListItems(static::getType(), sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
         foreach (array_merge(array(''), self::getConcernedItems()) as $itemtype) {
             $table_options['itemtype'] = $itemtype;
             $link = getItemForItemtype(static::getType());
             $link->getTableGroup($item, $table, $table_options, $delete_all_column, $common_column, $specific_column, $delete_column, $dynamic_column);
         }
     } else {
         $devtypes = array();
         foreach (self::getItemAffinities($item->getType()) as $link_type) {
             $devtypes[] = $link_type::getDeviceType();
             $link = getItemForItemtype($link_type);
             Session::initNavigateListItems($link_type, sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
             $link->getTableGroup($item, $table, $table_options, $delete_all_column, $common_column, $specific_column, $delete_column, $dynamic_column);
         }
     }
     if ($canedit) {
         echo "<table class='tab_cadre_fixe'><tr class='tab_bg_1'><td>";
         echo __('Add a new component') . "</td><td class=left width='70%'>";
         if ($is_device) {
             Dropdown::showNumber('number_devices_to_add', array('value' => 0, 'min' => 0, 'max' => 10));
         } else {
             Dropdown::showSelectItemFromItemtypes(array('itemtype_name' => 'devicetype', 'items_id_name' => 'devices_id', 'itemtypes' => $devtypes, 'entity_restrict' => $item->getEntityID(), 'showItemSpecificity' => $CFG_GLPI['root_doc'] . '/ajax/selectUnaffectedOrNewItem_Device.php'));
         }
         echo "</td><td>";
         echo "<input type='submit' class='submit' name='add' value='" . _sx('button', 'Add') . "'>";
         echo "</td></tr></table>";
         Html::closeForm();
     }
     if ($canedit) {
         echo "\n<form id='form_device_action{$rand}' name='form_device_action{$rand}'\n                  action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "' method='post'>\n";
         echo "\t<input type='hidden' name='items_id' value='{$ID}'>\n";
         echo "\t<input type='hidden' name='itemtype' value='" . $item->getType() . "'>\n";
     }
     $table->display(array('display_super_for_each_group' => false, 'display_title_for_each_group' => false));
     if ($canedit) {
         //          echo "<input type='submit' class='submit' name='updateall' value='" .
         //               _sx('button', 'Save')."'>";
         Html::closeForm();
     }
     echo "</div>";
     // Force disable selected items
     $_SESSION['glpimassiveactionselected'] = array();
 }