示例#1
0
        if ($license->restore($_POST)) {
            Event::log($_POST["id"], "software", 4, "inventory", sprintf(__('%s restores an item'), $_SESSION["glpiname"]));
        }
        $license->redirectToList();
    } else {
        if (isset($_POST["delete"])) {
            $license->check($_POST['id'], DELETE);
            $license->delete($_POST, 0);
            Event::log($license->fields['softwares_id'], "software", 4, "inventory", sprintf(__('%1$s deletes the license %2$s'), $_SESSION["glpiname"], $_POST["id"]));
            $license->redirectToList();
        } else {
            if (isset($_POST["purge"])) {
                $license->check($_POST['id'], PURGE);
                $license->delete($_POST, 1);
                Event::log($license->fields['softwares_id'], "software", 4, "inventory", sprintf(__('%1$s purges the license %2$s'), $_SESSION["glpiname"], $_POST["id"]));
                $license->redirectToList();
            } else {
                if (isset($_POST["update"])) {
                    $license->check($_POST['id'], UPDATE);
                    $license->update($_POST);
                    Event::log($license->fields['softwares_id'], "software", 4, "inventory", sprintf(__('%1$s updates the license %2$s'), $_SESSION["glpiname"], $_POST["id"]));
                    Html::back();
                } else {
                    Html::header(SoftwareLicense::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "management", "softwarelicense");
                    $license->display($_REQUEST);
                    Html::footer();
                }
            }
        }
    }
}
    $_GET["softwares_id"] = "";
}
$license = new SoftwareLicense();
if (isset($_POST["add"])) {
    $license->check(-1, CREATE, $_POST);
    if ($newID = $license->add($_POST)) {
        Event::log($_POST['softwares_id'], "software", 4, "inventory", sprintf(__('%1$s adds the license %2$s'), $_SESSION["glpiname"], $newID));
        if ($_SESSION['glpibackcreated']) {
            Html::redirect($license->getFormURL() . "?id=" . $newID);
        }
    }
    Html::back();
} else {
    if (isset($_POST["purge"])) {
        $license->check($_POST['id'], PURGE);
        $license->delete($_POST, 1);
        Event::log($license->fields['softwares_id'], "software", 4, "inventory", sprintf(__('%1$s purges the license %2$s'), $_SESSION["glpiname"], $_POST["id"]));
        $license->redirectToList();
    } else {
        if (isset($_POST["update"])) {
            $license->check($_POST['id'], UPDATE);
            $license->update($_POST);
            Event::log($license->fields['softwares_id'], "software", 4, "inventory", sprintf(__('%1$s updates the license %2$s'), $_SESSION["glpiname"], $_POST["id"]));
            Html::back();
        } else {
            Html::header(SoftwareLicense::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "assets", "software");
            $license->display(array('id' => $_GET["id"], 'softwares_id' => $_GET["softwares_id"]));
            Html::footer();
        }
    }
}