diff options
author | Ivo Kurzemnieks <ivo.kurzemnieks@zabbix.com> | 2021-05-28 10:33:58 +0300 |
---|---|---|
committer | Ivo Kurzemnieks <ivo.kurzemnieks@zabbix.com> | 2021-05-28 10:33:58 +0300 |
commit | a71344e8727afcb6e96c6130ba9b0d6dfeb866f4 (patch) | |
tree | 719c0b260579dcf514df88caa7b891baa7f6f549 /ui/app/controllers | |
parent | 9730e3ea47ae394159b07b57a17b763f50aac5bd (diff) | |
parent | 2f4cef24f8a8410cec2934568f42763cc0d8cd7f (diff) |
.......... [ZBX-19446] updated to latest from release/5.4
Diffstat (limited to 'ui/app/controllers')
4 files changed, 24 insertions, 7 deletions
diff --git a/ui/app/controllers/CControllerMenuPopup.php b/ui/app/controllers/CControllerMenuPopup.php index e7bb29ea293..71fc3d898c8 100644 --- a/ui/app/controllers/CControllerMenuPopup.php +++ b/ui/app/controllers/CControllerMenuPopup.php @@ -620,7 +620,8 @@ class CControllerMenuPopup extends CController { $menu_data['urls'][] = [ 'label' => $url['name'], 'url' => $url['url'], - 'target' => '_blank' + 'target' => '_blank', + 'rel' => 'noopener'.(ZBX_NOREFERER ? ' noreferrer' : '') ]; } } @@ -632,7 +633,7 @@ class CControllerMenuPopup extends CController { $url['url'] = 'javascript: alert(\''. _s('Provided URL "%1$s" is invalid.', zbx_jsvalue($url['url'], false, false)). '\');'; - unset($url['target']); + unset($url['target'], $url['rel']); } } unset($url); diff --git a/ui/app/controllers/CControllerPopupMassupdateHost.php b/ui/app/controllers/CControllerPopupMassupdateHost.php index 45463f60662..4c39dc6b0c1 100644 --- a/ui/app/controllers/CControllerPopupMassupdateHost.php +++ b/ui/app/controllers/CControllerPopupMassupdateHost.php @@ -118,7 +118,7 @@ class CControllerPopupMassupdateHost extends CControllerPopupMassupdateAbstract // filter only normal and discovery created hosts $options = [ - 'output' => ['hostid', 'inventory_mode'], + 'output' => ['hostid', 'inventory_mode', 'flags'], 'hostids' => $hostids, 'filter' => ['flags' => [ZBX_FLAG_DISCOVERY_NORMAL, ZBX_FLAG_DISCOVERY_CREATED]] ]; @@ -289,7 +289,12 @@ class CControllerPopupMassupdateHost extends CControllerPopupMassupdateAbstract } } - if (array_key_exists('inventory_mode', $new_values)) { + /* + * Inventory mode cannot be changed for discovered hosts. If discovered host has disabled inventory + * mode, inventory values also cannot be changed. + */ + if (array_key_exists('inventory_mode', $new_values) + && $host['flags'] != ZBX_FLAG_DISCOVERY_CREATED) { $host['inventory'] = $host_inventory; } elseif ($host['inventory_mode'] != HOST_INVENTORY_DISABLED) { @@ -407,10 +412,21 @@ class CControllerPopupMassupdateHost extends CControllerPopupMassupdateAbstract unset($host['parentTemplates']); $host = $new_values + $host; + + /* + * API prevents changing host inventory_mode for discovered hosts. However, inventory values can + * still be updated if inventory mode allows it. + */ + if ($host['flags'] == ZBX_FLAG_DISCOVERY_CREATED) { + unset($host['inventory_mode']); + } + unset($host['flags']); } unset($host); - if (!API::Host()->update($hosts)) { + $result = $hosts ? (bool) API::Host()->update($hosts) : true; + + if ($result === false) { throw new Exception(); } diff --git a/ui/app/controllers/CControllerProxyHostDisable.php b/ui/app/controllers/CControllerProxyHostDisable.php index 0048a636d75..990da67cb7b 100644 --- a/ui/app/controllers/CControllerProxyHostDisable.php +++ b/ui/app/controllers/CControllerProxyHostDisable.php @@ -63,7 +63,7 @@ class CControllerProxyHostDisable extends CController { } unset($host); - $result = API::Host()->update($hosts); + $result = $hosts ? (bool) API::Host()->update($hosts) : true; $updated = count($hosts); diff --git a/ui/app/controllers/CControllerProxyHostEnable.php b/ui/app/controllers/CControllerProxyHostEnable.php index ef255370d24..6a21002ed39 100644 --- a/ui/app/controllers/CControllerProxyHostEnable.php +++ b/ui/app/controllers/CControllerProxyHostEnable.php @@ -63,7 +63,7 @@ class CControllerProxyHostEnable extends CController { } unset($host); - $result = API::Host()->update($hosts); + $result = $hosts ? (bool) API::Host()->update($hosts) : true; $updated = count($hosts); |