diff options
Diffstat (limited to 'frontends/php/host_discovery.php')
-rw-r--r-- | frontends/php/host_discovery.php | 78 |
1 files changed, 48 insertions, 30 deletions
diff --git a/frontends/php/host_discovery.php b/frontends/php/host_discovery.php index fb36d818b98..b253ff07c9e 100644 --- a/frontends/php/host_discovery.php +++ b/frontends/php/host_discovery.php @@ -31,7 +31,7 @@ $page['hist_arg'] = array('hostid'); require_once dirname(__FILE__).'/include/page_header.php'; -$paramsFieldName = getParamFieldNameByType(get_request('type', 0)); +$paramsFieldName = getParamFieldNameByType(getRequest('type', 0)); // supported eval types $evalTypes = array( @@ -73,7 +73,7 @@ $fields = array( 'isset({save})&&isset({type})&&({type})=='.ITEM_TYPE_SSH.'&&({authtype})=='.ITEM_AUTHTYPE_PUBLICKEY), $paramsFieldName => array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, 'isset({save})&&isset({type})&&'. IN(ITEM_TYPE_SSH.','.ITEM_TYPE_DB_MONITOR.','.ITEM_TYPE_TELNET.','.ITEM_TYPE_CALCULATED, 'type'), - getParamFieldLabelByType(get_request('type', 0))), + getParamFieldLabelByType(getRequest('type', 0))), 'snmp_community' => array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, 'isset({save})&&isset({type})&&'.IN(ITEM_TYPE_SNMPV1.','.ITEM_TYPE_SNMPV2C,'type'), _('SNMP community')), @@ -99,7 +99,7 @@ $fields = array( 'isset({save})&&(isset({type})&&({type}=='.ITEM_TYPE_SNMPV3.')&&({snmpv3_securitylevel}=='.ITEM_SNMPV3_SECURITYLEVEL_AUTHPRIV.'))'), 'snmpv3_privpassphrase' => array(T_ZBX_STR, O_OPT, null, null, 'isset({save})&&(isset({type})&&({type}=='.ITEM_TYPE_SNMPV3.')&&({snmpv3_securitylevel}=='.ITEM_SNMPV3_SECURITYLEVEL_AUTHPRIV.'))'), - 'ipmi_sensor' => array(T_ZBX_STR, O_OPT, NO_TRIM, NOT_EMPTY, + 'ipmi_sensor' => array(T_ZBX_STR, O_OPT, P_NO_TRIM, NOT_EMPTY, 'isset({save})&&(isset({type})&&({type}=='.ITEM_TYPE_IPMI.'))', _('IPMI sensor')), 'trapper_hosts' => array(T_ZBX_STR, O_OPT, null, null, 'isset({save})&&isset({type})&&({type}==2)'), 'lifetime' => array(T_ZBX_STR, O_OPT, null, null, 'isset({save})'), @@ -108,7 +108,10 @@ $fields = array( 'formula' => array(T_ZBX_STR, O_OPT, null, null, 'isset({save})'), 'conditions' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), // actions - 'go' => array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null), + 'action' => array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, + IN('"discoveryrule.massdelete","discoveryrule.massdisable","discoveryrule.massenable"'), + null + ), 'g_hostdruleid' => array(T_ZBX_INT, O_OPT, null, DB_ID, null), 'save' => array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null), 'clone' => array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null), @@ -116,19 +119,20 @@ $fields = array( 'delete' => array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null), 'cancel' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'form' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), - 'form_refresh' => array(T_ZBX_INT, O_OPT, null, null, null) + 'form_refresh' => array(T_ZBX_INT, O_OPT, null, null, null), + // sort and sortorder + 'sort' => array(T_ZBX_STR, O_OPT, P_SYS, IN('"delay","key_","name","status","type"'), null), + 'sortorder' => array(T_ZBX_STR, O_OPT, P_SYS, IN('"'.ZBX_SORT_DOWN.'","'.ZBX_SORT_UP.'"'), null) ); check_fields($fields); -validate_sort_and_sortorder('name', ZBX_SORT_UP); -$_REQUEST['go'] = get_request('go', 'none'); -$_REQUEST['params'] = get_request($paramsFieldName, ''); +$_REQUEST['params'] = getRequest($paramsFieldName, ''); unset($_REQUEST[$paramsFieldName]); /* * Permissions */ -if (get_request('itemid', false)) { +if (getRequest('itemid', false)) { $item = API::DiscoveryRule()->get(array( 'itemids' => $_REQUEST['itemid'], 'output' => API_OUTPUT_EXTEND, @@ -161,7 +165,7 @@ else { */ if (isset($_REQUEST['add_delay_flex']) && isset($_REQUEST['new_delay_flex'])) { $timePeriodValidator = new CTimePeriodValidator(array('allowMultiple' => false)); - $_REQUEST['delay_flex'] = get_request('delay_flex', array()); + $_REQUEST['delay_flex'] = getRequest('delay_flex', array()); if ($timePeriodValidator->validate($_REQUEST['new_delay_flex']['period'])) { array_push($_REQUEST['delay_flex'], $_REQUEST['new_delay_flex']); @@ -175,12 +179,15 @@ if (isset($_REQUEST['add_delay_flex']) && isset($_REQUEST['new_delay_flex'])) { elseif (isset($_REQUEST['delete']) && isset($_REQUEST['itemid'])) { $result = API::DiscoveryRule()->delete(array(getRequest('itemid'))); + if ($result) { + uncheckTableRows(getRequest('hostid')); + } show_messages($result, _('Discovery rule deleted'), _('Cannot delete discovery rule')); + unset($_REQUEST['itemid'], $_REQUEST['form']); - clearCookies($result, $_REQUEST['hostid']); } elseif (isset($_REQUEST['save'])) { - $delay_flex = get_request('delay_flex', array()); + $delay_flex = getRequest('delay_flex', array()); $db_delay_flex = ''; foreach ($delay_flex as $val) { @@ -230,7 +237,7 @@ elseif (isset($_REQUEST['save'])) { $conditions = array_values($conditions); foreach ($conditions as $condition) { if (!zbx_empty($condition['macro'])) { - $condition['macro'] = zbx_strtoupper($condition['macro']); + $condition['macro'] = mb_strtoupper($condition['macro']); $filter['conditions'][] = $condition; } @@ -292,17 +299,21 @@ elseif (isset($_REQUEST['save'])) { if ($result) { unset($_REQUEST['itemid'], $_REQUEST['form']); - clearCookies($result, $_REQUEST['hostid']); + uncheckTableRows(getRequest('hostid')); } } -elseif (str_in_array(getRequest('go'), array('activate', 'disable')) && hasRequest('g_hostdruleid')) { +elseif (hasRequest('action') && str_in_array(getRequest('action'), array('discoveryrule.massenable', 'discoveryrule.massdisable')) && hasRequest('g_hostdruleid')) { $groupHostDiscoveryRuleId = getRequest('g_hostdruleid'); - $enable = (getRequest('go') == 'activate'); + $enable = (getRequest('action') == 'discoveryrule.massenable'); DBstart(); $result = $enable ? activate_item($groupHostDiscoveryRuleId) : disable_item($groupHostDiscoveryRuleId); $result = DBend($result); + if ($result) { + uncheckTableRows(getRequest('hostid')); + } + $updated = count($groupHostDiscoveryRuleId); $messageSuccess = $enable @@ -313,13 +324,14 @@ elseif (str_in_array(getRequest('go'), array('activate', 'disable')) && hasReque : _n('Cannot disable discovery rules', 'Cannot disable discovery rules', $updated); show_messages($result, $messageSuccess, $messageFailed); - clearCookies($result, getRequest('hostid')); } -elseif ($_REQUEST['go'] == 'delete' && isset($_REQUEST['g_hostdruleid'])) { - $goResult = API::DiscoveryRule()->delete($_REQUEST['g_hostdruleid']); +elseif (hasRequest('action') && getRequest('action') == 'discoveryrule.massdelete' && hasRequest('g_hostdruleid')) { + $result = API::DiscoveryRule()->delete(getRequest('g_hostdruleid')); - show_messages($goResult, _('Discovery rules deleted'), _('Cannot delete discovery rules')); - clearCookies($goResult, $_REQUEST['hostid']); + if ($result) { + uncheckTableRows(getRequest('hostid')); + } + show_messages($result, _('Discovery rules deleted'), _('Cannot delete discovery rules')); } /* @@ -355,14 +367,20 @@ if (isset($_REQUEST['form'])) { $itemView->show(); } else { + $sortField = getRequest('sort', CProfile::get('web.'.$page['file'].'.sort', 'name')); + $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); + $data = array( - 'hostid' => get_request('hostid', 0), + 'hostid' => getRequest('hostid', 0), 'host' => $host, - 'showInfoColumn' => ($host['status'] != HOST_STATUS_TEMPLATE) + 'showInfoColumn' => ($host['status'] != HOST_STATUS_TEMPLATE), + 'sort' => $sortField, + 'sortorder' => $sortOrder ); - $sortfield = getPageSortField('name'); - // discoveries $data['discoveries'] = API::DiscoveryRule()->get(array( 'hostids' => $data['hostid'], @@ -372,21 +390,21 @@ else { 'selectGraphs' => API_OUTPUT_COUNT, 'selectTriggers' => API_OUTPUT_COUNT, 'selectHostPrototypes' => API_OUTPUT_COUNT, - 'sortfield' => $sortfield, + 'sortfield' => $sortField, 'limit' => $config['search_limit'] + 1 )); $data['discoveries'] = CMacrosResolverHelper::resolveItemNames($data['discoveries']); - if ($sortfield === 'status') { - orderItemsByStatus($data['discoveries'], getPageSortOrder()); + if ($sortField === 'status') { + orderItemsByStatus($data['discoveries'], $sortOrder); } else { - order_result($data['discoveries'], $sortfield, getPageSortOrder()); + order_result($data['discoveries'], $sortField, $sortOrder); } // paging - $data['paging'] = getPagingLine($data['discoveries'], array('itemid'), array('hostid' => get_request('hostid'))); + $data['paging'] = getPagingLine($data['discoveries']); // render view $discoveryView = new CView('configuration.host.discovery.list', $data); |