grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026. -------------------------------------------------------------------------- */ /** @file * @brief */ if (!defined('GLPI_ROOT')) { die("Sorry. You can't access this file directly"); } class Link_Itemtype extends CommonDBChild { // From CommonDbChild static public $itemtype = 'Link'; static public $items_id = 'links_id'; /** * @since version 0.84 **/ function getForbiddenStandardMassiveAction() { $forbidden = parent::getForbiddenStandardMassiveAction(); $forbidden[] = 'update'; return $forbidden; } /** * Print the HTML array for device on link * * @param $link : Link * * @return Nothing (display) **/ static function showForLink($link) { global $DB,$CFG_GLPI; $links_id = $link->getField('id'); $canedit = $link->canEdit($links_id); $rand = mt_rand(); if (!Link::canView() || !$link->can($links_id, READ)) { return false; } $query = "SELECT * FROM `glpi_links_itemtypes` WHERE `links_id` = '$links_id' ORDER BY `itemtype`"; $result = $DB->query($query); $types = array(); $used = array(); if ($numrows = $DB->numrows($result)) { while ($data = $DB->fetch_assoc($result)) { $types[$data['id']] = $data; $used[$data['itemtype']] = $data['itemtype']; } } if ($canedit) { echo "
"; echo "
"; echo ""; echo ""; echo ""; echo "
".__('Add an item type')."
"; echo ""; Dropdown::showItemTypes('itemtype', $CFG_GLPI["link_types"], array('used' => $used)); echo ""; echo ""; echo "
"; Html::closeForm(); echo "
"; } echo "
"; if ($canedit && $numrows) { Html::openMassiveActionsForm('mass'.__CLASS__.$rand); $massiveactionparams = array('num_displayed' => min($_SESSION['glpilist_limit'], $numrows), 'container' => 'mass'.__CLASS__.$rand); Html::showMassiveActions($massiveactionparams); } echo ""; $header_begin = ""; $header_top = ''; $header_bottom = ''; $header_end = ''; if ($canedit && $numrows) { $header_top .= ""; $header_bottom .= ""; } $header_end .= ""; $header_end .= ""; echo $header_begin.$header_top.$header_end; foreach ($types as $data) { $typename = NOT_AVAILABLE; if ($item = getItemForItemtype($data['itemtype'])) { $typename = $item->getTypeName(1); echo ""; if ($canedit) { echo ""; } echo ""; echo ""; } } echo $header_begin.$header_bottom.$header_end; echo "
".Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand); $header_top .= "".Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand); $header_bottom .= "".__('Type')."
"; Html::showMassiveActionCheckBox(__CLASS__, $data["id"]); echo "$typename
"; if ($canedit && $numrows) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } echo "
"; } function getTabNameForItem(CommonGLPI $item, $withtemplate=0) { if (!$withtemplate) { $nb = 0; switch ($item->getType()) { case 'Link' : if ($_SESSION['glpishow_count_on_tabs']) { $nb = countElementsInTable($this->getTable(), "links_id = '".$item->getID()."'"); } return self::createTabEntry(_n('Associated item type', 'Associated item types', Session::getPluralNumber()), $nb); } } return ''; } static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) { if ($item->getType() == 'Link') { self::showForLink($item); } return true; } /** * * Remove all associations for an itemtype * * @since version 0.85 * * @param $itemtype itemtype for which all link associations must be removed */ static function deleteForItemtype($itemtype) { global $DB; $query = "DELETE FROM `".self::getTable()."` WHERE `itemtype` LIKE '%Plugin$itemtype%'"; $DB->query($query); } } ?>