本文整理汇总了PHP中Transfer::moveItems方法的典型用法代码示例。如果您正苦于以下问题:PHP Transfer::moveItems方法的具体用法?PHP Transfer::moveItems怎么用?PHP Transfer::moveItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transfer
的用法示例。
在下文中一共展示了Transfer::moveItems方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uninstall
//.........这里部分代码省略.........
$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
if ($item->isField('networks_id') && $model->fields["raz_network"] == 1) {
$fields["networks_id"] = 0;
}
}
//RAZ IPs from all the network cards
if ($model->fields["raz_ip"] == 1) {
self::razPortInfos($type, $id);
// For NetworkEquiment
if ($item->isField('ip')) {
$fields['ip'] = '';
}
if ($item->isField('mac')) {
$fields['mac'] = '';
}
}
foreach ($fields as $name => $value) {
if (!($item->getField($name) != NOT_AVAILABLE) || $item->getField($name) != $value) {
$input[$name] = $value;
}
}
$item->dohistory = true;
$item->update($input);
if ($model->fields["raz_budget"] == 1) {
$infocom_id = self::getInfocomPresentForDevice($type, $id);
if ($infocom_id > 0) {
$infocom = new InfoCom();
$tmp["id"] = $infocom_id;
$tmp["budgets_id"] = 0;
$infocom->dohistory = false;
$infocom->update($tmp);
}
}
//Delete machine from glpi_ocs_link
if ($type == 'Computer') {
//Delete computer's volumes
self::purgeComputerVolumes($id);
if ($model->fields["raz_history"] == 1) {
//Delete history related to software
self::deleteHistory($id, false);
} else {
if ($model->fields["raz_soft_history"] == 1) {
//Delete history related to software
self::deleteHistory($id, true);
}
}
$plug = new Plugin();
if ($plug->isActivated('ocsinventoryng')) {
//Delete computer from OCS
if ($model->fields["remove_from_ocs"] == 1) {
self::deleteComputerInOCSByGlpiID($id);
}
//Delete link in glpi_ocs_link
if ($model->fields["delete_ocs_link"] || $model->fields["remove_from_ocs"]) {
self::deleteOcsLink($id);
}
}
//Should never happend that transfer_id = 0, but just in case
if ($model->fields["transfers_id"] > 0) {
$transfer->moveItems(array($type => array($id => $id)), $entity, $transfer->fields);
}
}
if ($model->fields['raz_fusioninventory'] == 1) {
self::deleteFusionInventoryLink($type, $id);
}
//Plugin hook after uninstall
Plugin::doHook("plugin_uninstall_after", $item);
Html::changeProgressBarPosition($count, $tot + 1);
}
//Add line in machine's history to say that machine was uninstalled
self::addUninstallLog($type, $id);
Html::changeProgressBarPosition($count, $tot, __('Uninstallation successful', 'uninstall'));
echo "</td></tr>";
echo "</table></div>";
}
示例2: Transfer
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../inc/includes.php';
Html::header(__('Transfer'), '', 'admin', 'rule', 'transfer');
$transfer = new Transfer();
$transfer->checkGlobal(READ);
if (isset($_POST['transfer'])) {
if (isset($_SESSION['glpitransfer_list'])) {
if (!Session::haveAccessToEntity($_POST['to_entity'])) {
Html::displayRightError();
}
$transfer->moveItems($_SESSION['glpitransfer_list'], $_POST['to_entity'], $_POST);
unset($_SESSION['glpitransfer_list']);
echo "<div class='b center'>" . __('Operation successful') . "<br>";
echo "<a href='central.php'>" . __('Back') . "</a></div>";
Html::footer();
exit;
}
} else {
if (isset($_POST['clear'])) {
unset($_SESSION['glpitransfer_list']);
echo "<div class='b center'>" . __('Operation successful') . "<br>";
echo "<a href='central.php'>" . __('Back') . "</a></div>";
echo "</div>";
Html::footer();
exit;
}
示例3: 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);
}
示例4: 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');
}
示例5: 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>");
//.........这里部分代码省略.........
示例6: 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);
}
示例7: 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);
}