Skip to content

Commit

Permalink
Fix couple PHP notices
Browse files Browse the repository at this point in the history
  • Loading branch information
ddurieux committed Apr 4, 2024
1 parent 2b3c912 commit e966abc
Showing 1 changed file with 25 additions and 22 deletions.
47 changes: 25 additions & 22 deletions inc/inventorycomputerlib.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1499,33 +1499,36 @@ function updateComputer($a_computerinventory, $computers_id, $no_history, $setdy
}

if (count($db_crontasks) == 0) {
foreach ($a_computerinventory['crontasks'] as $a_crontask) {
if (isset($a_crontask['user_execution'])) {
$a_crontask['user_id_execution'] = $this->retrieveFusionInventoryCronTaskUserId($DB, $a_crontask['user_execution']);
}
if (isset($a_computerinventory['crontasks'])) {
foreach ($a_computerinventory['crontasks'] as $a_crontask) {
if (isset($a_crontask['user_execution'])) {
$a_crontask['user_id_execution'] = $this->retrieveFusionInventoryCronTaskUserId($DB, $a_crontask['user_execution']);
}

if (isset($a_crontask['user_storage'])) {
$a_crontask['user_id_storage'] = $this->retrieveFusionInventoryCronTaskUserId($DB, $a_crontask['user_storage']);
}
if (isset($a_crontask['user_storage'])) {
$a_crontask['user_id_storage'] = $this->retrieveFusionInventoryCronTaskUserId($DB, $a_crontask['user_storage']);
}

$a_crontask['computers_id'] = $computers_id;
$this->addFusionInventoryCronTask($a_crontask, $no_history);
$a_crontask['computers_id'] = $computers_id;
$this->addFusionInventoryCronTask($a_crontask, $no_history);
}
}
} else {
foreach ($a_computerinventory['crontasks'] as $key => $arrays) {
$arrayslower = array_map('strtolower', $arrays);

foreach ($db_crontasks as $keydb => $arraydb) {
if ($arrayslower['name'] == $arraydb['name']
&& $arrayslower['storage'] == $arraydb['storage']) {
$arrays['id'] = $keydb;
$cronTask->update($arrays);
unset($a_computerinventory['crontasks'][$key]);
unset($db_crontasks[$keydb]);
break;
if (isset($a_computerinventory['crontasks'])) {
foreach ($a_computerinventory['crontasks'] as $key => $arrays) {
$arrayslower = array_map('strtolower', $arrays);

foreach ($db_crontasks as $keydb => $arraydb) {
if ($arrayslower['name'] == $arraydb['name']
&& $arrayslower['storage'] == $arraydb['storage']) {
$arrays['id'] = $keydb;
$cronTask->update($arrays);
unset($a_computerinventory['crontasks'][$key]);
unset($db_crontasks[$keydb]);
break;
}
}
}
}

//delete remaining crontasks in database
if (count($db_crontasks) > 0) {
Expand All @@ -1534,7 +1537,7 @@ function updateComputer($a_computerinventory, $computers_id, $no_history, $setdy
}
}
//add new crontasks in database
if (count($a_computerinventory['crontasks']) != 0) {
if (isset($a_computerinventory['crontasks']) && count($a_computerinventory['crontasks']) != 0) {
foreach ($a_computerinventory['crontasks'] as $a_crontask) {
if (isset($a_crontask['user_execution'])) {
$a_crontask['user_id_execution'] = $this->retrieveFusionInventoryCronTaskUserId($DB, $a_crontask['user_execution']);
Expand Down

0 comments on commit e966abc

Please sign in to comment.