diff options
Diffstat (limited to 'frontends/php/proxies.php')
-rw-r--r-- | frontends/php/proxies.php | 88 |
1 files changed, 52 insertions, 36 deletions
diff --git a/frontends/php/proxies.php b/frontends/php/proxies.php index c8425595420..c7bef168fa3 100644 --- a/frontends/php/proxies.php +++ b/frontends/php/proxies.php @@ -37,23 +37,28 @@ $fields = array( 'hosts' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), 'description' => array(T_ZBX_STR, O_OPT, null, 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('"proxy.massenable","proxy.massdisable","proxy.massdelete"'), + 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), '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_STR, 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('"host"'), 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('host', ZBX_SORT_UP); /* * Permissions */ if (isset($_REQUEST['proxyid'])) { $dbProxy = API::Proxy()->get(array( - 'proxyids' => get_request('proxyid'), + 'proxyids' => getRequest('proxyid'), 'selectHosts' => array('hostid', 'host'), 'selectInterface' => API_OUTPUT_EXTEND, 'output' => API_OUTPUT_EXTEND @@ -63,7 +68,7 @@ if (isset($_REQUEST['proxyid'])) { access_deny(); } } -if (isset($_REQUEST['go'])) { +if (isset($_REQUEST['action'])) { if (!isset($_REQUEST['hosts']) || !is_array($_REQUEST['hosts'])) { access_deny(); } @@ -79,16 +84,15 @@ if (isset($_REQUEST['go'])) { } } } -$_REQUEST['go'] = get_request('go', 'none'); /* * Actions */ if (isset($_REQUEST['save'])) { $proxy = array( - 'host' => get_request('host'), - 'status' => get_request('status'), - 'interface' => get_request('interface'), + 'host' => getRequest('host'), + 'status' => getRequest('status'), + 'interface' => getRequest('interface'), 'description' => getRequest('description') ); @@ -96,7 +100,7 @@ if (isset($_REQUEST['save'])) { // skip discovered hosts $proxy['hosts'] = API::Host()->get(array( - 'hostids' => get_request('hosts', array()), + 'hostids' => getRequest('hosts', array()), 'output' => array('hostid'), 'filter' => array('flags' => ZBX_FLAG_DISCOVERY_NORMAL) )); @@ -124,19 +128,20 @@ if (isset($_REQUEST['save'])) { unset($_REQUEST['save']); $result = DBend($result); + + if ($result) { + uncheckTableRows(); + } show_messages($result, $messageSuccess, $messageFailed); - clearCookies($result); } elseif (isset($_REQUEST['delete'])) { $result = API::Proxy()->delete(array($_REQUEST['proxyid'])); if ($result) { unset($_REQUEST['form'], $_REQUEST['proxyid']); - $proxy = reset($dbProxy); + uncheckTableRows(); } - show_messages($result, _('Proxy deleted'), _('Cannot delete proxy')); - clearCookies($result); unset($_REQUEST['delete']); } @@ -144,11 +149,11 @@ elseif (isset($_REQUEST['clone']) && isset($_REQUEST['proxyid'])) { unset($_REQUEST['proxyid'], $_REQUEST['hosts']); $_REQUEST['form'] = 'clone'; } -elseif (str_in_array(getRequest('go'), array('activate', 'disable')) && hasRequest('hosts')) { +elseif (str_in_array(getRequest('action'), array('proxy.massenable', 'proxy.massdisable')) && hasRequest('hosts')) { $result = true; - $enable =(getRequest('go') == 'activate'); + $enable =(getRequest('action') == 'proxy.massenable'); $status = $enable ? HOST_STATUS_MONITORED : HOST_STATUS_NOT_MONITORED; - $hosts = getRequest('hosts', array()); + $hosts = getRequest('hosts'); DBstart(); @@ -175,6 +180,10 @@ elseif (str_in_array(getRequest('go'), array('activate', 'disable')) && hasReque $result = DBend($result && $hosts); + if ($result) { + uncheckTableRows(); + } + $messageSuccess = $enable ? _n('Host enabled', 'Hosts enabled', $updated) : _n('Host disabled', 'Hosts disabled', $updated); @@ -183,16 +192,17 @@ elseif (str_in_array(getRequest('go'), array('activate', 'disable')) && hasReque : _n('Cannot disable host', 'Cannot disable hosts', $updated); show_messages($result, $messageSuccess, $messageFailed); - clearCookies($result); } -elseif ($_REQUEST['go'] == 'delete' && isset($_REQUEST['hosts'])) { +elseif (hasRequest('action') && getRequest('action') == 'proxy.massdelete' && hasRequest('hosts')) { DBstart(); - $goResult = API::Proxy()->delete(get_request('hosts')); - $goResult = DBend($goResult); + $result = API::Proxy()->delete(getRequest('hosts')); + $result = DBend($result); - show_messages($goResult, _('Proxy deleted'), _('Cannot delete proxy')); - clearCookies($goResult); + if ($result) { + uncheckTableRows(); + } + show_messages($result, _('Proxy deleted'), _('Cannot delete proxy')); } /* @@ -200,13 +210,13 @@ elseif ($_REQUEST['go'] == 'delete' && isset($_REQUEST['hosts'])) { */ if (isset($_REQUEST['form'])) { $data = array( - 'form' => get_request('form', 1), - 'form_refresh' => get_request('form_refresh', 0) + 1, - 'proxyid' => get_request('proxyid', 0), - 'name' => get_request('host', ''), - 'status' => get_request('status', HOST_STATUS_PROXY_ACTIVE), - 'hosts' => get_request('hosts', array()), - 'interface' => get_request('interface', array()), + 'form' => getRequest('form', 1), + 'form_refresh' => getRequest('form_refresh', 0) + 1, + 'proxyid' => getRequest('proxyid', 0), + 'name' => getRequest('host', ''), + 'status' => getRequest('status', HOST_STATUS_PROXY_ACTIVE), + 'hosts' => getRequest('hosts', array()), + 'interface' => getRequest('interface', array()), 'proxy' => array(), 'description' => getRequest('description', '') ); @@ -249,17 +259,23 @@ if (isset($_REQUEST['form'])) { $proxyView->show(); } else { + $sortField = getRequest('sort', CProfile::get('web.'.$page['file'].'.sort', 'host')); + $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( - 'config' => select_config() + 'config' => select_config(), + 'sort' => $sortField, + 'sortorder' => $sortOrder ); - $sortfield = getPageSortField('host'); - $data['proxies'] = API::Proxy()->get(array( 'editable' => true, 'selectHosts' => array('hostid', 'host', 'name', 'status'), 'output' => API_OUTPUT_EXTEND, - 'sortfield' => $sortfield, + 'sortfield' => $sortField, 'limit' => $config['search_limit'] + 1 )); $data['proxies'] = zbx_toHash($data['proxies'], 'proxyid'); @@ -267,8 +283,8 @@ else { $proxyIds = array_keys($data['proxies']); // sorting & paging - order_result($data['proxies'], $sortfield, getPageSortOrder()); - $data['paging'] = getPagingLine($data['proxies'], array('proxyid')); + order_result($data['proxies'], $sortField, $sortOrder); + $data['paging'] = getPagingLine($data['proxies']); // calculate performance $dbPerformance = DBselect( |