} if (!isset($_GET["softwares_id"])) { $_GET["softwares_id"] = ""; } $version = new SoftwareVersion(); if (isset($_POST["add"])) { $version->check(-1, 'w', $_POST); if ($newID = $version->add($_POST)) { Event::log($_POST['softwares_id'], "software", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][82] . " {$newID}."); glpi_header($CFG_GLPI["root_doc"] . "/front/software.form.php?id=" . $version->fields['softwares_id']); } glpi_header($_SERVER['HTTP_REFERER']); } else { if (isset($_POST["delete"])) { $version->check($_POST['id'], 'w'); $version->delete($_POST); Event::log($version->fields['softwares_id'], "software", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][84] . " " . $_POST["id"]); $version->redirectToList(); } else { if (isset($_POST["update"])) { $version->check($_POST['id'], 'w'); $version->update($_POST); Event::log($version->fields['softwares_id'], "software", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][83] . " " . $_POST["id"]); glpi_header($_SERVER['HTTP_REFERER']); } else { commonHeader($LANG['Menu'][4], $_SERVER['PHP_SELF'], "inventory", "software"); $version->showForm($_GET["id"], array('softwares_id' => $_GET["softwares_id"])); commonFooter(); } } }
/** * Update config of a new version * * This function create a new software in GLPI with some general datas. * * @param $software : id of a software. * @param $version : version of the software * * @return integer : inserted version id. **/ static function updateVersion($software, $version, $comments) { global $DB; $query = "SELECT `id`\n FROM `glpi_softwareversions`\n WHERE `softwares_id` = '{$software}'\n AND `name` = '{$version}'"; $result = $DB->query($query); if ($DB->numrows($result) > 0) { $data = $DB->fetch_array($result); $input["id"] = $data["id"]; $input["comment"] = $comments; $vers = new SoftwareVersion(); $vers->update($input); } return; }