Skip to content
Browse files

Merge remote-tracking branch 'fusinv/glpi0.80' into glpi0.80

  • Loading branch information...
2 parents c2481a7 + 99c57ad commit 70b54fa230a16d78521f8cca5d3555ed83394a20 @goneri goneri committed Mar 21, 2012
View
5 fusinvdeploy/inc/package.class.php
@@ -174,17 +174,18 @@ function showMenu($options=array()) {
$this->displaylist = false;
$this->fields['id'] = -1;
- $this->showTabs($options);
- $this->addDivForTabs();
+ $this->showList();
}
function showList() {
+ echo "<center>";
echo "<table class='tab_cadre_navigation'><tr><td>";
self::title();
Search::show('PluginFusinvdeployPackage');
echo "</td></tr></table>";
+ echo "</center>";
}
function showForm($id, $options=array()) {
View
6 fusinvdeploy/install/install.php
@@ -47,10 +47,10 @@ function pluginFusinvdeployInstall($version, $migration='') {
$a_plugin = plugin_version_fusinvdeploy();
include_once (GLPI_ROOT . "/plugins/fusinvdeploy/install/update.php");
- $version_detected = pluginfusinvdeployGetCurrentVersion($a_plugin['version']);
- if ((isset($version_detected)) && ($version_detected != $a_plugin['version'])) {
+ $version_detected = pluginFusinvdeployGetCurrentVersion($a_plugin['version']);
+ if ($version_detected !== false && ($version_detected != $a_plugin['version'])) {
// Update
- pluginFusinvdeployUpdate($version_detected);
+ return pluginFusinvdeployUpdate($version_detected);
} else {
// Installation
if ($migration == '') {
View
23 fusinvdeploy/install/update.php
@@ -41,8 +41,12 @@
*/
function pluginFusinvdeployGetCurrentVersion($version) {
+
+ if (!TableExists("glpi_plugin_fusinvdeploy_files")) {
+ return false;
+ }
- if (TableExists("glpi_plugin_fusioninventory_config")) {
+ if (TableExists("glpi_plugin_fusioninventory_configs")) {
if (!class_exists('PluginFusioninventoryConfig')) { // if plugin is unactive
include(GLPI_ROOT . "/plugins/fusioninventory/inc/config.class.php");
}
@@ -56,16 +60,29 @@ function pluginFusinvdeployGetCurrentVersion($version) {
$plugins_id = PluginFusioninventoryModule::getModuleId('fusinvdeploy');
$versionconfig = $PluginFusioninventoryConfig->getValue($plugins_id, "version");
if (empty($versionconfig)) {
- return;
+ return "";
}
return $versionconfig;
} else {
- return;
+ return false;
}
}
function pluginFusinvdeployUpdate($current_version, $migrationname='Migration') {
+
+ if ($current_version == "") {
+ $config = new PluginFusioninventoryConfig;
+ $plugins_id = PluginFusioninventoryModule::getModuleId('fusinvdeploy');
+ $a_plugin = plugin_version_fusinvdeploy();
+ $params = array(
+ 'type' => "version",
+ 'value' => $a_plugin['version'],
+ 'plugins_id' => $plugins_id
+ );
+ $config->add($params);
+
+ }
}
?>
View
73 fusinvsnmp/inc/communicationnetdiscovery.class.php
@@ -221,39 +221,42 @@ function rulepassed($items_id, $itemtype, $entities_id=0) {
PluginFusioninventoryConfig::logIfExtradebug("pluginFusioninventory-rules",
"Rule passed : ".$items_id.", ".$itemtype."\n");
PluginFusioninventoryCommunication::addLog(
- 'Function PluginFusinvsnmpCommunicationSNMPQuery->rulepassed().');
+ 'Function PluginFusinvsnmpCommunicationNetDiscovery->rulepassed().');
- $class = new $itemtype();
+ $item = new $itemtype();
if ($items_id == "0") {
$input = array();
$input['date_mod'] = date("Y-m-d H:i:s");
$input['entities_id'] = $entities_id;
if (!isset($_SESSION['glpiactiveentities_string'])) {
$_SESSION['glpiactiveentities_string'] = "'".$entities_id."'";
}
- $items_id = $class->add($input);
+ $items_id = $item->add($input);
$_SESSION['plugin_fusinvsnmp_taskjoblog']['comment'] =
- '[==fusinvsnmp::7==] ==fusinvsnmp::4== '.$class->getTypeName().' [['.$itemtype.'::'.$items_id.']]';
+ '[==fusinvsnmp::7==] ==fusinvsnmp::4== '.$item->getTypeName().' [['.$itemtype.'::'.$items_id.']]';
$this->addtaskjoblog();
} else {
+
$_SESSION['plugin_fusinvsnmp_taskjoblog']['comment'] =
- '[==fusinvsnmp::7==] ==fusinvsnmp::5== '.$class->getTypeName().' [['.$itemtype.'::'.$items_id.']]';
+ '[==fusinvsnmp::7==] ==fusinvsnmp::5== '.$item->getTypeName().' [['.$itemtype.'::'.$items_id.']]';
$this->addtaskjoblog();
}
- $this->importDevice($itemtype, $items_id);
+ $item->getFromDB($items_id);
+ $this->importDevice($item);
}
- function importDevice($itemtype, $items_id) {
+ function importDevice($item) {
+
+ PluginFusioninventoryCommunication::addLog(
+ 'Function PluginFusinvsnmpCommunicationNetDiscovery->importDevice().');
$xml = simplexml_load_string($_SESSION['SOURCE_XMLDEVICE'],'SimpleXMLElement', LIBXML_NOCDATA);
- $class = new $itemtype();
- $class->getFromDB($items_id);
$input = array();
- $input['id'] = $class->fields['id'];
+ $input['id'] = $item->getID();
- $a_lockable = PluginFusioninventoryLock::getLockFields(getTableForItemType($itemtype), $items_id);
+ $a_lockable = PluginFusioninventoryLock::getLockFields(getTableForItemType($item->getType()), $item->getID());
if (!in_array('name', $a_lockable)) {
if (isset($xml->NETBIOSNAME) AND !empty($xml->NETBIOSNAME)) {
@@ -277,27 +280,27 @@ function importDevice($itemtype, $items_id) {
}
}
if (!isset($_SESSION['glpiactiveentities_string'])) {
- $_SESSION['glpiactiveentities_string'] = "'".$class->fields['entities_id']."'";
+ $_SESSION['glpiactiveentities_string'] = "'".$item->fields['entities_id']."'";
}
- switch ($itemtype) {
+ switch ($item->getType()) {
case 'Computer':
// If computer is update with Agent, don't update it
- if (Dropdown::getDropdownName("glpi_autoupdatesystems", $class->fields['autoupdatesystems_id']) != 'FusionInventory') {
+ if (Dropdown::getDropdownName("glpi_autoupdatesystems", $item->fields['autoupdatesystems_id']) != 'FusionInventory') {
if (isset($xml->WORKGROUP)) {
$domain = new Domain();
if (!in_array('domains_id', $a_lockable)) {
$input['domains_id'] = $domain->import(array('name'=>(string)$xml->WORKGROUP));
}
}
- $class->update($input);
+ $item->update($input);
//Manage IP and Mac address
$NetworkPort = new NetworkPort();
$a_computerports = array();
$a_computerports = $NetworkPort->find("`itemtype`='Computer'
- AND `items_id`='".$class->fields['id']."'");
+ AND `items_id`='".$item->getID()."'");
$update = 0;
foreach ($a_computerports as $a_computerport) {
if (isset($xml->MAC) AND !empty($xml->MAC)) {
@@ -329,9 +332,9 @@ function importDevice($itemtype, $items_id) {
if (isset($xml->IP)) {
$input['ip'] = (string)$xml->IP;
}
- $input['items_id'] = $class->fields['id'];
+ $input['items_id'] = $item->getID();
$input['itemtype'] = 'Computer';
- $input['entities_id'] = $class->fields['entities_id'];
+ $input['entities_id'] = $item->fields['entities_id'];
$NetworkPort->add($input);
}
}
@@ -340,7 +343,7 @@ function importDevice($itemtype, $items_id) {
case 'PluginFusioninventoryUnknownDevice':
// Write XML file
if (isset($_SESSION['SOURCE_XMLDEVICE'])) {
- PluginFusioninventoryUnknownDevice::writeXML($items_id, $_SESSION['SOURCE_XMLDEVICE']);
+ PluginFusioninventoryUnknownDevice::writeXML($item->getID(), $_SESSION['SOURCE_XMLDEVICE']);
}
@@ -371,13 +374,13 @@ function importDevice($itemtype, $items_id) {
}
}
$input['plugin_fusioninventory_agents_id'] = $_SESSION['glpi_plugin_fusioninventory_agentid'];
- $class->update($input);
+ $item->update($input);
//Manage IP and Mac address
$NetworkPort = new NetworkPort();
$a_unknownPorts = array();
$a_unknownPorts = $NetworkPort->find("`itemtype`='PluginFusioninventoryUnknownDevice'
- AND `items_id`='".$class->fields['id']."'");
+ AND `items_id`='".$item->getID()."'");
$update = 0;
foreach ($a_unknownPorts as $a_unknownPort) {
if (isset($xml->MAC) AND !empty($xml->MAC)) {
@@ -411,22 +414,22 @@ function importDevice($itemtype, $items_id) {
if (isset($xml->IP)) {
$input['ip'] = (string)$xml->IP;
}
- $input['items_id'] = $class->fields['id'];
+ $input['items_id'] = $item->getID();
$input['itemtype'] = 'PluginFusioninventoryUnknownDevice';
- $input['entities_id'] = $class->fields['entities_id'];
+ $input['entities_id'] = $item->fields['entities_id'];
$NetworkPort->add($input);
}
// Add informations for SNMP
$PluginFusinvsnmpUnknownDevice = new PluginFusinvsnmpUnknownDevice();
- $a_devices = $PluginFusinvsnmpUnknownDevice->find("`plugin_fusioninventory_unknowndevices_id`='".$items_id."'");
+ $a_devices = $PluginFusinvsnmpUnknownDevice->find("`plugin_fusioninventory_unknowndevices_id`='".$item->getID()."'");
if (count($a_devices) > 0) {
foreach ($a_devices as $data) {
$PluginFusinvsnmpUnknownDevice->getFromDB($data['id']);
}
} else {
$input = array();
- $input['plugin_fusioninventory_unknowndevices_id'] = $items_id;
+ $input['plugin_fusioninventory_unknowndevices_id'] = $item->getID();
$device_id = $PluginFusinvsnmpUnknownDevice->add($input);
$PluginFusinvsnmpUnknownDevice->getFromDB($device_id);
}
@@ -465,18 +468,18 @@ function importDevice($itemtype, $items_id) {
}
}
- $class->update($input);
+ $item->update($input);
// Update SNMP informations
$PluginFusinvsnmpNetworkEquipment = new PluginFusinvsnmpCommonDBTM("glpi_plugin_fusinvsnmp_networkequipments");
- $a_snmpnetworkequipments = $PluginFusinvsnmpNetworkEquipment->find("`networkequipments_id`='".$items_id."'");
+ $a_snmpnetworkequipments = $PluginFusinvsnmpNetworkEquipment->find("`networkequipments_id`='".$item->getID()."'");
if (count($a_snmpnetworkequipments) > 0) {
$a_snmpnetworkequipment = current($a_snmpnetworkequipments);
$PluginFusinvsnmpNetworkEquipment->load($a_snmpnetworkequipment['id']);
$PluginFusinvsnmpNetworkEquipment->setValue('id', $a_snmpnetworkequipment['id']);
} else {
$PluginFusinvsnmpNetworkEquipment->load();
- $PluginFusinvsnmpNetworkEquipment->setValue('networkequipments_id', $items_id);
+ $PluginFusinvsnmpNetworkEquipment->setValue('networkequipments_id', $item->getID());
}
// Write XML file
if (isset($_SESSION['SOURCE_XMLDEVICE'])
@@ -500,13 +503,13 @@ function importDevice($itemtype, $items_id) {
case 'Printer':
$input['have_ethernet'] = '1';
- $class->update($input);
+ $item->update($input);
//Manage IP and Mac address
$NetworkPort = new NetworkPort();
$a_printerports = array();
$a_printerports = $NetworkPort->find("`itemtype`='Printer'
- AND `items_id`='".$class->fields['id']."'");
+ AND `items_id`='".$item->getID()."'");
$update = 0;
foreach ($a_printerports as $a_printerport) {
if (isset($xml->MAC) AND !empty($xml->MAC)) {
@@ -536,27 +539,27 @@ function importDevice($itemtype, $items_id) {
if (isset($xml->IP)) {
$input['ip'] = (string)$xml->IP;
}
- $input['items_id'] = $class->fields['id'];
+ $input['items_id'] = $item->getID();
$input['itemtype'] = 'Printer';
- $input['entities_id'] = $class->fields['entities_id'];
+ $input['entities_id'] = $item->fields['entities_id'];
$NetworkPort->add($input);
}
// Update SNMP informations
$PluginFusinvsnmpPrinter = new PluginFusinvsnmpCommonDBTM("glpi_plugin_fusinvsnmp_printers");
- $a_snmpprinters = $PluginFusinvsnmpPrinter->find("`printers_id`='".$items_id."'");
+ $a_snmpprinters = $PluginFusinvsnmpPrinter->find("`printers_id`='".$item->getID()."'");
if (count($a_snmpprinters) > 0) {
$a_snmpprinter = current($a_snmpprinters);
$PluginFusinvsnmpPrinter->load($a_snmpprinter['id']);
$PluginFusinvsnmpPrinter->setValue('id', $a_snmpprinter['id']);
} else {
$PluginFusinvsnmpPrinter->load();
- $PluginFusinvsnmpPrinter->setValue('printers_id', $items_id);
+ $PluginFusinvsnmpPrinter->setValue('printers_id', $item->getID());
}
// Write XML file
if (isset($_SESSION['SOURCE_XMLDEVICE'])
AND is_null($PluginFusinvsnmpPrinter->getValue('last_fusioninventory_update'))) {
- PluginFusioninventoryUnknownDevice::writeXML($items_id,
+ PluginFusioninventoryUnknownDevice::writeXML($item->getID(),
$_SESSION['SOURCE_XMLDEVICE'],
"fusinvsnmp",
"Printer");
View
52 fusioninventory/inc/communication.class.php
@@ -491,20 +491,50 @@ function gzdecode($data,&$filename='',&$error='',$maxlength=null) {
function cleanXML($xml) {
+// foreach ($xml->children() as $key=>$value) {
+// if (count($value->children()) > 0) {
+// $value = $this->cleanXML($value);
+// } else {
+// if (count($value) > 1) {
+// for($i=count($value)-1;$i>=0;$i--){
+// $value2 = clean_cross_side_scripting_deep(addslashes_deep($value[$i]));
+// $xml->$key->$value[$i] = $value2;
+// }
+// } else {
+// $value = clean_cross_side_scripting_deep(addslashes_deep($value));
+// $xml->$key = $value;
+// }
+// }
+// }
+
+ $nodes = 0;
+ $previous = '';
foreach ($xml->children() as $key=>$value) {
- if (count($value->children()) > 0) {
- $value = $this->cleanXML($value);
- } else {
- if (count($value) > 1) {
- for($i=count($value)-1;$i>=0;$i--){
- $value2 = clean_cross_side_scripting_deep(addslashes_deep($value[$i]));
- $xml->$key->$value[$i] = $value2;
+ if ($key == $previous) {
+ $nodes++;
+ }
+ $previous = $key;
+ }
+ if (count($xml) > 0) {
+ if ($nodes == 0) {
+ foreach ($xml->children() as $key=>$value) {
+ if (count($value->children()) > 0) {
+ $this->cleanXML($value);
+ } else {
+ $xml->$key = clean_cross_side_scripting_deep(addslashes_deep($value));
}
- } else {
- $value = clean_cross_side_scripting_deep(addslashes_deep($value));
- $xml->$key = $value;
}
- }
+ } else {
+ $i = 0;
+ foreach ($xml->children() as $key=>$value) {
+ if (count($value->children()) > 0) {
+ $this->cleanXML($value);
+ } else {
+ $xml->$key->$i = clean_cross_side_scripting_deep(addslashes_deep($value));
+ $i++;
+ }
+ }
+ }
}
return $xml;
}

0 comments on commit 70b54fa

Please sign in to comment.
Something went wrong with that request. Please try again.