Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMihails Prihodko <mihails.prihodko@zabbix.com>2022-04-12 17:22:07 +0300
committerMihails Prihodko <mihails.prihodko@zabbix.com>2022-04-12 17:22:07 +0300
commit47db9b4216880bc7916d3d421e4ac1d2e705c4e5 (patch)
tree7ea9d2b252be33d97e0ef92749bd493fcc53b35d
parent5295c694d09634f1da003367c5d5f163670ea095 (diff)
parentc8bfb4556ea2abf8a4594db2670cbef5173ffaf3 (diff)
.......... [DEV-2087] merge with release/6.0
-rw-r--r--ChangeLog.d/bugfix/ZBX-205451
-rw-r--r--ChangeLog.d/bugfix/ZBX-206581
-rw-r--r--ChangeLog.d/bugfix/ZBX-207821
-rw-r--r--ChangeLog.d/bugfix/ZBX-208441
-rw-r--r--ChangeLog.d/feature/ZBXNEXT-75641
-rw-r--r--include/common.h1
-rw-r--r--src/libs/zbxcommon/str.c2
-rw-r--r--src/libs/zbxdbcache/dbconfig.c1
-rw-r--r--src/libs/zbxexec/execute.c15
-rw-r--r--src/libs/zbxicmpping/icmpping.c2
-rw-r--r--src/zabbix_server/escalator/escalator.c2
-rw-r--r--src/zabbix_server/poller/checks_external.c10
-rw-r--r--src/zabbix_server/poller/poller.c3
-rw-r--r--src/zabbix_server/scripts/scripts.c7
-rw-r--r--ui/app/views/configuration.host.list.php8
-rw-r--r--ui/app/views/js/popup.massupdate.js.php30
-rw-r--r--ui/app/views/popup.lldoperation.php3
-rw-r--r--ui/app/views/popup.massupdate.host.php3
-rw-r--r--ui/app/views/popup.massupdate.item.php3
-rw-r--r--ui/app/views/popup.massupdate.service.php3
-rw-r--r--ui/app/views/popup.massupdate.template.php3
-rw-r--r--ui/app/views/popup.massupdate.trigger.php3
-rw-r--r--ui/include/classes/api/services/CMediatype.php2
-rw-r--r--ui/include/classes/data/CItemData.php85
-rw-r--r--ui/include/classes/html/CFilter.php4
-rw-r--r--ui/include/classes/html/CVisibilityBox.php5
-rw-r--r--ui/include/js.inc.php43
-rw-r--r--ui/include/views/configuration.item.list.php2
-rw-r--r--ui/include/views/configuration.item.prototype.list.php4
-rw-r--r--ui/include/views/configuration.trigger.prototype.list.php4
-rw-r--r--ui/include/views/configuration.triggers.list.php4
-rw-r--r--ui/include/views/js/configuration.host.discovery.edit.overr.js.php1
-rw-r--r--ui/js/common.js45
-rw-r--r--ui/js/functions.js30
34 files changed, 157 insertions, 176 deletions
diff --git a/ChangeLog.d/bugfix/ZBX-20545 b/ChangeLog.d/bugfix/ZBX-20545
new file mode 100644
index 00000000000..9af564dcbbe
--- /dev/null
+++ b/ChangeLog.d/bugfix/ZBX-20545
@@ -0,0 +1 @@
+..F....... [ZBX-20545] fixed trend storage period field wrong appearance when item type of information is character/text/log (rdetlavs)
diff --git a/ChangeLog.d/bugfix/ZBX-20658 b/ChangeLog.d/bugfix/ZBX-20658
new file mode 100644
index 00000000000..cdda1a5ea9c
--- /dev/null
+++ b/ChangeLog.d/bugfix/ZBX-20658
@@ -0,0 +1 @@
+..F....... [ZBX-20658] fixed missing CR (carriage return) characters in line endings, in popup forms (averza)
diff --git a/ChangeLog.d/bugfix/ZBX-20782 b/ChangeLog.d/bugfix/ZBX-20782
new file mode 100644
index 00000000000..ae290d820c3
--- /dev/null
+++ b/ChangeLog.d/bugfix/ZBX-20782
@@ -0,0 +1 @@
+..F....... [ZBX-20782] fixed non unique ids browser console errors when executing Mass update action (rdetlavs)
diff --git a/ChangeLog.d/bugfix/ZBX-20844 b/ChangeLog.d/bugfix/ZBX-20844
new file mode 100644
index 00000000000..6b6b0984695
--- /dev/null
+++ b/ChangeLog.d/bugfix/ZBX-20844
@@ -0,0 +1 @@
+.......PS. [ZBX-20844] fixed external check becoming unsupported when Zabbix server or Zabbix proxy is stopped (vso)
diff --git a/ChangeLog.d/feature/ZBXNEXT-7564 b/ChangeLog.d/feature/ZBXNEXT-7564
new file mode 100644
index 00000000000..ec5e5a1af0a
--- /dev/null
+++ b/ChangeLog.d/feature/ZBXNEXT-7564
@@ -0,0 +1 @@
+..F....... [ZBXNEXT-7564] fixed media type importing in PHP 8 (rdetlavs)
diff --git a/include/common.h b/include/common.h
index 156c5bbcf8f..513d00d84bc 100644
--- a/include/common.h
+++ b/include/common.h
@@ -98,6 +98,7 @@ extern char ZABBIX_EVENT_SOURCE[ZBX_SERVICE_NAME_LEN];
#define AGENT_ERROR -5
#define GATEWAY_ERROR -6
#define CONFIG_ERROR -7
+#define SIG_ERROR -8
#define SUCCEED_OR_FAIL(result) (FAIL != (result) ? SUCCEED : FAIL)
const char *zbx_sysinfo_ret_string(int ret);
diff --git a/src/libs/zbxcommon/str.c b/src/libs/zbxcommon/str.c
index a26fb207ded..f3fa6aebc47 100644
--- a/src/libs/zbxcommon/str.c
+++ b/src/libs/zbxcommon/str.c
@@ -1470,6 +1470,8 @@ const char *zbx_result_string(int result)
return "AGENT_ERROR";
case GATEWAY_ERROR:
return "GATEWAY_ERROR";
+ case SIG_ERROR:
+ return "SIG_ERROR";
case SYSINFO_RET_FAIL:
return "SYSINFO_RET_FAIL";
default:
diff --git a/src/libs/zbxdbcache/dbconfig.c b/src/libs/zbxdbcache/dbconfig.c
index 6d15117683d..b0f952d8d55 100644
--- a/src/libs/zbxdbcache/dbconfig.c
+++ b/src/libs/zbxdbcache/dbconfig.c
@@ -9810,6 +9810,7 @@ static void dc_requeue_items(const zbx_uint64_t *itemids, const int *lastclocks,
case NOTSUPPORTED:
case AGENT_ERROR:
case CONFIG_ERROR:
+ case SIG_ERROR:
dc_item->queue_priority = ZBX_QUEUE_PRIORITY_NORMAL;
dc_requeue_item(dc_item, dc_host, dc_interface, ZBX_ITEM_COLLECTED, lastclocks[i]);
break;
diff --git a/src/libs/zbxexec/execute.c b/src/libs/zbxexec/execute.c
index 29db8bcae57..3e4d3eebc19 100644
--- a/src/libs/zbxexec/execute.c
+++ b/src/libs/zbxexec/execute.c
@@ -305,7 +305,8 @@ exit:
* pass NULL to stay in current directory *
* *
* Return value: SUCCEED if processed successfully, TIMEOUT_ERROR if *
- * timeout occurred or FAIL otherwise *
+ * timeout occurred, SIG_ERROR if interrupted by signal or FAIL *
+ * otherwise *
* *
******************************************************************************/
int zbx_execute(const char *command, char **output, char *error, size_t max_error_len, int timeout,
@@ -480,7 +481,16 @@ close:
if (-1 == rc || -1 == zbx_waitpid(pid, &status))
{
if (EINTR == errno)
- ret = TIMEOUT_ERROR;
+ {
+ if (SUCCEED == zbx_alarm_timed_out())
+ ret = TIMEOUT_ERROR;
+ else
+ {
+ ret = SIG_ERROR;
+ zbx_strlcpy(error, "Signal received while executing a shell script.",
+ max_error_len);
+ }
+ }
else
zbx_snprintf(error, max_error_len, "zbx_waitpid() failed: %s", zbx_strerror(errno));
@@ -508,6 +518,7 @@ close:
{
zbx_snprintf(error, max_error_len, "Process killed by signal: %d.",
WTERMSIG(status));
+ ret = SIG_ERROR;
}
else
zbx_strlcpy(error, "Process terminated unexpectedly.", max_error_len);
diff --git a/src/libs/zbxicmpping/icmpping.c b/src/libs/zbxicmpping/icmpping.c
index c183b2c5479..0713d9f13e9 100644
--- a/src/libs/zbxicmpping/icmpping.c
+++ b/src/libs/zbxicmpping/icmpping.c
@@ -148,7 +148,7 @@ static int get_interval_option(const char *fping, ZBX_FPING_HOST *hosts, int hos
goto out;
}
- if (FAIL == ret_exec)
+ if (SUCCEED != ret_exec)
{
zbx_snprintf(error, max_error_len, "Cannot execute \"%s\": %s", tmp, err);
goto out;
diff --git a/src/zabbix_server/escalator/escalator.c b/src/zabbix_server/escalator/escalator.c
index 488d5ed91eb..d9b3177dc8a 100644
--- a/src/zabbix_server/escalator/escalator.c
+++ b/src/zabbix_server/escalator/escalator.c
@@ -1502,7 +1502,7 @@ fail:
}
}
- if (FAIL == rc)
+ if (SUCCEED != rc)
status = ALERT_STATUS_FAILED;
add_command_alert(&db_insert, alerts_num++, alertid, host.host, event, r_event, actionid,
diff --git a/src/zabbix_server/poller/checks_external.c b/src/zabbix_server/poller/checks_external.c
index 786bcd4dc77..f1a03eeecd3 100644
--- a/src/zabbix_server/poller/checks_external.c
+++ b/src/zabbix_server/poller/checks_external.c
@@ -73,17 +73,21 @@ int get_value_external(const DC_ITEM *item, AGENT_RESULT *result)
zbx_free(param_esc);
}
- if (SUCCEED == zbx_execute(cmd, &buf, error, sizeof(error), CONFIG_TIMEOUT, ZBX_EXIT_CODE_CHECKS_DISABLED, NULL))
+ if (SUCCEED == (ret = zbx_execute(cmd, &buf, error, sizeof(error), CONFIG_TIMEOUT,
+ ZBX_EXIT_CODE_CHECKS_DISABLED, NULL)))
{
zbx_rtrim(buf, ZBX_WHITESPACE);
set_result_type(result, ITEM_VALUE_TYPE_TEXT, buf);
zbx_free(buf);
-
- ret = SUCCEED;
}
else
+ {
+ if (SIG_ERROR != ret)
+ ret = NOTSUPPORTED;
+
SET_MSG_RESULT(result, zbx_strdup(NULL, error));
+ }
out:
zbx_free(cmd);
diff --git a/src/zabbix_server/poller/poller.c b/src/zabbix_server/poller/poller.c
index ee9048b22e5..58338b6d91e 100644
--- a/src/zabbix_server/poller/poller.c
+++ b/src/zabbix_server/poller/poller.c
@@ -835,6 +835,9 @@ static int get_values(unsigned char poller_type, int *nextcheck)
case CONFIG_ERROR:
/* nothing to do */
break;
+ case SIG_ERROR:
+ /* nothing to do, execution was forcibly interrupted by signal */
+ break;
default:
zbx_error("unknown response code returned: %d", errcodes[i]);
THIS_SHOULD_NEVER_HAPPEN;
diff --git a/src/zabbix_server/scripts/scripts.c b/src/zabbix_server/scripts/scripts.c
index 8dcd7112708..9d88243113a 100644
--- a/src/zabbix_server/scripts/scripts.c
+++ b/src/zabbix_server/scripts/scripts.c
@@ -458,8 +458,11 @@ int zbx_script_execute(const zbx_script_t *script, const DC_HOST *host, const ch
break;
case ZBX_SCRIPT_EXECUTE_ON_SERVER:
case ZBX_SCRIPT_EXECUTE_ON_PROXY:
- ret = zbx_execute(script->command, result, error, max_error_len,
- CONFIG_TRAPPER_TIMEOUT, ZBX_EXIT_CODE_CHECKS_ENABLED, NULL);
+ if (SUCCEED != (ret = zbx_execute(script->command, result, error, max_error_len,
+ CONFIG_TRAPPER_TIMEOUT, ZBX_EXIT_CODE_CHECKS_ENABLED, NULL)))
+ {
+ ret = FAIL;
+ }
break;
default:
zbx_snprintf(error, max_error_len, "Invalid 'Execute on' option \"%d\".",
diff --git a/ui/app/views/configuration.host.list.php b/ui/app/views/configuration.host.list.php
index 8218f339f26..7effd7c68ba 100644
--- a/ui/app/views/configuration.host.list.php
+++ b/ui/app/views/configuration.host.list.php
@@ -54,7 +54,7 @@ $filter = (new CFilter())
->setResetUrl($action_url)
->setProfile($data['profileIdx'])
->setActiveTab($data['active_tab'])
- ->addVar('action', $data['action'])
+ ->addVar('action', $data['action'], 'filter_action')
->addFilterTab(_('Filter'), [
(new CFormGrid())
->addClass(CFormGrid::ZBX_STYLE_FORM_GRID_LABEL_WIDTH_TRUE)
@@ -169,7 +169,7 @@ $widget->addItem($filter);
// table hosts
$form = (new CForm())->setName('hosts');
-$header_checkbox = (new CCheckBox('all_hosts'))->onClick("checkAll('".$form->getName()."', 'all_hosts', 'ids');");
+$header_checkbox = (new CCheckBox('all_hosts'))->onClick("checkAll('".$form->getName()."', 'all_hosts', 'hostids');");
$show_monitored_by = ($data['filter']['monitored_by'] == ZBX_MONITORED_BY_PROXY
|| $data['filter']['monitored_by'] == ZBX_MONITORED_BY_ANY);
$header_sortable_name = make_sorting_header(_('Name'), 'name', $data['sortField'], $data['sortOrder'],
@@ -420,7 +420,7 @@ foreach ($data['hosts'] as $host) {
}
$table->addRow([
- new CCheckBox('ids['.$host['hostid'].']', $host['hostid']),
+ new CCheckBox('hostids['.$host['hostid'].']', $host['hostid']),
(new CCol($description))->addClass(ZBX_STYLE_NOWRAP),
[
new CLink(_('Items'),
@@ -492,7 +492,7 @@ $status_toggle_url = (new CUrl('zabbix.php'))
$form->addItem([
$table,
$data['paging'],
- new CActionButtonList('action', 'ids', [
+ new CActionButtonList('action', 'hostids', [
'enable-hosts' => [
'name' => _('Enable'),
'confirm' => _('Enable selected hosts?'),
diff --git a/ui/app/views/js/popup.massupdate.js.php b/ui/app/views/js/popup.massupdate.js.php
index ec1cb547f4c..393148ad94e 100644
--- a/ui/app/views/js/popup.massupdate.js.php
+++ b/ui/app/views/js/popup.massupdate.js.php
@@ -357,36 +357,6 @@ $('#tabs').on('tabsactivate', (event, ui) => {
toggleVisible(obj, obj.querySelector('[name=valuemap_massupdate]:checked').value);
})();
-function visibility_status_changeds(value, obj_id, replace_to) {
- const obj = document.getElementById(obj_id);
- if (obj === null) {
- throw `Cannot find objects with name [${obj_id}]`;
- }
-
- if (replace_to && replace_to != '') {
- if (obj.originalObject) {
- const old_obj = obj.originalObject;
- old_obj.originalObject = obj;
- obj.parentNode.replaceChild(old_obj, obj);
- }
- else if (!value) {
- const new_obj = document.createElement('span');
- new_obj.setAttribute('name', obj.name);
- new_obj.setAttribute('id', obj.id);
-
- new_obj.innerHTML = replace_to;
- new_obj.originalObject = obj;
- obj.parentNode.replaceChild(new_obj, obj);
- }
- else {
- throw 'Missing originalObject for restoring';
- }
- }
- else {
- obj.style.visibility = value ? 'visible' : 'hidden';
- }
-}
-
if (!CR && !GK) {
$("textarea[maxlength]").bind("paste contextmenu change keydown keypress keyup", function() {
var elem = $(this);
diff --git a/ui/app/views/popup.lldoperation.php b/ui/app/views/popup.lldoperation.php
index 054a3769adb..312cbe42439 100644
--- a/ui/app/views/popup.lldoperation.php
+++ b/ui/app/views/popup.lldoperation.php
@@ -23,9 +23,6 @@
* @var CView $this
*/
-// Visibility box javascript is already added in main page. It should not be added in popup response.
-define('CVISIBILITYBOX_JAVASCRIPT_INSERTED', 1);
-
$output = [
'header' => $data['title']
];
diff --git a/ui/app/views/popup.massupdate.host.php b/ui/app/views/popup.massupdate.host.php
index 321ad09e26b..0a7fe333594 100644
--- a/ui/app/views/popup.massupdate.host.php
+++ b/ui/app/views/popup.massupdate.host.php
@@ -23,9 +23,6 @@
* @var CView $this
*/
-// Visibility box javascript is already added. It should not be added in popup response.
-define('CVISIBILITYBOX_JAVASCRIPT_INSERTED', 1);
-
// create form
$form = (new CForm())
->setId('massupdate-form')
diff --git a/ui/app/views/popup.massupdate.item.php b/ui/app/views/popup.massupdate.item.php
index 60dab355873..e850ed410dc 100644
--- a/ui/app/views/popup.massupdate.item.php
+++ b/ui/app/views/popup.massupdate.item.php
@@ -23,9 +23,6 @@
* @var CView $this
*/
-// Visibility box javascript is already added. It should not be added in popup response.
-define('CVISIBILITYBOX_JAVASCRIPT_INSERTED', 1);
-
// Create form.
$form = (new CForm())
->setId('massupdate-form')
diff --git a/ui/app/views/popup.massupdate.service.php b/ui/app/views/popup.massupdate.service.php
index e67314bec37..c2b4a30d270 100644
--- a/ui/app/views/popup.massupdate.service.php
+++ b/ui/app/views/popup.massupdate.service.php
@@ -23,9 +23,6 @@
* @var CView $this
*/
-// Visibility box javascript is already added. It should not be added in popup response.
-define('CVISIBILITYBOX_JAVASCRIPT_INSERTED', 1);
-
// create form
$form = (new CForm())
->setId('massupdate-form')
diff --git a/ui/app/views/popup.massupdate.template.php b/ui/app/views/popup.massupdate.template.php
index c03c4262d07..9f426a725c3 100644
--- a/ui/app/views/popup.massupdate.template.php
+++ b/ui/app/views/popup.massupdate.template.php
@@ -23,9 +23,6 @@
* @var CView $this
*/
-// Visibility box javascript is already added. It should not be added in popup response.
-define('CVISIBILITYBOX_JAVASCRIPT_INSERTED', 1);
-
// Create form.
$form = (new CForm())
->setId('massupdate-form')
diff --git a/ui/app/views/popup.massupdate.trigger.php b/ui/app/views/popup.massupdate.trigger.php
index 4bed8a3afaf..e320f350496 100644
--- a/ui/app/views/popup.massupdate.trigger.php
+++ b/ui/app/views/popup.massupdate.trigger.php
@@ -23,9 +23,6 @@
* @var CView $this
*/
-// Visibility box javascript is already added. It should not be added in popup response.
-define('CVISIBILITYBOX_JAVASCRIPT_INSERTED', 1);
-
// Create form.
$form = (new CForm())
->setId('massupdate-form')
diff --git a/ui/include/classes/api/services/CMediatype.php b/ui/include/classes/api/services/CMediatype.php
index b1a0daecd24..a7ca68ebad5 100644
--- a/ui/include/classes/api/services/CMediatype.php
+++ b/ui/include/classes/api/services/CMediatype.php
@@ -623,7 +623,7 @@ class CMediatype extends CApiService {
'exec_params' => ['type' => API_STRING_UTF8, 'in' => DB::getDefault('media_type', 'exec_params')],
'content_type' => ['type' => API_INT32, 'in' => DB::getDefault('media_type', 'content_type')],
'script' => ['type' => API_STRING_UTF8, 'in' => DB::getDefault('media_type', 'script')],
- 'timeout' => ['type' => API_TIME_UNIT, 'in' => DB::getDefault('media_type', 'timeout')],
+ 'timeout' => ['type' => API_TIME_UNIT, 'in' => timeUnitToSeconds(DB::getDefault('media_type', 'timeout'))],
'process_tags' => ['type' => API_INT32, 'in' => DB::getDefault('media_type', 'process_tags')],
'show_event_menu' => ['type' => API_INT32, 'in' => DB::getDefault('media_type', 'show_event_menu')],
'event_menu_url' => ['type' => API_STRING_UTF8, 'in' => DB::getDefault('media_type', 'event_menu_url')],
diff --git a/ui/include/classes/data/CItemData.php b/ui/include/classes/data/CItemData.php
index dda8493f576..7deb756d420 100644
--- a/ui/include/classes/data/CItemData.php
+++ b/ui/include/classes/data/CItemData.php
@@ -430,9 +430,8 @@ final class CItemData {
'delay',
'js-item-flex-intervals-label',
'js-item-flex-intervals-field',
- 'js-item-trends-label',
- 'js-item-trends-field',
- ['id' => 'key', 'defaultValue' => '']
+ ['id' => 'key', 'defaultValue' => ''],
+ ['id' => 'value_type', 'defaultValue' => '']
],
ITEM_TYPE_DB_MONITOR => [
'js-item-delay-label',
@@ -448,19 +447,17 @@ final class CItemData {
'password',
'js-item-sql-query-label',
'js-item-sql-query-field',
- 'js-item-trends-label',
- 'js-item-trends-field',
['id' => 'key', 'defaultValue' => $data['is_discovery_rule']
? ZBX_DEFAULT_KEY_DB_MONITOR_DISCOVERY
: ZBX_DEFAULT_KEY_DB_MONITOR
- ]
+ ],
+ ['id' => 'value_type', 'defaultValue' => '']
],
ITEM_TYPE_DEPENDENT => [
'js-item-master-item-label',
'js-item-master-item-field',
- 'js-item-trends-label',
- 'js-item-trends-field',
- ['id' => 'key', 'defaultValue' => '']
+ ['id' => 'key', 'defaultValue' => ''],
+ ['id' => 'value_type', 'defaultValue' => '']
],
ITEM_TYPE_EXTERNAL => [
'js-item-interface-label',
@@ -471,9 +468,8 @@ final class CItemData {
'delay',
'js-item-flex-intervals-label',
'js-item-flex-intervals-field',
- 'js-item-trends-label',
- 'js-item-trends-field',
- ['id' => 'key', 'defaultValue' => '']
+ ['id' => 'key', 'defaultValue' => ''],
+ ['id' => 'value_type', 'defaultValue' => '']
],
ITEM_TYPE_HTTPAGENT => [
'js-item-url-label',
@@ -522,13 +518,12 @@ final class CItemData {
'js-item-interface-label',
'js-item-interface-field',
'interfaceid',
- 'js-item-trends-label',
- 'js-item-trends-field',
'js-item-allow-traps-label',
'js-item-allow-traps-field',
'allow_traps',
'trapper_hosts',
- ['id' => 'key', 'defaultValue' => '']
+ ['id' => 'key', 'defaultValue' => ''],
+ ['id' => 'value_type', 'defaultValue' => '']
],
ITEM_TYPE_INTERNAL => [
'js-item-delay-label',
@@ -536,9 +531,8 @@ final class CItemData {
'delay',
'js-item-flex-intervals-label',
'js-item-flex-intervals-field',
- 'js-item-trends-label',
- 'js-item-trends-field',
- ['id' => 'key', 'defaultValue' => '']
+ ['id' => 'key', 'defaultValue' => ''],
+ ['id' => 'value_type', 'defaultValue' => '']
],
ITEM_TYPE_IPMI => [
'js-item-interface-label',
@@ -552,9 +546,8 @@ final class CItemData {
'delay',
'js-item-flex-intervals-label',
'js-item-flex-intervals-field',
- 'js-item-trends-label',
- 'js-item-trends-field',
- ['id' => 'key', 'defaultValue' => '']
+ ['id' => 'key', 'defaultValue' => ''],
+ ['id' => 'value_type', 'defaultValue' => '']
],
ITEM_TYPE_JMX => [
'js-item-interface-label',
@@ -574,9 +567,8 @@ final class CItemData {
'delay',
'js-item-flex-intervals-label',
'js-item-flex-intervals-field',
- 'js-item-trends-label',
- 'js-item-trends-field',
- ['id' => 'key', 'defaultValue' => '']
+ ['id' => 'key', 'defaultValue' => ''],
+ ['id' => 'value_type', 'defaultValue' => '']
],
ITEM_TYPE_SCRIPT => [
'js-item-parameters-label',
@@ -590,9 +582,8 @@ final class CItemData {
'delay',
'js-item-flex-intervals-label',
'js-item-flex-intervals-field',
- 'js-item-trends-label',
- 'js-item-trends-field',
- ['id' => 'key', 'defaultValue' => '']
+ ['id' => 'key', 'defaultValue' => ''],
+ ['id' => 'value_type', 'defaultValue' => '']
],
ITEM_TYPE_SIMPLE => [
'js-item-delay-label',
@@ -609,9 +600,8 @@ final class CItemData {
'js-item-password-label',
'js-item-password-field',
'password',
- 'js-item-trends-label',
- 'js-item-trends-field',
- ['id' => 'key', 'defaultValue' => '']
+ ['id' => 'key', 'defaultValue' => ''],
+ ['id' => 'value_type', 'defaultValue' => '']
],
ITEM_TYPE_SNMP => [
'js-item-interface-label',
@@ -625,17 +615,15 @@ final class CItemData {
'delay',
'js-item-flex-intervals-label',
'js-item-flex-intervals-field',
- 'js-item-trends-label',
- 'js-item-trends-field',
- ['id' => 'key', 'defaultValue' => '']
+ ['id' => 'key', 'defaultValue' => ''],
+ ['id' => 'value_type', 'defaultValue' => '']
],
ITEM_TYPE_SNMPTRAP => [
'js-item-interface-label',
'js-item-interface-field',
'interfaceid',
- 'js-item-trends-label',
- 'js-item-trends-field',
- ['id' => 'key', 'defaultValue' => '']
+ ['id' => 'key', 'defaultValue' => ''],
+ ['id' => 'value_type', 'defaultValue' => '']
],
ITEM_TYPE_SSH => [
'js-item-interface-label',
@@ -657,10 +645,9 @@ final class CItemData {
'delay',
'js-item-flex-intervals-label',
'js-item-flex-intervals-field',
- 'js-item-trends-label',
- 'js-item-trends-field',
'params_script',
- ['id' => 'key', 'defaultValue' => ZBX_DEFAULT_KEY_SSH]
+ ['id' => 'key', 'defaultValue' => ZBX_DEFAULT_KEY_SSH],
+ ['id' => 'value_type', 'defaultValue' => '']
],
ITEM_TYPE_TELNET => [
'js-item-interface-label',
@@ -679,18 +666,16 @@ final class CItemData {
'delay',
'js-item-flex-intervals-label',
'js-item-flex-intervals-field',
- 'js-item-trends-label',
- 'js-item-trends-field',
'params_script',
- ['id' => 'key', 'defaultValue' => ZBX_DEFAULT_KEY_TELNET]
+ ['id' => 'key', 'defaultValue' => ZBX_DEFAULT_KEY_TELNET],
+ ['id' => 'value_type', 'defaultValue' => '']
],
ITEM_TYPE_TRAPPER => [
'js-item-trapper-hosts-label',
'js-item-trapper-hosts-field',
'trapper_hosts',
- 'js-item-trends-label',
- 'js-item-trends-field',
- ['id' => 'key', 'defaultValue' => '']
+ ['id' => 'key', 'defaultValue' => ''],
+ ['id' => 'value_type', 'defaultValue' => '']
],
ITEM_TYPE_ZABBIX => [
'js-item-interface-label',
@@ -701,9 +686,8 @@ final class CItemData {
'delay',
'js-item-flex-intervals-label',
'js-item-flex-intervals-field',
- 'js-item-trends-label',
- 'js-item-trends-field',
- ['id' => 'key', 'defaultValue' => '']
+ ['id' => 'key', 'defaultValue' => ''],
+ ['id' => 'value_type', 'defaultValue' => '']
],
ITEM_TYPE_ZABBIX_ACTIVE => [
'js-item-delay-label',
@@ -711,9 +695,8 @@ final class CItemData {
'delay',
'js-item-flex-intervals-label',
'js-item-flex-intervals-field',
- 'js-item-trends-field',
- 'js-item-trends-label',
- ['id' => 'key', 'defaultValue' => '']
+ ['id' => 'key', 'defaultValue' => ''],
+ ['id' => 'value_type', 'defaultValue' => '']
]
],
// Ids to toggle when the field 'authtype' is changed.
diff --git a/ui/include/classes/html/CFilter.php b/ui/include/classes/html/CFilter.php
index c3588f8ac08..5bc1bdf2fd4 100644
--- a/ui/include/classes/html/CFilter.php
+++ b/ui/include/classes/html/CFilter.php
@@ -122,8 +122,8 @@ class CFilter extends CDiv {
*
* @return CFilter
*/
- public function addVar($name, $value) {
- $this->form->addVar($name, $value);
+ public function addVar($name, $value, $id = null) {
+ $this->form->addVar($name, $value, $id);
return $this;
}
diff --git a/ui/include/classes/html/CVisibilityBox.php b/ui/include/classes/html/CVisibilityBox.php
index 9e1af6b7453..15ab93e5e90 100644
--- a/ui/include/classes/html/CVisibilityBox.php
+++ b/ui/include/classes/html/CVisibilityBox.php
@@ -26,9 +26,8 @@ class CVisibilityBox extends CCheckBox {
$this->replace_to = unpack_object($replace_to);
parent::__construct($name);
- $this->onClick('visibility_status_changeds(this.checked, '.zbx_jsvalue($this->object_id).', '.
+ $this->onClick('visibilityStatusChanges(this.checked, '.zbx_jsvalue($this->object_id).', '.
zbx_jsvalue($this->replace_to).');');
- insert_javascript_for_visibilitybox();
}
/**
@@ -47,7 +46,7 @@ class CVisibilityBox extends CCheckBox {
public function toString($destroy = true) {
if (!isset($this->attributes['checked'])) {
- zbx_add_post_js('visibility_status_changeds(false, '.zbx_jsvalue($this->object_id).', '.
+ zbx_add_post_js('visibilityStatusChanges(false, '.zbx_jsvalue($this->object_id).', '.
zbx_jsvalue($this->replace_to).');');
}
diff --git a/ui/include/js.inc.php b/ui/include/js.inc.php
index 76aa7cffc32..2ed91c094a2 100644
--- a/ui/include/js.inc.php
+++ b/ui/include/js.inc.php
@@ -75,49 +75,6 @@ function zbx_jsvalue($value, $as_object = false, $addQuotes = true) {
return $is_object ? '{'.implode(',', $value).'}' : '['.implode(',', $value).']';
}
-function insert_javascript_for_visibilitybox() {
- if (defined('CVISIBILITYBOX_JAVASCRIPT_INSERTED')) {
- return null;
- }
- define('CVISIBILITYBOX_JAVASCRIPT_INSERTED', 1);
-
- $js = '
- function visibility_status_changeds(value, obj_id, replace_to) {
- var obj = document.getElementById(obj_id);
- if (is_null(obj)) {
- throw "Cannot find objects with name [" + obj_id +"]";
- }
-
- if (replace_to && replace_to != "") {
- if (obj.originalObject) {
- var old_obj = obj.originalObject;
- old_obj.originalObject = obj;
- obj.parentNode.replaceChild(old_obj, obj);
- }
- else if (!value) {
- try {
- var new_obj = document.createElement("span");
- new_obj.setAttribute("name", obj.name);
- new_obj.setAttribute("id", obj.id);
- }
- catch(e) {
- throw "Cannot create new element";
- }
- new_obj.innerHTML = replace_to;
- new_obj.originalObject = obj;
- obj.parentNode.replaceChild(new_obj, obj);
- }
- else {
- throw "Missing originalObject for restoring";
- }
- }
- else {
- obj.style.visibility = value ? "visible" : "hidden";
- }
- }';
- insert_js($js);
-}
-
function insert_js($script, $jQueryDocumentReady = false) {
echo get_js($script, $jQueryDocumentReady);
}
diff --git a/ui/include/views/configuration.item.list.php b/ui/include/views/configuration.item.list.php
index 3ae9193685b..7dcb5e8fddb 100644
--- a/ui/include/views/configuration.item.list.php
+++ b/ui/include/views/configuration.item.list.php
@@ -64,7 +64,7 @@ $url = (new CUrl('items.php'))
$itemForm = (new CForm('post', $url))
->setName('items')
->addVar('checkbox_hash', $data['checkbox_hash'])
- ->addVar('context', $data['context']);
+ ->addVar('context', $data['context'], 'form_context');
if (!empty($data['hostid'])) {
$itemForm->addVar('hostid', $data['hostid']);
diff --git a/ui/include/views/configuration.item.prototype.list.php b/ui/include/views/configuration.item.prototype.list.php
index 19e5d5aed0c..646b1afdef2 100644
--- a/ui/include/views/configuration.item.prototype.list.php
+++ b/ui/include/views/configuration.item.prototype.list.php
@@ -48,8 +48,8 @@ $url = (new CUrl('disc_prototypes.php'))
// create form
$itemForm = (new CForm('post', $url))
->setName('items')
- ->addVar('parent_discoveryid', $data['parent_discoveryid'])
- ->addVar('context', $data['context']);
+ ->addVar('parent_discoveryid', $data['parent_discoveryid'], 'form_parent_discoveryid')
+ ->addVar('context', $data['context'], 'form_context');
// create table
$itemTable = (new CTableInfo())
diff --git a/ui/include/views/configuration.trigger.prototype.list.php b/ui/include/views/configuration.trigger.prototype.list.php
index f3b3dc85ac6..bf6a0a4d66e 100644
--- a/ui/include/views/configuration.trigger.prototype.list.php
+++ b/ui/include/views/configuration.trigger.prototype.list.php
@@ -47,8 +47,8 @@ $url = (new CUrl('trigger_prototypes.php'))
// create form
$triggersForm = (new CForm('post', $url))
->setName('triggersForm')
- ->addVar('parent_discoveryid', $data['parent_discoveryid'])
- ->addVar('context', $data['context']);
+ ->addVar('parent_discoveryid', $data['parent_discoveryid'], 'form_parent_discoveryid')
+ ->addVar('context', $data['context'], 'form_context');
// create table
$triggersTable = (new CTableInfo())
diff --git a/ui/include/views/configuration.triggers.list.php b/ui/include/views/configuration.triggers.list.php
index cdcb9d5ba3d..012418bd45a 100644
--- a/ui/include/views/configuration.triggers.list.php
+++ b/ui/include/views/configuration.triggers.list.php
@@ -139,7 +139,7 @@ $filter = (new CFilter())
->setResetUrl((new CUrl('triggers.php'))->setArgument('context', $data['context']))
->setProfile($data['profileIdx'])
->setActiveTab($data['active_tab'])
- ->addvar('context', $data['context'])
+ ->addvar('context', $data['context'], 'filter_context')
->addFilterTab(_('Filter'), [$filter_column1, $filter_column2]);
$widget = (new CWidget())
@@ -174,7 +174,7 @@ $url = (new CUrl('triggers.php'))
$triggers_form = (new CForm('post', $url))
->setName('triggersForm')
->addVar('checkbox_hash', $data['checkbox_hash'])
- ->addVar('context', $data['context']);
+ ->addVar('context', $data['context'], 'form_context');
// create table
$triggers_table = (new CTableInfo())->setHeader([
diff --git a/ui/include/views/js/configuration.host.discovery.edit.overr.js.php b/ui/include/views/js/configuration.host.discovery.edit.overr.js.php
index 0d37346ebaa..20b2d831a8f 100644
--- a/ui/include/views/js/configuration.host.discovery.edit.overr.js.php
+++ b/ui/include/views/js/configuration.host.discovery.edit.overr.js.php
@@ -22,7 +22,6 @@
/**
* @var CView $this
*/
-insert_javascript_for_visibilitybox();
?>
<script type="text/x-jquery-tmpl" id="lldoverride-row-templated">
<?= (new CRow([
diff --git a/ui/js/common.js b/ui/js/common.js
index 3c5f061cdce..367cd988cbc 100644
--- a/ui/js/common.js
+++ b/ui/js/common.js
@@ -1012,18 +1012,18 @@ function openMassupdatePopup(action, parameters = {}, {
switch (action) {
case 'popup.massupdate.item':
- parameters.context = form.querySelector('#context').value;
+ parameters.context = form.querySelector('#form_context').value;
parameters.prototype = 0;
break;
case 'popup.massupdate.trigger':
- parameters.context = form.querySelector('#context').value;
+ parameters.context = form.querySelector('#form_context').value;
break;
case 'popup.massupdate.itemprototype':
case 'popup.massupdate.triggerprototype':
- parameters.parent_discoveryid = form.querySelector('#parent_discoveryid').value;
- parameters.context = form.querySelector('#context').value;
+ parameters.parent_discoveryid = form.querySelector('#form_parent_discoveryid').value;
+ parameters.context = form.querySelector('#form_context').value;
parameters.prototype = 1;
break;
}
@@ -1032,6 +1032,43 @@ function openMassupdatePopup(action, parameters = {}, {
}
/**
+ * @param {boolean} value
+ * @param {string} objectid
+ * @param {string} replace_to
+ */
+function visibilityStatusChanges(value, objectid, replace_to) {
+ const obj = document.getElementById(objectid);
+
+ if (obj === null) {
+ throw `Cannot find objects with name [${objectid}]`;
+ }
+
+ if (replace_to && replace_to != '') {
+ if (obj.originalObject) {
+ const old_obj = obj.originalObject;
+ old_obj.originalObject = obj;
+
+ obj.parentNode.replaceChild(old_obj, obj);
+ }
+ else if (!value) {
+ const new_obj = document.createElement('span');
+ new_obj.setAttribute('name', obj.name);
+ new_obj.setAttribute('id', obj.id);
+ new_obj.innerHTML = replace_to;
+ new_obj.originalObject = obj;
+
+ obj.parentNode.replaceChild(new_obj, obj);
+ }
+ else {
+ throw 'Missing originalObject for restoring';
+ }
+ }
+ else {
+ obj.style.visibility = value ? 'visible' : 'hidden';
+ }
+}
+
+/**
* Clears session storage from markers of checked table rows.
* Or keeps only accessible IDs in the list of checked rows.
*
diff --git a/ui/js/functions.js b/ui/js/functions.js
index 91457e0eb37..04761a99e0e 100644
--- a/ui/js/functions.js
+++ b/ui/js/functions.js
@@ -947,9 +947,31 @@ function urlEncodeData(parameters, prefix = '') {
}
/**
- * Get all input fields from the given form and return them. The order of returned fields is not predictable.
- *
- * @param {object} form Form object from which fields are retrieved.
+ * Get form field values as deep object.
+ *
+ * Example:
+ * <form>
+ * <input name="a" value="1">
+ * <input name="b[c]" value="2">
+ * <input name="b[d]" value="3">
+ * <input name="e[f][]" value="4">
+ * <input name="e[f][]" value="5">
+ * </form>
+ *
+ * ... will result in:
+ *
+ * {
+ * a: "1",
+ * b: {
+ * c: "2",
+ * d: "3"
+ * },
+ * e: {
+ * f: ["4", "5"]
+ * }
+ * }
+ *
+ * @param {HTMLFormElement} form
*
* @return {object}
*/
@@ -957,6 +979,8 @@ function getFormFields(form) {
const fields = {};
for (let [key, value] of new FormData(form)) {
+ value = value.replace(/\r?\n/g, '\r\n');
+
const key_parts = [...key.matchAll(/[^\[\]]+|\[\]/g)];
let key_fields = fields;