本文整理汇总了PHP中Computer::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Computer::update方法的具体用法?PHP Computer::update怎么用?PHP Computer::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Computer
的用法示例。
在下文中一共展示了Computer::update方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pluginFusioninventoryUpdate
//.........这里部分代码省略.........
$result = $DB->query($query);
while ($data = $DB->fetch_array($result)) {
$prepare_agentConfig[] = array("id" => $data["ID"], "threads_networkinventory" => $data['threads_query'], "threads_networkdiscovery" => $data['threads_discovery'], "NETORKINVENTORY" => $data['module_snmpquery'], "NETWORKDISCOVERY" => $data['module_netdiscovery'], "INVENTORY" => $data['module_inventory'], "WAKEONLAN" => $data['module_wakeonlan']);
}
}
}
}
}
$a_table = array();
$a_table['name'] = 'glpi_plugin_fusioninventory_agents';
$a_table['oldname'] = array('glpi_plugin_tracker_agents');
$a_table['fields'] = array();
$a_table['fields']['id'] = array('type' => 'autoincrement', 'value' => '');
$a_table['fields']['entities_id'] = array('type' => 'integer', 'value' => NULL);
$a_table['fields']['is_recursive'] = array('type' => 'bool', 'value' => '1');
$a_table['fields']['name'] = array('type' => 'string', 'value' => NULL);
$a_table['fields']['last_contact'] = array('type' => 'datetime', 'value' => NULL);
$a_table['fields']['version'] = array('type' => 'string', 'value' => NULL);
$a_table['fields']['lock'] = array('type' => 'bool', 'value' => NULL);
$a_table['fields']['device_id'] = array('type' => 'string', 'value' => NULL);
$a_table['fields']['computers_id'] = array('type' => 'integer', 'value' => NULL);
$a_table['fields']['token'] = array('type' => 'string', 'value' => NULL);
$a_table['fields']['useragent'] = array('type' => 'string', 'value' => NULL);
$a_table['fields']['tag'] = array('type' => 'string', 'value' => NULL);
$a_table['fields']['threads_networkdiscovery'] = array('type' => "int(4) NOT NULL DEFAULT '1' COMMENT 'array(xmltag=>value)'", 'value' => NULL);
$a_table['fields']['threads_networkinventory'] = array('type' => "int(4) NOT NULL DEFAULT '1' COMMENT 'array(xmltag=>value)'", 'value' => NULL);
$a_table['fields']['senddico'] = array('type' => 'bool', 'value' => NULL);
$a_table['fields']['timeout_networkdiscovery'] = array('type' => "int(4) NOT NULL DEFAULT '0' COMMENT 'Network Discovery task timeout'", 'value' => NULL);
$a_table['fields']['timeout_networkinventory'] = array('type' => "int(4) NOT NULL DEFAULT '0' COMMENT 'Network Inventory task timeout'", 'value' => NULL);
$a_table['fields']['agent_port'] = array('type' => 'varchar(6)', 'value' => NULL);
$a_table['oldfields'] = array('module_snmpquery', 'module_netdiscovery', 'module_inventory', 'module_wakeonlan', 'core_discovery', 'threads_discovery', 'core_query', 'threads_query', 'tracker_agent_version', 'logs', 'fragment', 'itemtype', 'device_type');
$a_table['renamefields'] = array();
$a_table['renamefields']['ID'] = 'id';
$a_table['renamefields']['last_agent_update'] = 'last_contact';
$a_table['renamefields']['fusioninventory_agent_version'] = 'version';
$a_table['renamefields']['key'] = 'device_id';
$a_table['renamefields']['on_device'] = 'computers_id';
$a_table['renamefields']['items_id'] = 'computers_id';
$a_table['keys'] = array();
$a_table['keys'][] = array('field' => 'name', 'name' => '', 'type' => 'INDEX');
$a_table['keys'][] = array('field' => 'device_id', 'name' => '', 'type' => 'INDEX');
$a_table['keys'][] = array('field' => 'computers_id', 'name' => '', 'type' => 'INDEX');
$a_table['oldkeys'] = array('key');
migrateTablesFusionInventory($migration, $a_table);
/*
* Table glpi_plugin_fusioninventory_agentmodules
*/
$a_table = array();
$a_table['name'] = 'glpi_plugin_fusioninventory_agentmodules';
$a_table['oldname'] = array();
$a_table['fields'] = array();
$a_table['fields']['id'] = array('type' => 'autoincrement', 'value' => '');
$a_table['fields']['modulename'] = array('type' => 'string', 'value' => NULL);
$a_table['fields']['is_active'] = array('type' => 'bool', 'value' => NULL);
$a_table['fields']['exceptions'] = array('type' => 'text', 'value' => NULL);
$a_table['oldfields'] = array();
$a_table['oldfields'][] = 'plugins_id';
$a_table['oldfields'][] = 'entities_id';
$a_table['oldfields'][] = 'url';
$a_table['renamefields'] = array();
$a_table['keys'] = array();
$a_table['keys'][] = array('field' => 'modulename', 'name' => '', 'type' => 'UNIQUE');
$a_table['oldkeys'] = array('unicity', 'entities_id');
migrateTablesFusionInventory($migration, $a_table);
/*
* Add Deploy module
示例2: sprintf
$computer->check($_POST['id'], DELETE);
if ($computer->restore($_POST)) {
Event::log($_POST["id"], "computers", 4, "inventory", sprintf(__('%s restores an item'), $_SESSION["glpiname"]));
}
$computer->redirectToList();
} else {
if (isset($_POST["purge"])) {
$computer->check($_POST['id'], PURGE);
if ($computer->delete($_POST, 1)) {
Event::log($_POST["id"], "computers", 4, "inventory", sprintf(__('%s purges an item'), $_SESSION["glpiname"]));
}
$computer->redirectToList();
//update a computer
} else {
if (isset($_POST["update"])) {
$computer->check($_POST['id'], UPDATE);
$computer->update($_POST);
Event::log($_POST["id"], "computers", 4, "inventory", sprintf(__('%s updates an item'), $_SESSION["glpiname"]));
Html::back();
// Disconnect a computer from a printer/monitor/phone/peripheral
} else {
//print computer information
Html::header(Computer::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "assets", "computer");
//show computer form to add
$computer->display(array('id' => $_GET["id"], 'withtemplate' => $_GET["withtemplate"]));
Html::footer();
}
}
}
}
}
示例3: updateLocation
/**
* Update location for a computer if needed after rule processing
*
* @param line_links
* @param data
*
* @return nothing
*/
static function updateLocation($line_links, $data)
{
//If there's a location to update
if (isset($data['locations_id'])) {
$computer = new Computer();
$computer->getFromDB($line_links['computers_id']);
$ancestors = getAncestorsOf('glpi_entities', $computer->fields['entities_id']);
$location = new Location();
if ($location->getFromDB($data['locations_id'])) {
//If location is in the same entity as the computer, or if the location is
//defined in a parent entity, but recursive
if ($location->fields['entities_id'] == $computer->fields['entities_id'] || in_array($location->fields['entities_id'], $ancestors) && $location->fields['is_recursive']) {
$tmp['locations_id'] = $data['locations_id'];
$tmp['id'] = $line_links['computers_id'];
$computer->update($tmp);
}
}
}
}
示例4: setDynamicLinkItems
function setDynamicLinkItems($computers_id)
{
global $DB;
$computer = new Computer();
$input = array('id' => $computers_id);
PluginFusioninventoryInventoryComputerInventory::addDefaultStateIfNeeded($input);
$computer->update($input);
$DB->query("UPDATE `glpi_computerdisks` SET `is_dynamic`='1'\n WHERE `computers_id`='" . $computers_id . "'");
$DB->query("UPDATE `glpi_computers_items` SET `is_dynamic`='1'\n WHERE `computers_id`='" . $computers_id . "'");
$DB->query("UPDATE `glpi_computers_softwareversions` SET `is_dynamic`='1'\n WHERE `computers_id`='" . $computers_id . "'");
$DB->query("UPDATE `glpi_computervirtualmachines` SET `is_dynamic`='1'\n WHERE `computers_id`='" . $computers_id . "'");
$a_tables = array("glpi_networkports", "glpi_items_devicecases", "glpi_items_devicecontrols", "glpi_items_devicedrives", "glpi_items_devicegraphiccards", "glpi_items_deviceharddrives", "glpi_items_devicememories", "glpi_items_devicemotherboards", "glpi_items_devicenetworkcards", "glpi_items_devicepcis", "glpi_items_devicepowersupplies", "glpi_items_deviceprocessors", "glpi_items_devicesoundcards");
foreach ($a_tables as $table) {
$DB->query("UPDATE `" . $table . "` SET `is_dynamic`='1'\n WHERE `items_id`='" . $computers_id . "'\n AND `itemtype`='Computer'");
}
}
示例5:
// TODO: to be done according to automatic link configuration
$input["id"] = $event["items_id"];
$input["name"] = NULL;
// No name
$input["is_dynamic"] = 0;
// No Ocs link
$input["state"] = 5;
// Available
// Unlink the computer
$sql = "DELETE\n FROM `glpi_ocslinks`\n WHERE `computers_id` = '" . $event["items_id"] . "'";
if ($debug) {
echo "DEBUG: {$sql} \n";
}
if ($run) {
// Restore previous state
$comp->update($input);
// Unlink the computer
$resupd = $DB->query($sql);
if ($res) {
$nbupd += $DB->affected_rows();
$changes[0] = 0;
$changes[2] = "Rollback: restauration statut au {$maxti}";
$changes[1] = "";
Log::history($event["items_id"], 'Computer', $changes, 0, Log::HISTORY_LOG_SIMPLE_MESSAGE);
} else {
echo "*** MySQL : {$sql}\n*** Error : " . $DB->error() . "\n";
}
}
}
// Else
}
示例6: prepareTaskWithdynamicgroupchanged
/**
* @test
*/
public function prepareTaskWithdynamicgroupchanged()
{
global $DB;
// Verify cancel agent prepared when one computer not verify dynamic group in deploy task
$DB->connect();
$computer = new Computer();
$computer->update(array('id' => 2, 'name' => 'koin'));
PluginFusioninventoryTask::cronTaskscheduler();
$pfTask = new PluginFusioninventoryTask();
$data = $pfTask->getJoblogs(array(1));
$ref = array(1 => 'portdavid', 2 => 'computer2', 3 => 'computer3', 4 => 'computer4');
$this->assertEquals($ref, $data['agents']);
$ref_prepared = array(1 => 1, 3 => 1, 4 => 1);
$this->assertEquals($ref_prepared, $data['tasks'][1]['jobs'][1]['targets']['PluginFusioninventoryDeployPackage_1']['counters']['agents_prepared']);
}
示例7: updateLocation
/**
* Update location for a computer if needed after rule processing
*
* @param $line_links
* @param $data
* @param $cfg_ocs
* @return nothing
* @internal param $line_links
* @internal param $data
*
*/
static function updateLocation($line_links, $data, $cfg_ocs)
{
//If there's a location to update
if (isset($data['locations_id'])) {
$computer = new Computer();
$computer->getFromDB($line_links['computers_id']);
$ancestors = getAncestorsOf('glpi_entities', $computer->fields['entities_id']);
$location = new Location();
if ($location->getFromDB($data['locations_id'])) {
//If location is in the same entity as the computer, or if the location is
//defined in a parent entity, but recursive
if ($location->fields['entities_id'] == $computer->fields['entities_id'] || in_array($location->fields['entities_id'], $ancestors) && $location->fields['is_recursive']) {
$ko = 0;
$locks = self::getLocksForComputer($line_links['computers_id']);
if (is_array($locks) && count($locks)) {
if (in_array("locations_id", $locks)) {
$ko = 1;
}
}
if ($ko == 0) {
$tmp['locations_id'] = $data['locations_id'];
$tmp['id'] = $line_links['computers_id'];
$computer->update($tmp, $cfg_ocs['history_hardware']);
}
}
}
}
}
示例8: updateAdministrativeInfo
/**
* Update the administrative informations
*
* This function erase old data and import the new ones about administrative informations
*
* @param $computers_id integer : glpi computer id.
* @param $ocsid integer : ocs computer id (ID).
* @param $ocsservers_id integer : ocs server id
* @param $cfg_ocs array : configuration ocs of the server
* @param $computer_updates array : already updated fields of the computer
* @param $entity integer : entity of the computer
* @param $dohistory boolean : log changes ?
*
* @return Nothing (void).
**/
static function updateAdministrativeInfo($computers_id, $ocsid, $ocsservers_id, $cfg_ocs, $computer_updates, $entity, $dohistory)
{
global $DB, $DBocs;
self::checkOCSconnection($ocsservers_id);
//check link between ocs and glpi column
$queryListUpdate = "SELECT *\n FROM `glpi_ocsadmininfoslinks`\n WHERE `ocsservers_id` = '{$ocsservers_id}' ";
$result = $DB->query($queryListUpdate);
if ($DB->numrows($result) > 0) {
$queryOCS = "SELECT *\n FROM `accountinfo`\n WHERE `HARDWARE_ID` = '{$ocsid}'";
$resultOCS = $DBocs->query($queryOCS);
if ($DBocs->numrows($resultOCS) > 0) {
$data_ocs = $DBocs->fetch_array($resultOCS);
$comp = new Computer();
//update data
while ($links_glpi_ocs = $DB->fetch_array($result)) {
//get info from ocs
$ocs_column = $links_glpi_ocs['ocs_column'];
$glpi_column = $links_glpi_ocs['glpi_column'];
if (isset($data_ocs[$ocs_column]) && !in_array($glpi_column, $computer_updates)) {
$var = $data_ocs[$ocs_column];
switch ($glpi_column) {
case "groups_id":
$var = self::importGroup($var, $entity);
break;
case "locations_id":
$var = Dropdown::importExternal("Location", $var, $entity);
break;
case "networks_id":
$var = Dropdown::importExternal("Network", $var);
break;
}
$input = array();
$input[$glpi_column] = $var;
$input["id"] = $computers_id;
$input["entities_id"] = $entity;
$comp->update($input, $dohistory);
}
}
}
}
}