本文整理汇总了PHP中Transfer::getFromDB方法的典型用法代码示例。如果您正苦于以下问题:PHP Transfer::getFromDB方法的具体用法?PHP Transfer::getFromDB怎么用?PHP Transfer::getFromDB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transfer
的用法示例。
在下文中一共展示了Transfer::getFromDB方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uninstall
static function uninstall($type, $model_id, $tab_ids, $location)
{
global $UNINSTALL_DIRECT_CONNECTIONS_TYPE;
//Get the model
$model = new PluginUninstallModel();
$model->getConfig($model_id);
//Then destroy all the connexions
$transfer = new Transfer();
$transfer->getFromDB($model->fields["transfers_id"]);
echo "<div class='center'>";
echo "<table class='tab_cadre_fixe'><tr><th>" . __('Uninstall', 'uninstall') . "</th></tr>";
echo "<tr class='tab_bg_2'><td>";
$count = 0;
$tot = count($tab_ids[$type]);
Html::createProgressBar(__('Please wait, uninstallation is running...', 'uninstall'));
foreach ($tab_ids[$type] as $id => $value) {
$count++;
$item = new $type();
$item->getFromDB($id);
//First clean object and change location and status if needed
$entity = $item->fields["entities_id"];
$input = array();
$input["id"] = $id;
$input["entities_id"] = $entity;
$fields = array();
//Hook to perform actions before item is being uninstalled
$item->fields['_uninstall_event'] = $model->getID();
$item->fields['_action'] = 'uninstall';
Plugin::doHook("plugin_uninstall_before", $item);
//--------------------//
//Direct connections //
//------------------//
if (in_array($type, $UNINSTALL_DIRECT_CONNECTIONS_TYPE)) {
$conn = new Computer_Item();
$conn->deleteByCriteria(array('computers_id' => $id), true);
}
//--------------------//
//-- Common fields --//
//------------------//
//RAZ contact and contactnumber
if ($item->isField('contact') && $model->fields["raz_contact"] == 1) {
$fields["contact"] = '';
if ($item->isField('contact_num')) {
$fields["contact_num"] = '';
}
}
//RAZ user
if ($model->fields["raz_user"] == 1 && $item->isField('users_id')) {
$fields["users_id"] = 0;
}
//RAZ status
if ($model->fields["states_id"] > 0 && $item->isField('states_id')) {
$fields["states_id"] = $model->fields["states_id"];
}
//RAZ machine's name
if ($item->isField('name') && $model->fields["raz_name"] == 1) {
$fields["name"] = '';
}
if ($item->isField('locations_id')) {
if ($location == '') {
$location = 0;
}
switch ($location) {
case -1:
break;
default:
$fields["locations_id"] = $location;
break;
}
}
if ($item->isField('groups_id')) {
$nbgroup = countElementsInTableForEntity("glpi_groups", $entity, "`id`='" . $item->fields['groups_id'] . "'");
if ($model->fields["groups_id"] > -1 && $nbgroup == 1) {
// If a new group is defined and if the group is accessible in the object's entity
$fields["groups_id"] = $model->fields["groups_id"];
}
}
//------------------------------//
//-- Computer specific fields --//
//------------------------------//
if ($type == 'Computer') {
//RAZ all OS related informations
if ($model->fields["raz_os"] == 1) {
$fields["operatingsystems_id"] = 0;
$fields["operatingsystemversions_id"] = 0;
$fields["operatingsystemservicepacks_id"] = 0;
$fields["os_licenseid"] = '';
$fields["os_license_number"] = '';
$fields["autoupdatesystems_id"] = 0;
}
$plug = new Plugin();
if ($plug->isActivated('ocsinventoryng')) {
if ($item->fields["is_dynamic"] && ($model->fields["remove_from_ocs"] || $model->fields["delete_ocs_link"])) {
$input["is_dynamic"] = 0;
}
}
if ($item->isField('domains_id') && $model->fields["raz_domain"]) {
$fields["domains_id"] = 0;
}
//RAZ network
//.........这里部分代码省略.........
示例2: transferComputer
/**
* Do automatic transfer if option is enable
*
* @param $line_links array : data from glpi_plugin_ocsinventoryng_ocslinks table
* @param $line_ocs array : data from ocs tables
*
* @return nothing
**/
static function transferComputer($line_links, $line_ocs)
{
global $DB, $PluginOcsinventoryngDBocs, $CFG_GLPI;
// Get all rules for the current plugin_ocsinventoryng_ocsservers_id
$rule = new RuleImportEntityCollection();
$data = array();
$data = $rule->processAllRules(array('ocsservers_id' => $line_links["plugin_ocsinventoryng_ocsservers_id"], '_source' => 'ocsinventoryng'), array(), array('ocsid' => $line_links["ocsid"]));
// If entity is changing move items to the new entities_id
if (isset($data['entities_id']) && $data['entities_id'] != $line_links['entities_id']) {
if (!isCommandLine() && !Session::haveAccessToEntity($data['entities_id'])) {
Html::displayRightError();
}
$transfer = new Transfer();
$transfer->getFromDB($CFG_GLPI['transfers_id_auto']);
$item_to_transfer = array("Computer" => array($line_links['computers_id'] => $line_links['computers_id']));
$transfer->moveItems($item_to_transfer, $data['entities_id'], $transfer->fields);
}
//If location is update by a rule
self::updateLocation($line_links, $data);
}
示例3: updateComputerNoTranfer
/**
* Update computer to not change entity (transfer not allowed)
*
* @test
*/
public function updateComputerNoTranfer()
{
global $DB;
$DB->connect();
$transfer = new Transfer();
$computer = new Computer();
$pfiComputerInv = new PluginFusioninventoryInventoryComputerInventory();
$pfEntity = new PluginFusioninventoryEntity();
// Manual transfer computer to entity 2
$transfer->getFromDB(1);
$item_to_transfer = array("Computer" => array(1 => 1));
$transfer->moveItems($item_to_transfer, 2, $transfer->fields);
$computer->getFromDB(1);
$this->assertEquals(2, $computer->fields['entities_id'], 'Transfer move computer');
$this->AgentEntity(1, 2, 'Transfer computer on entity 2');
// Define entity 2 not allowed to transfer
$ents_id = $pfEntity->add(array('entities_id' => 2, 'transfers_id_auto' => 0));
$this->assertEquals(2, $ents_id, 'Entity 2 defined with no transfer');
// Update computer and computer must not be transfered (keep in entoty 2)
$a_inventory = array();
$a_inventory['CONTENT']['HARDWARE'] = array('NAME' => 'pc1');
$a_inventory['CONTENT']['BIOS'] = array('SSN' => 'xxyyzz');
$pfiComputerInv->import("pc-2013-02-13", "", $a_inventory);
// Update
$this->assertEquals(1, countElementsInTable('glpi_computers'), 'Must have only 1 computer');
$computer->getFromDB(1);
$this->assertEquals(2, $computer->fields['entities_id'], 'Computer must not be transfered');
$this->AgentEntity(1, 2, 'Agent must stay with entity 2');
}
示例4: rulepassed
/**
* If rule have found computer or rule give to create computer
*
* @param $items_id integer id of the computer found (or 0 if must be created)
* @param $itemtype value Computer type here
*
* @return nothing
*
**/
function rulepassed($items_id, $itemtype)
{
global $DB, $PLUGIN_FUSIONINVENTORY_XML, $PF_ESXINVENTORY, $CFG_GLPI;
PluginFusioninventoryToolbox::logIfExtradebug("pluginFusioninventory-rules", "Rule passed : " . $items_id . ", " . $itemtype . "\n");
$pfFormatconvert = new PluginFusioninventoryFormatconvert();
$a_computerinventory = $pfFormatconvert->replaceids($this->arrayinventory);
$entities_id = $_SESSION["plugin_fusioninventory_entity"];
if ($itemtype == 'Computer') {
$pfInventoryComputerLib = new PluginFusioninventoryInventoryComputerLib();
$pfAgent = new PluginFusioninventoryAgent();
$computer = new Computer();
if ($items_id == '0') {
if ($entities_id == -1) {
$entities_id = 0;
$_SESSION["plugin_fusioninventory_entity"] = 0;
}
$_SESSION['glpiactiveentities'] = array($entities_id);
$_SESSION['glpiactiveentities_string'] = $entities_id;
$_SESSION['glpiactive_entity'] = $entities_id;
} else {
$computer->getFromDB($items_id);
$a_computerinventory['Computer']['states_id'] = $computer->fields['states_id'];
$input = array();
PluginFusioninventoryInventoryComputerInventory::addDefaultStateIfNeeded($input);
if (isset($input['states_id'])) {
$a_computerinventory['Computer']['states_id'] = $input['states_id'];
}
if ($entities_id == -1) {
$entities_id = $computer->fields['entities_id'];
$_SESSION["plugin_fusioninventory_entity"] = $computer->fields['entities_id'];
}
$_SESSION['glpiactiveentities'] = array($entities_id);
$_SESSION['glpiactiveentities_string'] = $entities_id;
$_SESSION['glpiactive_entity'] = $entities_id;
if ($computer->fields['entities_id'] != $entities_id) {
$pfEntity = new PluginFusioninventoryEntity();
$pfInventoryComputerComputer = new PluginFusioninventoryInventoryComputerComputer();
$moveentity = FALSE;
if ($pfEntity->getValue('transfers_id_auto', $computer->fields['entities_id']) > 0) {
if (!$pfInventoryComputerComputer->getLock($items_id)) {
$moveentity = TRUE;
}
}
if ($moveentity) {
$pfEntity = new PluginFusioninventoryEntity();
$transfer = new Transfer();
$transfer->getFromDB($pfEntity->getValue('transfers_id_auto', $entities_id));
$item_to_transfer = array("Computer" => array($items_id => $items_id));
$transfer->moveItems($item_to_transfer, $entities_id, $transfer->fields);
} else {
$_SESSION["plugin_fusioninventory_entity"] = $computer->fields['entities_id'];
$_SESSION['glpiactiveentities'] = array($computer->fields['entities_id']);
$_SESSION['glpiactiveentities_string'] = $computer->fields['entities_id'];
$_SESSION['glpiactive_entity'] = $computer->fields['entities_id'];
$entities_id = $computer->fields['entities_id'];
}
}
}
$a_computerinventory = $pfFormatconvert->extraCollectInfo($a_computerinventory, $items_id);
$a_computerinventory = $pfFormatconvert->computerSoftwareTransformation($a_computerinventory, $entities_id);
$no_history = FALSE;
// * New
$setdynamic = 1;
if ($items_id == '0') {
$input = array();
$input['entities_id'] = $entities_id;
PluginFusioninventoryInventoryComputerInventory::addDefaultStateIfNeeded($input);
if (isset($input['states_id'])) {
$a_computerinventory['Computer']['states_id'] = $input['states_id'];
} else {
$a_computerinventory['Computer']['states_id'] = 0;
}
$items_id = $computer->add($input);
$no_history = TRUE;
$setdynamic = 0;
}
if (isset($_SESSION['plugin_fusioninventory_locations_id'])) {
$a_computerinventory['Computer']['locations_id'] = $_SESSION['plugin_fusioninventory_locations_id'];
unset($_SESSION['plugin_fusioninventory_locations_id']);
}
$serialized = gzcompress(serialize($a_computerinventory));
$a_computerinventory['fusioninventorycomputer']['serialized_inventory'] = Toolbox::addslashes_deep($serialized);
if (!$PF_ESXINVENTORY) {
$pfAgent->setAgentWithComputerid($items_id, $this->device_id, $entities_id);
}
$pfConfig = new PluginFusioninventoryConfig();
$query = "INSERT INTO `glpi_plugin_fusioninventory_dblockinventories`\n SET `value`='" . $items_id . "'";
$CFG_GLPI["use_log_in_files"] = FALSE;
if (!$DB->query($query)) {
$communication = new PluginFusioninventoryCommunication();
$communication->setMessage("<?xml version='1.0' encoding='UTF-8'?>\n <REPLY>\n <ERROR>ERROR: SAME COMPUTER IS CURRENTLY UPDATED</ERROR>\n </REPLY>");
//.........这里部分代码省略.........
示例5: transferComputer
/**
* Do automatic transfer if option is enable
*
* @param $line_links array : data from glpi_plugin_ocsinventoryng_ocslinks table
* @return nothing
* @internal param array $line_ocs : data from ocs tables
*
*/
static function transferComputer($line_links)
{
global $DB, $CFG_GLPI;
$ocsClient = self::getDBocs($line_links["plugin_ocsinventoryng_ocsservers_id"]);
$cfg_ocs = self::getConfig($line_links["plugin_ocsinventoryng_ocsservers_id"]);
$ocsComputer = $ocsClient->getComputer($line_links["ocsid"]);
$locations_id = 0;
$contact = isset($ocsComputer['META']["USERID"]) ? $ocsComputer['META']["USERID"] : "";
if (!empty($contact)) {
$query = "SELECT `id`\n FROM `glpi_users`\n WHERE `name` = '" . $contact . "';";
$result = $DB->query($query);
if ($DB->numrows($result) == 1) {
$user_id = $DB->result($result, 0, 0);
$user = new User();
$user->getFromDB($user_id);
$locations_id = $user->fields["locations_id"];
}
}
// Get all rules for the current plugin_ocsinventoryng_ocsservers_id
$rule = new RuleImportEntityCollection();
$data = array();
$data = $rule->processAllRules(array('ocsservers_id' => $line_links["plugin_ocsinventoryng_ocsservers_id"], '_source' => 'ocsinventoryng', 'locations_id' => $locations_id), array('locations_id' => $locations_id), array('ocsid' => $line_links["ocsid"]));
// If entity is changing move items to the new entities_id
if (isset($data['entities_id']) && $data['entities_id'] > -1 && $data['entities_id'] != $line_links['entities_id']) {
if (!isCommandLine() && !Session::haveAccessToEntity($data['entities_id'])) {
Html::displayRightError();
}
$transfer = new Transfer();
$transfer->getFromDB($CFG_GLPI['transfers_id_auto']);
$item_to_transfer = array("Computer" => array($line_links['computers_id'] => $line_links['computers_id']));
$transfer->moveItems($item_to_transfer, $data['entities_id'], $transfer->fields);
}
//If location is update by a rule
self::updateLocation($line_links, $data, $cfg_ocs);
}
示例6: transferComputer
/**
* Do automatic transfer if option is enable
*
* @param $line_links array : data from glpi_ocslinks table
* @param $line_ocs array : data from ocs tables
*
* @return nothing
**/
static function transferComputer($line_links, $line_ocs)
{
global $DB, $DBocs, $CFG_GLPI;
// Get all rules for the current ocsservers_id
$rules = new RuleOcsCollection($line_links["ocsservers_id"]);
$data = array();
$data = $rules->processAllRules(array(), array(), $line_links["ocsid"]);
// If entity is changing move items to the new entities_id
if (isset($data['entities_id']) && $data['entities_id'] != $line_links['entities_id']) {
if (!isCommandLine() && !haveAccessToEntity($data['entities_id'])) {
displayRightError();
}
$transfer = new Transfer();
$transfer->getFromDB($CFG_GLPI['transfers_id_auto']);
$item_to_transfer = array("Computer" => array($line_links['computers_id'] => $line_links['computers_id']));
$transfer->moveItems($item_to_transfer, $data['entities_id'], $transfer->fields);
}
// Update TAG
self::updateTag($line_links, $line_ocs);
}