Commit b8f81913 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

:ambulance: fix(opsi): Do not search for empty macAddress

This was causing PHP errors and bad behavior from OPSI tab

issue #5765
Showing with 16 additions and 13 deletions
+16 -13
......@@ -312,20 +312,23 @@ class opsiClient extends simplePlugin
);
return FALSE;
}
$infos = $s_daemon->append_call('OPSI.host_getObjects', $macAddress, array('args' => array(array('lastSeen', 'hardwareAddress'), array('hardwareAddress' => $this->getMacAddresses()))));
if ($s_daemon->is_error()) {
$this->lastSeen = sprintf(_('Failed to contact OPSI server: %s'), $s_daemon->get_error());
} elseif (count($infos) == 0) {
$this->lastSeen = _('Never');
} else {
if (!$this->editing_group() && ($this->initialOpsiId === NULL)) {
$this->initialOpsiId = reset($infos)['id'];
}
$text = '';
foreach ($infos as $info) {
$text .= htmlentities(sprintf('%s - %s', $info['id'], $info['lastSeen']), ENT_COMPAT, 'UTF-8')."<br/>\n";
$macAddresses = $this->getMacAddresses();
if (!empty($macAddresses)) {
$infos = $s_daemon->append_call('OPSI.host_getObjects', $macAddress, array('args' => array(array('lastSeen', 'hardwareAddress'), array('hardwareAddress' => $macAddresses))));
if ($s_daemon->is_error()) {
$this->lastSeen = sprintf(_('Failed to contact OPSI server: %s'), $s_daemon->get_error());
} elseif (count($infos) == 0) {
$this->lastSeen = _('Never');
} else {
if (!$this->editing_group() && ($this->initialOpsiId === NULL)) {
$this->initialOpsiId = reset($infos)['id'];
}
$text = '';
foreach ($infos as $info) {
$text .= htmlentities(sprintf('%s - %s', $info['id'], $info['lastSeen']), ENT_COMPAT, 'UTF-8')."<br/>\n";
}
$this->lastSeen = $text;
}
$this->lastSeen = $text;
}
if (!isset($this->products[$this->fdOpsiServerDn])) {
$opsi_args = array('id','name','setupScript','alwaysScript','onceScript','customScript','userLoginScript','updateScript','productVersion','packageVersion');
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment