Exemplo n.º 1
0
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../inc/includes.php';
$ic = new Infocom();
if (isset($_POST['add'])) {
    $ic->check(-1, CREATE, $_POST);
    $newID = $ic->add($_POST, false);
    Event::log($newID, "infocom", 4, "financial", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $newID));
    Html::back();
} else {
    if (isset($_POST["purge"])) {
        $ic->check($_POST["id"], PURGE);
        $ic->delete($_POST, 1);
        Event::log($_POST["id"], "infocom", 4, "financial", sprintf(__('%s purges an item'), $_SESSION["glpiname"]));
        Html::back();
    } else {
        if (isset($_POST["update"])) {
            $ic->check($_POST["id"], UPDATE);
            $ic->update($_POST);
            Event::log($_POST["id"], "infocom", 4, "financial", sprintf(__('%s updates an item'), $_SESSION["glpiname"]));
            Html::back();
        } else {
            Session::checkRight("infocom", READ);
            Html::popHeader(Infocom::getTypeName(), $_SERVER['PHP_SELF']);
            if (isset($_GET["id"])) {
                $ic->getFromDB($_GET["id"]);
                $_GET["itemtype"] = $ic->fields["itemtype"];
                $_GET["items_id"] = $ic->fields["items_id"];
Exemplo n.º 2
0
 /**
  * Clean the date in the relation tables for the deleted item
  * Clear N/N Relation
  **/
 function cleanRelationTable()
 {
     global $CFG_GLPI, $DB;
     // If this type have INFOCOM, clean one associated to purged item
     if (Infocom::canApplyOn($this)) {
         $infocom = new Infocom();
         if ($infocom->getFromDBforDevice($this->getType(), $this->fields['id'])) {
             $infocom->delete(array('id' => $infocom->fields['id']));
         }
     }
     // If this type have NETPORT, clean one associated to purged item
     if (in_array($this->getType(), $CFG_GLPI['networkport_types'])) {
         // If we don't use delete, then cleanDBonPurge() is not call and the NetworkPorts are not
         // clean properly
         $networkPortObject = new NetworkPort();
         $networkPortObject->cleanDBonItemDelete($this->getType(), $this->getID());
         // Manage networkportmigration if exists
         if (TableExists('glpi_networkportmigrations')) {
             $networkPortMigObject = new NetworkPortMigration();
             $networkPortMigObject->cleanDBonItemDelete($this->getType(), $this->getID());
         }
     }
     // If this type is RESERVABLE clean one associated to purged item
     if (in_array($this->getType(), $CFG_GLPI['reservation_types'])) {
         $rr = new ReservationItem();
         if ($rr->getFromDBbyItem($this->getType(), $this->fields['id'])) {
             $rr->delete(array('id' => $infocom->fields['id']));
         }
     }
     // If this type have CONTRACT, clean one associated to purged item
     if (in_array($this->getType(), $CFG_GLPI['contract_types'])) {
         $ci = new Contract_Item();
         $ci->cleanDBonItemDelete($this->getType(), $this->fields['id']);
     }
     // If this type have DOCUMENT, clean one associated to purged item
     if (Document::canApplyOn($this)) {
         $di = new Document_Item();
         $di->cleanDBonItemDelete($this->getType(), $this->fields['id']);
     }
     // If this type have NOTEPAD, clean one associated to purged item
     if ($this->usenotepad) {
         $note = new Notepad();
         $note->cleanDBonItemDelete($this->getType(), $this->fields['id']);
     }
 }
Exemplo n.º 3
0
 /**
  * Clean the date in the relation tables for the deleted item
  * Clear N/N Relation
  **/
 function cleanRelationTable()
 {
     global $CFG_GLPI, $DB;
     // If this type have INFOCOM, clean one associated to purged item
     if (in_array($this->getType(), $CFG_GLPI['infocom_types'])) {
         $infocom = new Infocom();
         if ($infocom->getFromDBforDevice($this->getType(), $this->fields['id'])) {
             $infocom->delete(array('id' => $infocom->fields['id']));
         }
     }
     // If this type have NETPORT, clean one associated to purged item
     if (in_array($this->getType(), $CFG_GLPI['networkport_types'])) {
         $query = "SELECT `id`\n                   FROM `glpi_networkports`\n                   WHERE (`items_id` = '" . $this->fields['id'] . "'\n                          AND `itemtype` = '" . $this->getType() . "')";
         $result = $DB->query($query);
         while ($data = $DB->fetch_array($result)) {
             $q = "DELETE\n                  FROM `glpi_networkports_networkports`\n                  WHERE (`networkports_id_1` = '" . $data["id"] . "'\n                         OR `networkports_id_2` = '" . $data["id"] . "')";
             $result2 = $DB->query($q);
         }
         $query = "DELETE\n                   FROM `glpi_networkports`\n                   WHERE (`items_id` = '" . $this->fields['id'] . "'\n                          AND `itemtype` = '" . $this->getType() . "')";
         $result = $DB->query($query);
     }
     // If this type is RESERVABLE clean one associated to purged item
     if (in_array($this->getType(), $CFG_GLPI['reservation_types'])) {
         $rr = new ReservationItem();
         if ($rr->getFromDBbyItem($this->getType(), $this->fields['id'])) {
             $rr->delete(array('id' => $infocom->fields['id']));
         }
     }
     // If this type have CONTRACT, clean one associated to purged item
     if (in_array($this->getType(), $CFG_GLPI['contract_types'])) {
         $ci = new Contract_Item();
         $ci->cleanDBonItemDelete($this->getType(), $this->fields['id']);
     }
     // If this type have DOCUMENT, clean one associated to purged item
     if (in_array($this->getType(), $CFG_GLPI["document_types"])) {
         $di = new Document_Item();
         $di->cleanDBonItemDelete($this->getType(), $this->fields['id']);
     }
 }
Exemplo n.º 4
0
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../inc/includes.php';
$ic = new Infocom();
if (isset($_POST['add'])) {
    $ic->check(-1, 'w', $_POST);
    $newID = $ic->add($_POST, false);
    Event::log($newID, "infocom", 4, "financial", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $newID));
    Html::back();
} else {
    if (isset($_POST["delete"])) {
        $ic->check($_POST["id"], 'd');
        $ic->delete($_POST);
        Event::log($_POST["id"], "infocom", 4, "financial", sprintf(__('%s purges an item'), $_SESSION["glpiname"]));
        Html::back();
    } else {
        if (isset($_POST["update"])) {
            $ic->check($_POST["id"], 'w');
            $ic->update($_POST);
            Event::log($_POST["id"], "infocom", 4, "financial", sprintf(__('%s updates an item'), $_SESSION["glpiname"]));
            Html::back();
        } else {
            Session::checkRight("infocom", "r");
            Html::popHeader(Infocom::getTypeName(), $_SERVER['PHP_SELF']);
            if (isset($_GET["id"])) {
                $ic->getFromDB($_GET["id"]);
                $_GET["itemtype"] = $ic->fields["itemtype"];
                $_GET["items_id"] = $ic->fields["items_id"];