本文整理汇总了PHP中Software::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Software::update方法的具体用法?PHP Software::update怎么用?PHP Software::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Software
的用法示例。
在下文中一共展示了Software::update方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: popHeader
} else {
if (isset($_POST["restore"])) {
$soft->check($_POST["id"], 'd');
$soft->restore($_POST);
Event::log($_POST["id"], "software", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][23]);
$soft->redirectToList();
} else {
if (isset($_REQUEST["purge"])) {
$soft->check($_REQUEST["id"], 'd');
$soft->delete($_REQUEST, 1);
Event::log($_REQUEST["id"], "software", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][24]);
$soft->redirectToList();
} else {
if (isset($_POST["update"])) {
$soft->check($_POST["id"], 'w');
$soft->update($_POST);
Event::log($_POST["id"], "software", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][21]);
glpi_header($_SERVER['HTTP_REFERER']);
} else {
if (isset($_POST["mergesoftware"])) {
popHeader($LANG['Menu'][4]);
if (isset($_POST["id"]) && isset($_POST["item"]) && is_array($_POST["item"]) && count($_POST["item"])) {
$soft->check($_POST["id"], 'w');
$soft->merge($_POST["item"]);
}
glpi_header($_SERVER['HTTP_REFERER']);
} else {
commonHeader($LANG['Menu'][4], $_SERVER['PHP_SELF'], "inventory", "software");
$soft->showForm($_GET["id"], array('withtemplate' => $_GET["withtemplate"]));
commonFooter();
}
示例2: AddComputerStep3
/**
* @test
*/
public function AddComputerStep3()
{
global $DB;
$this->mark_incomplete();
return;
// TODO: recode this test
$DB->connect();
$DB->query("UPDATE `glpi_entities`\n SET `entities_id_software` = '-2'\n WHERE `id`='1'");
$_SESSION['glpiactive_entity'] = 0;
$_SESSION['glpiactiveentities_string'] = 0;
$_SESSION['glpishowallentities'] = 1;
$_SESSION['glpiname'] = 'glpi';
$pfiComputerInv = new PluginFusioninventoryInventoryComputerInventory();
$computer = new Computer();
$software = new Software();
$input = array('id' => 1, 'is_recursive' => 0);
$software->update($input);
$computer->add(array('name' => 'pc2', 'entities_id' => 1));
$a_inventory = array();
$a_inventory['CONTENT']['HARDWARE'] = array('NAME' => 'pc2');
$a_inventory['CONTENT']['SOFTWARES'][] = array('COMMENTS' => "Non-interactive tool to get files from FTP, GOPHER, HTTP(S)", 'NAME' => "curl", 'VERSION' => "7.24.0_1");
// ** Add agent
$pfAgent = new PluginFusioninventoryAgent();
$a_agents_id = $pfAgent->add(array('name' => 'pc-2013-02-13', 'device_id' => 'pc-2013-02-13'));
$_SESSION['plugin_fusioninventory_agents_id'] = $a_agents_id;
// ** Add
$pfiComputerInv->import("pc2-2013-02-13", "", $a_inventory);
// creation
$computer->getFromDB(2);
$this->assertEquals(1, $computer->fields['entities_id'], 'Add computer');
$nbSoftwares = countElementsInTable("glpi_softwares");
$softs = getAllDatasFromTable("glpi_softwares");
$this->assertEquals(2, $nbSoftwares, 'Nb softwares ' . print_r($softs, true));
$software->getFromDB(2);
$this->assertEquals(1, $software->fields['entities_id'], "May be on entity 1");
// Software not in same entity as computer, may be recursive
$this->assertEquals(0, $software->fields['is_recursive'], 'Software may have recursive = 0');
}
示例3: replayDictionnaryOnOneSoftware
/**
* Replay dictionnary on one software
*
* @param &$new_softs array containing new softwares already computed
* @param $res_rule array of rule results
* @param $ID ID of the software
* @param $entity working entity ID
* @param $name softwrae name
* @param $manufacturer manufacturer name
* @param &$soft_ids array containing replay software need to be dustbined
**/
function replayDictionnaryOnOneSoftware(array &$new_softs, array $res_rule, $ID, $entity, $name, $manufacturer, array &$soft_ids)
{
global $DB;
$input["name"] = $name;
$input["manufacturer"] = $manufacturer;
$input["entities_id"] = $entity;
if (empty($res_rule)) {
$res_rule = $this->processAllRules($input, array(), array());
}
$soft = new Software();
if (isset($res_rules['_ignore_import']) && $res_rules['_ignore_import'] == 1) {
$soft->putInTrash($ID, __('Software deleted by GLPI dictionary rules'));
return;
}
//Software's name has changed or entity
if (isset($res_rule["name"]) && $res_rule["name"] != $name || !isset($res_rule["name"]) && isset($res_rule['new_entities_id']) && in_array($res_rule['new_entities_id'], getAncestorsOf('glpi_entities', $entity))) {
if (isset($res_rule["name"])) {
$new_name = $res_rule["name"];
} else {
$new_name = addslashes($name);
}
if (isset($res_rule["manufacturer"]) && $res_rule["manufacturer"]) {
$manufacturer = $res_rule["manufacturer"];
} else {
$manufacturer = addslashes($manufacturer);
}
//New software not already present in this entity
if (!isset($new_softs[$entity][$new_name])) {
// create new software or restore it from dustbin
$new_software_id = $soft->addOrRestoreFromTrash($new_name, $manufacturer, $entity, '', true);
$new_softs[$entity][$new_name] = $new_software_id;
} else {
$new_software_id = $new_softs[$entity][$new_name];
}
// Move licenses to new software
$this->moveLicenses($ID, $new_software_id);
} else {
$new_software_id = $ID;
$res_rule["id"] = $ID;
if (isset($res_rule["manufacturer"]) && $res_rule["manufacturer"]) {
$res_rule["manufacturers_id"] = Dropdown::importExternal('Manufacturer', $res_rule["manufacturer"]);
unset($res_rule["manufacturer"]);
}
$soft->update($res_rule);
}
// Add to software to deleted list
if ($new_software_id != $ID) {
$soft_ids[] = $ID;
}
//Get all the different versions for a software
$result = $DB->query("SELECT *\n FROM `glpi_softwareversions`\n WHERE `softwares_id` = '{$ID}'");
while ($version = $DB->fetch_assoc($result)) {
$input["version"] = addslashes($version["name"]);
$old_version_name = $input["version"];
if (isset($res_rule["version"]) && $res_rule["version"] != '') {
$new_version_name = $res_rule["version"];
} else {
$new_version_name = $version["name"];
}
if ($ID != $new_software_id || $new_version_name != $old_version_name) {
$this->moveVersions($ID, $new_software_id, $version["id"], $old_version_name, $new_version_name, $entity);
}
}
}
示例4: RuleSoftwareCategoryCollection
You should have received a copy of the GNU General Public License
along with GLPI; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--------------------------------------------------------------------------
*/
// ----------------------------------------------------------------------
// Original Author of file: Julien Dombre
// Purpose of file:
// ----------------------------------------------------------------------
define('GLPI_ROOT', '..');
include GLPI_ROOT . "/inc/includes.php";
// COMPUTER ONLY UNDEF CATEGORIES
$ONLY_UNDEFINED = true;
$softcatrule = new RuleSoftwareCategoryCollection();
$soft = new Software();
$query = "SELECT `id`, `softwarecategories_id`\n FROM `glpi_softwares`";
if ($result = $DB->query($query)) {
if ($DB->numrows($result) > 0) {
while ($data = $DB->fetch_array($result)) {
if (!$ONLY_UNDEFINED || $data['softwarecategories_id'] == 0) {
$params = array();
//Get software name and manufacturer
$soft->getFromDB($data['id']);
$params["name"] = $soft->fields["name"];
$params["manufacturers_id"] = $soft->fields["manufacturers_id"];
//Process rules
$soft->update($softcatrule->processAllRules(null, $soft->fields, $params));
}
}
}
}
示例5: testSoftwareImport
/**
* test for addOrRestoreFromTrash
*/
public function testSoftwareImport()
{
$ent0 = $this->sharedFixture['entity'][0];
$ent1 = $this->sharedFixture['entity'][1];
$ent2 = $this->sharedFixture['entity'][2];
$soft = new Software();
$manu = new Manufacturer();
// Import Software
$id[0] = $soft->addOrRestoreFromTrash('GLPI', 'Indepnet', $ent0);
$this->assertGreaterThan(0, $id[0], "Fail: can't create software 1");
// Check name
$this->assertTrue($soft->getFromDB($id[0]), "Fail: can't read new soft");
$this->assertEquals('GLPI', $soft->getField('name'), "Fail: name not set");
// Check manufacturer
$manid = $soft->getField('manufacturers_id');
$this->assertGreaterThan(0, $manid, "Fail: manufacturer not set");
$this->assertTrue($manu->getFromDB($manid), "Fail: can't manufacturer");
$this->assertEquals('Indepnet', $manu->getField('name'));
// Import again => same result
$id[1] = $soft->addOrRestoreFromTrash('GLPI', 'Indepnet', $ent0);
$this->assertGreaterThan(0, $id[1], "Fail: can't create software 2");
$this->assertEquals($id[0], $id[1], "Fail: previous not found");
// Import in another entity
$id[2] = $soft->addOrRestoreFromTrash('GLPI', 'Indepnet', $ent1);
$this->assertGreaterThan(0, $id[2], "Fail: can't create software 3");
$this->assertNotEquals($id[0], $id[2], "Fail: previous used (from another entity)");
// Delete
$this->assertTrue($soft->delete(array('id' => $id[2])), "Fail: can't delete software 3)");
$this->assertTrue($soft->getFromDB($id[2]), "Fail: can't read new soft");
$this->assertEquals(1, $soft->getField('is_deleted'), "Fail: soft not deleted");
// Import again => restore
$id[3] = $soft->addOrRestoreFromTrash('GLPI', 'Indepnet', $ent1);
$this->assertEquals($id[2], $id[3], "Fail: previous not used");
$this->assertTrue($soft->getFromDB($id[2]), "Fail: can't read new soft");
$this->assertEquals(0, $soft->getField('is_deleted'), "Fail: soft not restored");
// Import again => with recursive
$this->assertTrue($soft->update(array('id' => $id[0], 'is_recursive' => 1)), "Fail: can't update software 1)");
$id[4] = $soft->addOrRestoreFromTrash('GLPI', 'Indepnet', $ent2);
$this->assertEquals($id[0], $id[4], "Fail: previous not used");
// Clean
$this->assertTrue($soft->delete(array('id' => $id[0]), true), "Fail: can't delete software 1)");
$this->assertTrue($soft->delete(array('id' => $id[2]), true), "Fail: can't delete software 1)");
}
示例6: replayDictionnaryOnOneSoftware
/**
* Replay dictionnary on one software
*
* @param $new_softs array containing new softwares already computed
* @param $res_rule array of rule results
* @param $ID ID of the software
* @param $entity working entity ID
* @param $name softwrae name
* @param $manufacturer manufacturer ID
* @param $soft_ids array containing replay software need to be trashed
**/
function replayDictionnaryOnOneSoftware(&$new_softs, $res_rule, $ID, $entity, $name, $manufacturer, &$soft_ids)
{
global $DB;
$input["name"] = $name;
$input["manufacturer"] = $manufacturer;
$input = addslashes_deep($input);
if (empty($res_rule)) {
$res_rule = $this->processAllRules($input, array(), array());
$res_rule = addslashes_deep($res_rule);
}
$soft = new Software();
//Software's name has changed
if (isset($res_rule["name"]) && $res_rule["name"] != $name) {
if (isset($res_rule["manufacturer"])) {
$manufacturer = Dropdown::getDropdownName("glpi_manufacturers", $res_rule["manufacturer"]);
}
//New software not already present in this entity
if (!isset($new_softs[$entity][$res_rule["name"]])) {
// create new software or restore it from trash
$new_software_id = $soft->addOrRestoreFromTrash($res_rule["name"], $manufacturer, $entity);
$new_softs[$entity][$res_rule["name"]] = $new_software_id;
} else {
$new_software_id = $new_softs[$entity][$res_rule["name"]];
}
// Move licenses to new software
$this->moveLicenses($ID, $new_software_id);
} else {
$new_software_id = $ID;
$res_rule["id"] = $ID;
if (isset($res_rule["manufacturer"])) {
$res_rule["manufacturers_id"] = $res_rule["manufacturer"];
unset($res_rule["manufacturer"]);
}
$soft->update($res_rule);
}
// Add to software to deleted list
if ($new_software_id != $ID) {
$soft_ids[] = $ID;
}
//Get all the different versions for a software
$result = $DB->query("SELECT *\n FROM `glpi_softwareversions`\n WHERE `softwares_id` = '{$ID}'");
while ($version = $DB->fetch_array($result)) {
$input["version"] = addslashes($version["name"]);
$old_version_name = $input["version"];
if (isset($res_rule["version"]) && $res_rule["version"] != '') {
$new_version_name = $res_rule["version"];
} else {
$new_version_name = $version["name"];
}
if ($ID != $new_software_id || $new_version_name != $old_version_name) {
$this->moveVersions($ID, $new_software_id, $version["id"], $old_version_name, $new_version_name, $entity);
}
}
}
示例7: updateSoftware
/**
* Update config of a new software
*
* This function create a new software in GLPI with some general datas.
*
* @param $computers_id integer : glpi computer id.
* @param $entity integer : entity of the computer
* @param $ocsid integer : ocs computer id (ID).
* @param $ocsservers_id integer : ocs server id
* @param $cfg_ocs array : ocs config
* @param $import_software array : already imported softwares
* @param $dohistory boolean : log changes ?
*
* @return Nothing (void).
**/
static function updateSoftware($computers_id, $entity, $ocsid, $ocsservers_id, $cfg_ocs, $import_software, $dohistory)
{
global $DB, $DBocs, $LANG;
self::checkOCSconnection($ocsservers_id);
if ($cfg_ocs["import_software"]) {
//------------------------------------------------------------------------------//
//---- Import_software array is not in the new form ( ID => name+version) ------//
//------------------------------------------------------------------------------//
if (!in_array(self::IMPORT_TAG_070, $import_software)) {
//Add the tag of the version at the beginning of the array
$softs_array[0] = self::IMPORT_TAG_070;
//For each element of the table, add instID=>name.version
foreach ($import_software as $key => $value) {
$query_softs = "SELECT `glpi_softwareversions`.`name` AS version\n FROM `glpi_computers_softwareversions`,\n `glpi_softwareversions`\n WHERE `glpi_computers_softwareversions`.`softwareversions_id`\n =`glpi_softwareversions`.`id`\n AND `glpi_computers_softwareversions`.`computers_id`\n = '{$computers_id}'\n AND `glpi_computers_softwareversions`.`id` = '{$key}'";
$result_softs = $DB->query($query_softs);
$softs = $DB->fetch_array($result_softs);
$softs_array[$key] = $value . self::FIELD_SEPARATOR . $softs["version"];
}
//Replace in GLPI database the import_software by the new one
self::replaceOcsArray($computers_id, $softs_array, "import_software");
// Get import_software from the GLPI db
$query = "SELECT `import_software`\n FROM `glpi_ocslinks`\n WHERE `computers_id` = '{$computers_id}'";
$result = $DB->query($query);
//Reload import_software from DB
if ($DB->numrows($result)) {
$tmp = $DB->fetch_array($result);
$import_software = importArrayFromDB($tmp["import_software"]);
}
}
//---- Get all the softwares for this machine from OCS -----//
if ($cfg_ocs["use_soft_dict"]) {
$query2 = "SELECT `softwares`.`NAME` AS INITNAME,\n `dico_soft`.`FORMATTED` AS NAME,\n `softwares`.`VERSION` AS VERSION,\n `softwares`.`PUBLISHER` AS PUBLISHER,\n `softwares`.`COMMENTS` AS COMMENTS\n FROM `softwares`\n INNER JOIN `dico_soft` ON (`softwares`.`NAME` = dico_soft.EXTRACTED)\n WHERE `softwares`.`HARDWARE_ID` = '{$ocsid}'";
} else {
$query2 = "SELECT `softwares`.`NAME` AS INITNAME,\n `softwares`.`NAME` AS NAME,\n `softwares`.`VERSION` AS VERSION,\n `softwares`.`PUBLISHER` AS PUBLISHER,\n `softwares`.`COMMENTS` AS COMMENTS\n FROM `softwares`\n WHERE `softwares`.`HARDWARE_ID` = '{$ocsid}'";
}
$result2 = $DBocs->query($query2);
$to_add_to_ocs_array = array();
$soft = new Software();
if ($DBocs->numrows($result2) > 0) {
while ($data2 = $DBocs->fetch_array($result2)) {
$data2 = clean_cross_side_scripting_deep(addslashes_deep($data2));
$initname = $data2["INITNAME"];
// Hack for OCS encoding problems
if (!$cfg_ocs["ocs_db_utf8"] && !seems_utf8($initname)) {
$initname = encodeInUtf8($initname);
}
$name = $data2["NAME"];
// Hack for OCS encoding problems
if (!$cfg_ocs["ocs_db_utf8"] && !seems_utf8($name)) {
$name = encodeInUtf8($name);
}
// Hack for OCS encoding problems
if (!$cfg_ocs["ocs_db_utf8"] && !seems_utf8($data2["PUBLISHER"])) {
$data2["PUBLISHER"] = encodeInUtf8($data2["PUBLISHER"]);
}
$version = $data2["VERSION"];
$manufacturer = Manufacturer::processName($data2["PUBLISHER"]);
$use_glpi_dictionnary = false;
if (!$cfg_ocs["use_soft_dict"]) {
//Software dictionnary
$rulecollection = new RuleDictionnarySoftwareCollection();
$res_rule = $rulecollection->processAllRules(array("name" => $name, "manufacturer" => $manufacturer, "old_version" => $version), array(), array('version' => $version));
$res_rule = addslashes_deep($res_rule);
if (isset($res_rule["name"])) {
$modified_name = $res_rule["name"];
} else {
$modified_name = $name;
}
if (isset($res_rule["version"]) && $res_rule["version"] != '') {
$modified_version = $res_rule["version"];
} else {
$modified_version = $version;
}
} else {
$modified_name = $name;
$modified_version = $version;
}
//Ignore this software
if (!isset($res_rule["_ignore_ocs_import"]) || !$res_rule["_ignore_ocs_import"]) {
// Clean software object
$soft->reset();
//If name+version not in present for this computer in glpi, add it
if (!in_array(stripslashes($initname . self::FIELD_SEPARATOR . $version), $import_software)) {
//------------------------------------------------------------------------//
//---- The software doesn't exists in this version for this computer -----//
//.........这里部分代码省略.........