} $proxyForm = (new CForm())->setId('proxyForm')->addVar('proxyid', $data['proxyid'])->addVar('tls_accept', $data['tls_accept']); if ($data['status'] == HOST_STATUS_PROXY_PASSIVE && array_key_exists('interfaceid', $data)) { $proxyForm->addVar('interfaceid', $data['interfaceid']); } $interfaceTable = (new CTable())->setHeader([_('IP address'), _('DNS name'), _('Connect to'), _('Port')])->addRow([(new CTextBox('ip', $data['ip'], false, 64))->setWidth(ZBX_TEXTAREA_INTERFACE_IP_WIDTH), (new CTextBox('dns', $data['dns'], false, 64))->setWidth(ZBX_TEXTAREA_INTERFACE_DNS_WIDTH), (new CRadioButtonList('useip', (int) $data['useip']))->addValue(_('IP'), INTERFACE_USE_IP)->addValue(_('DNS'), INTERFACE_USE_DNS)->setModern(true), (new CTextBox('port', $data['port'], false, 64))->setWidth(ZBX_TEXTAREA_INTERFACE_PORT_WIDTH)]); // append hosts to form list $hosts_tween_box = new CTweenBox($proxyForm, 'proxy_hostids', $data['proxy_hostids']); foreach ($data['all_hosts'] as $host) { // show only normal hosts, and discovered hosts monitored by the current proxy // for new proxies display only normal hosts if ($host['flags'] == ZBX_FLAG_DISCOVERY_NORMAL || $data['proxyid'] != 0 && bccomp($data['proxyid'], $host['proxy_hostid']) == 0) { $hosts_tween_box->addItem($host['hostid'], $host['name'], null, $host['proxy_hostid'] == 0 || bccomp($host['proxy_hostid'], $data['proxyid']) == 0 && $host['flags'] == ZBX_FLAG_DISCOVERY_NORMAL); } } $proxy_form_list = (new CFormList('proxyFormList'))->addRow(_('Proxy name'), (new CTextBox('host', $data['host'], false, 128))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)->setAttribute('autofocus', 'autofocus'))->addRow(_('Proxy mode'), new CComboBox('status', $data['status'], null, [HOST_STATUS_PROXY_ACTIVE => _('Active'), HOST_STATUS_PROXY_PASSIVE => _('Passive')]))->addRow(_('Interface'), (new CDiv($interfaceTable))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR))->addRow(_('Hosts'), $hosts_tween_box->get(_('Proxy hosts'), _('Other hosts')))->addRow(_('Description'), (new CTextArea('description', $data['description']))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)); // append tabs to form $proxyTab = (new CTabView())->addTab('proxyTab', _('Proxy'), $proxy_form_list); // Encryption form list. $encryption_form_list = (new CFormList('encryption'))->addRow(_('Connections to proxy'), (new CRadioButtonList('tls_connect', (int) $data['tls_connect']))->addValue(_('No encryption'), HOST_ENCRYPTION_NONE)->addValue(_('PSK'), HOST_ENCRYPTION_PSK)->addValue(_('Certificate'), HOST_ENCRYPTION_CERTIFICATE)->setModern(true))->addRow(_('Connections from proxy'), [new CLabel([new CCheckBox('tls_in_none'), _('No encryption')]), BR(), new CLabel([new CCheckBox('tls_in_psk'), _('PSK')]), BR(), new CLabel([new CCheckBox('tls_in_cert'), _('Certificate')])])->addRow(_('PSK identity'), (new CTextBox('tls_psk_identity', $data['tls_psk_identity'], false, 128))->setWidth(ZBX_TEXTAREA_BIG_WIDTH))->addRow(_('PSK'), (new CTextBox('tls_psk', $data['tls_psk'], false, 512))->setWidth(ZBX_TEXTAREA_BIG_WIDTH))->addRow(_('Issuer'), (new CTextBox('tls_issuer', $data['tls_issuer'], false, 1024))->setWidth(ZBX_TEXTAREA_BIG_WIDTH))->addRow(_x('Subject', 'encryption certificate'), (new CTextBox('tls_subject', $data['tls_subject'], false, 1024))->setWidth(ZBX_TEXTAREA_BIG_WIDTH)); $tabs->addTab('proxyTab', _('Proxy'), $proxy_form_list); $tabs->addTab('encryptionTab', _('Encryption'), $encryption_form_list); // append buttons to form $cancelButton = new CRedirectButton(_('Cancel'), 'zabbix.php?action=proxy.list'); if ($data['proxyid'] == 0) { $tabs->setFooter(makeFormFooter(new CSubmitButton(_('Add'), 'action', 'proxy.create'), [$cancelButton])); } else { $tabs->setFooter(makeFormFooter(new CSubmitButton(_('Update'), 'action', 'proxy.update'), [(new CSimpleButton(_('Clone')))->setId('clone'), new CRedirectButton(_('Delete'), 'zabbix.php?action=proxy.delete&sid=' . $data['sid'] . '&proxyids[]=' . $data['proxyid'], _('Delete proxy?')), $cancelButton])); } $proxyForm->addItem($tabs); $widget->addItem($proxyForm)->show();
$graphFormList->addRow(_('Items'), (new CDiv($itemsTable))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)); // append tabs to form $graphTab = new CTabView(); if (!$this->data['form_refresh']) { $graphTab->setSelected(0); } $graphTab->addTab('graphTab', empty($this->data['parent_discoveryid']) ? _('Graph') : _('Graph prototype'), $graphFormList); /* * Preview tab */ $graphPreviewTable = (new CTable())->addStyle('width: 100%;')->addRow((new CRow((new CDiv())->setId('previewChar')))->addClass(ZBX_STYLE_CENTER)); $graphTab->addTab('previewTab', _('Preview'), $graphPreviewTable); // append buttons to form if (!empty($this->data['graphid'])) { $updateButton = new CSubmit('update', _('Update')); $deleteButton = new CButtonDelete($this->data['parent_discoveryid'] ? _('Delete graph prototype?') : _('Delete graph?'), url_params(['graphid', 'parent_discoveryid', 'hostid'])); if (!empty($this->data['templateid'])) { $updateButton->setEnabled(false); $deleteButton->setEnabled(false); } $graphTab->setFooter(makeFormFooter($updateButton, [new CSubmit('clone', _('Clone')), $deleteButton, new CButtonCancel(url_param('parent_discoveryid') . url_param('hostid', $this->data['hostid']))])); } else { $graphTab->setFooter(makeFormFooter(new CSubmit('add', _('Add')), [new CButtonCancel(url_param('parent_discoveryid') . url_param('hostid', $this->data['hostid']))])); } // insert js (depended from some variables inside the file) insert_show_color_picker_javascript(); require_once dirname(__FILE__) . '/js/configuration.graph.edit.js.php'; $graphForm->addItem($graphTab); // append form to widget $widget->addItem($graphForm); return $widget;
$hostsComboBox->addItem($host['hostid'], $host['name']); } } foreach ($this->data['r_hosts'] as $host) { if ($host['flags'] == ZBX_FLAG_DISCOVERY_NORMAL) { $hostsComboBox->addItem($host['hostid'], $host['name']); } else { $hostsComboBox->addItem($host['hostid'], $host['name'], true, false); } } $hostGroupFormList->addRow(_('Hosts'), $hostsComboBox->get(_('Hosts in'), [_('Other hosts | Group') . SPACE, $groupsComboBox])); // append tabs to form $hostGroupTab = new CTabView(); $hostGroupTab->addTab('hostgroupTab', _('Host group'), $hostGroupFormList); // append buttons to form if ($this->data['groupid'] == 0) { $hostGroupTab->setFooter(makeFormFooter(new CSubmit('add', _('Add')), [new CButtonCancel()])); } else { $clone_button = new CSubmit('clone', _('Clone')); if (CWebUser::getType() != USER_TYPE_SUPER_ADMIN) { $clone_button->setAttribute('disabled', 'disabled'); } $delete_button = new CButtonDelete(_('Delete selected group?'), url_param('form') . url_param('groupid')); if (!isset($this->data['deletableHostGroups'][$this->data['groupid']])) { $delete_button->setAttribute('disabled', 'disabled'); } $hostGroupTab->setFooter(makeFormFooter(new CSubmit('update', _('Update')), [$clone_button, $delete_button, new CButtonCancel()])); } $hostGroupForm->addItem($hostGroupTab); $widget->addItem($hostGroupForm); return $widget;
$user_group_shares_table->addRow((new CRow((new CCol($add_user_group_btn))->setColSpan(3)))->setId('user_group_list_footer')); $user_groups = []; foreach ($data['sysmap']['userGroups'] as $user_group) { $user_groupid = $user_group['usrgrpid']; $user_groups[$user_groupid] = ['usrgrpid' => $user_groupid, 'name' => $data['user_groups'][$user_groupid]['name'], 'permission' => $user_group['permission']]; } $js_insert = 'addPopupValues(' . zbx_jsvalue(['object' => 'usrgrpid', 'values' => $user_groups]) . ');'; // User sharing table. $user_shares_table = (new CTable())->setHeader([_('Users'), _('Permissions'), _('Action')])->setAttribute('style', 'width: 100%;'); $add_user_btn = [(new CButton(null, _('Add')))->onClick('return PopUp("popup.php?dstfrm=' . $form->getName() . '&srctbl=users&srcfld1=userid&srcfld2=fullname&multiselect=1")')->addClass(ZBX_STYLE_BTN_LINK)]; $user_shares_table->addRow((new CRow((new CCol($add_user_btn))->setColSpan(3)))->setId('user_list_footer')); $users = []; foreach ($data['sysmap']['users'] as $user) { $userid = $user['userid']; $users[$userid] = ['id' => $userid, 'name' => getUserFullname($data['users'][$userid]), 'permission' => $user['permission']]; } $js_insert .= 'addPopupValues(' . zbx_jsvalue(['object' => 'userid', 'values' => $users]) . ');'; zbx_add_post_js($js_insert); $sharing_tab = (new CFormList('sharing_form'))->addRow(_('Type'), (new CRadioButtonList('private', (int) $data['sysmap']['private']))->addValue(_('Private'), PRIVATE_SHARING)->addValue(_('Public'), PUBLIC_SHARING)->setModern(true))->addRow(_('List of user group shares'), (new CDiv($user_group_shares_table))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_STANDARD_WIDTH . 'px;'))->addRow(_('List of user shares'), (new CDiv($user_shares_table))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_STANDARD_WIDTH . 'px;')); // Append data to form. $tabs->addTab('sharing_tab', _('Sharing'), $sharing_tab); // Append buttons to form. if (hasRequest('sysmapid') && getRequest('sysmapid') > 0) { $tabs->setFooter(makeFormFooter(new CSubmit('update', _('Update')), [new CButton('clone', _('Clone')), new CButtonDelete(_('Delete selected map?'), url_param('form') . url_param('sysmapid')), new CButtonCancel()])); } else { $tabs->setFooter(makeFormFooter(new CSubmit('add', _('Add')), [new CButtonCancel()])); } $form->addItem($tabs); // Append form to widget. $widget->addItem($form); return $widget;
} if (hasRequest('stepid')) { $followRedirects = getRequest('follow_redirects', HTTPTEST_STEP_FOLLOW_REDIRECTS_OFF); $retrieveMode = getRequest('retrieve_mode', HTTPTEST_STEP_RETRIEVE_MODE_CONTENT); } else { $followRedirects = HTTPTEST_STEP_FOLLOW_REDIRECTS_ON; $retrieveMode = HTTPTEST_STEP_RETRIEVE_MODE_CONTENT; } if ((hasRequest('add') || hasRequest('update')) && $result) { $httpStepForJs = ['stepid' => getRequest('stepid'), 'name' => getRequest('name'), 'timeout' => getRequest('timeout'), 'url' => getRequest('url'), 'posts' => getRequest('posts'), 'variables' => getRequest('variables'), 'required' => getRequest('required'), 'status_codes' => getRequest('status_codes'), 'headers' => getRequest('headers'), 'follow_redirects' => getRequest('follow_redirects', HTTPTEST_STEP_FOLLOW_REDIRECTS_OFF), 'retrieve_mode' => getRequest('retrieve_mode', HTTPTEST_STEP_RETRIEVE_MODE_CONTENT)]; if (!hasRequest('stepid')) { insert_js('add_httpstep(' . CJs::encodeJson(getRequest('dstfrm')) . ',' . CJs::encodeJson($httpStepForJs) . ');' . "\n"); } else { insert_js('update_httpstep(' . CJs::encodeJson(getRequest('dstfrm')) . ',' . CJs::encodeJson(getRequest('list_name')) . ',' . CJs::encodeJson($httpStepForJs) . ');' . "\n"); } } else { $httpPopupForm = (new CForm())->addVar('dstfrm', getRequest('dstfrm'))->addVar('stepid', getRequest('stepid'))->addVar('list_name', getRequest('list_name'))->addVar('templated', getRequest('templated'))->addVar('old_name', getRequest('old_name'))->addVar('steps_names', getRequest('steps_names')); $httpPopupFormList = (new CFormList())->addRow(_('Name'), (new CTextBox('name', getRequest('name', ''), (bool) getRequest('templated'), 64))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH))->addRow(_('URL'), (new CTextBox('url', getRequest('url', ''), false, null))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH))->addRow(_('Post'), (new CTextArea('posts', getRequest('posts', '')))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH))->addRow(_('Variables'), (new CTextArea('variables', getRequest('variables', '')))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH))->addRow(_('Headers'), (new CTextArea('headers', getRequest('headers', '')))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH))->addRow(_('Follow redirects'), (new CCheckBox('follow_redirects'))->setChecked($followRedirects == 1))->addRow(_('Retrieve only headers'), (new CCheckBox('retrieve_mode'))->setChecked($retrieveMode == 1))->addRow(_('Timeout'), (new CNumericBox('timeout', getRequest('timeout', 15), 5))->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH))->addRow(_('Required string'), (new CTextBox('required', getRequest('required', '')))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH))->addRow(_('Required status codes'), (new CTextBox('status_codes', getRequest('status_codes', '')))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)); // append tabs to form $httpPopupTab = new CTabView(); $httpPopupTab->addTab('scenarioStepTab', _('Step of web scenario'), $httpPopupFormList); // append buttons to form if (hasRequest('stepid')) { $httpPopupTab->setFooter(makeFormFooter(new CSubmit('update', _('Update')), [new CButtonCancel(null, 'close_window();')])); } else { $httpPopupTab->setFooter(makeFormFooter(new CSubmit('add', _('Add')), [new CButtonCancel(null, 'close_window();')])); } $httpPopupForm->addItem($httpPopupTab); $httpPopupWidget->addItem($httpPopupForm); } return $httpPopupWidget;
$profileLinksComboBox = new CComboBox('iconmap[mappings][' . $i . '][inventory_link]', $mapping['inventory_link'], null, $this->data['inventoryList']); $expressionTextBox = [(new CTextBox('iconmap[mappings][' . $i . '][expression]', $mapping['expression']))->setWidth(ZBX_TEXTAREA_SMALL_WIDTH)->setAttribute('maxlength', 64)]; if (isset($mapping['iconmappingid'])) { $expressionTextBox[] = new CVar('iconmap[mappings][' . $i . '][iconmappingid]', $mapping['iconmappingid']); } $iconsComboBox = new CComboBox('iconmap[mappings][' . $i . '][iconid]', $mapping['iconid'], null, $this->data['iconList']); $iconsComboBox->addClass('mappingIcon'); $iconPreviewImage = (new CImg('imgstore.php?iconid=' . $mapping['iconid'] . '&width=' . ZBX_ICON_PREVIEW_WIDTH . '&height=' . ZBX_ICON_PREVIEW_HEIGHT, _('Preview'), null, null))->addClass('preview')->addClass(ZBX_STYLE_CURSOR_POINTER)->setAttribute('data-image-full', 'imgstore.php?iconid=' . $mapping['iconid']); $iconMapTable->addRow((new CRow([(new CCol((new CDiv())->addClass(ZBX_STYLE_DRAG_ICON)))->addClass(ZBX_STYLE_TD_DRAG_ICON), $numSpan, $profileLinksComboBox, $expressionTextBox, $iconsComboBox, $iconPreviewImage, (new CCol((new CButton('remove', _('Remove')))->addClass(ZBX_STYLE_BTN_LINK)->addClass('removeMapping')))->addClass(ZBX_STYLE_NOWRAP)]))->addClass('sortable')->setId('iconmapidRow_' . $i)); $i++; } // add row button $iconMapTable->addRow((new CRow([(new CCol((new CButton('addMapping', _('Add')))->addClass(ZBX_STYLE_BTN_LINK)))->setColSpan(7)]))->setId('iconMapListFooter')); // <default icon row> $iconsComboBox = new CComboBox('iconmap[default_iconid]', $this->data['iconmap']['default_iconid'], null, $this->data['iconList']); $iconsComboBox->addClass('mappingIcon'); $iconPreviewImage = (new CImg('imgstore.php?iconid=' . $this->data['iconmap']['default_iconid'] . '&width=' . ZBX_ICON_PREVIEW_WIDTH . '&height=' . ZBX_ICON_PREVIEW_HEIGHT, _('Preview'), null, null))->addClass(ZBX_STYLE_CURSOR_POINTER)->addClass('preview')->setAttribute('data-image-full', 'imgstore.php?iconid=' . $this->data['iconmap']['default_iconid']); $iconMapTable->addRow([(new CCol(_('Default')))->setColSpan(4), $iconsComboBox, $iconPreviewImage]); // </default icon row> $iconMapTab->addRow(_('Mappings'), (new CDiv($iconMapTable))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_BIG_WIDTH . 'px;')); $iconMapView = new CTabView(); $iconMapView->addTab('iconmap', _('Icon map'), $iconMapTab); // footer if (isset($this->data['iconmapid'])) { $iconMapView->setFooter(makeFormFooter(new CSubmit('update', _('Update')), [new CSubmit('clone', _('Clone')), new CButtonDelete(_('Delete icon map?'), url_param('form') . url_param('iconmapid')), new CButtonCancel()])); } else { $iconMapView->setFooter(makeFormFooter(new CSubmit('add', _('Add')), [new CButtonCancel()])); } $iconMapForm->addItem($iconMapView); $widget->addItem($iconMapForm); return $widget;
$ipmiList->addRow(_('Privilege level'), (new CTextBox('ipmi_privilege', ipmiPrivileges($parentHost['ipmi_privilege']), true))->setWidth(ZBX_TEXTAREA_SMALL_WIDTH)); $ipmiList->addRow(_('Username'), (new CTextBox('ipmi_username', $parentHost['ipmi_username'], true))->setWidth(ZBX_TEXTAREA_SMALL_WIDTH)); $ipmiList->addRow(_('Password'), (new CTextBox('ipmi_password', $parentHost['ipmi_password'], true))->setWidth(ZBX_TEXTAREA_SMALL_WIDTH)); $divTabs->addTab('ipmiTab', _('IPMI'), $ipmiList); // macros $macros = $parentHost['macros']; if ($data['show_inherited_macros']) { $macros = mergeInheritedMacros($macros, getInheritedMacros(zbx_objectValues($hostPrototype['templates'], 'templateid'))); } $macros = array_values(order_macros($macros, 'macro')); $macrosView = new CView('hostmacros', ['macros' => $macros, 'show_inherited_macros' => $data['show_inherited_macros'], 'is_template' => false, 'readonly' => true]); $divTabs->addTab('macroTab', _('Macros'), $macrosView->render()); } $inventoryFormList = (new CFormList('inventorylist'))->addRow(null, (new CRadioButtonList('inventory_mode', (int) $hostPrototype['inventory']['inventory_mode']))->addValue(_('Disabled'), HOST_INVENTORY_DISABLED)->addValue(_('Manual'), HOST_INVENTORY_MANUAL)->addValue(_('Automatic'), HOST_INVENTORY_AUTOMATIC)->setEnabled($hostPrototype['templateid'] == 0)->setModern(true)); $divTabs->addTab('inventoryTab', _('Host inventory'), $inventoryFormList); // Encryption form list. $encryption_form_list = (new CFormList('encryption'))->addRow(_('Connections to host'), (new CRadioButtonList('tls_connect', (int) $parentHost['tls_connect']))->addValue(_('No encryption'), HOST_ENCRYPTION_NONE)->addValue(_('PSK'), HOST_ENCRYPTION_PSK)->addValue(_('Certificate'), HOST_ENCRYPTION_CERTIFICATE)->setModern(true)->setEnabled(false))->addRow(_('Connections from host'), [new CLabel([(new CCheckBox('tls_in_none'))->setAttribute('disabled', 'disabled'), _('No encryption')]), BR(), new CLabel([(new CCheckBox('tls_in_psk'))->setAttribute('disabled', 'disabled'), _('PSK')]), BR(), new CLabel([(new CCheckBox('tls_in_cert'))->setAttribute('disabled', 'disabled'), _('Certificate')])])->addRow(_('PSK identity'), (new CTextBox('tls_psk_identity', $parentHost['tls_psk_identity'], false, 128))->setWidth(ZBX_TEXTAREA_BIG_WIDTH)->setAttribute('disabled', 'disabled'))->addRow(_('PSK'), (new CTextBox('tls_psk', $parentHost['tls_psk'], false, 512))->setWidth(ZBX_TEXTAREA_BIG_WIDTH)->setAttribute('disabled', 'disabled'))->addRow(_('Issuer'), (new CTextBox('tls_issuer', $parentHost['tls_issuer'], false, 1024))->setWidth(ZBX_TEXTAREA_BIG_WIDTH)->setAttribute('disabled', 'disabled'))->addRow(_x('Subject', 'encryption certificate'), (new CTextBox('tls_subject', $parentHost['tls_subject'], false, 1024))->setWidth(ZBX_TEXTAREA_BIG_WIDTH)->setAttribute('disabled', 'disabled')); $divTabs->addTab('encryptionTab', _('Encryption'), $encryption_form_list); /* * footer */ if (isset($hostPrototype['hostid'])) { $btnDelete = new CButtonDelete(_('Delete selected host prototype?'), url_param('form') . url_param('hostid') . url_param('parent_discoveryid')); $btnDelete->setEnabled($hostPrototype['templateid'] == 0); $divTabs->setFooter(makeFormFooter(new CSubmit('update', _('Update')), [new CSubmit('clone', _('Clone')), $btnDelete, new CButtonCancel(url_param('parent_discoveryid'))])); } else { $divTabs->setFooter(makeFormFooter(new CSubmit('add', _('Add')), [new CButtonCancel(url_param('parent_discoveryid'))])); } $frmHost->addItem($divTabs); $widget->addItem($frmHost); return $widget;
$user_group_shares_table->addRow((new CRow((new CCol($add_user_group_btn))->setColSpan(3)))->setId('user_group_list_footer')); $user_groups = []; foreach ($data['screen']['userGroups'] as $user_group) { $user_groupid = $user_group['usrgrpid']; $user_groups[$user_groupid] = ['usrgrpid' => $user_groupid, 'name' => $data['user_groups'][$user_groupid]['name'], 'permission' => $user_group['permission']]; } $js_insert = 'addPopupValues(' . zbx_jsvalue(['object' => 'usrgrpid', 'values' => $user_groups]) . ');'; // User sharing table. $user_shares_table = (new CTable())->setHeader([_('Users'), _('Permissions'), _('Action')])->setAttribute('style', 'width: 100%;'); $add_user_btn = [(new CButton(null, _('Add')))->onClick('return PopUp("popup.php?dstfrm=' . $form->getName() . '&srctbl=users&srcfld1=userid&srcfld2=fullname&multiselect=1")')->addClass(ZBX_STYLE_BTN_LINK)]; $user_shares_table->addRow((new CRow((new CCol($add_user_btn))->setColSpan(3)))->setId('user_list_footer')); $users = []; foreach ($data['screen']['users'] as $user) { $userid = $user['userid']; $users[$userid] = ['id' => $userid, 'name' => getUserFullname($data['users'][$userid]), 'permission' => $user['permission']]; } $js_insert .= 'addPopupValues(' . zbx_jsvalue(['object' => 'userid', 'values' => $users]) . ');'; zbx_add_post_js($js_insert); $sharing_tab = (new CFormList('sharing_form'))->addRow(_('Type'), (new CRadioButtonList('private', (int) $data['screen']['private']))->addValue(_('Private'), PRIVATE_SHARING)->addValue(_('Public'), PUBLIC_SHARING)->setModern(true))->addRow(_('List of user group shares'), (new CDiv($user_group_shares_table))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_STANDARD_WIDTH . 'px;'))->addRow(_('List of user shares'), (new CDiv($user_shares_table))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_STANDARD_WIDTH . 'px;')); // Append data to form. $tabs->addTab('sharing_tab', _('Sharing'), $sharing_tab); } // append buttons to form if ($data['screen']['screenid']) { $tabs->setFooter(makeFormFooter(new CSubmit('update', _('Update')), [new CSubmit('clone', _('Clone')), new CButtonDelete(_('Delete screen?'), url_params(['form', 'screenid', 'templateid'])), new CButtonCancel(url_param('templateid'))])); } else { $tabs->setFooter(makeFormFooter(new CSubmit('add', _('Add')), [new CButtonCancel(url_param('templateid'))])); } $form->addItem($tabs); $widget->addItem($form); return $widget;
if (!empty($data['hostid'])) { $triggersWidget->addItem(get_header_host_table('triggers', $data['hostid'])); } // create form $triggersForm = (new CForm())->setName('triggersForm')->addVar('hostid', $data['hostid'])->addVar('action', $data['action']); foreach ($data['g_triggerid'] as $triggerid) { $triggersForm->addVar('g_triggerid[' . $triggerid . ']', $triggerid); } $triggersFormList = (new CFormList('triggersFormList'))->addRow([_('Severity'), SPACE, (new CVisibilityBox('visible[priority]', 'priority_div', _('Original')))->setChecked(isset($data['visible']['priority']))], (new CDiv(new CSeverity(['name' => 'priority', 'value' => (int) $data['priority']])))->setId('priority_div')); // append dependencies to form list $dependenciesTable = (new CTable())->setAttribute('style', 'width: 100%;')->setHeader([_('Name'), _('Action')]); foreach ($data['dependencies'] as $dependency) { $triggersForm->addVar('dependencies[]', $dependency['triggerid'], 'dependencies_' . $dependency['triggerid']); $depTriggerDescription = CHtml::encode(implode(', ', zbx_objectValues($dependency['hosts'], 'name')) . NAME_DELIMITER . $dependency['description']); if ($dependency['flags'] == ZBX_FLAG_DISCOVERY_NORMAL) { $description = (new CLink($depTriggerDescription, 'triggers.php?form=update&triggerid=' . $dependency['triggerid']))->setAttribute('target', '_blank'); } else { $description = $depTriggerDescription; } $dependenciesTable->addRow((new CRow([$description, (new CCol((new CButton('remove', _('Remove')))->onClick('javascript: removeDependency(\'' . $dependency['triggerid'] . '\');')->addClass(ZBX_STYLE_BTN_LINK)))->addClass(ZBX_STYLE_NOWRAP)]))->setId('dependency_' . $dependency['triggerid'])); } $dependenciesDiv = (new CDiv([$dependenciesTable, (new CButton('btn1', _('Add')))->onClick('return PopUp("popup.php?dstfrm=massupdate&dstact=add_dependency&reference=deptrigger' . '&dstfld1=new_dependency&srctbl=triggers&objname=triggers&srcfld1=triggerid&multiselect=1' . '&with_triggers=1&noempty=1");')->addClass(ZBX_STYLE_BTN_LINK)]))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_BIG_WIDTH . 'px;')->setId('dependencies_div'); $triggersFormList->addRow([_('Replace dependencies'), SPACE, (new CVisibilityBox('visible[dependencies]', 'dependencies_div', _('Original')))->setChecked(isset($data['visible']['dependencies']))], $dependenciesDiv); $triggersTab = new CTabView(); $triggersTab->addTab('triggersTab', _('Mass update'), $triggersFormList); // append buttons to form $triggersTab->setFooter(makeFormFooter(new CSubmit('massupdate', _('Update')), [new CButtonCancel(url_param('hostid'))])); // append tabs to form $triggersForm->addItem($triggersTab); $triggersWidget->addItem($triggersForm); return $triggersWidget;
$user_groupid = $user_group['usrgrpid']; if (array_key_exists($user_groupid, $data['user_groups'])) { $user_groups[$user_groupid] = ['usrgrpid' => $user_groupid, 'name' => $data['user_groups'][$user_groupid]['name'], 'permission' => $user_group['permission']]; } } $js_insert = 'addPopupValues(' . zbx_jsvalue(['object' => 'usrgrpid', 'values' => $user_groups]) . ');'; // User sharing table. $user_shares_table = (new CTable())->setHeader([_('Users'), _('Permissions'), _('Action')])->setAttribute('style', 'width: 100%;'); $add_user_btn = [(new CButton(null, _('Add')))->onClick('return PopUp("popup.php?dstfrm=' . $form->getName() . '&srctbl=users&srcfld1=userid&srcfld2=fullname&multiselect=1")')->addClass(ZBX_STYLE_BTN_LINK)]; $user_shares_table->addRow((new CRow((new CCol($add_user_btn))->setColSpan(3)))->setId('user_list_footer')); $users = []; foreach ($data['slideshow']['users'] as $user) { $userid = $user['userid']; if (array_key_exists($userid, $data['users'])) { $users[$userid] = ['id' => $userid, 'name' => getUserFullname($data['users'][$userid]), 'permission' => $user['permission']]; } } $js_insert .= 'addPopupValues(' . zbx_jsvalue(['object' => 'userid', 'values' => $users]) . ');'; zbx_add_post_js($js_insert); $sharing_tab = (new CFormList('sharing_form'))->addRow(_('Type'), (new CRadioButtonList('private', (int) $data['slideshow']['private']))->addValue(_('Private'), PRIVATE_SHARING)->addValue(_('Public'), PUBLIC_SHARING)->setModern(true))->addRow(_('List of user group shares'), (new CDiv($user_group_shares_table))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_STANDARD_WIDTH . 'px;'))->addRow(_('List of user shares'), (new CDiv($user_shares_table))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_STANDARD_WIDTH . 'px;')); // Append data to form. $tabs->addTab('sharing_tab', _('Sharing'), $sharing_tab); // append buttons to form if (isset($data['slideshow']['slideshowid'])) { $tabs->setFooter(makeFormFooter(new CSubmit('update', _('Update')), [new CSubmit('clone', _('Clone')), new CButtonDelete(_('Delete slide show?'), url_params(['form', 'slideshowid'])), new CRedirectButton(_('Cancel'), 'slides.php')])); } else { $tabs->setFooter(makeFormFooter(new CSubmit('add', _('Add')), [new CButtonCancel()])); } $form->addItem($tabs); $widget->addItem($form); return $widget;
$exp_delimiter->addStyle('display: none;'); } $row = [(new CComboBox('expressions[' . $i . '][expression_type]', $expression['expression_type'], null, expression_type2str()))->onChange('onChangeExpressionType(this, ' . $i . ')'), (new CTextBox('expressions[' . $i . '][expression]', $expression['expression'], false, 255))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH), $exp_delimiter, (new CCheckBox('expressions[' . $i . '][case_sensitive]', '1'))->setChecked($expression['case_sensitive'])]; $button_cell = [(new CButton('expressions[' . $i . '][remove]', _('Remove')))->addClass(ZBX_STYLE_BTN_LINK)->addClass('element-table-remove')]; if (array_key_exists('expressionid', $expression)) { $button_cell[] = new CVar('expressions[' . $i . '][expressionid]', $expression['expressionid']); } $row[] = (new CCol($button_cell))->addClass(ZBX_STYLE_NOWRAP); $exprTable->addRow((new CRow($row))->addClass('form_row')->setAttribute('data-index', $i)); } $exprTable->setFooter((new CButton('expression_add', _('Add')))->addClass(ZBX_STYLE_BTN_LINK)->addClass('element-table-add')); $exprTab = (new CFormList('exprTab'))->addRow(_('Name'), (new CTextBox('name', $data['name'], false, 128))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)->setAttribute('autofocus', 'autofocus'))->addRow(_('Expressions'), (new CDiv($exprTable))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_BIG_WIDTH . 'px;')); /* * Test tab */ $testTab = (new CFormList())->addRow(_('Test string'), (new CTextArea('test_string', $data['test_string']))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH))->addRow('', (new CButton('testExpression', _('Test expressions')))->addClass(ZBX_STYLE_BTN_ALT))->addRow(_('Result'), (new CDiv((new CTable())->setId('testResultTable')->setAttribute('style', 'width: 100%;')->setHeader([_('Expression type'), _('Expression'), _('Result')])))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_BIG_WIDTH . 'px;')); $regExpView = new CTabView(); if (!$data['form_refresh']) { $regExpView->setSelected(0); } $regExpView->addTab('expr', _('Expressions'), $exprTab); $regExpView->addTab('test', _('Test'), $testTab); // footer if (isset($data['regexpid'])) { $regExpView->setFooter(makeFormFooter(new CSubmit('update', _('Update')), [new CButton('clone', _('Clone')), new CButtonDelete(_('Delete regular expression?'), url_param('regexpid') . url_param('regexp.massdelete', false, 'action')), new CButtonCancel()])); } else { $regExpView->setFooter(makeFormFooter(new CSubmit('add', _('Add')), [new CButtonCancel()])); } $form->addItem($regExpView); $widget->addItem($form); return $widget;
$permissionsFormList->addRow(_('User type'), [$userTypeComboBox, SPACE, new CSpan(_('User can\'t change type for himself'))]); $userForm->addVar('user_type', $this->data['user_type']); } else { $permissionsFormList->addRow(_('User type'), $userTypeComboBox); } $permissionsFormList = getPermissionsFormList($this->data['user_rights'], $this->data['user_type'], $permissionsFormList); $permissionsFormList->addInfo(_('Permissions can be assigned for user groups only.')); $userTab->addTab('permissionsTab', _('Permissions'), $permissionsFormList); } if (isset($userMessagingFormList)) { $userTab->addTab('messagingTab', _('Messaging'), $userMessagingFormList); } // append buttons to form if ($data['userid'] != 0) { $buttons = [new CButtonCancel()]; if (!$this->data['is_profile']) { $deleteButton = new CButtonDelete(_('Delete selected user?'), url_param('form') . url_param('userid')); if (bccomp(CWebUser::$data['userid'], $data['userid']) == 0) { $deleteButton->setAttribute('disabled', 'disabled'); } array_unshift($buttons, $deleteButton); } $userTab->setFooter(makeFormFooter(new CSubmit('update', _('Update')), $buttons)); } else { $userTab->setFooter(makeFormFooter(new CSubmit('add', _('Add')), [new CButtonCancel()])); } // append tab to form $userForm->addItem($userTab); // append form to widget $userWidget->addItem($userForm); return $userWidget;
// add new or existing applications $appToAdd = null; if (hasRequest('new_applications')) { foreach (getRequest('new_applications') as $newApplication) { if (is_array($newApplication) && isset($newApplication['new'])) { $appToAdd[] = ['id' => $newApplication['new'], 'name' => $newApplication['new'] . ' (' . _x('new', 'new element in multiselect') . ')', 'isNew' => true]; } else { $appToAddId[] = $newApplication; } } if (isset($appToAddId)) { $getApps = API::Application()->get(['applicationids' => $appToAddId, 'output' => ['applicationid', 'name']]); foreach ($getApps as $getApp) { $appToAdd[] = ['id' => $getApp['applicationid'], 'name' => $getApp['name']]; } } } $newApp = (new CDiv((new CMultiSelect(['name' => 'new_applications[]', 'objectName' => 'applications', 'objectOptions' => ['hostid' => $this->data['hostid']], 'data' => $appToAdd, 'addNew' => true, 'popup' => ['parameters' => 'srctbl=applications&dstfrm=' . $itemForm->getName() . '&dstfld1=new_applications_' . '&srcfld1=applicationid&multiselect=1&noempty=1&hostid=' . $this->data['hostid']]]))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)))->setId('newApp'); $itemFormList->addRow([_('Add new or existing applications'), SPACE, (new CVisibilityBox('visible[new_applications]', 'newApp', _('Original')))->setChecked(isset($this->data['visible']['new_applications']))], $newApp); } // append description to form list $itemFormList->addRow([_('Description'), SPACE, (new CVisibilityBox('visible[description]', 'description', _('Original')))->setChecked(isset($this->data['visible']['description']))], (new CTextArea('description', $this->data['description']))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)); // append tabs to form $itemTab = new CTabView(); $itemTab->addTab('itemTab', _('Mass update'), $itemFormList); // append buttons to form $itemTab->setFooter(makeFormFooter(new CSubmit('massupdate', _('Update')), [new CButtonCancel(url_param('groupid') . url_param('hostid'))])); $itemForm->addItem($itemTab); $itemWidget->addItem($itemForm); require_once dirname(__FILE__) . '/js/configuration.item.massupdate.js.php'; return $itemWidget;
$templateLink = (new CLink($template['name'], 'templates.php?form=update&templateid=' . $template['templateid']))->setTarget('_blank'); $linkedTemplateTable->addRow([$templateLink, (new CCol(new CHorList([(new CSubmit('unlink[' . $template['templateid'] . ']', _('Unlink')))->addClass(ZBX_STYLE_BTN_LINK), array_key_exists($template['templateid'], $data['original_templates']) && !$cloneOrFullClone ? (new CSubmit('unlink_and_clear[' . $template['templateid'] . ']', _('Unlink and clear')))->addClass(ZBX_STYLE_BTN_LINK) : null])))->addClass(ZBX_STYLE_NOWRAP)], null, 'conditions_' . $template['templateid']); $ignoredTemplates[$template['templateid']] = $template['name']; } foreach ($data['hostIdsLinkedTo'] as $templateid) { $ignoredTemplates[$templateid] = ''; } $tmplList->addRow(_('Linked templates'), (new CDiv($linkedTemplateTable))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_BIG_WIDTH . 'px;')); // create new linked template table $newTemplateTable = (new CTable())->addRow([(new CMultiSelect(['name' => 'add_templates[]', 'objectName' => 'templates', 'ignored' => $ignoredTemplates, 'popup' => ['parameters' => 'srctbl=templates&srcfld1=hostid&srcfld2=host&dstfrm=' . $frmHost->getName() . '&dstfld1=add_templates_&templated_hosts=1&multiselect=1&templateid=' . $data['templateId']]]))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)])->addRow([(new CSubmit('add_template', _('Add')))->addClass(ZBX_STYLE_BTN_LINK)]); $tmplList->addRow(_('Link new templates'), (new CDiv($newTemplateTable))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_BIG_WIDTH . 'px;')); $divTabs->addTab('tmplTab', _('Linked templates'), $tmplList); // } TEMPLATES // macros if (!$macros) { $macro = ['macro' => '', 'value' => '']; if ($data['show_inherited_macros']) { $macro['type'] = MACRO_TYPE_HOSTMACRO; } $macros[] = $macro; } $macrosView = new CView('hostmacros', ['macros' => $macros, 'show_inherited_macros' => $data['show_inherited_macros'], 'is_template' => true, 'readonly' => false]); $divTabs->addTab('macroTab', _('Macros'), $macrosView->render()); // Footer if ($data['templateId'] != 0 && $data['form'] !== 'full_clone') { $divTabs->setFooter(makeFormFooter(new CSubmit('update', _('Update')), [new CSubmit('clone', _('Clone')), new CSubmit('full_clone', _('Full clone')), new CButtonDelete(_('Delete template?'), url_param('form') . url_param('templateid') . url_param('groupid')), new CButtonQMessage('delete_and_clear', _('Delete and clear'), _('Delete and clear template? (Warning: all linked hosts will be cleared!)'), url_param('form') . url_param('templateid') . url_param('groupid')), new CButtonCancel(url_param('groupid'))])); } else { $divTabs->setFooter(makeFormFooter(new CSubmit('add', _('Add')), [new CButtonCancel(url_param('groupid'))])); } $frmHost->addItem($divTabs); return $frmHost;
$form_list->addRow(_('Hide selected groups'), (new CMultiSelect(['name' => 'hidegroupids[]', 'objectName' => 'hostGroup', 'data' => $this->data['hideGroups'], 'disabled' => !$this->data['isFilterEnable'], 'popup' => ['parameters' => 'srctbl=host_groups&dstfrm=' . $form->getName() . '&dstfld1=hidegroupids_' . '&srcfld1=groupid&multiselect=1']]))->setWidth(ZBX_TEXTAREA_FILTER_STANDARD_WIDTH)); } // append host in maintenance checkbox to form list $maintenanceCheckBox = (new CCheckBox('maintenance'))->setChecked($this->data['maintenance'] == 1); if (!$this->data['isFilterEnable']) { $maintenanceCheckBox->setAttribute('disabled', 'disabled'); } $form_list->addRow(_('Hosts'), new CLabel([$maintenanceCheckBox, _('Show hosts in maintenance')], 'maintenance')); // append trigger severities to form list $severities = []; foreach ($this->data['severities'] as $severity) { $serverityCheckBox = (new CCheckBox('trgSeverity[' . $severity . ']'))->setChecked(isset($this->data['severity'][$severity]))->setEnabled($this->data['isFilterEnable']); $severities[] = new CLabel([$serverityCheckBox, getSeverityName($severity, $this->data['config'])], 'trgSeverity[' . $severity . ']'); $severities[] = BR(); } array_pop($severities); $form_list->addRow(_('Triggers with severity'), $severities); $form_list->addRow(_('Trigger name like'), (new CTextBox('trigger_name', $data['trigger_name']))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)->setEnabled($data['isFilterEnable'])); if ($data['config']['event_ack_enable']) { // append problem display to form list $ext_ack_combobox = new CComboBox('extAck', $data['extAck'], null, [EXTACK_OPTION_ALL => _('All'), EXTACK_OPTION_BOTH => _('Separated'), EXTACK_OPTION_UNACK => _('Unacknowledged only')]); $ext_ack_combobox->setEnabled($data['isFilterEnable']); $form_list->addRow(_('Problem display'), $ext_ack_combobox); } // create tab $tab = new CTabView(); $tab->addTab('dashconfTab', _('Filter'), $form_list); $tab->setFooter(makeFormFooter(new CSubmit('update', _('Update')), [new CButtonCancel()])); $form->addItem($tab); $widget->addItem($form); return $widget;
$screenFormList->addRow(_('Width'), (new CNumericBox('width', $width, 5))->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH)); $screenFormList->addRow(_('Height'), (new CNumericBox('height', $height, 5))->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH)); } else { $form->addVar('width', 500)->addVar('height', 100); } $resourcesWithHAlign = [SCREEN_RESOURCE_GRAPH, SCREEN_RESOURCE_SIMPLE_GRAPH, SCREEN_RESOURCE_MAP, SCREEN_RESOURCE_CLOCK, SCREEN_RESOURCE_URL, SCREEN_RESOURCE_LLD_GRAPH, SCREEN_RESOURCE_LLD_SIMPLE_GRAPH]; if (in_array($resourceType, $resourcesWithHAlign)) { $screenFormList->addRow(_('Horizontal align'), (new CRadioButtonList('halign', (int) $halign))->addValue(_('Left'), HALIGN_LEFT)->addValue(_('Center'), HALIGN_CENTER)->addValue(_('Right'), HALIGN_RIGHT)->setModern(true)); } else { $form->addVar('halign', 0); } $screenFormList->addRow(_('Vertical align'), (new CRadioButtonList('valign', (int) $valign))->addValue(_('Top'), VALIGN_TOP)->addValue(_('Middle'), VALIGN_MIDDLE)->addValue(_('Bottom'), VALIGN_BOTTOM)->setModern(true)); $screenFormList->addRow(_('Column span'), (new CNumericBox('colspan', $colspan, 3))->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH)); $screenFormList->addRow(_('Row span'), (new CNumericBox('rowspan', $rowspan, 3))->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH)); // dynamic addon $resourcesWithDynamic = [SCREEN_RESOURCE_GRAPH, SCREEN_RESOURCE_SIMPLE_GRAPH, SCREEN_RESOURCE_PLAIN_TEXT, SCREEN_RESOURCE_URL, SCREEN_RESOURCE_LLD_GRAPH, SCREEN_RESOURCE_LLD_SIMPLE_GRAPH]; if ($this->data['screen']['templateid'] == 0 && in_array($resourceType, $resourcesWithDynamic)) { $screenFormList->addRow(_('Dynamic item'), (new CCheckBox('dynamic'))->setChecked($dynamic == 1)); } // append tabs to form $screenTab = new CTabView(); $screenTab->setAttribute('style', 'text-align: left;'); $screenTab->addTab('screenTab', _('Screen cell configuration'), $screenFormList); // append buttons to form if (isset($_REQUEST['screenitemid'])) { $screenTab->setFooter(makeFormFooter(new CSubmit('update', _('Update')), [new CButtonDelete(null, url_params(['form', 'screenid', 'templateid', 'screenitemid'])), new CButtonCancel(url_params(['screenid', 'templateid']))])); } else { $screenTab->setFooter(makeFormFooter(new CSubmit('add', _('Add')), [new CButtonCancel(url_params(['screenid', 'templateid']))])); } $form->addItem($screenTab); return $form;
/* * Dependencies tab */ $dependenciesFormList = new CFormList('dependenciesFormList'); $dependenciesTable = (new CTable())->setAttribute('style', 'width: 100%;')->setHeader([_('Name'), _('Action')]); foreach ($this->data['db_dependencies'] as $dependency) { $triggersForm->addVar('dependencies[]', $dependency['triggerid'], 'dependencies_' . $dependency['triggerid']); $depTriggerDescription = CHtml::encode(implode(', ', zbx_objectValues($dependency['hosts'], 'name')) . NAME_DELIMITER . $dependency['description']); if ($dependency['flags'] == ZBX_FLAG_DISCOVERY_NORMAL) { $description = (new CLink($depTriggerDescription, 'triggers.php?form=update&triggerid=' . $dependency['triggerid']))->setAttribute('target', '_blank'); } else { $description = $depTriggerDescription; } $dependenciesTable->addRow((new CRow([$description, (new CCol((new CButton('remove', _('Remove')))->onClick('javascript: removeDependency("' . $dependency['triggerid'] . '");')->addClass(ZBX_STYLE_BTN_LINK)))->addClass(ZBX_STYLE_NOWRAP)]))->setId('dependency_' . $dependency['triggerid'])); } $dependenciesFormList->addRow(_('Dependencies'), (new CDiv([$dependenciesTable, (new CButton('bnt1', _('Add')))->onClick('return PopUp("popup.php?srctbl=triggers&srcfld1=triggerid&reference=deptrigger&multiselect=1' . '&with_triggers=1&noempty=1");')->addClass(ZBX_STYLE_BTN_LINK)]))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_BIG_WIDTH . 'px;')); $triggersTab->addTab('dependenciesTab', _('Dependencies'), $dependenciesFormList); // append buttons to form if (!empty($this->data['triggerid'])) { $deleteButton = new CButtonDelete(_('Delete trigger?'), url_params(['form', 'hostid', 'triggerid'])); if ($this->data['limited']) { $deleteButton->setAttribute('disabled', 'disabled'); } $triggersTab->setFooter(makeFormFooter(new CSubmit('update', _('Update')), [new CSubmit('clone', _('Clone')), $deleteButton, new CButtonCancel(url_param('hostid'))])); } else { $triggersTab->setFooter(makeFormFooter(new CSubmit('add', _('Add')), [new CButtonCancel(url_param('hostid'))])); } // append tabs to form $triggersForm->addItem($triggersTab); $widget->addItem($triggersForm); return $widget;
$inventory_item = (new CSpan([' ← ', $link]))->addClass('populating_item'); if ($data['inventory_mode'] != HOST_INVENTORY_AUTOMATIC) { // those links are visible only in automatic mode $inventory_item->addStyle('display: none'); } // this will be used for disabling fields via jquery $input->addClass('linked_to_item'); if ($data['inventory_mode'] == HOST_INVENTORY_AUTOMATIC) { $input->setAttribute('disabled', 'disabled'); } } else { $inventory_item = null; } $inventoryFormList->addRow($inventoryInfo['title'], [$input, $inventory_item]); } $divTabs->addTab('inventoryTab', _('Host inventory'), $inventoryFormList); // Encryption form list. $encryption_form_list = (new CFormList('encryption'))->addRow(_('Connections to host'), (new CRadioButtonList('tls_connect', (int) $data['tls_connect']))->addValue(_('No encryption'), HOST_ENCRYPTION_NONE)->addValue(_('PSK'), HOST_ENCRYPTION_PSK)->addValue(_('Certificate'), HOST_ENCRYPTION_CERTIFICATE)->setModern(true)->setEnabled($data['flags'] != ZBX_FLAG_DISCOVERY_CREATED))->addRow(_('Connections from host'), [new CLabel([(new CCheckBox('tls_in_none'))->setEnabled($data['flags'] != ZBX_FLAG_DISCOVERY_CREATED), _('No encryption')]), BR(), new CLabel([(new CCheckBox('tls_in_psk'))->setEnabled($data['flags'] != ZBX_FLAG_DISCOVERY_CREATED), _('PSK')]), BR(), new CLabel([(new CCheckBox('tls_in_cert'))->setEnabled($data['flags'] != ZBX_FLAG_DISCOVERY_CREATED), _('Certificate')])])->addRow(_('PSK identity'), (new CTextBox('tls_psk_identity', $data['tls_psk_identity'], $data['flags'] == ZBX_FLAG_DISCOVERY_CREATED, 128))->setWidth(ZBX_TEXTAREA_BIG_WIDTH))->addRow(_('PSK'), (new CTextBox('tls_psk', $data['tls_psk'], $data['flags'] == ZBX_FLAG_DISCOVERY_CREATED, 512))->setWidth(ZBX_TEXTAREA_BIG_WIDTH))->addRow(_('Issuer'), (new CTextBox('tls_issuer', $data['tls_issuer'], $data['flags'] == ZBX_FLAG_DISCOVERY_CREATED, 1024))->setWidth(ZBX_TEXTAREA_BIG_WIDTH))->addRow(_x('Subject', 'encryption certificate'), (new CTextBox('tls_subject', $data['tls_subject'], $data['flags'] == ZBX_FLAG_DISCOVERY_CREATED, 1024))->setWidth(ZBX_TEXTAREA_BIG_WIDTH)); $divTabs->addTab('encryptionTab', _('Encryption'), $encryption_form_list); /* * footer */ // Do not display the clone and delete buttons for clone forms and new host forms. if ($data['hostid'] != 0) { $divTabs->setFooter(makeFormFooter(new CSubmit('update', _('Update')), [new CSubmit('clone', _('Clone')), new CSubmit('full_clone', _('Full clone')), new CButtonDelete(_('Delete selected host?'), url_param('form') . url_param('hostid') . url_param('groupid')), new CButtonCancel(url_param('groupid'))])); } else { $divTabs->setFooter(makeFormFooter(new CSubmit('add', _('Add')), [new CButtonCancel(url_param('groupid'))])); } $frmHost->addItem($divTabs); $widget->addItem($frmHost); return $widget;
if (isset($this->data['change_bind_password']) || zbx_empty($this->data['config']['ldap_bind_password'])) { $authenticationForm->addVar('change_bind_password', 1); $authenticationFormList->addRow(_('Bind password'), (new CPassBox('ldap_bind_password'))->setWidth(ZBX_TEXTAREA_SMALL_WIDTH)); } else { $authenticationFormList->addRow(_('Bind password'), (new CSubmit('change_bind_password', _('Change password')))->addClass(ZBX_STYLE_BTN_GREY)); } $authenticationFormList->addRow(_('Test authentication'), ' [' . _('must be a valid LDAP user') . ']'); $authenticationFormList->addRow(_('Login'), $userComboBox); $authenticationFormList->addRow(_('User password'), (new CPassBox('user_password'))->setWidth(ZBX_TEXTAREA_SMALL_WIDTH)); } // append form list to tab $authenticationTab = new CTabView(); $authenticationTab->addTab('authenticationTab', $this->data['title'], $authenticationFormList); // create save button $saveButton = new CSubmit('update', _('Update')); if ($this->data['is_authentication_type_changed']) { $saveButton->onClick('javascript: if (confirm(' . CJs::encodeJson(_('Switching authentication method will reset all except this session! Continue?')) . ')) {' . 'jQuery("#authenticationForm").submit(); return true; } else { return false; }'); } elseif ($this->data['config']['authentication_type'] != ZBX_AUTH_LDAP) { $saveButton->setAttribute('disabled', 'true'); } // append buttons to form if ($this->data['config']['authentication_type'] == ZBX_AUTH_LDAP) { $authenticationTab->setFooter(makeFormFooter($saveButton, [new CSubmit('test', _('Test'))])); } else { $authenticationTab->setFooter(makeFormFooter($saveButton)); } // append tab to form $authenticationForm->addItem($authenticationTab); // append form to widget $widget->addItem($authenticationForm); return $widget;
$timeFromHourTextBox = (new CTextBox('new_service_time[from_hour]', isset($_REQUEST['new_service_time']['from_hour']) ? $_REQUEST['new_service_time']['from_hour'] : '', false, 2))->setWidth(ZBX_TEXTAREA_2DIGITS_WIDTH)->setAttribute('placeholder', _('hh')); $timeFromMinuteTextBox = (new CTextBox('new_service_time[from_minute]', isset($_REQUEST['new_service_time']['from_minute']) ? $_REQUEST['new_service_time']['from_minute'] : '', false, 2))->setWidth(ZBX_TEXTAREA_2DIGITS_WIDTH)->setAttribute('placeholder', _('mm')); $timeToHourTextBox = (new CTextBox('new_service_time[to_hour]', isset($_REQUEST['new_service_time']['to_hour']) ? $_REQUEST['new_service_time']['to_hour'] : '', false, 2))->setWidth(ZBX_TEXTAREA_2DIGITS_WIDTH)->setAttribute('placeholder', _('hh')); $timeToMinuteTextBox = (new CTextBox('new_service_time[to_minute]', isset($_REQUEST['new_service_time']['to_minute']) ? $_REQUEST['new_service_time']['to_minute'] : '', false, 2))->setWidth(ZBX_TEXTAREA_2DIGITS_WIDTH)->setAttribute('placeholder', _('mm')); $serviceTimeTable->addRow([_('From'), [$weekFromComboBox, (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), _('Time'), (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), $timeFromHourTextBox, (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), ':', (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), $timeFromMinuteTextBox]]); $serviceTimeTable->addRow([_('Till'), [$weekToComboBox, (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), _('Time'), (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), $timeToHourTextBox, (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), ':', (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), $timeToMinuteTextBox]]); $servicesForm->addVar('new_service_time[note]', ''); } $servicesTimeFormList->addRow(_('New service time'), (new CDiv([$serviceTimeTable, (new CButton('add_service_time', _('Add')))->addClass(ZBX_STYLE_BTN_LINK)]))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_BIG_WIDTH . 'px;')); /* * Append tabs to form */ $servicesTab = new CTabView(); if (!$this->data['form_refresh']) { $servicesTab->setSelected(0); } $servicesTab->addTab('servicesTab', _('Service'), $servicesFormList)->addTab('servicesDependenciesTab', _('Dependencies'), $servicesDependenciesFormList)->addTab('servicesTimeTab', _('Time'), $servicesTimeFormList); // append buttons to form if ($service['serviceid']) { $buttons = [new CButtonCancel()]; if (!$service['dependencies']) { array_unshift($buttons, new CButtonDelete('Delete selected service?', url_param('form') . url_param('serviceid') . '&saction=1')); } $servicesTab->setFooter(makeFormFooter((new CSubmit('update', _('Update')))->onClick('javascript: document.forms[0].action += \'?saction=1\';'), $buttons)); } else { $servicesTab->setFooter(makeFormFooter((new CSubmit('add', _('Add')))->onClick('javascript: document.forms[0].action += \'?saction=1\';'), [new CButtonCancel()])); } $servicesForm->addItem($servicesTab); // append form to widget $widget->addItem($servicesForm); return $widget;