*/ /** @file * @brief */ include '../inc/includes.php'; Session::checkCentralAccess(); if (!isset($_GET["id"])) { $_GET["id"] = ""; } if (!isset($_GET["computers_id"])) { $_GET["computers_id"] = ""; } $antivirus = new ComputerAntivirus(); if (isset($_POST["add"])) { $antivirus->check(-1, CREATE, $_POST); if ($newID = $antivirus->add($_POST)) { Event::log($_POST['computers_id'], "computers", 4, "inventory", sprintf(__('%s adds an antivirus'), $_SESSION["glpiname"])); if ($_SESSION['glpibackcreated']) { Html::redirect($antivirus->getFormURL() . "?id=" . $newID); } } Html::back(); } else { if (isset($_POST["purge"])) { $antivirus->check($_POST["id"], PURGE); if ($antivirus->delete($_POST, 1)) { Event::log($antivirus->fields['computers_id'], "computers", 4, "inventory", sprintf(__('%s purges an antivirus'), $_SESSION["glpiname"])); } $computer = new Computer(); $computer->getFromDB($antivirus->fields['computers_id']); Html::redirect(Toolbox::getItemTypeFormURL('Computer') . '?id=' . $antivirus->fields['computers_id'] . ($computer->fields['is_template'] ? "&withtemplate=1" : ""));
/** * Update config of the antivirus * * This function erase old data and import the new ones about antivirus * * @param $computers_id integer : glpi computer id. * @param $ocsComputer * @param $cfg_ocs array : ocs config * @internal param int $plugin_ocsinventoryng_ocsservers_id : ocs server id * @internal param int $ocsid : ocs computer id (ID). */ static function updateAntivirus($computers_id, $ocsComputer, $cfg_ocs) { self::resetAntivirus($computers_id, $cfg_ocs); $av = new ComputerAntivirus(); //update data foreach ($ocsComputer as $anti) { $antivirus = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($anti)); $input = array(); if ($antivirus["category"] == "AntiVirus") { $input["computers_id"] = $computers_id; $input["name"] = $antivirus["product"]; $input["manufacturers_id"] = Dropdown::importExternal('Manufacturer', self::encodeOcsDataInUtf8($cfg_ocs['ocs_db_utf8'], $antivirus["company"])); $input["antivirus_version"] = $antivirus["version"]; $input["is_active"] = $antivirus["enabled"]; $input["is_uptodate"] = $antivirus["uptodate"]; $input["is_dynamic"] = 1; $av->add($input, array('disable_unicity_check' => true)); unset($anti->fields); } } return; }