本文整理汇总了PHP中Computer::restore方法的典型用法代码示例。如果您正苦于以下问题:PHP Computer::restore方法的具体用法?PHP Computer::restore怎么用?PHP Computer::restore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Computer
的用法示例。
在下文中一共展示了Computer::restore方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sprintf
}
}
Html::back();
// delete a computer
} else {
if (isset($_POST["delete"])) {
$computer->check($_POST['id'], DELETE);
$ok = $computer->delete($_POST);
if ($ok) {
Event::log($_POST["id"], "computers", 4, "inventory", sprintf(__('%s deletes an item'), $_SESSION["glpiname"]));
}
$computer->redirectToList();
} else {
if (isset($_POST["restore"])) {
$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);
示例2: linkComputer
/**
* @param $ocsid
* @param $plugin_ocsinventoryng_ocsservers_id
* @param $computers_id
**/
static function linkComputer($ocsid, $plugin_ocsinventoryng_ocsservers_id, $computers_id)
{
global $DB, $PluginOcsinventoryngDBocs, $CFG_GLPI;
self::checkOCSconnection($plugin_ocsinventoryng_ocsservers_id);
$query = "SELECT *\n FROM `glpi_plugin_ocsinventoryng_ocslinks`\n WHERE `computers_id` = '{$computers_id}'";
$result = $DB->query($query);
$ocs_id_change = false;
$ocs_link_exists = false;
$numrows = $DB->numrows($result);
// Already link - check if the OCS computer already exists
if ($numrows > 0) {
$ocs_link_exists = true;
$data = $DB->fetch_assoc($result);
$query = "SELECT *\n FROM `hardware`\n WHERE `ID` = '" . $data["ocsid"] . "'";
$result_ocs = $PluginOcsinventoryngDBocs->query($query);
// Not found
if ($PluginOcsinventoryngDBocs->numrows($result_ocs) == 0) {
$idlink = $data["id"];
$query = "UPDATE `glpi_plugin_ocsinventoryng_ocslinks`\n SET `ocsid` = '{$ocsid}'\n WHERE `id` = '" . $data["id"] . "'";
if ($DB->query($query)) {
$ocs_id_change = true;
//Add history to indicates that the ocsid changed
$changes[0] = '0';
//Old ocsid
$changes[1] = $data["ocsid"];
//New ocsid
$changes[2] = $ocsid;
PluginOcsinventoryngOcslink::history($computers_id, $changes, PluginOcsinventoryngOcslink::HISTORY_OCS_IDCHANGED);
}
}
}
// No ocs_link or ocs id change does not exists so can link
if ($ocs_id_change || !$ocs_link_exists) {
$ocsConfig = self::getConfig($plugin_ocsinventoryng_ocsservers_id);
// Set OCS checksum to max value
self::setChecksumForComputer($ocsid, self::MAX_CHECKSUM);
if ($ocs_id_change || ($idlink = self::ocsLink($ocsid, $plugin_ocsinventoryng_ocsservers_id, $computers_id))) {
// automatic transfer computer
if ($CFG_GLPI['transfers_id_auto'] > 0 && Session::isMultiEntitiesMode()) {
// Retrieve data from glpi_plugin_ocsinventoryng_ocslinks
$ocsLink = new PluginOcsinventoryngOcslink();
$ocsLink->getFromDB($idlink);
if (count($ocsLink->fields)) {
// Retrieve datas from OCS database
$query_ocs = "SELECT *\n FROM `hardware`\n WHERE `ID` = '" . $ocsLink->fields['ocsid'] . "'";
$result_ocs = $PluginOcsinventoryngDBocs->query($query_ocs);
if ($PluginOcsinventoryngDBocs->numrows($result_ocs) == 1) {
$data_ocs = Toolbox::addslashes_deep($PluginOcsinventoryngDBocs->fetch_array($result_ocs));
self::transferComputer($ocsLink->fields, $data_ocs);
}
}
}
$comp = new Computer();
$comp->getFromDB($computers_id);
$input["id"] = $computers_id;
$input["entities_id"] = $comp->fields['entities_id'];
$input["is_dynamic"] = 1;
$input["_nolock"] = true;
// Not already import from OCS / mark default state
if (!$ocs_id_change || !$comp->fields['is_dynamic'] && $ocsConfig["states_id_default"] > 0) {
$input["states_id"] = $ocsConfig["states_id_default"];
}
$comp->update($input);
// Auto restore if deleted
if ($comp->fields['is_deleted']) {
$comp->restore(array('id' => $computers_id));
}
// Reset using GLPI Config
$cfg_ocs = self::getConfig($plugin_ocsinventoryng_ocsservers_id);
// Reset only if not in ocs id change case
if (!$ocs_id_change) {
if ($cfg_ocs["import_general_os"]) {
self::resetDropdown($computers_id, "operatingsystems_id", "glpi_operatingsystems");
}
if ($cfg_ocs["import_device_processor"]) {
self::resetDevices($computers_id, 'DeviceProcessor');
}
if ($cfg_ocs["import_device_iface"]) {
self::resetDevices($computers_id, 'DeviceNetworkCard');
}
if ($cfg_ocs["import_device_memory"]) {
self::resetDevices($computers_id, 'DeviceMemory');
}
if ($cfg_ocs["import_device_hdd"]) {
self::resetDevices($computers_id, 'DeviceHardDrive');
}
if ($cfg_ocs["import_device_sound"]) {
self::resetDevices($computers_id, 'DeviceSoundCard');
}
if ($cfg_ocs["import_device_gfxcard"]) {
self::resetDevices($computers_id, 'DeviceGraphicCard');
}
if ($cfg_ocs["import_device_drive"]) {
self::resetDevices($computers_id, 'DeviceDrive');
}
//.........这里部分代码省略.........
示例3: linkComputer
/**
* @param $ocsid
* @param $plugin_ocsinventoryng_ocsservers_id
* @param $computers_id
*
* @return bool
*/
static function linkComputer($ocsid, $plugin_ocsinventoryng_ocsservers_id, $computers_id)
{
global $DB, $CFG_GLPI;
self::checkOCSconnection($plugin_ocsinventoryng_ocsservers_id);
$ocsClient = self::getDBocs($plugin_ocsinventoryng_ocsservers_id);
$cfg_ocs = self::getConfig($plugin_ocsinventoryng_ocsservers_id);
$query = "SELECT *\n FROM `glpi_plugin_ocsinventoryng_ocslinks`\n WHERE `computers_id` = '{$computers_id}'";
$result = $DB->query($query);
$ocs_id_change = false;
$ocs_link_exists = false;
$numrows = $DB->numrows($result);
// Already link - check if the OCS computer already exists
if ($numrows > 0) {
$ocs_link_exists = true;
$data = $DB->fetch_assoc($result);
// Not found
if (!$ocsClient->getIfOCSComputersExists($data['ocsid'])) {
$idlink = $data["id"];
$query = "UPDATE `glpi_plugin_ocsinventoryng_ocslinks`\n SET `ocsid` = '{$ocsid}'\n WHERE `id` = '" . $data["id"] . "'";
if ($DB->query($query)) {
$ocs_id_change = true;
//Add history to indicates that the ocsid changed
$changes[0] = '0';
//Old ocsid
$changes[1] = $data["ocsid"];
//New ocsid
$changes[2] = $ocsid;
PluginOcsinventoryngOcslink::history($computers_id, $changes, PluginOcsinventoryngOcslink::HISTORY_OCS_IDCHANGED);
}
}
}
$options = array("DISPLAY" => array("CHECKSUM" => PluginOcsinventoryngOcsClient::CHECKSUM_BIOS | PluginOcsinventoryngOcsClient::CHECKSUM_NETWORK_ADAPTERS));
$ocsComputer = $ocsClient->getComputer($ocsid, $options);
$serial = isset($ocsComputer['BIOS']["SSN"]) ? $ocsComputer['BIOS']["SSN"] : "";
$ssnblacklist = Blacklist::getSerialNumbers();
if (in_array($serial, $ssnblacklist)) {
Session::addMessageAfterRedirect(sprintf(__('Unable to link this computer, Serial number is blacklisted (%d)', 'ocsinventoryng'), $ocsid), false, ERROR);
return false;
}
$uuid = isset($ocsComputer['META']["UUID"]) ? $ocsComputer['META']["UUID"] : "";
$uuidblacklist = Blacklist::getUUIDs();
if (in_array($uuid, $uuidblacklist)) {
Session::addMessageAfterRedirect(sprintf(__('Unable to link this computer, UUID is blacklisted (%d)', 'ocsinventoryng'), $ocsid), false, ERROR);
return false;
}
// No ocs_link or ocs id change does not exists so can link
if ($ocs_id_change || !$ocs_link_exists) {
$ocsConfig = self::getConfig($plugin_ocsinventoryng_ocsservers_id);
// Set OCS checksum to max value
$ocsClient->setChecksum(PluginOcsinventoryngOcsClient::CHECKSUM_ALL, $ocsid);
if ($ocs_id_change || ($idlink = self::ocsLink($ocsid, $plugin_ocsinventoryng_ocsservers_id, $computers_id))) {
// automatic transfer computer
if ($CFG_GLPI['transfers_id_auto'] > 0 && Session::isMultiEntitiesMode()) {
// Retrieve data from glpi_plugin_ocsinventoryng_ocslinks
$ocsLink = new PluginOcsinventoryngOcslink();
$ocsLink->getFromDB($idlink);
if (count($ocsLink->fields)) {
// Retrieve datas from OCS database
$ocsComputer = $ocsClient->getComputer($ocsLink->fields['ocsid']);
if (!is_null($ocsComputer)) {
$ocsComputer = Toolbox::addslashes_deep($ocsComputer);
self::transferComputer($ocsLink->fields);
}
}
}
$comp = new Computer();
$comp->getFromDB($computers_id);
$input["id"] = $computers_id;
$input["entities_id"] = $comp->fields['entities_id'];
$input["is_dynamic"] = 1;
$input["_nolock"] = true;
// Not already import from OCS / mark default state
if (!$ocs_id_change && $ocsConfig["states_id_default"] > 0 || !$comp->fields['is_dynamic'] && $ocsConfig["states_id_default"] > 0) {
$input["states_id"] = $ocsConfig["states_id_default"];
}
$comp->update($input, $cfg_ocs['history_hardware']);
// Auto restore if deleted
if ($comp->fields['is_deleted']) {
$comp->restore(array('id' => $computers_id));
}
// Reset only if not in ocs id change case
if (!$ocs_id_change) {
$changes[0] = '0';
$changes[1] = "";
$changes[2] = $ocsid;
PluginOcsinventoryngOcslink::history($computers_id, $changes, PluginOcsinventoryngOcslink::HISTORY_OCS_LINK);
if ($ocsConfig["import_general_os"]) {
self::resetDropdown($computers_id, "operatingsystems_id", "glpi_operatingsystems");
}
if ($ocsConfig["import_device_processor"]) {
self::resetDevices($computers_id, 'DeviceProcessor', $cfg_ocs);
}
if ($ocsConfig["import_device_iface"]) {
//.........这里部分代码省略.........