Copyright (C) 2003-2011 by the Racks Development Team.

https://forge.indepnet.net/projects/racks
-------------------------------------------------------------------------

LICENSE
     
This file is part of Racks.

Racks 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.

Racks 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 Racks. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
$PluginRacksRack_Item = new PluginRacksRack_Item();
if (isset($_POST["update"])) {
    if ($PluginRacksRack_Item->canCreate()) {
        $PluginRacksRack_Item->update($_POST);
    }
    Html::back();
}
 function cleanDBonPurge()
 {
     $temp = new PluginRacksRack_Item();
     $temp->deleteByCriteria(array('plugin_racks_racks_id' => $this->fields['id']));
 }
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Racks. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
if (!isset($_GET["id"])) {
    $_GET["id"] = "";
}
if (!isset($_GET["withtemplate"])) {
    $_GET["withtemplate"] = "";
}
$PluginRacksRack = new PluginRacksRack();
$PluginRacksOther = new PluginRacksOther();
$PluginRacksRack_Item = new PluginRacksRack_Item();
if (isset($_POST["add"])) {
    $PluginRacksRack->check(-1, CREATE, $_POST);
    $PluginRacksRack->add($_POST);
    Html::back();
} elseif (isset($_POST["delete"])) {
    $PluginRacksRack->check($_POST['id'], DELETE);
    $PluginRacksRack->delete($_POST);
    $PluginRacksRack->redirectToList();
} elseif (isset($_POST["restore"])) {
    $PluginRacksRack->check($_POST['id'], PURGE);
    $PluginRacksRack->restore($_POST);
    $PluginRacksRack->redirectToList();
} else {
    if (isset($_POST["purge"])) {
        $PluginRacksRack->check($_POST['id'], PURGE);
 function UpdateItemSpecification($input)
 {
     global $DB;
     $modelfield = getForeignKeyFieldForTable(getTableForItemType($input['itemtype']));
     $itemtype = substr($input['itemtype'], 0, -5);
     $table = getTableForItemType($itemtype);
     //selection de tous les materiels lies au modele
     $query_spec = "SELECT *\n            FROM `" . $this->getTable() . "`\n            WHERE `id` = '" . $input["id"] . "' ";
     $result_spec = $DB->query($query_spec);
     while ($device = $DB->fetch_array($result_spec)) {
         $query_device = "SELECT `" . $table . "`.`id` FROM `" . $table . "`, `" . $this->getTable() . "` " . "WHERE `" . $this->getTable() . "`.`model_id` = `" . $table . "`.`" . $modelfield . "`\n              AND `" . $this->getTable() . "`.`id` = '" . $input["id"] . "'";
         $result_device = $DB->query($query_device);
         while ($model = $DB->fetch_array($result_device)) {
             //detail de chaque materiel dans la baie
             $query_content = "SELECT * FROM `glpi_plugin_racks_racks_items` " . "WHERE `itemtype` = '" . $input['itemtype'] . "'\n              AND `items_id` = '" . $model['id'] . "' ";
             $result_content = $DB->query($query_content);
             while ($content = $DB->fetch_array($result_content)) {
                 if ($device["amps"] == $content["amps"] && $device["flow_rate"] == $content["flow_rate"] && $device["dissipation"] == $content["dissipation"] && $device["weight"] == $content["weight"]) {
                     //si les params du materiel sont les memes que le modele alors update
                     $PluginRacksRack_Item = new PluginRacksRack_Item();
                     $values["id"] = $content['id'];
                     $values["amps"] = $input["amps"];
                     $values["flow_rate"] = $input["flow_rate"];
                     $values["dissipation"] = $input["dissipation"];
                     $values["weight"] = $input["weight"];
                     $PluginRacksRack_Item->update($values);
                 }
             }
         }
     }
     $this->update($input);
 }
    $_REQUEST["limit"] = $_SESSION["glpidropdown_chars_limit"];
}
$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);
Example #6
0
function plugin_item_purge_racks($item)
{
    $type = get_class($item);
    $temp = new PluginRacksRack_Item();
    $temp->deleteByCriteria(array('itemtype' => $type . "Model", 'items_id' => $item->getField('id')));
    return true;
}
Example #7
0
 public function execQuery($post)
 {
     global $DB;
     $pRackItem = new PluginRacksRack_Item();
     $pRack = new PluginRacksRack();
     $query = "";
     $face = -1;
     if (isset($post['select_front_rear']) && $post['select_front_rear'] != 0) {
         $face = $post['select_front_rear'];
     }
     if (isset($post['plugin_racks_racks_id']) && $post['plugin_racks_racks_id'] != 0) {
         $restrictRackId = "   AND `" . $pRack->getTable() . "`.`id` = '" . $post['plugin_racks_racks_id'] . "'";
         $restrictRackId .= "   AND `" . $pRack->getTable() . "`.`id` = `" . $pRackItem->getTable() . "`.`plugin_racks_racks_id`";
         $leftjoin = ", `glpi_plugin_racks_racks_items` WHERE (1) " . $restrictRackId;
     } else {
         $restrictRackId = "";
         $leftjoin = "LEFT JOIN `glpi_plugin_racks_racks_items` ON (`glpi_plugin_racks_racks_items`.`plugin_racks_racks_id` = `glpi_plugin_racks_racks`.`id`)";
         $restrictRackId = "AND `glpi_plugin_racks_racks_items`.`plugin_racks_racks_id` = `glpi_plugin_racks_racks`.`id`";
     }
     switch ($face) {
         case PluginRacksRack::FRONT_FACE:
             $query = "SELECT `" . $pRackItem->getTable() . "`.* , `" . $pRack->getTable() . "`.*\r\n              FROM `" . $pRackItem->getTable() . "`,`glpi_plugin_racks_itemspecifications` , `" . $pRack->getTable() . "`\r\n              WHERE `" . $pRackItem->getTable() . "`.`plugin_racks_itemspecifications_id` = `glpi_plugin_racks_itemspecifications`.`id` " . $restrictRackId . " \r\n              AND (`" . $pRackItem->getTable() . "`.`faces_id` = '" . PluginRacksRack::FRONT_FACE . "' ) AND NOT `" . $pRack->getTable() . "`.`is_deleted`\r\n              ORDER BY `" . $pRack->getTable() . "`.`name` ASC, `" . $pRackItem->getTable() . "`.`faces_id` ASC, `" . $pRackItem->getTable() . "`.`position` DESC";
             break;
         case PluginRacksRack::BACK_FACE:
             $query = "SELECT `" . $pRackItem->getTable() . "`.* , `" . $pRack->getTable() . "`.*\r\n              FROM `" . $pRackItem->getTable() . "`,`glpi_plugin_racks_itemspecifications` , `" . $pRack->getTable() . "`\r\n              WHERE `" . $pRackItem->getTable() . "`.`plugin_racks_itemspecifications_id` = `glpi_plugin_racks_itemspecifications`.`id` " . $restrictRackId . " \r\n              AND (`" . $pRackItem->getTable() . "`.`faces_id` = '" . PluginRacksRack::BACK_FACE . "' ) AND NOT `" . $pRack->getTable() . "`.`is_deleted`\r\n              ORDER BY `" . $pRack->getTable() . "`.`name` ASC, `" . $pRackItem->getTable() . "`.`faces_id` ASC, `" . $pRackItem->getTable() . "`.`position` DESC";
             break;
         default:
             $query = "SELECT `" . $pRackItem->getTable() . "`.* , `" . $pRack->getTable() . "`.*\r\n              FROM  `" . $pRack->getTable() . "`\r\n              {$leftjoin}\r\n              AND NOT `" . $pRack->getTable() . "`.`is_deleted`\r\n              ORDER BY `" . $pRack->getTable() . "`.`name` ASC, `" . $pRackItem->getTable() . "`.`faces_id` ASC, `" . $pRackItem->getTable() . "`.`position` DESC";
             break;
     }
     $ret = array("query" => $query, "query_result" => $DB->query($query));
     return $ret;
 }