function deleteFromDB($force = 0)
{
global $DB, $CFG_GLPI;
if ($force == 1 || !$this->maybeDeleted() || $this->useDeletedToLockIfDynamic() && !$this->isDynamic()) {
$this->cleanDBonPurge();
if ($this instanceof CommonDropdown) {
$this->cleanTranslations();
}
$this->cleanHistory();
$this->cleanRelationData();
$this->cleanRelationTable();
$query = "DELETE\n FROM `" . $this->getTable() . "`\n WHERE `id` = '" . $this->fields['id'] . "'";
if ($result = $DB->query($query)) {
$this->post_deleteFromDB();
return true;
}
} else {
// Auto set date_mod if exsist
$toadd = '';
if (isset($this->fields['date_mod'])) {
$toadd = ", `date_mod` ='" . $_SESSION["glpi_currenttime"] . "' ";
}
$query = "UPDATE `" . $this->getTable() . "`\n SET `is_deleted`='1' {$toadd}\n WHERE `id` = '" . $this->fields['id'] . "'";
$this->cleanDBonMarkDeleted();
if ($result = $DB->query($query)) {
return true;
}
}
return false;
}