/** * Check is the curent user is allowed to see the file * * @param $options array of options (only 'tickets_id' used) * * @return boolean **/ function canViewFile($options) { global $DB, $CFG_GLPI; if (isset($_SESSION["glpiactiveprofile"]["interface"]) && $_SESSION["glpiactiveprofile"]["interface"] == "central") { // My doc Check and Common doc right access if ($this->can($this->fields["id"], READ) || $this->fields["users_id"] === Session::getLoginUserID()) { return true; } // Reminder Case $query = "SELECT *\n FROM `glpi_documents_items`\n LEFT JOIN `glpi_reminders`\n ON (`glpi_reminders`.`id` = `glpi_documents_items`.`items_id`\n AND `glpi_documents_items`.`itemtype` = 'Reminder')\n " . Reminder::addVisibilityJoins() . "\n WHERE `glpi_documents_items`.`documents_id` = '" . $this->fields["id"] . "'\n AND " . Reminder::addVisibilityRestrict(); $result = $DB->query($query); if ($DB->numrows($result) > 0) { return true; } // Knowbase Case if (Session::haveRight("knowbase", READ)) { $query = "SELECT *\n FROM `glpi_documents_items`\n LEFT JOIN `glpi_knowbaseitems`\n ON (`glpi_knowbaseitems`.`id` = `glpi_documents_items`.`items_id`\n AND `glpi_documents_items`.`itemtype` = 'KnowbaseItem')\n " . KnowbaseItem::addVisibilityJoins() . "\n WHERE `glpi_documents_items`.`documents_id` = '" . $this->fields["id"] . "'\n AND " . KnowbaseItem::addVisibilityRestrict(); $result = $DB->query($query); if ($DB->numrows($result) > 0) { return true; } } if (Session::haveRight('knowbase', KnowbaseItem::READFAQ)) { $query = "SELECT *\n FROM `glpi_documents_items`\n LEFT JOIN `glpi_knowbaseitems`\n ON (`glpi_knowbaseitems`.`id` = `glpi_documents_items`.`items_id`\n AND `glpi_documents_items`.`itemtype` = 'KnowbaseItem')\n " . KnowbaseItem::addVisibilityJoins() . "\n WHERE `glpi_documents_items`.`documents_id` = '" . $this->fields["id"] . "'\n AND `glpi_knowbaseitems`.`is_faq` = '1'\n AND " . KnowbaseItem::addVisibilityRestrict(); $result = $DB->query($query); if ($DB->numrows($result) > 0) { return true; } } // Tracking Case if (isset($options["tickets_id"])) { $job = new Ticket(); if ($job->can($options["tickets_id"], READ)) { $query = "SELECT *\n FROM `glpi_documents_items`\n WHERE `glpi_documents_items`.`items_id` = '" . $options["tickets_id"] . "'\n AND `glpi_documents_items`.`itemtype` = 'Ticket'\n AND `documents_id`='" . $this->fields["id"] . "'"; $result = $DB->query($query); if ($DB->numrows($result) > 0) { return true; } } } } else { if (Session::getLoginUserID()) { // ! central // Check if it is my doc if ($this->fields["users_id"] === Session::getLoginUserID()) { return true; } // Reminder Case $query = "SELECT *\n FROM `glpi_documents_items`\n LEFT JOIN `glpi_reminders`\n ON (`glpi_reminders`.`id` = `glpi_documents_items`.`items_id`\n AND `glpi_documents_items`.`itemtype` = 'Reminder')\n " . Reminder::addVisibilityJoins() . "\n WHERE `glpi_documents_items`.`documents_id` = '" . $this->fields["id"] . "'\n AND " . Reminder::addVisibilityRestrict(); $result = $DB->query($query); if ($DB->numrows($result) > 0) { return true; } if (Session::haveRight('knowbase', KnowbaseItem::READFAQ)) { // Check if it is a FAQ document $query = "SELECT *\n FROM `glpi_documents_items`\n LEFT JOIN `glpi_knowbaseitems`\n ON (`glpi_knowbaseitems`.`id` = `glpi_documents_items`.`items_id`)\n " . KnowbaseItem::addVisibilityJoins() . "\n WHERE `glpi_documents_items`.`itemtype` = 'KnowbaseItem'\n AND `glpi_documents_items`.`documents_id` = '" . $this->fields["id"] . "'\n AND `glpi_knowbaseitems`.`is_faq` = '1'\n AND " . KnowbaseItem::addVisibilityRestrict(); $result = $DB->query($query); if ($DB->numrows($result) > 0) { return true; } } // Tracking Case if (isset($options["tickets_id"])) { $job = new Ticket(); if ($job->can($options["tickets_id"], READ)) { $query = "SELECT *\n FROM `glpi_documents_items`\n WHERE `glpi_documents_items`.`items_id` = '" . $options["tickets_id"] . "'\n AND `glpi_documents_items`.`itemtype` = 'Ticket'\n AND `documents_id` = '" . $this->fields["id"] . "'"; $result = $DB->query($query); if ($DB->numrows($result) > 0) { return true; } } } } } // Public FAQ for not connected user if ($CFG_GLPI["use_public_faq"]) { $query = "SELECT *\n FROM `glpi_documents_items`\n LEFT JOIN `glpi_knowbaseitems`\n ON (`glpi_knowbaseitems`.`id` = `glpi_documents_items`.`items_id`)\n LEFT JOIN `glpi_entities_knowbaseitems`\n ON (`glpi_knowbaseitems`.`id` = `glpi_entities_knowbaseitems`.`knowbaseitems_id`)\n WHERE `glpi_documents_items`.`itemtype` = 'KnowbaseItem'\n AND `glpi_documents_items`.`documents_id` = '" . $this->fields["id"] . "'\n AND `glpi_knowbaseitems`.`is_faq` = '1'\n AND `glpi_entities_knowbaseitems`.`entities_id` = '0'\n AND `glpi_entities_knowbaseitems`.`is_recursive` = '1'"; $result = $DB->query($query); if ($DB->numrows($result) > 0) { return true; } } return false; }
/** * Show items links to a document * * @since version 0.84 * * @param $doc Document object * * @return nothing (HTML display) **/ static function showForDocument(Document $doc) { global $DB, $CFG_GLPI; $instID = $doc->fields['id']; if (!$doc->can($instID, READ)) { return false; } $canedit = $doc->can($instID, UPDATE); // for a document, // don't show here others documents associated to this one, // it's done for both directions in self::showAssociated $query = "SELECT DISTINCT `itemtype`\n FROM `glpi_documents_items`\n WHERE `glpi_documents_items`.`documents_id` = '{$instID}'\n AND `glpi_documents_items`.`itemtype` != 'Document'\n ORDER BY `itemtype`"; $result = $DB->query($query); $number = $DB->numrows($result); $rand = mt_rand(); if ($canedit) { echo "<div class='firstbloc'>"; echo "<form name='documentitem_form{$rand}' id='documentitem_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add an item') . "</th></tr>"; echo "<tr class='tab_bg_1'><td class='right'>"; Dropdown::showSelectItemFromItemtypes(array('itemtypes' => Document::getItemtypesThatCanHave(), 'entity_restrict' => $doc->fields['is_recursive'] ? getSonsOf('glpi_entities', $doc->fields['entities_id']) : $doc->fields['entities_id'], 'checkright' => true)); echo "</td><td class='center'>"; echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "<input type='hidden' name='documents_id' value='{$instID}'>"; echo "</td></tr>"; echo "</table>"; Html::closeForm(); echo "</div>"; } echo "<div class='spaced'>"; if ($canedit && $number) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand); Html::showMassiveActions($massiveactionparams); } echo "<table class='tab_cadre_fixehov'>"; $header_begin = "<tr>"; $header_top = ''; $header_bottom = ''; $header_end = ''; if ($canedit && $number) { $header_top .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_top .= "</th>"; $header_bottom .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_bottom .= "</th>"; } $header_end .= "<th>" . __('Type') . "</th>"; $header_end .= "<th>" . __('Name') . "</th>"; $header_end .= "<th>" . __('Entity') . "</th>"; $header_end .= "<th>" . __('Serial number') . "</th>"; $header_end .= "<th>" . __('Inventory number') . "</th>"; $header_end .= "</tr>"; echo $header_begin . $header_top . $header_end; for ($i = 0; $i < $number; $i++) { $itemtype = $DB->result($result, $i, "itemtype"); if (!($item = getItemForItemtype($itemtype))) { continue; } if ($item->canView()) { if ($item instanceof CommonDevice) { $column = "designation"; } else { if ($item instanceof Item_Devices) { $column = "itemtype"; } else { $column = "name"; } } if ($itemtype == 'Ticket') { $column = "id"; } $itemtable = getTableForItemType($itemtype); $query = "SELECT `{$itemtable}`.*,\n `glpi_documents_items`.`id` AS IDD, "; if ($itemtype == 'KnowbaseItem') { $query .= "-1 AS entity\n FROM `glpi_documents_items`, `{$itemtable}`\n " . KnowbaseItem::addVisibilityJoins() . "\n WHERE `{$itemtable}`.`id` = `glpi_documents_items`.`items_id`\n AND "; } else { $query .= "`glpi_entities`.`id` AS entity\n FROM `glpi_documents_items`, `{$itemtable}`"; if ($itemtype != 'Entity') { $query .= " LEFT JOIN `glpi_entities`\n ON (`glpi_entities`.`id` = `{$itemtable}`.`entities_id`)"; } $query .= " WHERE `{$itemtable}`.`id` = `glpi_documents_items`.`items_id`\n AND "; } $query .= "`glpi_documents_items`.`itemtype` = '{$itemtype}'\n AND `glpi_documents_items`.`documents_id` = '{$instID}' "; if ($itemtype == 'KnowbaseItem') { if (Session::getLoginUserID()) { $where = "AND " . KnowbaseItem::addVisibilityRestrict(); } else { // Anonymous access if (Session::isMultiEntitiesMode()) { $where = " AND (`glpi_entities_knowbaseitems`.`entities_id` = '0'\n AND `glpi_entities_knowbaseitems`.`is_recursive` = '1')"; } } } else { $query .= getEntitiesRestrictRequest(" AND ", $itemtable, '', '', $item->maybeRecursive()); } if ($item->maybeTemplate()) { $query .= " AND `{$itemtable}`.`is_template` = '0'"; } if ($itemtype == 'KnowbaseItem') { $query .= " ORDER BY `{$itemtable}`.`{$column}`"; } else { $query .= " ORDER BY `glpi_entities`.`completename`, `{$itemtable}`.`{$column}`"; } if ($itemtype == 'SoftwareLicense') { $soft = new Software(); } if ($result_linked = $DB->query($query)) { if ($DB->numrows($result_linked)) { while ($data = $DB->fetch_assoc($result_linked)) { if ($itemtype == 'Ticket') { $data["name"] = sprintf(__('%1$s: %2$s'), __('Ticket'), $data["id"]); } if ($itemtype == 'SoftwareLicense') { $soft->getFromDB($data['softwares_id']); $data["name"] = sprintf(__('%1$s - %2$s'), $data["name"], $soft->fields['name']); } if ($item instanceof CommonDevice) { $linkname = $data["designation"]; } else { if ($item instanceof Item_Devices) { $linkname = $data["itemtype"]; } else { $linkname = $data["name"]; } } if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) { $linkname = sprintf(__('%1$s (%2$s)'), $linkname, $data["id"]); } if ($item instanceof Item_Devices) { $tmpitem = new $item::$itemtype_2(); if ($tmpitem->getFromDB($data[$item::$items_id_2])) { $linkname = $tmpitem->getLink(); } } $link = Toolbox::getItemTypeFormURL($itemtype); $name = "<a href=\"" . $link . "?id=" . $data["id"] . "\">" . $linkname . "</a>"; echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td width='10'>"; Html::showMassiveActionCheckBox(__CLASS__, $data["IDD"]); echo "</td>"; } echo "<td class='center'>" . $item->getTypeName(1) . "</td>"; echo "<td " . (isset($data['is_deleted']) && $data['is_deleted'] ? "class='tab_bg_2_2'" : "") . ">" . $name . "</td>"; echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entity']); echo "</td>"; echo "<td class='center'>" . (isset($data["serial"]) ? "" . $data["serial"] . "" : "-") . "</td>"; echo "<td class='center'>" . (isset($data["otherserial"]) ? "" . $data["otherserial"] . "" : "-") . "</td>"; echo "</tr>"; } } } } } if ($number) { echo $header_begin . $header_bottom . $header_end; } echo "</table>"; if ($canedit && $number) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } echo "</div>"; }
/** * Show items links to a webapplication * * @since version 0.84 * * @param $PluginWebapplicationsWebapplication PluginWebapplicationsWebapplication object * * @return nothing (HTML display) **/ static function showForWebapplication(PluginWebapplicationsWebapplication $webapplication) { global $DB, $CFG_GLPI; $instID = $webapplication->fields['id']; if (!$webapplication->can($instID, READ)) { return false; } $canedit = $webapplication->can($instID, UPDATE); $query = "SELECT DISTINCT `itemtype`\n FROM `glpi_plugin_webapplications_webapplications_items`\n WHERE `plugin_webapplications_webapplications_id` = '{$instID}'\n ORDER BY `itemtype` "; $result = $DB->query($query); $number = $DB->numrows($result); $rand = mt_rand(); if ($canedit) { echo "<div class='firstbloc'>"; echo "<form name='webapplicationitem_form{$rand}' id='webapplicationitem_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL("PluginWebapplicationsWebapplication") . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add an item') . "</th></tr>"; echo "<tr class='tab_bg_1'><td class='right'>"; Dropdown::showAllItems("items_id", 0, 0, $webapplication->fields['is_recursive'] ? -1 : $webapplication->fields['entities_id'], PluginWebapplicationsWebapplication::getTypes(), false, true); echo "</td><td class='center'>"; echo "<input type='submit' name='additem' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "<input type='hidden' name='plugin_webapplications_webapplications_id' value='{$instID}'>"; 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($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>"; 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"; if ($itemtype == 'Ticket') { $column = "id"; } $itemtable = getTableForItemType($itemtype); $query = "SELECT `{$itemtable}`.*,\n `glpi_plugin_webapplications_webapplications_items`.`id` AS IDD, "; if ($itemtype == 'KnowbaseItem') { $query .= "-1 AS entity\n FROM `glpi_plugin_webapplications_webapplications_items`, `{$itemtable}`\n " . KnowbaseItem::addVisibilityJoins() . "\n WHERE `{$itemtable}`.`id` = `glpi_plugin_webapplications_webapplications_items`.`items_id`\n AND "; } else { $query .= "`glpi_entities`.`id` AS entity\n FROM `glpi_plugin_webapplications_webapplications_items`, `{$itemtable}` "; if ($itemtype != 'Entity') { $query .= "LEFT JOIN `glpi_entities`\n ON (`glpi_entities`.`id` = `{$itemtable}`.`entities_id`) "; } $query .= "WHERE `{$itemtable}`.`id` = `glpi_plugin_webapplications_webapplications_items`.`items_id`\n AND "; } $query .= "`glpi_plugin_webapplications_webapplications_items`.`itemtype` = '{$itemtype}'\n AND `glpi_plugin_webapplications_webapplications_items`.`plugin_webapplications_webapplications_id` = '{$instID}' "; if ($itemtype == 'KnowbaseItem') { if (Session::getLoginUserID()) { $where = "AND " . KnowbaseItem::addVisibilityRestrict(); } else { // Anonymous access if (Session::isMultiEntitiesMode()) { $where = " AND (`glpi_entities_knowbaseitems`.`entities_id` = '0'\n AND `glpi_entities_knowbaseitems`.`is_recursive` = '1')"; } } } else { $query .= getEntitiesRestrictRequest(" AND ", $itemtable, '', '', $item->maybeRecursive()); } if ($item->maybeTemplate()) { $query .= " AND `{$itemtable}`.`is_template` = '0'"; } if ($itemtype == 'KnowbaseItem') { $query .= " ORDER BY `{$itemtable}`.`{$column}`"; } else { $query .= " ORDER BY `glpi_entities`.`completename`, `{$itemtable}`.`{$column}`"; } if ($itemtype == 'SoftwareLicense') { $soft = new Software(); } if ($result_linked = $DB->query($query)) { if ($DB->numrows($result_linked)) { while ($data = $DB->fetch_assoc($result_linked)) { if ($itemtype == 'Ticket') { $data["name"] = sprintf(__('%1$s: %2$s'), __('Ticket'), $data["id"]); } if ($itemtype == 'SoftwareLicense') { $soft->getFromDB($data['softwares_id']); $data["name"] = sprintf(__('%1$s - %2$s'), $data["name"], $soft->fields['name']); } $linkname = $data["name"]; if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) { $linkname = sprintf(__('%1$s (%2$s)'), $linkname, $data["id"]); } $link = Toolbox::getItemTypeFormURL($itemtype); $name = "<a href=\"" . $link . "?id=" . $data["id"] . "\">" . $linkname . "</a>"; echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td width='10'>"; Html::showMassiveActionCheckBox(__CLASS__, $data["IDD"]); echo "</td>"; } echo "<td class='center'>" . $item->getTypeName(1) . "</td>"; echo "<td " . (isset($data['is_deleted']) && $data['is_deleted'] ? "class='tab_bg_2_2'" : "") . ">" . $name . "</td>"; echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entity']); echo "</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($paramsma); Html::closeForm(); } echo "</div>"; }
/** * Show KB categories * * @param $options $_GET * * @return nothing (display the form) **/ static function showFirstLevel($options) { global $DB, $CFG_GLPI; $faq = !Session::haveRight("knowbase", "r"); // Default values of parameters $params["knowbaseitemcategories_id"] = "0"; $params["target"] = $_SERVER['PHP_SELF']; if (is_array($options) && count($options)) { foreach ($options as $key => $val) { $params[$key] = $val; } } $faq_limit = ''; $parameters = ''; // Manage search solution if (isset($options['item_itemtype']) && isset($options['item_items_id'])) { $parameters = "&item_items_id=" . $options['item_items_id'] . "&item_itemtype=" . $options['item_itemtype']; } if ($faq) { if (!$CFG_GLPI["use_public_faq"] && !Session::haveRight("faq", "r")) { return false; } if (Session::getLoginUserID()) { $faq_limit = getEntitiesRestrictRequest("AND", "glpi_knowbaseitemcategories", "", "", true); } else { // Anonymous access if (Session::isMultiEntitiesMode()) { $faq_limit = " AND (`glpi_knowbaseitemcategories`.`entities_id` = '0'\n AND `glpi_knowbaseitemcategories`.`is_recursive` = '1')"; } } // Get All FAQ categories if (!isset($_SESSION['glpi_faqcategories'])) { $_SESSION['glpi_faqcategories'] = '(0)'; $tmp = array(); $query = "SELECT DISTINCT `glpi_knowbaseitems`.`knowbaseitemcategories_id`\n FROM `glpi_knowbaseitems`\n " . KnowbaseItem::addVisibilityJoins() . "\n LEFT JOIN `glpi_knowbaseitemcategories`\n ON (`glpi_knowbaseitemcategories`.`id`\n = `glpi_knowbaseitems`.`knowbaseitemcategories_id`)\n WHERE `glpi_knowbaseitems`.`is_faq` = '1'\n AND " . KnowbaseItem::addVisibilityRestrict() . "\n {$faq_limit}"; if ($result = $DB->query($query)) { if ($DB->numrows($result)) { while ($data = $DB->fetch_assoc($result)) { if (!in_array($data['knowbaseitemcategories_id'], $tmp)) { $tmp[] = $data['knowbaseitemcategories_id']; $tmp = array_merge($tmp, getAncestorsOf('glpi_knowbaseitemcategories', $data['knowbaseitemcategories_id'])); } } } if (count($tmp)) { $_SESSION['glpi_faqcategories'] = "('" . implode("','", $tmp) . "')"; } } } $query = "SELECT DISTINCT `glpi_knowbaseitemcategories`.*\n FROM `glpi_knowbaseitemcategories`\n WHERE `glpi_knowbaseitemcategories`.`id` IN " . $_SESSION['glpi_faqcategories'] . "\n AND (`glpi_knowbaseitemcategories`.`knowbaseitemcategories_id`\n = '" . $params["knowbaseitemcategories_id"] . "')\n {$faq_limit}\n ORDER BY `name` ASC"; } else { if (!Session::haveRight("knowbase", "r")) { return false; } $faq_limit = getEntitiesRestrictRequest("AND", "glpi_knowbaseitemcategories", "entities_id", $_SESSION['glpiactiveentities'], true); $query = "SELECT *\n FROM `glpi_knowbaseitemcategories`\n WHERE `glpi_knowbaseitemcategories`.`knowbaseitemcategories_id`\n = '" . $params["knowbaseitemcategories_id"] . "'\n {$faq_limit}\n ORDER BY `name` ASC"; } // Show category if ($result = $DB->query($query)) { echo "<table class='tab_cadre_central'>"; echo "<tr><td colspan='3'><a href='" . $params['target'] . "?knowbaseitemcategories_id=0{$parameters}'>"; echo "<img alt='' src='" . $CFG_GLPI["root_doc"] . "/pics/folder-open.png' class='bottom'></a>"; // Display Category if ($params["knowbaseitemcategories_id"] != 0) { $tmpID = $params["knowbaseitemcategories_id"]; $todisplay = ""; while ($tmpID != 0) { $query2 = "SELECT *\n FROM `glpi_knowbaseitemcategories`\n WHERE `glpi_knowbaseitemcategories`.`id` = '{$tmpID}'\n {$faq_limit}"; $result2 = $DB->query($query2); if ($DB->numrows($result2) == 1) { $data = $DB->fetch_assoc($result2); $tmpID = $data["knowbaseitemcategories_id"]; $todisplay = "<a href='" . $params['target'] . "?knowbaseitemcategories_id=" . $data["id"] . "{$parameters}'>" . $data["name"] . "</a>" . (empty($todisplay) ? "" : " > ") . $todisplay; } else { $tmpID = 0; } } echo " > " . $todisplay; } if ($DB->numrows($result) > 0) { $i = 0; while ($row = $DB->fetch_assoc($result)) { // on affiche les résultats sur trois colonnes if ($i % 3 == 0) { echo "<tr>"; } $ID = $row["id"]; echo "<td class='tdkb_result'>"; echo "<img alt='' src='" . $CFG_GLPI["root_doc"] . "/pics/folder.png' hspace='5'>"; echo "<span class='b'>" . "<a href='" . $params['target'] . "?knowbaseitemcategories_id=" . $row["id"] . "{$parameters}'>" . $row["name"] . "</a></span>"; echo "<div class='kb_resume'>" . Html::resume_text($row['comment'], 60) . "</div>"; if ($i % 3 == 2) { echo "</tr>"; } $i++; } } echo "<tr><td colspan='3'> </td></tr></table><br>"; } }