Skip to content

Commit

Permalink
begin update 9.4
Browse files Browse the repository at this point in the history
  • Loading branch information
amma35 committed Dec 14, 2018
1 parent 0167ce5 commit 0c118d6
Show file tree
Hide file tree
Showing 13 changed files with 603 additions and 72 deletions.
31 changes: 15 additions & 16 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,11 @@ function plugin_ocsinventoryng_install() {
}
}/*1.5.5*/

/******************* Migration 1.6.0 *******************/
if ($DB->fieldExists('glpi_plugin_ocsinventoryng_ocsservers', 'states_id_default')) {

}

$migration->executeMigration();

}
Expand Down Expand Up @@ -766,10 +771,7 @@ function plugin_ocsinventoryng_getDatabaseRelations() {
=> ["glpi_plugin_ocsinventoryng_networkports" => "networkports_id"],

"glpi_profiles"
=> ["glpi_plugin_ocsinventoryng_ocsservers_profiles" => "profiles_id"],

"glpi_states"
=> ["glpi_plugin_ocsinventoryng_ocsservers" => "states_id_default"]];
=> ["glpi_plugin_ocsinventoryng_ocsservers_profiles" => "profiles_id"]];
}
return [];
}
Expand Down Expand Up @@ -1064,27 +1066,24 @@ function plugin_ocsinventoryng_displayConfigItem($type, $ID, $data, $num) {
*
* @return string
*/
function plugin_ocsinventoryng_addSelect($type, $id, $num) {
function plugin_ocsinventoryng_addSelect($type, $id) {

$searchopt = &Search::getOptions($type);
$table = $searchopt[$id]["table"];
$field = $searchopt[$id]["field"];

$out = "`$table`.`$field` AS ITEM_$num,
$out = "`$table`.`$field` AS $field,
`$table`.`ocsid` AS ocsid,
`$table`.`plugin_ocsinventoryng_ocsservers_id` AS plugin_ocsinventoryng_ocsservers_id, ";

if ($num == 0) {
switch ($type) {
case 'PluginOcsinventoryngNotimportedcomputer' :
return $out;
switch ($type) {
case 'PluginOcsinventoryngNotimportedcomputer' :
return $out;

case 'PluginOcsinventoryngDetail' :
$out .= "`$table`.`plugin_ocsinventoryng_threads_id`,
`$table`.`threadid`, ";
return $out;
}
return "";
case 'PluginOcsinventoryngDetail' :
$out .= "`$table`.`plugin_ocsinventoryng_threads_id`,
`$table`.`threadid`, ";
return $out;
}
return "";
}
Expand Down
20 changes: 10 additions & 10 deletions inc/monitor.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ static function importMonitor($monitor_params) {
$id_monitor = $DB->result($result_search, 0, "id");
} else {
$input = $mon;
if ($cfg_ocs["states_id_default"] > 0) {
$input["states_id"] = $cfg_ocs["states_id_default"];
}
// if ($cfg_ocs["states_id_default"] > 0) {
// $input["states_id"] = $cfg_ocs["states_id_default"];
// }
$input["entities_id"] = $entity;
$id_monitor = $m->add($input, [], $install_history);
}
Expand Down Expand Up @@ -218,9 +218,9 @@ static function importMonitor($monitor_params) {

if (!$id_monitor) {
$input = $mon;
if ($cfg_ocs["states_id_default"] > 0) {
$input["states_id"] = $cfg_ocs["states_id_default"];
}
// if ($cfg_ocs["states_id_default"] > 0) {
// $input["states_id"] = $cfg_ocs["states_id_default"];
// }
$input["entities_id"] = $entity;
$id_monitor = $m->add($input, [], $install_history);
}
Expand All @@ -242,10 +242,10 @@ static function importMonitor($monitor_params) {
if ($old->fields["is_deleted"]) {
$input["is_deleted"] = 0;
}
if ($cfg_ocs["states_id_default"] > 0
&& $old->fields["states_id"] != $cfg_ocs["states_id_default"]) {
$input["states_id"] = $cfg_ocs["states_id_default"];
}
// if ($cfg_ocs["states_id_default"] > 0
// && $old->fields["states_id"] != $cfg_ocs["states_id_default"]) {
// $input["states_id"] = $cfg_ocs["states_id_default"];
// }
if (empty($old->fields["name"])
&& !empty($mon["name"])) {
$input["name"] = $mon["name"];
Expand Down
1 change: 0 additions & 1 deletion inc/ocsalert.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ static function queryNew($config, $entity) {
AND `glpi_items_operatingsystems`.`itemtype` = 'Computer')
WHERE `glpi_computers`.`is_deleted` = 0
AND `glpi_computers`.`is_template` = 0
AND `glpi_computers`.`states_id` = " . $config["states_id_default"] . "
AND `glpi_plugin_ocsinventoryng_ocslinks`.`plugin_ocsinventoryng_ocsservers_id` = '" . $config["id"] . "' ";
$query .= "AND `glpi_computers`.`entities_id` = '" . $entity . "' ";
$query .= " ORDER BY `glpi_plugin_ocsinventoryng_ocslinks`.`last_ocs_update` ASC";
Expand Down
8 changes: 4 additions & 4 deletions inc/ocslink.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -933,8 +933,8 @@ static function ocsLink($link_params) {
return false;
}
$link = new self();
$data = $link->find("`ocsid` = " . $ocsid . "
AND `plugin_ocsinventoryng_ocsservers_id` = " . $plugin_ocsinventoryng_ocsservers_id);
$data = $link->find(["ocsid" => $ocsid,
"plugin_ocsinventoryng_ocsservers_id" => $plugin_ocsinventoryng_ocsservers_id]);
if (count($data) > 0) {
return false;
}
Expand Down Expand Up @@ -1265,7 +1265,7 @@ static function showLockIcon($computers_id, $data) {
|| $field == "serial"
|| $field == "name"
|| $field == "otherserial"
|| $field == "license_id"
|| $field == "licenseid"
|| $field == "contact_num"
|| $field == "license_number"
|| $field == "use_date"
Expand Down Expand Up @@ -1407,7 +1407,7 @@ static function migrateComputerUpdates($computers_id, $computer_update) {
'os' => 'operatingsystems_id',
'os_version' => 'operatingsystemversions_id',
'os_sp' => 'operatingsystemservicepacks_id',
'os_license_id' => 'license_id',
'os_license_id' => 'licenseid',
'auto_update' => 'autoupdatesystems_id',
'location' => 'locations_id',
'domain' => 'domains_id',
Expand Down
22 changes: 12 additions & 10 deletions inc/ocsprocess.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ static function getOcsFieldsMatching() {
return ['manufacturer' => ['BIOS', 'SMANUFACTURER'],
'manufacturers_id' => ['BIOS', 'SMANUFACTURER'],
'license_number' => ['HARDWARE', 'WINPRODKEY'],
'license_id' => ['HARDWARE', 'WINPRODID'],
'licenseid' => ['HARDWARE', 'WINPRODID'],
'operatingsystems_id' => ['HARDWARE', 'OSNAME'],
'operatingsystemversions_id' => ['HARDWARE', 'OSVERSION'],
'operatingsystemarchitectures_id' => ['HARDWARE', 'ARCH'],
Expand Down Expand Up @@ -307,10 +307,11 @@ static function getComputerInformations($ocs_fields = [], $cfg_ocs, $entities_id
$groups_id = 0, $is_recursive = 0, $groups_id_tech = 0) {
$input = [];
$input["is_dynamic"] = 1;
$input['_auto'] = 1;

if ($cfg_ocs["states_id_default"] > 0) {
$input["states_id"] = $cfg_ocs["states_id_default"];
}
// if ($cfg_ocs["states_id_default"] > 0) {
// $input["states_id"] = $cfg_ocs["states_id_default"];
// }

$input["entities_id"] = $entities_id;

Expand Down Expand Up @@ -407,7 +408,7 @@ static function getComputerInformations($ocs_fields = [], $cfg_ocs, $entities_id

if (intval($cfg_ocs["import_os_serial"]) == 0) {
unset($input["license_number"]);
unset($input["license_id"]);
unset($input["licenseid"]);
}

if (intval($cfg_ocs["import_general_serial"]) == 0) {
Expand Down Expand Up @@ -775,13 +776,14 @@ static function linkComputer($link_params) {
$input["entities_id"] = $comp->fields['entities_id'];
$input["is_dynamic"] = 1;
$input["_nolock"] = true;
$input['_auto'] = 1;

// 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"];
}
// 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"];
// }
$update_history = 0;
$input["_no_history"] = 1;
if ($cfg_ocs['dohistory'] == 1 && $cfg_ocs['history_hardware'] == 1) {
Expand Down
6 changes: 0 additions & 6 deletions inc/ocsserver.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1196,12 +1196,6 @@ function ocsFormImportOptions($ID) {
echo "<td><input type='text' size='30' name='tag_exclude' value='" .
$this->fields["tag_exclude"] . "'></td></tr>\n";

echo "<tr class='tab_bg_2'><td class='center'>" . __('Default status', 'ocsinventoryng') .

This comment has been minimized.

Copy link
@kabassanov

kabassanov Oct 17, 2020

Why has the default status field been dropped?

"</td>\n<td>";
State::dropdown(['name' => 'states_id_default',
'value' => $this->fields["states_id_default"]]);
echo "</td></tr>\n";

echo "<tr class='tab_bg_2'><td class='center'>" . __('Behavior when disconnecting', 'ocsinventoryng') . "</td>\n<td>";
Dropdown::showFromArray("deconnection_behavior", ['' => __('Preserve link', 'ocsinventoryng'),
"trash" => __('Put the link in dustbin and add a lock', 'ocsinventoryng'),
Expand Down
10 changes: 5 additions & 5 deletions inc/os.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static function getOSLockableFields($plugin_ocsinventoryng_ocsservers_id = 0) {

if (intval($cfg_ocs["import_os_serial"]) > 0) {
$locks["license_number"] = __('Serial of the operating system');
$locks["license_id"] = __('Product ID of the operating system');
$locks["licenseid"] = __('Product ID of the operating system');
}

} else {
Expand All @@ -97,7 +97,7 @@ static function getOSLockableFields($plugin_ocsinventoryng_ocsservers_id = 0) {
"operatingsystemversions_id" => __('Version of the operating system'),
'operatingsystemarchitectures_id' => __('Operating system architecture'),//Enable 9.1
"license_number" => __('Serial of the operating system'),
"license_id" => __('Product ID of the operating system')];
"licenseid" => __('Product ID of the operating system')];
}

return $locks;
Expand Down Expand Up @@ -182,7 +182,7 @@ static function updateComputerOS($options = []) {
}
$license_id = null;
if (intval($options['cfg_ocs']["import_os_serial"]) > 0
&& !in_array("license_id", $options['computers_updates'])) {
&& !in_array("licenseid", $options['computers_updates'])) {
if (!empty($hardware["WINPRODID"])) {
$license_id = PluginOcsinventoryngOcsProcess::encodeOcsDataInUtf8($is_utf8, $hardware["WINPRODID"]);
$updates++;
Expand Down Expand Up @@ -235,7 +235,7 @@ static function updateComputerOS($options = []) {
'operatingsystemservicepacks_id' => $operatingsystemservicepacks_id,
'operatingsystemarchitectures_id' => $operatingsystemarchitectures_id,
'license_number' => $license_number,
'license_id' => $license_id,
'licenseid' => $license_id,
'_nolock' => true,
'is_dynamic' => 1,
'entities_id' => $options['entities_id']
Expand All @@ -251,7 +251,7 @@ static function updateComputerOS($options = []) {
'operatingsystemservicepacks_id' => $operatingsystemservicepacks_id,
'operatingsystemarchitectures_id' => $operatingsystemarchitectures_id,
'license_number' => $license_number,
'license_id' => $license_id,
'licenseid' => $license_id,
'_nolock' => true,
'is_dynamic' => 1,
'entities_id' => $options['entities_id']
Expand Down
18 changes: 9 additions & 9 deletions inc/peripheral.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ static function importPeripheral($periph_params) {
$id_periph = $DB->result($result_search, 0, "id");
} else {
$input = $periph;
if ($cfg_ocs["states_id_default"] > 0) {
$input["states_id"] = $cfg_ocs["states_id_default"];
}
// if ($cfg_ocs["states_id_default"] > 0) {
// $input["states_id"] = $cfg_ocs["states_id_default"];
// }
$input["entities_id"] = $entity;
$id_periph = $p->add($input, [], $install_history);
}
Expand All @@ -143,9 +143,9 @@ static function importPeripheral($periph_params) {
//Import all peripherals as non global.
$input = $periph;
$input["is_global"] = 0;
if ($cfg_ocs["states_id_default"] > 0) {
$input["states_id"] = $cfg_ocs["states_id_default"];
}
// if ($cfg_ocs["states_id_default"] > 0) {
// $input["states_id"] = $cfg_ocs["states_id_default"];
// }
$input["entities_id"] = $entity;
$id_periph = $p->add($input, [], $install_history);
}
Expand All @@ -161,9 +161,9 @@ static function importPeripheral($periph_params) {
$input["id"] = $id_periph;
$input["is_deleted"] = 0;
$input["entities_id"] = $entity;
if ($cfg_ocs["states_id_default"] > 0) {
$input["states_id"] = $cfg_ocs["states_id_default"];
}
// if ($cfg_ocs["states_id_default"] > 0) {
// $input["states_id"] = $cfg_ocs["states_id_default"];
// }
$p->update($input, $install_history);
}
}
Expand Down
21 changes: 12 additions & 9 deletions inc/printer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,12 @@ static function importPrinter($printer_params) {
} else {
$input = $print;

if ($cfg_ocs["states_id_default"] > 0) {
$input["states_id"] = $cfg_ocs["states_id_default"];
}
// if ($cfg_ocs["states_id_default"] > 0) {
// $input["states_id"] = $cfg_ocs["states_id_default"];
// }
$input['_auto'] = 1;
$input["entities_id"] = $entity;

$id_printer = $p->add($input, [], $install_history);
}
} else if ($management_process == 2) {
Expand All @@ -174,9 +176,9 @@ static function importPrinter($printer_params) {
$input = $print;
$input["is_global"] = MANAGEMENT_UNITARY;

if ($cfg_ocs["states_id_default"] > 0) {
$input["states_id"] = $cfg_ocs["states_id_default"];
}
// if ($cfg_ocs["states_id_default"] > 0) {
// $input["states_id"] = $cfg_ocs["states_id_default"];
// }
$input["entities_id"] = $entity;
$input['is_dynamic'] = 1;
$id_printer = $p->add($input, [], $install_history);
Expand All @@ -194,9 +196,10 @@ static function importPrinter($printer_params) {
$input["is_deleted"] = 0;
$input["entities_id"] = $entity;

if ($cfg_ocs["states_id_default"] > 0) {
$input["states_id"] = $cfg_ocs["states_id_default"];
}
// if ($cfg_ocs["states_id_default"] > 0) {
// $input["states_id"] = $cfg_ocs["states_id_default"];
// }
$input['_auto'] = 1;
$p->update($input, $install_history);
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion inc/profile.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function showForm($profiles_id = 0, $openform = true, $closeform = true) {
Dropdown::show('PluginOcsinventoryngOcsServer', ['width' => '50%',
'used' => $used,
'value' => '',
'condition' => "is_active = 1",
'condition' => ["is_active" => 1],
'toadd' => ['-1' => __('All')]]);
echo "&nbsp;&nbsp;<input type='hidden' name='profile' value='$profiles_id'>";
echo "&nbsp;&nbsp;<input type='submit' name='addocsserver' value=\"" . _sx('button', 'Add') . "\" class='submit' >";
Expand Down
3 changes: 2 additions & 1 deletion inc/ruleimportentity.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ static function checkRuleImportEntity($plugin_ocsinventoryng_ocsservers_id) {
static function getComputerOcsLink($plugin_ocsinventoryng_ocsservers_id) {
$ocslink = new PluginOcsinventoryngOcslink();

$ocslinks = $ocslink->find("`plugin_ocsinventoryng_ocsservers_id` = $plugin_ocsinventoryng_ocsservers_id", "entities_id");
$ocslinks = $ocslink->find(["plugin_ocsinventoryng_ocsservers_id" => $plugin_ocsinventoryng_ocsservers_id],
["entities_id"]);

$computers = [];
foreach ($ocslinks as $ocs) {
Expand Down
Loading

0 comments on commit 0c118d6

Please sign in to comment.