// header $configForm = new CForm('get'); $configComboBox = new CComboBox('config', 'auditacts.php'); $configComboBox->setAttribute('onchange', 'javascript: redirect(this.options[this.selectedIndex].value);'); $configComboBox->addItem('auditlogs.php', _('Logs')); $configComboBox->addItem('auditacts.php', _('Actions')); $configForm->addItem($configComboBox); $auditWidget->addPageHeader(_('AUDIT ACTIONS'), $configForm); $auditWidget->addHeader(_('Actions')); $auditWidget->addHeaderRowNumber(); // create filter $filterForm = new CForm('get'); $filterForm->setAttribute('name', 'zbx_filter'); $filterForm->setAttribute('id', 'zbx_filter'); $filterTable = new CTable('', 'filter'); $filterTable->addRow(array(array(bold(_('Recipient')), SPACE, new CTextBox('alias', $this->data['alias'], 20), new CButton('btn1', _('Select'), 'return PopUp(\'popup.php?dstfrm=' . $filterForm->getName() . '&dstfld1=alias&srctbl=users&srcfld1=alias&real_hosts=1\');', 'T')))); $filterButton = new CButton('filter', _('Filter'), "javascript: create_var('zbx_filter', 'filter_set', '1', true);"); $filterButton->useJQueryStyle('main'); $resetButton = new CButton('filter_rst', _('Reset'), 'javascript: var uri = new Curl(location.href); uri.setArgument("filter_rst", 1); location.href = uri.getUrl();'); $resetButton->useJQueryStyle(); $buttonsDiv = new CDiv(array($filterButton, SPACE, $resetButton)); $buttonsDiv->setAttribute('style', 'padding: 4px 0px;'); $filterTable->addRow(new CCol($buttonsDiv, 'controls')); $filterForm->addItem($filterTable); $auditWidget->addFlicker($filterForm, CProfile::get('web.auditacts.filter.state', 1)); $auditWidget->addFlicker(new CDiv(null, null, 'scrollbar_cntr'), CProfile::get('web.auditacts.filter.state', 1)); // create form $auditForm = new CForm('get'); $auditForm->setName('auditForm'); // create table $auditTable = new CTableInfo(_('No actions defined.'));
$itemsWidget->addPageHeader(_('CONFIGURATION OF ITEM PROTOTYPES'), $createForm); // header $itemsWidget->addHeader(array(_('Item prototypes of') . SPACE, new CSpan($this->data['discovery_rule']['name'], 'parent-discovery'))); $itemsWidget->addHeaderRowNumber(); $itemsWidget->addItem(get_header_host_table('items', $this->data['hostid'], $this->data['parent_discoveryid'])); // create form $itemForm = new CForm(); $itemForm->setName('items'); $itemForm->addVar('hostid', $this->data['hostid']); $itemForm->addVar('parent_discoveryid', $this->data['parent_discoveryid']); // create table $itemTable = new CTableInfo(_('No item prototypes found.')); $sortLink = new CUrl(); $sortLink->setArgument('parent_discoveryid', $this->data['parent_discoveryid']); $sortLink = $sortLink->getUrl(); $itemTable->setHeader(array(new CCheckBox('all_items', null, "checkAll('" . $itemForm->getName() . "', 'all_items', 'group_itemid');"), make_sorting_header(_('Name'), 'name', $sortLink), make_sorting_header(_('Key'), 'key_', $sortLink), make_sorting_header(_('Interval'), 'delay', $sortLink), make_sorting_header(_('History'), 'history', $sortLink), make_sorting_header(_('Trends'), 'trends', $sortLink), make_sorting_header(_('Type'), 'type', $sortLink), _('Applications'), make_sorting_header(_('Status'), 'status', $sortLink))); foreach ($this->data['items'] as $item) { $description = array(); if (!empty($item['templateid'])) { $template_host = get_realhost_by_itemid($item['templateid']); $templateDiscoveryRuleId = get_realrule_by_itemid_and_hostid($this->data['parent_discoveryid'], $template_host['hostid']); $description[] = new CLink($template_host['name'], '?parent_discoveryid=' . $templateDiscoveryRuleId, 'unknown'); $description[] = NAME_DELIMITER; } $description[] = new CLink($item['name_expanded'], '?form=update&itemid=' . $item['itemid'] . '&parent_discoveryid=' . $this->data['parent_discoveryid']); $status = new CLink(itemIndicator($item['status']), '?group_itemid=' . $item['itemid'] . '&parent_discoveryid=' . $this->data['parent_discoveryid'] . '&go=' . ($item['status'] ? 'activate' : 'disable'), itemIndicatorStyle($item['status'])); if (!empty($item['applications'])) { order_result($item['applications'], 'name'); $applications = zbx_objectValues($item['applications'], 'name'); $applications = implode(', ', $applications); if (empty($applications)) {
** along with this program; if not, write to the Free Software ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ $mediaTypeWidget = new CWidget(); // create new media type button $createForm = new CForm('get'); $createForm->addItem(new CSubmit('form', _('Create media type'))); $mediaTypeWidget->addPageHeader(_('CONFIGURATION OF MEDIA TYPES'), $createForm); $mediaTypeWidget->addHeader(_('Media types')); $mediaTypeWidget->addHeaderRowNumber(); // create form $mediaTypeForm = new CForm(); $mediaTypeForm->setName('mediaTypesForm'); // create table $mediaTypeTable = new CTableInfo(_('No media types found.')); $mediaTypeTable->setHeader(array(new CCheckBox('all_media_types', null, "checkAll('" . $mediaTypeForm->getName() . "', 'all_media_types', 'mediatypeids');"), $this->data['displayNodes'] ? _('Node') : null, make_sorting_header(_('Name'), 'description'), make_sorting_header(_('Type'), 'type'), _('Status'), _('Used in actions'), _('Details'))); foreach ($this->data['mediatypes'] as $mediaType) { switch ($mediaType['typeid']) { case MEDIA_TYPE_EMAIL: $details = _('SMTP server') . NAME_DELIMITER . '"' . $mediaType['smtp_server'] . '", ' . _('SMTP helo') . NAME_DELIMITER . '"' . $mediaType['smtp_helo'] . '", ' . _('SMTP email') . NAME_DELIMITER . '"' . $mediaType['smtp_email'] . '"'; break; case MEDIA_TYPE_EXEC: $details = _('Script name') . NAME_DELIMITER . '"' . $mediaType['exec_path'] . '"'; break; case MEDIA_TYPE_SMS: $details = _('GSM modem') . NAME_DELIMITER . '"' . $mediaType['gsm_modem'] . '"'; break; case MEDIA_TYPE_JABBER: $details = _('Jabber identifier') . NAME_DELIMITER . '"' . $mediaType['username'] . '"'; break; case MEDIA_TYPE_EZ_TEXTING:
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ $proxyWidget = new CWidget(); // create new proxy button $createForm = new CForm('get'); $createForm->cleanItems(); $createForm->addItem(new CSubmit('form', _('Create proxy'))); $proxyWidget->addPageHeader(_('CONFIGURATION OF PROXIES'), $createForm); $proxyWidget->addHeader(_('Proxies')); $proxyWidget->addHeaderRowNumber(); // create form $proxyForm = new CForm('get'); $proxyForm->setName('proxyForm'); // create table $proxyTable = new CTableInfo(_('No proxies found.')); $proxyTable->setHeader(array(new CCheckBox('all_hosts', null, "checkAll('" . $proxyForm->getName() . "', 'all_hosts', 'hosts');"), make_sorting_header(_('Name'), 'host', $this->data['sort'], $this->data['sortorder']), _('Mode'), _('Last seen (age)'), _('Host count'), _('Item count'), _('Required performance (vps)'), _('Hosts'))); foreach ($this->data['proxies'] as $proxy) { $hosts = array(); if (!empty($proxy['hosts'])) { $i = 1; foreach ($proxy['hosts'] as $host) { if ($i > $this->data['config']['max_in_table']) { $hosts[] = ' …'; break; } $i++; if ($host['status'] == HOST_STATUS_MONITORED) { $style = 'off'; } elseif ($host['status'] == HOST_STATUS_TEMPLATE) { $style = 'unknown'; } else {
$form = new CForm(); $form->SetMethod('get'); $form->AddItem(new CButton("form", S_CREATE_MAP)); show_table_header(S_CONFIGURATION_OF_NETWORK_MAPS, $form); echo SBR; if (isset($_REQUEST["form"])) { insert_map_form(); } else { $form = new CForm(); $form->setName('frm_maps'); $numrows = new CSpan(null, 'info'); $numrows->setAttribute('name', 'numrows'); $header = get_table_header(array(S_MAPS_BIG, new CSpan(SPACE . SPACE . '|' . SPACE . SPACE, 'divider'), S_FOUND . ': ', $numrows)); show_table_header($header); $table = new CTableInfo(S_NO_MAPS_DEFINED); $table->SetHeader(array(new CCheckBox('all_maps', NULL, "checkAll('" . $form->getName() . "','all_maps','maps');"), make_sorting_link(S_NAME, 'sm.name'), make_sorting_link(S_WIDTH, 'sm.width'), make_sorting_link(S_HEIGHT, 'sm.height'), S_MAP)); $result = DBselect('SELECT sm.sysmapid,sm.name,sm.width,sm.height ' . ' FROM sysmaps sm' . ' WHERE ' . DBin_node('sm.sysmapid') . order_by('sm.name,sm.width,sm.height', 'sm.sysmapid')); while ($row = DBfetch($result)) { if (!sysmap_accessible($row["sysmapid"], PERM_READ_WRITE)) { continue; } $table->AddRow(array(new CCheckBox('maps[' . $row['sysmapid'] . ']', NULL, NULL, $row['sysmapid']), new CLink($row["name"], "sysmaps.php?form=update" . "&sysmapid=" . $row["sysmapid"] . "#form", 'action'), $row["width"], $row["height"], new CLink(S_EDIT, "sysmap.php?sysmapid=" . $row["sysmapid"]))); } //----- GO ------ $goBox = new CComboBox('go'); $goBox->addItem('delete', S_DELETE_SELECTED); // goButton name is necessary!!! $goButton = new CButton('goButton', S_GO . ' (0)'); $goButton->setAttribute('id', 'goButton'); zbx_add_post_js('chkbxRange.pageGoName = "maps";'); $table->setFooter(new CCol(array($goBox, $goButton)));
**/ require_once dirname(__FILE__) . '/js/configuration.triggers.expression.js.php'; $expressionWidget = new CWidget(); // create form $expressionForm = new CForm(); $expressionForm->setName('expression'); $expressionForm->addVar('dstfrm', $this->data['dstfrm']); $expressionForm->addVar('dstfld1', $this->data['dstfld1']); $expressionForm->addVar('itemid', $this->data['itemid']); if (!empty($this->data['parent_discoveryid'])) { $expressionForm->addVar('parent_discoveryid', $this->data['parent_discoveryid']); } // create form list $expressionFormList = new CFormList('expressionFormList'); // append item to form list $item = array(new CTextBox('description', $this->data['description'], ZBX_TEXTBOX_STANDARD_SIZE, 'yes'), new CButton('select', _('Select'), 'return PopUp(\'popup.php?writeonly=1&dstfrm=' . $expressionForm->getName() . '&dstfld1=itemid&dstfld2=description&submitParent=1' . (!empty($this->data['parent_discoveryid']) ? '&normal_only=1' : '') . '&srctbl=items&srcfld1=itemid&srcfld2=name\', 0, 0, \'zbx_popup_item\');', 'formlist')); if (!empty($this->data['parent_discoveryid'])) { $item[] = new CButton('select', _('Select prototype'), 'return PopUp(\'popup.php?dstfrm=' . $expressionForm->getName() . '&dstfld1=itemid&dstfld2=description&submitParent=1' . url_param('parent_discoveryid', true) . '&srctbl=prototypes&srcfld1=itemid&srcfld2=name\', 0, 0, \'zbx_popup_item\');', 'formlist'); } $expressionFormList->addRow(_('Item'), $item); // append function to form list $functionComboBox = new CComboBox('expr_type', $this->data['expr_type'], 'submit()'); $functionComboBox->addStyle('width: 605px;'); foreach ($this->data['functions'] as $id => $f) { // if user has selected an item, we are filtering out the triggers that can't work with it if (empty($this->data['itemValueType']) || !empty($f['allowed_types'][$this->data['itemValueType']])) { $functionComboBox->addItem($id, $f['description']); } } $expressionFormList->addRow(_('Function'), $functionComboBox); if (isset($this->data['functions'][$this->data['function'] . '[' . $this->data['operator'] . ']']['params'])) {
// create new maintenance button $createForm = new CForm('get'); $createForm->cleanItems(); $createForm->addItem(new CSubmit('form', _('Create maintenance period'))); $maintenanceWidget->addPageHeader(_('CONFIGURATION OF MAINTENANCE PERIODS'), $createForm); // header $filterForm = new CForm('get'); $filterForm->addItem(array(_('Group') . SPACE, $this->data['pageFilter']->getGroupsCB(true))); $maintenanceWidget->addHeader(_('Maintenance periods'), $filterForm); $maintenanceWidget->addHeaderRowNumber(); // create form $maintenanceForm = new CForm(); $maintenanceForm->setName('maintenanceForm'); // create table $maintenanceTable = new CTableInfo(_('No maintenance periods found.')); $maintenanceTable->setHeader(array(new CCheckBox('all_maintenances', null, "checkAll('" . $maintenanceForm->getName() . "', 'all_maintenances', 'maintenanceids');"), $this->data['displayNodes'] ? _('Node') : null, make_sorting_header(_('Name'), 'name'), make_sorting_header(_('Type'), 'maintenance_type'), _('State'), _('Description'))); foreach ($this->data['maintenances'] as $maintenance) { $maintenanceid = $maintenance['maintenanceid']; switch ($maintenance['status']) { case MAINTENANCE_STATUS_EXPIRED: $maintenanceStatus = new CSpan(_x('Expired', 'maintenance status'), 'red'); break; case MAINTENANCE_STATUS_APPROACH: $maintenanceStatus = new CSpan(_x('Approaching', 'maintenance status'), 'blue'); break; case MAINTENANCE_STATUS_ACTIVE: $maintenanceStatus = new CSpan(_x('Active', 'maintenance status'), 'green'); break; } $maintenanceTable->addRow(array(new CCheckBox('maintenanceids[' . $maintenanceid . ']', null, null, $maintenanceid), $this->data['displayNodes'] ? $maintenance['nodename'] : null, new CLink($maintenance['name'], 'maintenance.php?form=update&maintenanceid=' . $maintenanceid), $maintenance['maintenance_type'] ? _('No data collection') : _('With data collection'), $maintenanceStatus, $maintenance['description'])); }
$caption = ''; $id = 0; $graphs = API::Graph()->get(array('graphids' => $resourceId, 'selectHosts' => array('hostid', 'name', 'status'), 'output' => API_OUTPUT_EXTEND)); if (!empty($graphs)) { $id = $resourceId; $graph = reset($graphs); order_result($graph['hosts'], 'name'); $graph['host'] = reset($graph['hosts']); $caption = $graph['host']['name'] . NAME_DELIMITER . $graph['name']; $nodeName = get_node_name_by_elid($graph['host']['hostid']); if (!zbx_empty($nodeName)) { $caption = '(' . $nodeName . ') ' . $caption; } } if ($this->data['screen']['templateid']) { $selectButton = new CButton('select', _('Select'), 'javascript: return PopUp("popup.php?srctbl=graphs&srcfld1=graphid&srcfld2=name' . '&dstfrm=' . $screenForm->getName() . '&dstfld1=resourceid&dstfld2=caption' . '&templated_hosts=1&only_hostid=' . $this->data['screen']['templateid'] . '&writeonly=1", 800, 450);', 'formlist'); } else { $selectButton = new CButton('select', _('Select'), 'javascript: return PopUp("popup.php?srctbl=graphs&srcfld1=graphid&srcfld2=name' . '&dstfrm=' . $screenForm->getName() . '&dstfld1=resourceid&dstfld2=caption' . '&real_hosts=1&with_graphs=1&writeonly=1", 800, 450);', 'formlist'); } $screenFormList->addVar('resourceid', $id); $screenFormList->addRow(_('Graph name'), array(new CTextBox('caption', $caption, ZBX_TEXTBOX_STANDARD_SIZE, 'yes'), $selectButton)); } elseif ($resourceType == SCREEN_RESOURCE_SIMPLE_GRAPH) { $caption = ''; $id = 0; $items = API::Item()->get(array('itemids' => $resourceId, 'selectHosts' => array('name'), 'output' => array('itemid', 'hostid', 'key_', 'name'))); if ($items) { $items = CMacrosResolverHelper::resolveItemNames($items); $id = $resourceId; $item = reset($items); $item['host'] = reset($item['hosts']); $caption = $item['host']['name'] . NAME_DELIMITER . $item['name_expanded'];
$createForm->addVar('templateid', $this->data['templateid']); $screenWidget->addItem(get_header_host_table('screens', $this->data['templateid'])); } else { $createForm->addItem(new CButton('form', _('Import'), 'redirect("conf.import.php?rules_preset=screen")')); } $screenWidget->addPageHeader(_('CONFIGURATION OF SCREENS'), $createForm); // header $screenWidget->addHeader(_('Screens')); $screenWidget->addHeaderRowNumber(); // create form $screenForm = new CForm(); $screenForm->setName('screenForm'); $screenForm->addVar('templateid', $this->data['templateid']); // create table $screenTable = new CTableInfo(_('No screens found.')); $screenTable->setHeader(array(new CCheckBox('all_screens', null, "checkAll('" . $screenForm->getName() . "', 'all_screens', 'screens');"), make_sorting_header(_('Name'), 'name', $this->data['sort'], $this->data['sortorder']), _('Dimension (cols x rows)'), _('Screen'))); foreach ($this->data['screens'] as $screen) { $screenTable->addRow(array(new CCheckBox('screens[' . $screen['screenid'] . ']', null, null, $screen['screenid']), new CLink($screen['name'], 'screenedit.php?screenid=' . $screen['screenid'] . url_param('templateid')), $screen['hsize'] . ' x ' . $screen['vsize'], new CLink(_('Edit'), '?form=update&screenid=' . $screen['screenid'] . url_param('templateid')))); } // create go button $goComboBox = new CComboBox('action'); if (empty($this->data['templateid'])) { $goComboBox->addItem('screen.export', _('Export selected')); } $goOption = new CComboItem('screen.massdelete', _('Delete selected')); $goOption->setAttribute('confirm', _('Delete selected screens?')); $goComboBox->addItem($goOption); $goButton = new CSubmit('goButton', _('Go') . ' (0)'); $goButton->setAttribute('id', 'goButton'); zbx_add_post_js('chkbxRange.pageGoName = "screens";'); // append table to form
** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ $scriptsWidget = new CWidget(); $createForm = new CForm('get'); $createForm->addItem(new CSubmit('form', _('Create script'))); $scriptsWidget->addPageHeader(_('CONFIGURATION OF SCRIPTS'), $createForm); $scriptsWidget->addHeader(_('Scripts')); $scriptsWidget->addHeaderRowNumber(); $scriptsForm = new CForm(); $scriptsForm->setName('scriptsForm'); $scriptsForm->setAttribute('id', 'scripts'); $scriptsTable = new CTableInfo(_('No scripts found.')); $scriptsTable->setHeader(array(new CCheckBox('all_scripts', null, "checkAll('" . $scriptsForm->getName() . "', 'all_scripts', 'scripts');"), make_sorting_header(_('Name'), 'name', $this->data['sort'], $this->data['sortorder']), _('Type'), _('Execute on'), make_sorting_header(_('Commands'), 'command', $this->data['sort'], $this->data['sortorder']), _('User group'), _('Host group'), _('Host access'))); foreach ($this->data['scripts'] as $script) { switch ($script['type']) { case ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT: $scriptType = _('Script'); break; case ZBX_SCRIPT_TYPE_IPMI: $scriptType = _('IPMI'); break; default: $scriptType = ''; break; } if ($script['type'] == ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT) { switch ($script['execute_on']) { case ZBX_SCRIPT_EXECUTE_ON_AGENT:
if (!$data['is_profile']) { $nameTextBox = new CTextBox('alias', $this->data['alias'], ZBX_TEXTBOX_STANDARD_SIZE); $nameTextBox->attr('autofocus', 'autofocus'); $userFormList->addRow(_('Alias'), $nameTextBox); $userFormList->addRow(_x('Name', 'user first name'), new CTextBox('name', $this->data['name'], ZBX_TEXTBOX_STANDARD_SIZE)); $userFormList->addRow(_('Surname'), new CTextBox('surname', $this->data['surname'], ZBX_TEXTBOX_STANDARD_SIZE)); } // append user groups to form list if (!$this->data['is_profile']) { $userForm->addVar('user_groups', $this->data['user_groups']); $lstGroups = new CListBox('user_groups_to_del[]', null, 10); $lstGroups->attributes['style'] = 'width: 320px'; foreach ($this->data['groups'] as $group) { $lstGroups->addItem($group['usrgrpid'], $group['name']); } $userFormList->addRow(_('Groups'), array($lstGroups, new CButton('add_group', _('Add'), 'return PopUp("popup_usrgrp.php?dstfrm=' . $userForm->getName() . '&list_name=user_groups_to_del[]&var_name=user_groups", 450, 450);', 'formlist'), BR(), count($this->data['user_groups']) > 0 ? new CSubmit('del_user_group', _('Delete selected'), null, 'formlist') : null)); } // append password to form list if ($data['auth_type'] == ZBX_AUTH_INTERNAL) { if (!$this->data['userid'] || isset($this->data['change_password'])) { $userFormList->addRow(_('Password'), new CPassBox('password1', $this->data['password1'], ZBX_TEXTBOX_SMALL_SIZE)); $userFormList->addRow(_('Password (once again)'), new CPassBox('password2', $this->data['password2'], ZBX_TEXTBOX_SMALL_SIZE)); if (isset($this->data['change_password'])) { $userForm->addVar('change_password', $this->data['change_password']); } } else { $passwdButton = new CSubmit('change_password', _('Change password'), null, 'formlist'); if ($this->data['alias'] == ZBX_GUEST_USER) { $passwdButton->setAttribute('disabled', 'disabled'); } $userFormList->addRow(_('Password'), $passwdButton);
$frmScr->addItemToBottomRow(SPACE); } $frmScr->addItemToBottomRow(new CButtonCancel()); $frmScr->Show(); } else { validate_sort_and_sortorder('s.name', ZBX_SORT_UP); $form = new CForm(); $form->setName('scripts'); $form->setAttribute('id', 'scripts'); $form->addVar('action', '1'); $numrows = new CSpan(null, 'info'); $numrows->setAttribute('name', 'numrows'); $header = get_table_header(array(S_SCRIPTS, new CSpan(SPACE . SPACE . '|' . SPACE . SPACE, 'divider'), S_FOUND . ': ', $numrows)); show_table_header($header); $table = new CTableInfo(S_NO_SCRIPTS_DEFINED); $table->setHeader(array(new CCheckBox('all_scripts', null, "checkAll('" . $form->getName() . "','all_scripts','scripts');"), make_sorting_link(S_NAME, 's.name'), make_sorting_link(S_COMMAND, 's.command'), S_USER_GROUP, S_HOST_GROUP, S_HOST_ACCESS)); $sql = 'SELECT s.* ' . ' FROM scripts s ' . ' WHERE ' . DBin_node('s.scriptid') . order_by('s.name,s.command'); $scripts = DBselect($sql); while ($script = DBfetch($scripts)) { $user_group_name = S_ALL_S; if ($script['usrgrpid'] > 0) { $user_group = get_group_by_usrgrpid($script['usrgrpid']); $user_group_name = $user_group['name']; } $host_group_name = S_ALL_S; if ($script['groupid'] > 0) { $group = get_hostgroup_by_groupid($script['groupid']); $host_group_name = $group['name']; } $table->addRow(array(new CCheckBox('scripts[' . $script['scriptid'] . ']', 'no', NULL, $script['scriptid']), new CLink($script['name'], 'scripts.php?form=1' . '&scriptid=' . $script['scriptid'] . '#form'), htmlspecialchars($script['command']), $user_group_name, $host_group_name, PERM_READ_WRITE == $script['host_access'] ? S_WRITE : S_READ)); $row_count++;
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ $dashconfWidget = new CWidget(); $dashconfWidget->setClass('header'); $dashconfWidget->addPageHeader(_('DASHBOARD CONFIGURATION')); // create form $dashconfForm = new CForm(); $dashconfForm->setName('dashconf'); $dashconfForm->setAttribute('id', 'dashform'); $dashconfForm->addVar('filterEnable', $this->data['isFilterEnable']); // create form list $dashconfFormList = new CFormList('dashconfFormList'); // append filter status to form list if ($this->data['isFilterEnable']) { $filterStatusSpan = new CSpan(_('Enabled'), 'green underline pointer'); $filterStatusSpan->setAttribute('onclick', "create_var('" . $dashconfForm->getName() . "', 'filterEnable', 0, true);"); } else { $filterStatusSpan = new CSpan(_('Disabled'), 'red underline pointer'); $filterStatusSpan->setAttribute('onclick', "\$('dashform').enable(); create_var('" . $dashconfForm->getName() . "', 'filterEnable', 1, true);"); } $dashconfFormList->addRow(_('Dashboard filter'), $filterStatusSpan); // append host groups to form list $hostGroupsComboBox = new CComboBox('grpswitch', $this->data['grpswitch'], 'submit();'); $hostGroupsComboBox->addItem(0, _('All')); $hostGroupsComboBox->addItem(1, _('Selected')); if (!$this->data['isFilterEnable']) { $hostGroupsComboBox->setAttribute('disabled', 'disabled'); } $dashconfFormList->addRow(_('Host groups'), $hostGroupsComboBox); if ($this->data['grpswitch']) { $dashconfFormList->addRow(_('Show selected groups'), new CMultiSelect(array('name' => 'groupids[]', 'objectName' => 'hostGroup', 'data' => $this->data['groups'], 'disabled' => !$this->data['isFilterEnable'], 'popup' => array('parameters' => 'srctbl=host_groups&dstfrm=' . $dashconfForm->getName() . '&dstfld1=groupids_' . '&srcfld1=groupid&multiselect=1', 'width' => 450, 'height' => 450))));
$sortOrder = getRequest('sortorder', CProfile::get('web.' . $page['file'] . '.sortorder', ZBX_SORT_UP)); CProfile::update('web.' . $page['file'] . '.sort', $sortField, PROFILE_TYPE_STR); CProfile::update('web.' . $page['file'] . '.sortorder', $sortOrder, PROFILE_TYPE_STR); $frmForm = new CForm(); $frmForm->cleanItems(); $frmForm->addItem(new CDiv(array(new CSubmit('form', _('Create template')), new CButton('form', _('Import'), 'redirect("conf.import.php?rules_preset=template")')))); $frmForm->addItem(new CVar('groupid', $_REQUEST['groupid'], 'filter_groupid_id')); $templateWidget->addPageHeader(_('CONFIGURATION OF TEMPLATES'), $frmForm); $frmGroup = new CForm('get'); $frmGroup->addItem(array(_('Group') . SPACE, $pageFilter->getGroupsCB())); $templateWidget->addHeader(_('Templates'), $frmGroup); $templateWidget->addHeaderRowNumber(); $form = new CForm(); $form->setName('templates'); $table = new CTableInfo(_('No templates found.')); $table->setHeader(array(new CCheckBox('all_templates', null, "checkAll('" . $form->getName() . "', 'all_templates', 'templates');"), make_sorting_header(_('Templates'), 'name', $sortField, $sortOrder), _('Applications'), _('Items'), _('Triggers'), _('Graphs'), _('Screens'), _('Discovery'), _('Web'), _('Linked templates'), _('Linked to'))); // get templates $templates = array(); if ($pageFilter->groupsSelected) { $templates = API::Template()->get(array('output' => array('templateid', 'name'), 'groupids' => $pageFilter->groupid > 0 ? $pageFilter->groupid : null, 'editable' => true, 'sortfield' => $sortField, 'limit' => $config['search_limit'] + 1)); } // sorting && paging order_result($templates, $sortField, $sortOrder); $paging = getPagingLine($templates); $templates = API::Template()->get(array('templateids' => zbx_objectValues($templates, 'templateid'), 'editable' => true, 'output' => array('name', 'proxy_hostid'), 'selectHosts' => array('hostid', 'name', 'status'), 'selectTemplates' => array('hostid', 'name', 'status'), 'selectParentTemplates' => array('hostid', 'name', 'status'), 'selectItems' => API_OUTPUT_COUNT, 'selectTriggers' => API_OUTPUT_COUNT, 'selectGraphs' => API_OUTPUT_COUNT, 'selectApplications' => API_OUTPUT_COUNT, 'selectDiscoveries' => API_OUTPUT_COUNT, 'selectScreens' => API_OUTPUT_COUNT, 'selectHttpTests' => API_OUTPUT_COUNT, 'nopermissions' => true)); order_result($templates, $sortField, $sortOrder); foreach ($templates as $template) { $templatesOutput = array(); if ($template['proxy_hostid']) { $proxy = get_host_by_hostid($template['proxy_hostid']); $templatesOutput[] = $proxy['host'] . NAME_DELIMITER;
} } $nameTextBox = new CTextBox('name', $this->data['name'], ZBX_TEXTBOX_STANDARD_SIZE, $this->data['limited']); $nameTextBox->attr('autofocus', 'autofocus'); $itemFormList->addRow(_('Name'), $nameTextBox); // append type to form list if ($this->data['limited']) { $itemForm->addVar('type', $this->data['type']); $itemFormList->addRow(_('Type'), new CTextBox('typename', item_type2str($this->data['type']), ZBX_TEXTBOX_STANDARD_SIZE, 'yes')); } else { $typeComboBox = new CComboBox('type', $this->data['type']); $typeComboBox->addItems($this->data['types']); $itemFormList->addRow(_('Type'), $typeComboBox); } // append key to form list $itemFormList->addRow(_('Key'), array(new CTextBox('key', $this->data['key'], ZBX_TEXTBOX_STANDARD_SIZE, $this->data['limited']), !$this->data['limited'] && !$this->data['is_discovery_rule'] ? new CButton('keyButton', _('Select'), 'return PopUp("popup.php?srctbl=help_items&srcfld1=key' . '&dstfrm=' . $itemForm->getName() . '&dstfld1=key&itemtype="+jQuery("#type option:selected").val());', 'formlist') : null)); // append interfaces to form list if (!empty($this->data['interfaces'])) { $interfacesComboBox = new CComboBox('interfaceid', $this->data['interfaceid']); // set up interface groups $interfaceGroups = array(); foreach (zbx_objectValues($this->data['interfaces'], 'type') as $interfaceType) { $interfaceGroups[$interfaceType] = new COptGroup(interfaceType2str($interfaceType)); } // add interfaces to groups foreach ($this->data['interfaces'] as $interface) { $option = new CComboItem($interface['interfaceid'], $interface['useip'] ? $interface['ip'] . ' : ' . $interface['port'] : $interface['dns'] . ' : ' . $interface['port'], $interface['interfaceid'] == $this->data['interfaceid'] ? 'yes' : 'no'); $option->setAttribute('data-interfacetype', $interface['type']); $interfaceGroups[$interface['type']]->addItem($option); } foreach ($interfaceGroups as $interfaceGroup) {
// append new condition to form list $conditionTypeComboBox = new CComboBox('new_condition[conditiontype]', $this->data['new_condition']['conditiontype'], 'submit()'); foreach ($this->data['allowedConditions'] as $key => $condition) { $this->data['allowedConditions'][$key] = array('name' => condition_type2str($condition), 'type' => $condition); } order_result($this->data['allowedConditions'], 'name'); foreach ($this->data['allowedConditions'] as $condition) { $conditionTypeComboBox->addItem($condition['type'], $condition['name']); } $conditionOperatorsComboBox = new CComboBox('new_condition[operator]', $this->data['new_condition']['operator']); foreach (get_operators_by_conditiontype($this->data['new_condition']['conditiontype']) as $operator) { $conditionOperatorsComboBox->addItem($operator, condition_operator2str($operator)); } switch ($this->data['new_condition']['conditiontype']) { case CONDITION_TYPE_HOST_GROUP: $condition = new CMultiSelect(array('name' => 'new_condition[value][]', 'objectName' => 'hostGroup', 'objectOptions' => array('editable' => true), 'defaultValue' => 0, 'popup' => array('parameters' => 'srctbl=host_groups&dstfrm=' . $actionForm->getName() . '&dstfld1=new_condition_value_' . '&srcfld1=groupid&writeonly=1&multiselect=1', 'width' => 450, 'height' => 450))); break; case CONDITION_TYPE_TEMPLATE: $condition = new CMultiSelect(array('name' => 'new_condition[value][]', 'objectName' => 'templates', 'objectOptions' => array('editable' => true), 'defaultValue' => 0, 'popup' => array('parameters' => 'srctbl=templates&srcfld1=hostid&srcfld2=host&dstfrm=' . $actionForm->getName() . '&dstfld1=new_condition_value_&templated_hosts=1&multiselect=1&writeonly=1', 'width' => 450, 'height' => 450))); break; case CONDITION_TYPE_HOST: $condition = new CMultiSelect(array('name' => 'new_condition[value][]', 'objectName' => 'hosts', 'objectOptions' => array('editable' => true), 'defaultValue' => 0, 'popup' => array('parameters' => 'srctbl=hosts&dstfrm=' . $actionForm->getName() . '&dstfld1=new_condition_value_' . '&srcfld1=hostid&writeonly=1&multiselect=1', 'width' => 450, 'height' => 450))); break; case CONDITION_TYPE_TRIGGER: $condition = new CMultiSelect(array('name' => 'new_condition[value][]', 'objectName' => 'triggers', 'objectOptions' => array('editable' => true), 'defaultValue' => 0, 'popup' => array('parameters' => 'srctbl=triggers&dstfrm=' . $actionForm->getName() . '&dstfld1=new_condition_value_' . '&srcfld1=triggerid&writeonly=1&multiselect=1&noempty=1', 'width' => 600, 'height' => 450))); break; case CONDITION_TYPE_TRIGGER_NAME: $condition = new CTextBox('new_condition[value]', '', ZBX_TEXTBOX_STANDARD_SIZE); break; case CONDITION_TYPE_TRIGGER_VALUE: $condition = new CComboBox('new_condition[value]');
$permissionsTable = new CTable(null, 'right_table'); $permissionsTable->setHeader(array(_('Read-write'), _('Read only'), _('Deny')), 'header'); $lstWrite = new CListBox('right_to_del[read_write][]', null, 20); $lstRead = new CListBox('right_to_del[read_only][]', null, 20); $lstDeny = new CListBox('right_to_del[deny][]', null, 20); foreach ($this->data['group_rights'] as $id => $rights) { if ($rights['permission'] == PERM_DENY) { $lstDeny->addItem($id, $rights['name']); } elseif ($rights['permission'] == PERM_READ) { $lstRead->addItem($id, $rights['name']); } elseif ($rights['permission'] == PERM_READ_WRITE) { $lstWrite->addItem($id, $rights['name']); } } $permissionsTable->addRow(array(new CCol($lstWrite, 'read_write'), new CCol($lstRead, 'read_only'), new CCol($lstDeny, 'deny'))); $permissionsTable->addRow(array(array(new CButton('add_read_write', _('Add'), "return PopUp('popup_right.php?dstfrm=" . $userGroupForm->getName() . '&permission=' . PERM_READ_WRITE . "', 450, 450);", 'formlist'), new CSubmit('del_read_write', _('Delete selected'), null, 'formlist')), array(new CButton('add_read_only', _('Add'), "return PopUp('popup_right.php?dstfrm=" . $userGroupForm->getName() . '&permission=' . PERM_READ . "', 450, 450);", 'formlist'), new CSubmit('del_read_only', _('Delete selected'), null, 'formlist')), array(new CButton('add_deny', _('Add'), "return PopUp('popup_right.php?dstfrm=" . $userGroupForm->getName() . '&permission=' . PERM_DENY . "', 450, 450);", 'formlist'), new CSubmit('del_deny', _('Delete selected'), null, 'formlist')))); $permissionsFormList->addRow(_('Composing permissions'), $permissionsTable); $permissionsFormList->addRow(_('Calculated permissions'), ''); $permissionsFormList = getPermissionsFormList($this->data['group_rights'], null, $permissionsFormList); // append form lists to tab $userGroupTab = new CTabView(); if (!$this->data['form_refresh']) { $userGroupTab->setSelected(0); } $userGroupTab->addTab('userGroupTab', _('User group'), $userGroupFormList); $userGroupTab->addTab('permissionsTab', _('Permissions'), $permissionsFormList); // append tab to form $userGroupForm->addItem($userGroupTab); // append buttons to form if (isset($this->data['usrgrpid'])) { $userGroupForm->addItem(makeFormFooter(new CSubmit('update', _('Update')), array(new CButtonDelete(_('Delete selected group?'), url_param('form') . url_param('usrgrpid') . url_param('config')), new CButtonCancel(url_param('config')))));
$linkedTemplateTable = new CTable(_('No templates linked.'), 'formElementTable'); $linkedTemplateTable->attr('id', 'linkedTemplateTable'); $linkedTemplateTable->attr('style', 'min-width: 400px;'); $linkedTemplateTable->setHeader(array(_('Name'), _('Action'))); $ignoredTemplates = array(); foreach ($this->data['linkedTemplates'] as $template) { $tmplList->addVar('templates[]', $template['templateid']); $linkedTemplateTable->addRow(array($template['name'], array(new CSubmit('unlink[' . $template['templateid'] . ']', _('Unlink'), null, 'link_menu'), SPACE, SPACE, isset($this->data['original_templates'][$template['templateid']]) ? new CSubmit('unlink_and_clear[' . $template['templateid'] . ']', _('Unlink and clear'), null, 'link_menu') : SPACE)), null, 'conditions_' . $template['templateid']); $ignoredTemplates[$template['templateid']] = $template['name']; } $tmplList->addRow(_('Linked templates'), new CDiv($linkedTemplateTable, 'objectgroup inlineblock border_dotted ui-corner-all')); // create new linked template table $newTemplateTable = new CTable(null, 'formElementTable'); $newTemplateTable->attr('id', 'newTemplateTable'); $newTemplateTable->attr('style', 'min-width: 400px;'); $newTemplateTable->addRow(array(new CMultiSelect(array('name' => 'add_templates[]', 'objectName' => 'templates', 'ignored' => $ignoredTemplates, 'popup' => array('parameters' => 'srctbl=templates&srcfld1=hostid&srcfld2=host&dstfrm=' . $frmHost->getName() . '&dstfld1=add_templates_&templated_hosts=1&multiselect=1', 'width' => 450, 'height' => 450))))); $newTemplateTable->addRow(array(new CSubmit('add_template', _('Add'), null, 'link_menu'))); $tmplList->addRow(_('Link new templates'), new CDiv($newTemplateTable, 'objectgroup inlineblock border_dotted ui-corner-all')); $divTabs->addTab('tmplTab', _('Linked templates'), $tmplList); // } TEMPLATES // macros if (empty($macros)) { $macros = array(array('macro' => '', 'value' => '')); } $macrosView = new CView('common.macros', array('macros' => $macros)); $divTabs->addTab('macroTab', _('Macros'), $macrosView->render()); $frmHost->addItem($divTabs); // Footer $others = array(); if ($templateid > 0 && $_REQUEST['form'] != 'full_clone') { $others[] = new CSubmit('clone', _('Clone'));
function getItemFilterForm(&$items) { $filter_groupId = $_REQUEST['filter_groupid']; $filter_hostId = $_REQUEST['filter_hostid']; $filter_application = $_REQUEST['filter_application']; $filter_name = $_REQUEST['filter_name']; $filter_type = $_REQUEST['filter_type']; $filter_key = $_REQUEST['filter_key']; $filter_snmp_community = $_REQUEST['filter_snmp_community']; $filter_snmpv3_securityname = $_REQUEST['filter_snmpv3_securityname']; $filter_snmp_oid = $_REQUEST['filter_snmp_oid']; $filter_port = $_REQUEST['filter_port']; $filter_value_type = $_REQUEST['filter_value_type']; $filter_data_type = $_REQUEST['filter_data_type']; $filter_delay = $_REQUEST['filter_delay']; $filter_history = $_REQUEST['filter_history']; $filter_trends = $_REQUEST['filter_trends']; $filter_status = $_REQUEST['filter_status']; $filter_state = $_REQUEST['filter_state']; $filter_templated_items = $_REQUEST['filter_templated_items']; $filter_with_triggers = $_REQUEST['filter_with_triggers']; $subfilter_hosts = $_REQUEST['subfilter_hosts']; $subfilter_apps = $_REQUEST['subfilter_apps']; $subfilter_types = $_REQUEST['subfilter_types']; $subfilter_value_types = $_REQUEST['subfilter_value_types']; $subfilter_status = $_REQUEST['subfilter_status']; $subfilter_state = $_REQUEST['subfilter_state']; $subfilter_templated_items = $_REQUEST['subfilter_templated_items']; $subfilter_with_triggers = $_REQUEST['subfilter_with_triggers']; $subfilter_history = $_REQUEST['subfilter_history']; $subfilter_trends = $_REQUEST['subfilter_trends']; $subfilter_interval = $_REQUEST['subfilter_interval']; $form = new CForm('get'); $form->setAttribute('name', 'zbx_filter'); $form->setAttribute('id', 'zbx_filter'); $form->addVar('subfilter_hosts', $subfilter_hosts); $form->addVar('subfilter_apps', $subfilter_apps); $form->addVar('subfilter_types', $subfilter_types); $form->addVar('subfilter_value_types', $subfilter_value_types); $form->addVar('subfilter_status', $subfilter_status); $form->addVar('subfilter_state', $subfilter_state); $form->addVar('subfilter_templated_items', $subfilter_templated_items); $form->addVar('subfilter_with_triggers', $subfilter_with_triggers); $form->addVar('subfilter_history', $subfilter_history); $form->addVar('subfilter_trends', $subfilter_trends); $form->addVar('subfilter_interval', $subfilter_interval); // type select $fTypeVisibility = array(); $cmbType = new CComboBox('filter_type', $filter_type); $cmbType->setAttribute('id', 'filter_type'); $cmbType->addItem(-1, _('all')); foreach (array('filter_delay_label', 'filter_delay') as $vItem) { zbx_subarray_push($fTypeVisibility, -1, $vItem); } $itemTypes = item_type2str(); unset($itemTypes[ITEM_TYPE_HTTPTEST]); // httptest items are only for internal zabbix logic $cmbType->addItems($itemTypes); foreach ($itemTypes as $typeNum => $typeLabel) { if ($typeNum != ITEM_TYPE_TRAPPER) { zbx_subarray_push($fTypeVisibility, $typeNum, 'filter_delay_label'); zbx_subarray_push($fTypeVisibility, $typeNum, 'filter_delay'); } switch ($typeNum) { case ITEM_TYPE_SNMPV1: case ITEM_TYPE_SNMPV2C: $snmp_types = array('filter_snmp_community_label', 'filter_snmp_community', 'filter_snmp_oid_label', 'filter_snmp_oid', 'filter_port_label', 'filter_port'); foreach ($snmp_types as $vItem) { zbx_subarray_push($fTypeVisibility, $typeNum, $vItem); } break; case ITEM_TYPE_SNMPV3: foreach (array('filter_snmpv3_securityname_label', 'filter_snmpv3_securityname', 'filter_snmp_oid_label', 'filter_snmp_oid', 'filter_port_label', 'filter_port') as $vItem) { zbx_subarray_push($fTypeVisibility, $typeNum, $vItem); } break; } } zbx_add_post_js("var filterTypeSwitcher = new CViewSwitcher('filter_type', 'change', " . zbx_jsvalue($fTypeVisibility, true) . ');'); // type of information select $fVTypeVisibility = array(); $cmbValType = new CComboBox('filter_value_type', $filter_value_type); $cmbValType->addItem(-1, _('all')); $cmbValType->addItem(ITEM_VALUE_TYPE_UINT64, _('Numeric (unsigned)')); $cmbValType->addItem(ITEM_VALUE_TYPE_FLOAT, _('Numeric (float)')); $cmbValType->addItem(ITEM_VALUE_TYPE_STR, _('Character')); $cmbValType->addItem(ITEM_VALUE_TYPE_LOG, _('Log')); $cmbValType->addItem(ITEM_VALUE_TYPE_TEXT, _('Text')); foreach (array('filter_data_type_label', 'filter_data_type') as $vItem) { zbx_subarray_push($fVTypeVisibility, ITEM_VALUE_TYPE_UINT64, $vItem); } zbx_add_post_js("var filterValueTypeSwitcher = new CViewSwitcher('filter_value_type', 'change', " . zbx_jsvalue($fVTypeVisibility, true) . ');'); // status select $cmbStatus = new CComboBox('filter_status', $filter_status); $cmbStatus->addItem(-1, _('all')); foreach (array(ITEM_STATUS_ACTIVE, ITEM_STATUS_DISABLED) as $status) { $cmbStatus->addItem($status, item_status2str($status)); } // state select $cmbState = new CComboBox('filter_state', $filter_state); $cmbState->addItem(-1, _('all')); foreach (array(ITEM_STATE_NORMAL, ITEM_STATE_NOTSUPPORTED) as $state) { $cmbState->addItem($state, itemState($state)); } // update interval $updateIntervalLabel = new CSpan(array(bold(_('Update interval')), SPACE . _('(in sec)') . NAME_DELIMITER)); $updateIntervalLabel->setAttribute('id', 'filter_delay_label'); $updateIntervalInput = new CNumericBox('filter_delay', $filter_delay, 5, false, true); $updateIntervalInput->setEnabled('no'); // data type $dataTypeLabel = new CSpan(bold(_('Data type') . NAME_DELIMITER)); $dataTypeLabel->setAttribute('id', 'filter_data_type_label'); $dataTypeInput = new CComboBox('filter_data_type', $filter_data_type); $dataTypeInput->addItem(-1, _('all')); $dataTypeInput->addItems(item_data_type2str()); $dataTypeInput->setEnabled('no'); // filter table $table = new CTable('', 'filter'); $table->setCellPadding(0); $table->setCellSpacing(0); // SNMP community $snmpCommunityLabel = new CSpan(array(bold(_('SNMP community')), SPACE . _('like') . NAME_DELIMITER)); $snmpCommunityLabel->setAttribute('id', 'filter_snmp_community_label'); $snmpCommunityField = new CTextBox('filter_snmp_community', $filter_snmp_community, ZBX_TEXTBOX_FILTER_SIZE); $snmpCommunityField->setEnabled('no'); // SNMPv3 security name $snmpSecurityLabel = new CSpan(array(bold(_('Security name')), SPACE . _('like') . NAME_DELIMITER)); $snmpSecurityLabel->setAttribute('id', 'filter_snmpv3_securityname_label'); $snmpSecurityField = new CTextBox('filter_snmpv3_securityname', $filter_snmpv3_securityname, ZBX_TEXTBOX_FILTER_SIZE); $snmpSecurityField->setEnabled('no'); // SNMP OID $snmpOidLabel = new CSpan(array(bold(_('SNMP OID')), SPACE . _('like') . NAME_DELIMITER)); $snmpOidLabel->setAttribute('id', 'filter_snmp_oid_label'); $snmpOidField = new CTextBox('filter_snmp_oid', $filter_snmp_oid, ZBX_TEXTBOX_FILTER_SIZE); $snmpOidField->setEnabled('no'); // port $portLabel = new CSpan(array(bold(_('Port')), SPACE . _('like') . NAME_DELIMITER)); $portLabel->setAttribute('id', 'filter_port_label'); $portField = new CNumericBox('filter_port', $filter_port, 5, false, true); $portField->setEnabled('no'); // row 1 $groupFilter = null; if (!empty($filter_groupId)) { $getHostInfo = API::HostGroup()->get(array('groupids' => $filter_groupId, 'output' => array('name'))); $getHostInfo = reset($getHostInfo); if (!empty($getHostInfo)) { $groupFilter[] = array('id' => $getHostInfo['groupid'], 'name' => $getHostInfo['name']); } } $table->addRow(array(new CCol(bold(_('Host group') . NAME_DELIMITER), 'label col1'), new CCol(array(new CMultiSelect(array('name' => 'filter_groupid', 'selectedLimit' => 1, 'objectName' => 'hostGroup', 'objectOptions' => array('editable' => true), 'data' => $groupFilter, 'popup' => array('parameters' => 'srctbl=host_groups&dstfrm=' . $form->getName() . '&dstfld1=filter_groupid' . '&srcfld1=groupid&writeonly=1', 'width' => 450, 'height' => 450, 'buttonClass' => 'input filter-multiselect-select-button')))), 'col1'), new CCol(bold(_('Type') . NAME_DELIMITER), 'label col2'), new CCol($cmbType, 'col2'), new CCol(bold(_('Type of information') . NAME_DELIMITER), 'label col3'), new CCol($cmbValType, 'col3'), new CCol(bold(_('State') . NAME_DELIMITER), 'label'), new CCol($cmbState, 'col4')), 'item-list-row'); // row 2 $hostFilterData = null; if (!empty($filter_hostId)) { $getHostInfo = API::Host()->get(array('hostids' => $filter_hostId, 'templated_hosts' => true, 'output' => array('name'))); $getHostInfo = reset($getHostInfo); if (!empty($getHostInfo)) { $hostFilterData[] = array('id' => $getHostInfo['hostid'], 'name' => $getHostInfo['name']); } } $table->addRow(array(new CCol(bold(_('Host') . NAME_DELIMITER), 'label'), new CCol(array(new CMultiSelect(array('name' => 'filter_hostid', 'selectedLimit' => 1, 'objectName' => 'hosts', 'objectOptions' => array('editable' => true, 'templated_hosts' => true), 'data' => $hostFilterData, 'popup' => array('parameters' => 'srctbl=host_templates&dstfrm=' . $form->getName() . '&dstfld1=filter_hostid' . '&srcfld1=hostid&writeonly=1', 'width' => 450, 'height' => 450, 'buttonClass' => 'input filter-multiselect-select-button')))), 'col1'), new CCol($updateIntervalLabel, 'label'), new CCol($updateIntervalInput), new CCol($dataTypeLabel, 'label'), new CCol($dataTypeInput), new CCol(bold(_('Status') . NAME_DELIMITER), 'label col4'), new CCol($cmbStatus, 'col4')), 'item-list-row'); // row 3 $table->addRow(array(new CCol(bold(_('Application') . NAME_DELIMITER), 'label'), new CCol(array(new CTextBox('filter_application', $filter_application, ZBX_TEXTBOX_FILTER_SIZE), new CButton('btn_app', _('Select'), 'return PopUp("popup.php?srctbl=applications&srcfld1=name' . '&dstfrm=' . $form->getName() . '&dstfld1=filter_application' . '&with_applications=1' . '" + (jQuery("input[name=\'filter_hostid\']").length > 0 ? "&hostid="+jQuery("input[name=\'filter_hostid\']").val() : "")' . ', 550, 450, "application");', 'filter-select-button')), 'col1'), new CCol(array($snmpCommunityLabel, $snmpSecurityLabel), 'label'), new CCol(array($snmpCommunityField, $snmpSecurityField)), new CCol(array(bold(_('History')), SPACE . _('(in days)') . NAME_DELIMITER), 'label'), new CCol(new CNumericBox('filter_history', $filter_history, 8, false, true)), new CCol(bold(_('Triggers') . NAME_DELIMITER), 'label'), new CCol(new CComboBox('filter_with_triggers', $filter_with_triggers, null, array(-1 => _('all'), 1 => _('With triggers'), 0 => _('Without triggers'))))), 'item-list-row'); // row 4 $table->addRow(array(new CCol(array(bold(_('Name')), SPACE . _('like') . NAME_DELIMITER), 'label'), new CCol(new CTextBox('filter_name', $filter_name, ZBX_TEXTBOX_FILTER_SIZE), 'col1'), new CCol($snmpOidLabel, 'label'), new CCol($snmpOidField), new CCol(array(bold(_('Trends')), SPACE . _('(in days)') . NAME_DELIMITER), 'label'), new CCol(new CNumericBox('filter_trends', $filter_trends, 8, false, true)), new CCol(bold(_('Template') . NAME_DELIMITER), 'label'), new CCol(new CComboBox('filter_templated_items', $filter_templated_items, null, array(-1 => _('all'), 1 => _('Templated items'), 0 => _('Not Templated items'))))), 'item-list-row'); // row 5 $table->addRow(array(new CCol(array(bold(_('Key')), SPACE . _('like') . NAME_DELIMITER), 'label'), new CCol(new CTextBox('filter_key', $filter_key, ZBX_TEXTBOX_FILTER_SIZE), 'col1'), new CCol($portLabel, 'label'), new CCol($portField), new CCol(null, 'label'), new CCol(), new CCol(null, 'label'), new CCol()), 'item-list-row'); $filter = new CSubmit('filter_set', _('Filter'), 'chkbxRange.clearSelectedOnFilterChange();'); $filter->useJQueryStyle('main'); $reset = new CSubmit('filter_rst', _('Reset'), 'chkbxRange.clearSelectedOnFilterChange();'); $reset->useJQueryStyle(); $div_buttons = new CDiv(array($filter, SPACE, $reset)); $div_buttons->setAttribute('style', 'padding: 4px 0px;'); $footer = new CCol($div_buttons, 'controls', 8); $table->addRow($footer); $form->addItem($table); // subfilters $table_subfilter = new CTable(null, 'filter sub-filter'); // array contains subfilters and number of items in each $item_params = array('hosts' => array(), 'applications' => array(), 'types' => array(), 'value_types' => array(), 'status' => array(), 'state' => array(), 'templated_items' => array(), 'with_triggers' => array(), 'history' => array(), 'trends' => array(), 'interval' => array()); // generate array with values for subfilters of selected items foreach ($items as $item) { // hosts if (zbx_empty($filter_hostId)) { $host = reset($item['hosts']); if (!isset($item_params['hosts'][$host['hostid']])) { $item_params['hosts'][$host['hostid']] = array('name' => $host['name'], 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_hosts') { continue; } $show_item &= $value; } if ($show_item) { $host = reset($item['hosts']); $item_params['hosts'][$host['hostid']]['count']++; } } // applications if (!empty($item['applications'])) { foreach ($item['applications'] as $application) { if (!isset($item_params['applications'][$application['name']])) { $item_params['applications'][$application['name']] = array('name' => $application['name'], 'count' => 0); } } } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_apps') { continue; } $show_item &= $value; } $sel_app = false; if ($show_item) { // if any of item applications are selected foreach ($item['applications'] as $app) { if (str_in_array($app['name'], $subfilter_apps)) { $sel_app = true; break; } } foreach ($item['applications'] as $app) { if (str_in_array($app['name'], $subfilter_apps) || !$sel_app) { $item_params['applications'][$app['name']]['count']++; } } } // types if ($filter_type == -1) { if (!isset($item_params['types'][$item['type']])) { $item_params['types'][$item['type']] = array('name' => item_type2str($item['type']), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_types') { continue; } $show_item &= $value; } if ($show_item) { $item_params['types'][$item['type']]['count']++; } } // value types if ($filter_value_type == -1) { if (!isset($item_params['value_types'][$item['value_type']])) { $item_params['value_types'][$item['value_type']] = array('name' => itemValueTypeString($item['value_type']), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_value_types') { continue; } $show_item &= $value; } if ($show_item) { $item_params['value_types'][$item['value_type']]['count']++; } } // status if ($filter_status == -1) { if (!isset($item_params['status'][$item['status']])) { $item_params['status'][$item['status']] = array('name' => item_status2str($item['status']), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_status') { continue; } $show_item &= $value; } if ($show_item) { $item_params['status'][$item['status']]['count']++; } } // state if ($filter_state == -1) { if (!isset($item_params['state'][$item['state']])) { $item_params['state'][$item['state']] = array('name' => itemState($item['state']), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_state') { continue; } $show_item &= $value; } if ($show_item) { $item_params['state'][$item['state']]['count']++; } } // template if ($filter_templated_items == -1) { if ($item['templateid'] == 0 && !isset($item_params['templated_items'][0])) { $item_params['templated_items'][0] = array('name' => _('Not Templated items'), 'count' => 0); } elseif ($item['templateid'] > 0 && !isset($item_params['templated_items'][1])) { $item_params['templated_items'][1] = array('name' => _('Templated items'), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_templated_items') { continue; } $show_item &= $value; } if ($show_item) { if ($item['templateid'] == 0) { $item_params['templated_items'][0]['count']++; } else { $item_params['templated_items'][1]['count']++; } } } // with triggers if ($filter_with_triggers == -1) { if (count($item['triggers']) == 0 && !isset($item_params['with_triggers'][0])) { $item_params['with_triggers'][0] = array('name' => _('Without triggers'), 'count' => 0); } elseif (count($item['triggers']) > 0 && !isset($item_params['with_triggers'][1])) { $item_params['with_triggers'][1] = array('name' => _('With triggers'), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_with_triggers') { continue; } $show_item &= $value; } if ($show_item) { if (count($item['triggers']) == 0) { $item_params['with_triggers'][0]['count']++; } else { $item_params['with_triggers'][1]['count']++; } } } // trends if (zbx_empty($filter_trends)) { if (!isset($item_params['trends'][$item['trends']])) { $item_params['trends'][$item['trends']] = array('name' => $item['trends'], 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_trends') { continue; } $show_item &= $value; } if ($show_item) { $item_params['trends'][$item['trends']]['count']++; } } // history if (zbx_empty($filter_history)) { if (!isset($item_params['history'][$item['history']])) { $item_params['history'][$item['history']] = array('name' => $item['history'], 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_history') { continue; } $show_item &= $value; } if ($show_item) { $item_params['history'][$item['history']]['count']++; } } // interval if (zbx_empty($filter_delay) && $filter_type != ITEM_TYPE_TRAPPER) { if (!isset($item_params['interval'][$item['delay']])) { $item_params['interval'][$item['delay']] = array('name' => $item['delay'], 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_interval') { continue; } $show_item &= $value; } if ($show_item) { $item_params['interval'][$item['delay']]['count']++; } } } // output if (zbx_empty($filter_hostId) && count($item_params['hosts']) > 1) { $hosts_output = prepareSubfilterOutput($item_params['hosts'], $subfilter_hosts, 'subfilter_hosts'); $table_subfilter->addRow(array(_('Hosts'), $hosts_output)); } if (!empty($item_params['applications']) && count($item_params['applications']) > 1) { $application_output = prepareSubfilterOutput($item_params['applications'], $subfilter_apps, 'subfilter_apps'); $table_subfilter->addRow(array(_('Applications'), $application_output)); } if ($filter_type == -1 && count($item_params['types']) > 1) { $type_output = prepareSubfilterOutput($item_params['types'], $subfilter_types, 'subfilter_types'); $table_subfilter->addRow(array(_('Types'), $type_output)); } if ($filter_value_type == -1 && count($item_params['value_types']) > 1) { $value_types_output = prepareSubfilterOutput($item_params['value_types'], $subfilter_value_types, 'subfilter_value_types'); $table_subfilter->addRow(array(_('Type of information'), $value_types_output)); } if ($filter_status == -1 && count($item_params['status']) > 1) { $status_output = prepareSubfilterOutput($item_params['status'], $subfilter_status, 'subfilter_status'); $table_subfilter->addRow(array(_('Status'), $status_output)); } if ($filter_state == -1 && count($item_params['state']) > 1) { $state_output = prepareSubfilterOutput($item_params['state'], $subfilter_state, 'subfilter_state'); $table_subfilter->addRow(array(_('State'), $state_output)); } if ($filter_templated_items == -1 && count($item_params['templated_items']) > 1) { $templated_items_output = prepareSubfilterOutput($item_params['templated_items'], $subfilter_templated_items, 'subfilter_templated_items'); $table_subfilter->addRow(array(_('Template'), $templated_items_output)); } if ($filter_with_triggers == -1 && count($item_params['with_triggers']) > 1) { $with_triggers_output = prepareSubfilterOutput($item_params['with_triggers'], $subfilter_with_triggers, 'subfilter_with_triggers'); $table_subfilter->addRow(array(_('With triggers'), $with_triggers_output)); } if (zbx_empty($filter_history) && count($item_params['history']) > 1) { $history_output = prepareSubfilterOutput($item_params['history'], $subfilter_history, 'subfilter_history'); $table_subfilter->addRow(array(_('History'), $history_output)); } if (zbx_empty($filter_trends) && count($item_params['trends']) > 1) { $trends_output = prepareSubfilterOutput($item_params['trends'], $subfilter_trends, 'subfilter_trends'); $table_subfilter->addRow(array(_('Trends'), $trends_output)); } if (zbx_empty($filter_delay) && $filter_type != ITEM_TYPE_TRAPPER && count($item_params['interval']) > 1) { $interval_output = prepareSubfilterOutput($item_params['interval'], $subfilter_interval, 'subfilter_interval'); $table_subfilter->addRow(array(_('Interval'), $interval_output)); } $form->addItem(new CDiv(_('Subfilter [affects only filtered data!]'), 'thin_header')); $form->addItem($table_subfilter); return $form; }
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ $slideWidget = new CWidget(); // create new hostgroup button $createForm = new CForm('get'); $createForm->cleanItems(); $createForm->addItem(new CSubmit('form', _('Create slide show'))); $slideWidget->addPageHeader(_('CONFIGURATION OF SLIDE SHOWS'), $createForm); $slideWidget->addHeader(_('Slide shows')); $slideWidget->addHeaderRowNumber(); // create form $slideForm = new CForm(); $slideForm->setName('slideForm'); // create table $slidesTable = new CTableInfo(_('No slide shows found.')); $slidesTable->setHeader(array(new CCheckBox('all_shows', null, "checkAll('" . $slideForm->getName() . "', 'all_shows', 'shows');"), $this->data['displayNodes'] ? _('Node') : null, make_sorting_header(_('Name'), 'name'), make_sorting_header(_('Delay'), 'delay'), make_sorting_header(_('Count of slides'), 'cnt'))); foreach ($this->data['slides'] as $slide) { $slidesTable->addRow(array(new CCheckBox('shows[' . $slide['slideshowid'] . ']', null, null, $slide['slideshowid']), $this->data['displayNodes'] ? $slide['nodename'] : null, new CLink($slide['name'], '?form=update&slideshowid=' . $slide['slideshowid'], 'action'), $slide['delay'], $slide['cnt'])); } // create go button $goComboBox = new CComboBox('go'); $goOption = new CComboItem('delete', _('Delete selected')); $goOption->setAttribute('confirm', _('Delete selected slide shows?')); $goComboBox->addItem($goOption); $goButton = new CSubmit('goButton', _('Go') . ' (0)'); $goButton->setAttribute('id', 'goButton'); zbx_add_post_js('chkbxRange.pageGoName = "shows";'); // append table to form $slideForm->addItem(array($this->data['paging'], $slidesTable, $this->data['paging'], get_table_header(array($goComboBox, $goButton)))); // append form to widget $slideWidget->addItem($slideForm);
foreach ($this->data['slides'] as $step => $slides) { $name = ''; if (!empty($slides['screenid'])) { $screen = get_screen_by_screenid($slides['screenid']); if (!empty($screen['name'])) { $name = $screen['name']; } } $delay = new CNumericBox('slides[' . $step . '][delay]', !empty($slides['delay']) ? $slides['delay'] : '', 5, 'no', true, false); $delay->setAttribute('placeholder', _('default')); $removeButton = new CButton('remove_' . $step, _('Remove'), 'javascript: removeSlide(this);', 'link_menu'); $removeButton->setAttribute('remove_slide', $step); $row = new CRow(array(new CSpan(null, 'ui-icon ui-icon-arrowthick-2-n-s move'), new CSpan($i++ . ':', 'rowNum', 'current_slide_' . $step), $name, $delay, $removeButton), 'sortable', 'slides_' . $step); $slideTable->addRow($row); } $addButtonColumn = new CCol(empty($this->data['work_slide']) ? new CButton('add', _('Add'), 'return PopUp("popup.php?srctbl=screens&srcfld1=screenid&dstfrm=' . $slideForm->getName() . '&multiselect=1", 450, 450)', 'link_menu') : null, null, 5); $addButtonColumn->setAttribute('style', 'vertical-align: middle;'); $slideTable->addRow(new CRow($addButtonColumn, null, 'screenListFooter')); $slideFormList->addRow(_('Slides'), new CDiv($slideTable, 'objectgroup inlineblock border_dotted ui-corner-all')); // append tabs to form $slideTab = new CTabView(); $slideTab->addTab('slideTab', _('Slide'), $slideFormList); $slideForm->addItem($slideTab); // append buttons to form if (empty($this->data['slideshowid'])) { $slideForm->addItem(makeFormFooter(new CSubmit('save', _('Save')), new CButtonCancel())); } else { $slideForm->addItem(makeFormFooter(new CSubmit('save', _('Save')), array(new CSubmit('clone', _('Clone')), new CButtonDelete(_('Delete slide show?'), url_param('form') . url_param('slideshowid') . url_param('config')), new CButtonCancel()))); } $slideWidget->addItem($slideForm); return $slideWidget;
// create widget header $sourceComboBox = new CComboBox('eventsource', $this->data['eventsource'], 'submit()'); $sourceComboBox->addItem(EVENT_SOURCE_TRIGGERS, _('Triggers')); $sourceComboBox->addItem(EVENT_SOURCE_DISCOVERY, _('Discovery')); $sourceComboBox->addItem(EVENT_SOURCE_AUTO_REGISTRATION, _('Auto registration')); $sourceComboBox->addItem(EVENT_SOURCE_INTERNAL, _x('Internal', 'event source')); $filterForm = new CForm('get'); $filterForm->addItem(array(_('Event source'), SPACE, $sourceComboBox)); $actionWidget->addHeader(_('Actions'), $filterForm); $actionWidget->addHeaderRowNumber(); // create form $actionForm = new CForm(); $actionForm->setName('actionForm'); // create table $actionTable = new CTableInfo(_('No actions found.')); $actionTable->setHeader(array(new CCheckBox('all_items', null, "checkAll('" . $actionForm->getName() . "', 'all_items', 'g_actionid');"), make_sorting_header(_('Name'), 'name', $this->data['sort'], $this->data['sortorder']), _('Conditions'), _('Operations'), make_sorting_header(_('Status'), 'status', $this->data['sort'], $this->data['sortorder']))); foreach ($this->data['actions'] as $action) { $conditions = array(); order_result($action['filter']['conditions'], 'conditiontype', ZBX_SORT_DOWN); foreach ($action['filter']['conditions'] as $condition) { $conditions[] = get_condition_desc($condition['conditiontype'], $condition['operator'], $condition['value']); $conditions[] = BR(); } sortOperations($this->data['eventsource'], $action['operations']); $operations = array(); foreach ($action['operations'] as $operation) { $operations[] = get_operation_descr(SHORT_DESCRIPTION, $operation); } if ($action['status'] == ACTION_STATUS_DISABLED) { $status = new CLink(_('Disabled'), 'actionconf.php?action=action.massenable&g_actionid[]=' . $action['actionid'] . url_param('eventsource'), 'disabled'); } else {
$condition->addItem($trigerValue, trigger_value2str($trigerValue)); } break; case CONDITION_TYPE_TIME_PERIOD: $condition = new CTextBox('new_condition[value]', ZBX_DEFAULT_INTERVAL, ZBX_TEXTBOX_STANDARD_SIZE); break; case CONDITION_TYPE_TRIGGER_SEVERITY: $condition = new CComboBox('new_condition[value]'); $condition->addItems(getSeverityCaption()); break; case CONDITION_TYPE_MAINTENANCE: $condition = new CCol(_('maintenance')); break; case CONDITION_TYPE_NODE: $conditionFormList->addItem(new CVar('new_condition[value]', '0')); $condition = array(new CTextBox('node', '', ZBX_TEXTBOX_STANDARD_SIZE, 'yes'), SPACE, new CButton('btn1', _('Select'), 'return PopUp("popup.php?srctbl=nodes&srcfld1=nodeid&srcfld2=name' . '&dstfrm=' . $actionForm->getName() . '&dstfld1=new_condition_value&dstfld2=node' . '&writeonly=1", 450, 450);', 'link_menu')); break; case CONDITION_TYPE_DRULE: $conditionFormList->addItem(new CVar('new_condition[value]', '0')); $condition = array(new CTextBox('drule', '', ZBX_TEXTBOX_STANDARD_SIZE, 'yes'), SPACE, new CButton('btn1', _('Select'), 'return PopUp("popup.php?srctbl=drules&srcfld1=druleid&srcfld2=name' . '&dstfrm=' . $actionForm->getName() . '&dstfld1=new_condition_value&dstfld2=drule", 450, 450);', 'link_menu')); break; case CONDITION_TYPE_DCHECK: $conditionFormList->addItem(new CVar('new_condition[value]', '0')); $condition = array(new CTextBox('dcheck', '', ZBX_TEXTBOX_STANDARD_SIZE, 'yes'), SPACE, new CButton('btn1', _('Select'), 'return PopUp("popup.php?srctbl=dchecks&srcfld1=dcheckid&srcfld2=name' . '&dstfrm=' . $actionForm->getName() . '&dstfld1=new_condition_value&dstfld2=dcheck&writeonly=1", 450, 450);', 'link_menu')); break; case CONDITION_TYPE_PROXY: $conditionFormList->addItem(new CVar('new_condition[value]', '0')); $condition = array(new CTextBox('proxy', '', ZBX_TEXTBOX_STANDARD_SIZE, 'yes'), SPACE, new CButton('btn1', _('Select'), 'return PopUp("popup.php?srctbl=proxies&srcfld1=hostid&srcfld2=host' . '&dstfrm=' . $actionForm->getName() . '&dstfld1=new_condition_value&dstfld2=proxy' . '", 450, 450);', 'link_menu')); break; case CONDITION_TYPE_DHOST_IP: $condition = new CTextBox('new_condition[value]', '192.168.0.1-127,192.168.2.1', ZBX_TEXTBOX_STANDARD_SIZE);
$filter->useJQueryStyle('main'); $reset = new CButton('reset', _('Reset'), "javascript: clearAllForm('zbx_filter');"); $reset->useJQueryStyle(); $divButtons = new CDiv(array($filter, SPACE, $reset)); $divButtons->setAttribute('style', 'padding: 4px 0;'); $filterTable->addRow(new CCol($divButtons, 'center', 4)); $filterForm = new CForm('get'); $filterForm->setAttribute('name', 'zbx_filter'); $filterForm->setAttribute('id', 'zbx_filter'); $filterForm->addItem($filterTable); $hostsWidget->addFlicker($filterForm, CProfile::get('web.hosts.filter.state', 0)); // table hosts $form = new CForm(); $form->setName('hosts'); $table = new CTableInfo(_('No hosts found.')); $table->setHeader(array(new CCheckBox('all_hosts', null, "checkAll('" . $form->getName() . "', 'all_hosts', 'hosts');"), $displayNodes ? _('Node') : null, make_sorting_header(_('Name'), 'name'), _('Applications'), _('Items'), _('Triggers'), _('Graphs'), _('Discovery'), _('Web'), _('Interface'), _('Templates'), make_sorting_header(_('Status'), 'status'), _('Availability'))); // get Hosts $hosts = array(); $sortfield = getPageSortField('name'); $sortorder = getPageSortOrder(); if ($pageFilter->groupsSelected) { $hosts = API::Host()->get(array('groupids' => $pageFilter->groupid > 0 ? $pageFilter->groupid : null, 'editable' => true, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'limit' => $config['search_limit'] + 1, 'search' => array('name' => empty($_REQUEST['filter_host']) ? null : $_REQUEST['filter_host'], 'ip' => empty($_REQUEST['filter_ip']) ? null : $_REQUEST['filter_ip'], 'dns' => empty($_REQUEST['filter_dns']) ? null : $_REQUEST['filter_dns']), 'filter' => array('port' => empty($_REQUEST['filter_port']) ? null : $_REQUEST['filter_port']))); } else { $hosts = array(); } // sorting && paging order_result($hosts, $sortfield, $sortorder); $paging = getPagingLine($hosts, array('hostid')); $hosts = API::Host()->get(array('hostids' => zbx_objectValues($hosts, 'hostid'), 'output' => API_OUTPUT_EXTEND, 'selectParentTemplates' => array('hostid', 'name'), 'selectInterfaces' => API_OUTPUT_EXTEND, 'selectItems' => API_OUTPUT_COUNT, 'selectDiscoveries' => API_OUTPUT_COUNT, 'selectTriggers' => API_OUTPUT_COUNT, 'selectGraphs' => API_OUTPUT_COUNT, 'selectApplications' => API_OUTPUT_COUNT, 'selectHttpTests' => API_OUTPUT_COUNT, 'selectDiscoveryRule' => array('itemid', 'name'), 'selectHostDiscovery' => array('ts_delete'))); order_result($hosts, $sortfield, $sortorder); // selecting linked templates to templates linked to hosts
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ $discoveryWidget = new CWidget(); // create new discovery rule button $createForm = new CForm('get'); $createForm->cleanItems(); $createForm->addItem(new CSubmit('form', _('Create discovery rule'))); $discoveryWidget->addPageHeader(_('CONFIGURATION OF DISCOVERY RULES'), $createForm); $discoveryWidget->addHeader(_('Discovery rules')); $discoveryWidget->addHeaderRowNumber(); // create form $discoveryForm = new CForm(); $discoveryForm->setName('druleForm'); // create table $discoveryTable = new CTableInfo(_('No discovery rules found.')); $discoveryTable->setHeader(array(new CCheckBox('all_drules', null, "checkAll('" . $discoveryForm->getName() . "', 'all_drules', 'g_druleid');"), make_sorting_header(_('Name'), 'name', $this->data['sort'], $this->data['sortorder']), _('IP range'), _('Delay'), _('Checks'), _('Status'))); foreach ($data['drules'] as $drule) { array_push($drule['description'], new CLink($drule['name'], '?form=update&druleid=' . $drule['druleid'])); $status = new CCol(new CLink(discovery_status2str($drule['status']), '?g_druleid[]=' . $drule['druleid'] . '&action=' . ($drule['status'] == DRULE_STATUS_ACTIVE ? 'drule.massdisable' : 'drule.massenable'), discovery_status2style($drule['status']))); $discoveryTable->addRow(array(new CCheckBox('g_druleid[' . $drule['druleid'] . ']', null, null, $drule['druleid']), $drule['description'], $drule['iprange'], $drule['delay'], !empty($drule['checks']) ? implode(', ', $drule['checks']) : '', $status)); } // create go buttons $goComboBox = new CComboBox('action'); $goOption = new CComboItem('drule.massenable', _('Enable selected')); $goOption->setAttribute('confirm', _('Enable selected discovery rules?')); $goComboBox->addItem($goOption); $goOption = new CComboItem('drule.massdisable', _('Disable selected')); $goOption->setAttribute('confirm', _('Disable selected discovery rules?')); $goComboBox->addItem($goOption); $goOption = new CComboItem('drule.massdelete', _('Delete selected')); $goOption->setAttribute('confirm', _('Delete selected discovery rules?'));
$graphWidget->addHeader(_('Graphs'), $filterForm); if (!empty($this->data['hostid'])) { $graphWidget->addItem(get_header_host_table('graphs', $this->data['hostid'])); } } $graphWidget->addHeaderRowNumber(); // create form $graphForm = new CForm(); $graphForm->setName('graphForm'); $graphForm->addVar('hostid', $this->data['hostid']); if (!empty($this->data['parent_discoveryid'])) { $graphForm->addVar('parent_discoveryid', $this->data['parent_discoveryid']); } // create table $graphTable = new CTableInfo(!empty($this->data['parent_discoveryid']) ? _('No graph prototypes found.') : _('No graphs found.')); $graphTable->setHeader(array(new CCheckBox('all_graphs', null, "checkAll('" . $graphForm->getName() . "', 'all_graphs', 'group_graphid');"), $this->data['displayNodes'] ? _('Node') : null, !empty($this->data['hostid']) ? null : _('Hosts'), make_sorting_header(_('Name'), 'name'), _('Width'), _('Height'), make_sorting_header(_('Graph type'), 'graphtype'))); foreach ($this->data['graphs'] as $graph) { $graphid = $graph['graphid']; $hostList = null; if (empty($this->data['hostid'])) { $hostList = array(); foreach ($graph['hosts'] as $host) { $hostList[$host['name']] = $host['name']; } foreach ($graph['templates'] as $template) { $hostList[$template['name']] = $template['name']; } $hostList = implode(', ', $hostList); } $isCheckboxEnabled = true; $name = array();
// append form header to widget $userGroupListForm = new CForm('get'); $userGroupComboBox = new CComboBox('filter_usrgrpid', $_REQUEST['filter_usrgrpid'], 'submit()'); $userGroupComboBox->addItem(0, _('All')); foreach ($this->data['userGroups'] as $userGroup) { $userGroupComboBox->addItem($userGroup['usrgrpid'], $userGroup['name']); } $userGroupListForm->addItem(array(_('User group') . SPACE, $userGroupComboBox)); $usersWidget->addHeader(_('Users'), $userGroupListForm); $usersWidget->addHeaderRowNumber(); // create form $usersForm = new CForm(); $usersForm->setName('userForm'); // create users table $usersTable = new CTableInfo(_('No users found.')); $usersTable->setHeader(array(new CCheckBox('all_users', null, "checkAll('" . $usersForm->getName() . "', 'all_users', 'group_userid');"), make_sorting_header(_('Alias'), 'alias', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_x('Name', 'user first name'), 'name', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_('Surname'), 'surname', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_('User type'), 'type', $this->data['sort'], $this->data['sortorder']), _('Groups'), _('Is online?'), _('Login'), _('Frontend access'), _('Debug mode'), _('Status'))); foreach ($this->data['users'] as $user) { $userId = $user['userid']; $session = $this->data['usersSessions'][$userId]; // online time if ($session['lastaccess']) { $onlineTime = $user['autologout'] == 0 || ZBX_USER_ONLINE_TIME < $user['autologout'] ? ZBX_USER_ONLINE_TIME : $user['autologout']; $online = $session['lastaccess'] + $onlineTime >= time() ? new CCol(_('Yes') . ' (' . zbx_date2str(DATE_TIME_FORMAT_SECONDS, $session['lastaccess']) . ')', 'enabled') : new CCol(_('No') . ' (' . zbx_date2str(DATE_TIME_FORMAT_SECONDS, $session['lastaccess']) . ')', 'disabled'); } else { $online = new CCol(_('No'), 'disabled'); } // blocked $blocked = $user['attempt_failed'] >= ZBX_LOGIN_ATTEMPTS ? new CLink(_('Blocked'), 'users.php?action=user.massunblock&group_userid[]=' . $userId, 'on') : new CSpan(_('Ok'), 'green'); // user groups order_result($user['usrgrps'], 'name'); $usersGroups = array();
**/ $sysmapWidget = new CWidget(); // create header buttons $createForm = new CForm('get'); $createForm->cleanItems(); $createForm->addItem(new CSubmit('form', _('Create map'))); $createForm->addItem(new CButton('form', _('Import'), 'redirect("conf.import.php?rules_preset=map")')); $sysmapWidget->addPageHeader(_('CONFIGURATION OF NETWORK MAPS'), $createForm); // create form $sysmapForm = new CForm(); $sysmapForm->setName('frm_maps'); $sysmapWidget->addHeader(_('Maps')); $sysmapWidget->addHeaderRowNumber(); // create table $sysmapTable = new CTableInfo(_('No maps found.')); $sysmapTable->setHeader(array(new CCheckBox('all_maps', null, "checkAll('" . $sysmapForm->getName() . "', 'all_maps', 'maps');"), $this->data['displayNodes'] ? _('Node') : null, make_sorting_header(_('Name'), 'name'), make_sorting_header(_('Width'), 'width'), make_sorting_header(_('Height'), 'height'), _('Edit'))); foreach ($this->data['maps'] as $map) { $sysmapTable->addRow(array(new CCheckBox('maps[' . $map['sysmapid'] . ']', null, null, $map['sysmapid']), $this->data['displayNodes'] ? $map['nodename'] : null, new CLink($map['name'], 'sysmap.php?sysmapid=' . $map['sysmapid']), $map['width'], $map['height'], new CLink(_('Edit'), 'sysmaps.php?form=update&sysmapid=' . $map['sysmapid'] . '#form'))); } // create go button $goComboBox = new CComboBox('go'); $goComboBox->addItem('export', _('Export selected')); $goOption = new CComboItem('delete', _('Delete selected')); $goOption->setAttribute('confirm', _('Delete selected maps?')); $goComboBox->addItem($goOption); $goButton = new CSubmit('goButton', _('Go') . ' (0)'); $goButton->setAttribute('id', 'goButton'); zbx_add_post_js('chkbxRange.pageGoName = "maps";'); // append table to form $sysmapForm->addItem(array($this->data['paging'], $sysmapTable, $this->data['paging'], get_table_header(array($goComboBox, $goButton)))); // append form to widget
$createForm->addItem(new CSubmit('form', _('Create host prototype'))); $itemsWidget->addPageHeader(_('CONFIGURATION OF HOST PROTOTYPES'), $createForm); // header $itemsWidget->addHeader(array(_('Host prototypes of') . SPACE, new CSpan($this->data['discovery_rule']['name'], 'parent-discovery'))); $itemsWidget->addHeaderRowNumber(); $itemsWidget->addItem(get_header_host_table('hosts', $discoveryRule['hostid'], $this->data['parent_discoveryid'])); // create form $itemForm = new CForm(); $itemForm->setName('hosts'); $itemForm->addVar('parent_discoveryid', $this->data['parent_discoveryid']); // create table $hostTable = new CTableInfo(_('No host prototypes found.')); $sortLink = new CUrl(); $sortLink->setArgument('parent_discoveryid', $this->data['parent_discoveryid']); $sortLink = $sortLink->getUrl(); $hostTable->setHeader(array(new CCheckBox('all_hosts', null, "checkAll('" . $itemForm->getName() . "', 'all_hosts', 'group_hostid');"), make_sorting_header(_('Name'), 'name', $sortLink), _('Templates'), make_sorting_header(_('Status'), 'status', $sortLink))); foreach ($this->data['hostPrototypes'] as $hostPrototype) { // name $name = array(); if ($hostPrototype['templateid']) { $sourceTemplate = $hostPrototype['sourceTemplate']; $name[] = new CLink($sourceTemplate['name'], '?parent_discoveryid=' . $hostPrototype['sourceDiscoveryRuleId'], 'unknown'); $name[] = NAME_DELIMITER; } $name[] = new CLink($hostPrototype['name'], '?form=update&parent_discoveryid=' . $discoveryRule['itemid'] . '&hostid=' . $hostPrototype['hostid']); // template list if (empty($hostPrototype['templates'])) { $hostTemplates = '-'; } else { $hostTemplates = array(); order_result($hostPrototype['templates'], 'name');
} else { $hostHeader = make_sorting_header(_('Host'), 'host', $sortField, $sortOrder); $hostHeader->addClass('latest-host'); $hostHeader->setAttribute('title', _('Host')); $hostColumn = ''; } $nameHeader = make_sorting_header(_('Name'), 'name', $sortField, $sortOrder); $nameHeader->setAttribute('title', _('Name')); $lastCheckHeader = make_sorting_header(_('Last check'), 'lastclock', $sortField, $sortOrder); $lastCheckHeader->addClass('latest-lastcheck'); $lastCheckHeader->setAttribute('title', _('Last check')); $lastValueHeader = new CCol(new CSpan(_('Last value')), 'latest-lastvalue'); $lastValueHeader->setAttribute('title', _('Last value')); $lastDataHeader = new CCol(new CSpan(_x('Change', 'noun in latest data')), 'latest-data'); $lastDataHeader->setAttribute('title', _x('Change', 'noun in latest data')); $checkAllCheckbox = new CCheckBox('all_items', null, "checkAll('" . $form->getName() . "', 'all_items', 'itemids');"); $checkAllCheckboxCol = new CCol($checkAllCheckbox, 'latest-checkbox'); if ($filter['showDetails']) { $intervalHeader = new CCol(new CSpan(_('Interval')), 'latest-interval'); $intervalHeader->setAttribute('title', _('Interval')); $historyHeader = new CCol(new CSpan(_('History')), 'latest-history'); $historyHeader->setAttribute('title', _('History')); $trendsHeader = new CCol(new CSpan(_('Trends')), 'latest-trends'); $trendsHeader->setAttribute('title', _('Trends')); $typeHeader = new CCol(new CSpan(_('Type')), 'latest-type'); $typeHeader->setAttribute('title', _('Type')); $infoHeader = new CCol(new CSpan(_('Info')), 'latest-info'); $infoHeader->setAttribute('title', _('Info')); $table->addClass('latest-details'); $table->setHeader(array(new CCol(new CDiv(null, 'app-list-toggle-all icon-plus-9x9')), $checkAllCheckboxCol, $hostHeader, $nameHeader, $intervalHeader, $historyHeader, $trendsHeader, $typeHeader, $lastCheckHeader, $lastValueHeader, $lastDataHeader, new CCol(null, 'latest-actions'), $infoHeader)); } else {