}
$where = "WHERE 1=1";
if ($item->maybeDeleted()) {
    $where .= " AND `is_deleted` = '0' ";
}
if ($item->maybeTemplate()) {
    $where .= " AND `is_template` = '0' ";
}
$NBMAX = $CFG_GLPI["dropdown_max"];
$LIMIT = "LIMIT 0,{$NBMAX}";
if ($_REQUEST['searchText'] == $CFG_GLPI["ajax_wildcard"]) {
    $LIMIT = "";
}
//why ?
$PluginRacksRack_Item = new PluginRacksRack_Item();
if (in_array(get_class($item), PluginRacksRack::getTypes())) {
    if (isset($_REQUEST['value'])) {
        $where .= "AND `" . $table . "`.`id` <> '" . $_REQUEST['value'] . "' ";
    }
    if ($item->isEntityAssign()) {
        $multi = $item->maybeRecursive();
        $field = "entities_id";
        $add_order = " entities_id, ";
        if (isset($_REQUEST["entity_restrict"]) && !($_REQUEST["entity_restrict"] < 0)) {
            $where .= getEntitiesRestrictRequest(" AND ", $table, $field, $_REQUEST["entity_restrict"]);
            if (is_array($_REQUEST["entity_restrict"]) && count($_REQUEST["entity_restrict"]) > 1) {
                $multi = true;
            }
        } else {
            $where .= getEntitiesRestrictRequest(" AND ", $table, $field);
            if (count($_SESSION['glpiactiveentities']) > 1) {
 function showAllItems($myname, $value_type = 0, $value = 0, $entity_restrict = -1)
 {
     global $CFG_GLPI;
     $types = PluginRacksRack::getTypes();
     $types[] = 'PluginRacksOther';
     $rand = mt_rand();
     $options = array();
     echo "<table border='0'><tr><td>\n";
     echo "<select name='type' id='itemtype{$rand}'>\n";
     echo "<option value='0'>" . Dropdown::EMPTY_VALUE . "</option>\n";
     foreach ($types as $type) {
         $item = new $type();
         echo "<option value='" . $type . "Model'>" . $item::getTypeName(2) . "</option>\n";
     }
     echo "</select>";
     $params = array('modeltable' => '__VALUE__', 'value' => $value, 'myname' => $myname, 'entity_restrict' => $entity_restrict);
     Ajax::UpdateItemOnSelectEvent("itemtype{$rand}", "show_{$myname}{$rand}", $CFG_GLPI["root_doc"] . "/plugins/racks/ajax/dropdownAllItems.php", $params);
     echo "</td><td>\n";
     echo "<span id='show_{$myname}{$rand}'>&nbsp;</span>\n";
     echo "</td></tr></table>\n";
     if ($value > 0) {
         echo "<script type='text/javascript' >\n";
         echo "document.getElementById('itemtype{$rand}').value='" . $value_type . "';";
         echo "</script>\n";
         $params["modeltable"] = $value_type;
         Ajax::updateItem("show_{$myname}{$rand}", $CFG_GLPI["root_doc"] . "/plugins/racks/ajax/dropdownAllItems.php", $params);
     }
     return $rand;
 }
Example #3
0
function plugin_racks_getAddSearchOptions($itemtype)
{
    $sopt = array();
    if (in_array($itemtype, PluginRacksRack::getTypes(true))) {
        if (PluginRacksRack::canView()) {
            $sopt[4460]['table'] = 'glpi_plugin_racks_racks';
            $sopt[4460]['field'] = 'name';
            $sopt[4460]['name'] = _n('Rack enclosure', 'Rack enclosures', 2, 'racks') . " - " . __('Name');
            $sopt[4460]['forcegroupby'] = '1';
            $sopt[4460]['datatype'] = 'itemlink';
            $sopt[4460]['itemlink_type'] = 'PluginRacksRack';
            $sopt[4460]['massiveaction'] = false;
        }
    }
    return $sopt;
}