Transfer::manageConnectionComputer PHP Method

manageConnectionComputer() public method

Delete direct connection beetween an item and a computer when transfering the item
public manageConnectionComputer ( $itemtype, $ID )
$itemtype itemtype to tranfer
$ID ID of the item
    function manageConnectionComputer($itemtype, $ID)
    {
        global $DB;
        // Get connections
        $query = "SELECT *\n                FROM `glpi_computers_items`\n                WHERE `computers_id` NOT IN " . $this->item_search['Computer'] . "\n                      AND `itemtype` = '" . $itemtype . "'\n                         AND `items_id` = {$ID}";
        if ($result = $DB->query($query)) {
            if ($DB->numrows($result) != 0) {
                // Foreach get item
                $conn = new Computer_Item();
                $comp = new Computer();
                while ($data = $DB->fetch_assoc($result)) {
                    $item_ID = $data['items_id'];
                    if ($comp->getFromDB($item_ID)) {
                        $conn->delete(array('id' => $data['id']));
                    } else {
                        // Unexisting item / Force disconnect
                        $conn->delete(array('id' => $data['id'], '_no_history' => true, '_no_auto_action' => true));
                    }
                }
            }
        }
    }