Esempio n. 1
0
    $_GET["withtemplate"] = "";
}
$peripheral = new Peripheral();
if (isset($_POST["add"])) {
    $peripheral->check(-1, CREATE, $_POST);
    if ($newID = $peripheral->add($_POST)) {
        Event::log($newID, "peripherals", 4, "inventory", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $_POST["name"]));
        if ($_SESSION['glpibackcreated']) {
            Html::redirect($peripheral->getFormURL() . "?id=" . $newID);
        }
    }
    Html::back();
} else {
    if (isset($_POST["delete"])) {
        $peripheral->check($_POST["id"], DELETE);
        $peripheral->delete($_POST);
        Event::log($_POST["id"], "peripherals", 4, "inventory", sprintf(__('%s deletes an item'), $_SESSION["glpiname"]));
        $peripheral->redirectToList();
    } else {
        if (isset($_POST["restore"])) {
            $peripheral->check($_POST["id"], DELETE);
            $peripheral->restore($_POST);
            Event::log($_POST["id"], "peripherals", 4, "inventory", sprintf(__('%s restores an item'), $_SESSION["glpiname"]));
            $peripheral->redirectToList();
        } else {
            if (isset($_POST["purge"])) {
                $peripheral->check($_POST["id"], PURGE);
                $peripheral->delete($_POST, 1);
                Event::log($_POST["id"], "peripherals", 4, "inventory", sprintf(__('%s purges an item'), $_SESSION["glpiname"]));
                $peripheral->redirectToList();
            } else {
Esempio n. 2
0
 /**
  * Delete all old periphs for a computer.
  *
  * @param $glpi_computers_id integer : glpi computer id.
  *
  * @return nothing.
  **/
 static function resetPeripherals($glpi_computers_id)
 {
     global $DB;
     $query = "SELECT*\n                FROM `glpi_computers_items`\n                WHERE `computers_id` = '{$glpi_computers_id}'\n                      AND `itemtype` = 'Peripheral'";
     $result = $DB->query($query);
     $per = new Peripheral();
     if ($DB->numrows($result) > 0) {
         $conn = new Computer_Item();
         while ($data = $DB->fetch_assoc($result)) {
             $conn->delete(array('id' => $data['id']));
             $query2 = "SELECT COUNT(*)\n                       FROM `glpi_computers_items`\n                       WHERE `items_id` = '" . $data['items_id'] . "'\n                             AND `itemtype` = 'Peripheral'";
             $result2 = $DB->query($query2);
             if ($DB->result($result2, 0, 0) == 1) {
                 $per->delete(array('id' => $data['items_id']), 1);
             }
         }
     }
 }