diff options
28 files changed, 484 insertions, 288 deletions
@@ -1,5 +1,6 @@ Changes for 1.5: + - [DEV-66] added sorting to screens (Artem) - The last character for last value is unreadable (Sasha) - [DEV-60] added availability of setting hosts view style in overview (Artem) - [DEV-53] added different style for dependent triggers in "Status of triggers" (Artem) diff --git a/frontends/php/actionconf.php b/frontends/php/actionconf.php index 4b0edd93..a590bcc5 100644 --- a/frontends/php/actionconf.php +++ b/frontends/php/actionconf.php @@ -82,6 +82,7 @@ include_once "include/page_header.php"; ); check_fields($fields); + validate_sort_and_sortorder(); if(isset($_REQUEST['actionid']) && !action_accessiable($_REQUEST['actionid'], PERM_READ_WRITE)) { @@ -339,14 +340,18 @@ include_once "include/page_header.php"; $tblActions = new CTableInfo(S_NO_ACTIONS_DEFINED); $tblActions->SetHeader(array( array( new CCheckBox('all_items',null,'CheckAll("'.$form->GetName().'","all_items");'), - S_NAME + make_sorting_link(S_NAME,'a.name') ), S_CONDITIONS, S_OPERATIONS, - S_STATUS)); - - $db_actions = DBselect('select * from actions where eventsource='.$_REQUEST['eventsource']. - ' and '.DBin_node('actionid').' order by name,actionid'); + make_sorting_link(S_STATUS,'a.status') + )); + + $db_actions = DBselect('SELECT a.* '. + ' FROM actions a'. + ' WHERE a.eventsource='.$_REQUEST['eventsource']. + ' AND '.DBin_node('actionid'). + order_by('a.name,a.status','a.actionid')); while($action_data = DBfetch($db_actions)) { if(!action_accessiable($action_data['actionid'], PERM_READ_WRITE)) continue; diff --git a/frontends/php/actions.php b/frontends/php/actions.php index f6ad5a85..1a123e57 100644 --- a/frontends/php/actions.php +++ b/frontends/php/actions.php @@ -43,6 +43,7 @@ include_once "include/page_header.php"; ); check_fields($fields); + validate_sort_and_sortorder(); ?> <?php diff --git a/frontends/php/discovery.php b/frontends/php/discovery.php index 7bad84e9..b8358ce8 100644 --- a/frontends/php/discovery.php +++ b/frontends/php/discovery.php @@ -17,8 +17,7 @@ ** along with this program; if not, write to the Free Software ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. **/ -?> -<?php + require_once "include/config.inc.php"; require_once "include/discovery.inc.php"; $page['hist_arg'] = array('druleid'); @@ -28,17 +27,15 @@ include_once "include/page_header.php"; -?> -<?php + // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields=array( "druleid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), ); check_fields($fields); + validate_sort_and_sortorder(); -?> -<?php $r_form = new CForm(); $r_form->SetMethod('get'); @@ -55,11 +52,11 @@ include_once "include/page_header.php"; $r_form->AddItem(array(S_DISCOVERY_RULE.SPACE,$cmbDRules)); show_table_header(S_STATUS_OF_DISCOVERY_BIG, $r_form); -?> -<?php - $db_dhosts = DBselect('select * from dhosts'. - ($druleid > 0 ? ' where druleid='.$druleid : ''). - ' order by status,ip' + + $db_dhosts = DBselect('SELECT d.* '. + ' FROM dhosts d'. + ($druleid > 0 ? ' WHERE d.druleid='.$druleid : ''). + order_by('d.dhostid','d.status,d.ip') ); $services = array(); @@ -77,7 +74,9 @@ include_once "include/page_header.php"; $discovery_info[$drule_data['ip']] = array('class' => $class, 'time' => $drule_data[$time], 'druleid' => $drule_data['druleid']); - $db_dservices = DBselect('select * from dservices where dhostid='.$drule_data['dhostid'].' order by status,type,port'); + $db_dservices = DBselect('SELECT * FROM dservices '. + ' WHERE dhostid='.$drule_data['dhostid']. + ' order by status,type,port'); while($dservice_data = DBfetch($db_dservices)) { $class = 'active'; @@ -103,8 +102,8 @@ include_once "include/page_header.php"; ksort($services); $header = array( - is_show_subnodes() ? S_NODE : null, - new CCol(S_HOST, 'center'), + is_show_subnodes() ? new CCol(S_NODE, 'center') : null, + new CCol(make_sorting_link(S_HOST,'d.dhostid'), 'center'), new CCol(S_UPTIME.'/'.BR.S_DOWNTIME,'center') ); diff --git a/frontends/php/discoveryconf.php b/frontends/php/discoveryconf.php index be9b9e95..df941d44 100644 --- a/frontends/php/discoveryconf.php +++ b/frontends/php/discoveryconf.php @@ -70,6 +70,8 @@ include_once "include/page_header.php"; ); check_fields($fields); + validate_sort_and_sortorder(); + $_REQUEST['dchecks'] = get_request('dchecks', array()); ?> @@ -201,15 +203,18 @@ include_once "include/page_header.php"; $tblDiscovery = new CTableInfo(S_NO_DISCOVERY_RULES_DEFINED); $tblDiscovery->SetHeader(array( array( new CCheckBox('all_drules',null,"CheckAll('".$form->GetName()."','all_drules');"), - S_NAME + make_sorting_link(S_NAME,'d.name') ), - S_IP_RANGE, - S_DELAY, + make_sorting_link(S_IP_RANGE,'d.iprange'), + make_sorting_link(S_DELAY,'d.delay'), S_CHECKS, S_STATUS)); - $db_rules = DBselect('select * from drules where '.DBin_node('druleid'). - ' order by name, druleid'); + $db_rules = DBselect('SELECT d.* '. + ' FROM drules d'. + ' WHERE '.DBin_node('druleid'). + order_by('d.name,d.iprange,d.delay','d.druleid')); + while($rule_data = DBfetch($db_rules)) { $cheks = array(); diff --git a/frontends/php/events.php b/frontends/php/events.php index 7439fda9..e3766107 100644 --- a/frontends/php/events.php +++ b/frontends/php/events.php @@ -55,7 +55,8 @@ include_once "include/page_header.php"; $_REQUEST['source'] = get_request('source', get_profile('web.events.source', 0)); check_fields($fields); - + validate_sort_and_sortorder(); + $source = get_request('source', EVENT_SOURCE_TRIGGERS); $show_unknown = get_request('show_unknown',get_profile('web.events.show_unknown',0)); @@ -190,7 +191,7 @@ include_once "include/page_header.php"; show_table_header($l_form,$r_form); - $table->Show(); + $table->Show(); ?> <?php diff --git a/frontends/php/exp_imp.php b/frontends/php/exp_imp.php index 4b90caf3..1e989e3d 100644 --- a/frontends/php/exp_imp.php +++ b/frontends/php/exp_imp.php @@ -63,7 +63,8 @@ include_once "include/page_header.php"; ); check_fields($fields); - + validate_sort_and_sortorder(); + $preview = isset($_REQUEST['preview']) ? true : false; $config = get_request('config', 0); $update = get_request('update', null); @@ -293,11 +294,11 @@ include_once "include/page_header.php"; $table = new CTableInfo(S_NO_HOSTS_DEFINED); $table->SetHeader(array( array( new CCheckBox("all_hosts",true, "CheckAll('".$form->GetName()."','all_hosts','hosts');"), - S_NAME), - S_DNS, - S_IP, - S_PORT, - S_STATUS, + make_sorting_link(S_NAME,'h.host')), + make_sorting_link(S_DNS,'h.dns'), + make_sorting_link(S_IP,'h.ip'), + make_sorting_link(S_PORT,'h.port'), + make_sorting_link(S_STATUS,'h.status'), array( new CCheckBox("all_templates",true, "CheckAll('".$form->GetName()."','all_templates','templates');"), S_TEMPLATES), array( new CCheckBox("all_items",true, "CheckAll('".$form->GetName()."','all_items','items');"), @@ -312,14 +313,19 @@ include_once "include/page_header.php"; */ )); - $sql = "select h.* from"; - if(isset($_REQUEST["groupid"])) - { - $sql .= " hosts h,hosts_groups hg where"; - $sql .= " hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid and"; - } else $sql .= " hosts h where"; - $sql .= " h.hostid in (".$available_hosts.") ". - " order by h.host"; + $sql = 'SELECT h.* '. + ' FROM '; + if(isset($_REQUEST["groupid"])){ + $sql .= ' hosts h,hosts_groups hg '; + $sql .= ' WHERE hg.groupid='.$_REQUEST['groupid']. + ' AND hg.hostid=h.hostid '. + ' AND'; + } + else $sql .= ' hosts h '. + ' WHERE'; + + $sql .= ' h.hostid in ('.$available_hosts.') '. + order_by('h.host,h.dns,h.ip,h.port,h.status'); $result=DBselect($sql); diff --git a/frontends/php/graphs.php b/frontends/php/graphs.php index f20237e5..4fec67d7 100644 --- a/frontends/php/graphs.php +++ b/frontends/php/graphs.php @@ -84,7 +84,8 @@ include_once "include/page_header.php"; ); check_fields($fields); - + validate_sort_and_sortorder(); + validate_group_with_host(PERM_READ_WRITE,array("allow_all_hosts","always_select_first_host","only_current_node"), 'web.last.conf.groupid', 'web.last.conf.hostid'); ?> @@ -363,28 +364,33 @@ include_once "include/page_header.php"; $table = new CTableInfo(S_NO_GRAPHS_DEFINED); $table->SetHeader(array( $_REQUEST["hostid"] != 0 ? NULL : S_HOSTS, - array( new CCheckBox("all_graphs",NULL, - "CheckAll('".$form->GetName()."','all_graphs');"), - S_NAME), - S_WIDTH,S_HEIGHT,S_GRAPH_TYPE)); + array( new CCheckBox("all_graphs",NULL,"CheckAll('".$form->GetName()."','all_graphs');"), + make_sorting_link(S_NAME,'g.name')), + make_sorting_link(S_WIDTH,'g.width'), + make_sorting_link(S_HEIGHT,'g.height'), + make_sorting_link(S_GRAPH_TYPE,'g.graphtype'))); if($_REQUEST["hostid"] > 0) { - $result = DBselect("SELECT distinct g.* FROM graphs g left join graphs_items gi on g.graphid=gi.graphid ". - " left join items i on gi.itemid=i.itemid ". - " WHERE i.hostid=".$_REQUEST["hostid"]. - " AND i.hostid not in (".$denyed_hosts.") ". - ' and '.DBin_node('g.graphid'). - " AND i.hostid is not NULL ". - " ORDER BY g.name, g.graphid"); + $result = DBselect('SELECT DISTINCT g.* '. + ' FROM graphs g '. + ' LEFT JOIN graphs_items gi ON g.graphid=gi.graphid '. + ' LEFT JOIN items i ON gi.itemid=i.itemid '. + ' WHERE i.hostid='.$_REQUEST['hostid']. + ' AND i.hostid NOT IN ('.$denyed_hosts.') '. + ' AND '.DBin_node('g.graphid'). + ' AND i.hostid is not NULL '. + order_by('g.name,g.width,g.height,g.graphtype','g.graphid')); } else { - $result = DBselect("SELECT distinct g.* FROM graphs g left join graphs_items gi on g.graphid=gi.graphid ". - " left join items i on gi.itemid=i.itemid ". - ' where '.DBin_node('g.graphid'). - " AND ( i.hostid not in (".$denyed_hosts.") OR i.hostid is NULL )". - " ORDER BY g.name, g.graphid"); + $result = DBselect('SELECT DISTINCT g.* '. + ' FROM graphs g '. + ' LEFT JOIN graphs_items gi ON g.graphid=gi.graphid '. + ' LEFT JOIN items i ON gi.itemid=i.itemid '. + ' WHERE '.DBin_node('g.graphid'). + ' AND ( i.hostid not in ('.$denyed_hosts.') OR i.hostid is NULL )'. + order_by('g.name,g.width,g.height,g.graphtype','g.graphid')); } while($row=DBfetch($result)) { diff --git a/frontends/php/hostprofiles.php b/frontends/php/hostprofiles.php index 34e2ffe4..c87d6710 100644 --- a/frontends/php/hostprofiles.php +++ b/frontends/php/hostprofiles.php @@ -38,7 +38,8 @@ include_once "include/page_header.php"; ); check_fields($fields); - + validate_sort_and_sortorder(); + validate_group(PERM_READ_ONLY, array("allow_all_hosts","always_select_first_host","monitored_hosts","with_items")); ?> <?php @@ -77,28 +78,40 @@ include_once "include/page_header.php"; else { $table = new CTableInfo(); - $table->setHeader(array(S_HOST,S_NAME,S_OS,S_SERIALNO,S_TAG,S_MACADDRESS)); + $table->setHeader(array( + is_show_subnodes() ? make_sorting_link(S_NODE,'h.hostid') : null, + make_sorting_link(S_HOST,'h.host'), + make_sorting_link(S_NAME,'p.name'), + make_sorting_link(S_OS,'p.os'), + make_sorting_link(S_SERIALNO,'p.serialno'), + make_sorting_link(S_TAG,'p.tag'), + make_sorting_link(S_MACADDRESS,'p.macaddress')) + ); if($_REQUEST["groupid"] > 0) { - $sql="select h.hostid,h.host,p.name,p.os,p.serialno,p.tag,p.macaddress". - " from hosts h,hosts_profiles p,hosts_groups hg where h.hostid=p.hostid". - " and h.hostid=hg.hostid and hg.groupid=".$_REQUEST["groupid"]. - " and h.hostid in (".$availiable_hosts.") ". - " order by h.host"; + $sql='SELECT h.hostid,h.host,p.name,p.os,p.serialno,p.tag,p.macaddress'. + ' FROM hosts h,hosts_profiles p,hosts_groups hg '. + ' WHERE h.hostid=p.hostid'. + ' and h.hostid=hg.hostid '. + ' and hg.groupid='.$_REQUEST['groupid']. + ' and h.hostid in ('.$availiable_hosts.') '. + order_by('h.host,h.hostid,p.name,p.os,p.serialno,p.tag,p.macaddress'); } - else - { - $sql="select h.hostid,h.host,p.name,p.os,p.serialno,p.tag,p.macaddress". - " from hosts h,hosts_profiles p where h.hostid=p.hostid". - " and h.hostid in (".$availiable_hosts.") ". - " order by h.host"; + else{ + + $sql='SELECT h.hostid,h.host,p.name,p.os,p.serialno,p.tag,p.macaddress'. + ' FROM hosts h,hosts_profiles p '. + ' WHERE h.hostid=p.hostid'. + ' AND h.hostid in ('.$availiable_hosts.') '. + order_by('h.host,h.hostid,p.name,p.os,p.serialno,p.tag,p.macaddress'); } $result=DBselect($sql); while($row=DBfetch($result)) { $table->AddRow(array( + get_node_name_by_elid($row['hostid']), new CLink($row["host"],"?hostid=".$row["hostid"].url_param("groupid"),"action"), $row["name"], $row["os"], diff --git a/frontends/php/hosts.php b/frontends/php/hosts.php index 1014ef30..0851ef90 100644 --- a/frontends/php/hosts.php +++ b/frontends/php/hosts.php @@ -122,7 +122,8 @@ include_once "include/page_header.php"; $_REQUEST["config"] = get_request("config",get_profile("web.host.config",0)); check_fields($fields); - + validate_sort_and_sortorder(); + if($_REQUEST["config"]==4) validate_group_with_host(PERM_READ_WRITE,array("always_select_first_host","only_current_node"),'web.last.conf.groupid', 'web.last.conf.hostid'); elseif($_REQUEST["config"]==0 || $_REQUEST["config"]==3) @@ -604,26 +605,33 @@ include_once "include/page_header.php"; $table = new CTableInfo(S_NO_HOSTS_DEFINED); $table->setHeader(array( array(new CCheckBox("all_hosts",NULL,"CheckAll('".$form->GetName()."','all_hosts');"), - SPACE.S_NAME), - $show_only_tmp ? NULL : S_DNS, - $show_only_tmp ? NULL : S_IP, - $show_only_tmp ? NULL : S_PORT, + SPACE,make_sorting_link(S_NAME,'h.host')), + $show_only_tmp ? NULL : make_sorting_link(S_DNS,'h.dns'), + $show_only_tmp ? NULL : make_sorting_link(S_IP,'h.ip'), + $show_only_tmp ? NULL : make_sorting_link(S_PORT,'h.port'), S_TEMPLATES, - $show_only_tmp ? NULL : S_STATUS, - $show_only_tmp ? NULL : S_AVAILABILITY, + $show_only_tmp ? NULL : make_sorting_link(S_STATUS,'h.status'), + $show_only_tmp ? NULL : make_sorting_link(S_AVAILABILITY,'h.available'), $show_only_tmp ? NULL : S_ERROR, S_ACTIONS )); - $sql="select h.* from"; - if(isset($_REQUEST["groupid"])) - { - $sql .= " hosts h,hosts_groups hg where"; - $sql .= " hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid and"; - } else $sql .= " hosts h where"; - $sql .= " h.hostid in (".$available_hosts.") ". + $sql='SELECT h.* '. + ' FROM'; + + if(isset($_REQUEST["groupid"])){ + $sql.= ' hosts h,hosts_groups hg '; + $sql.= ' WHERE hg.groupid='.$_REQUEST['groupid']. + ' AND hg.hostid=h.hostid '. + ' AND'; + + } + else $sql.= ' hosts h '. + ' WHERE'; + + $sql.= ' h.hostid IN ('.$available_hosts.') '. $status_filter. - " order by h.host"; + order_by('h.host,h.port,h.ip,h.status,h.available,h.dns'); $result=DBselect($sql); @@ -786,22 +794,26 @@ include_once "include/page_header.php"; array( new CCheckBox("all_groups",NULL, "CheckAll('".$form->GetName()."','all_groups');"), SPACE, - S_NAME), - " # ", + make_sorting_link(S_NAME,'g.name')), + ' # ', S_MEMBERS)); $available_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_WRITE,null,null,get_current_nodeid()); - $db_groups=DBselect("select groupid,name from groups". - " where groupid in (".$available_groups.")". - " order by name"); + $db_groups=DBselect('SELECT g.groupid,g.name '. + ' FROM groups g'. + ' WHERE g.groupid in ('.$available_groups.')'. + order_by('g.name')); while($db_group=DBfetch($db_groups)) { - $db_hosts = DBselect("select distinct h.host, h.status". - " from hosts h, hosts_groups hg". - " where h.hostid=hg.hostid and hg.groupid=".$db_group["groupid"]. - " and h.hostid in (".$available_hosts.")". - " and h.status not in (".HOST_STATUS_DELETED.") order by host"); + $db_hosts = DBselect('SELECT DISTINCT h.host, h.status'. + ' FROM hosts h, hosts_groups hg'. + ' WHERE h.hostid=hg.hostid '. + ' AND hg.groupid='.$db_group['groupid']. + ' AND h.hostid in ('.$available_hosts.')'. + ' AND h.status not in ('.HOST_STATUS_DELETED.') '. + ' order by host' + ); $hosts = array(); $count = 0; @@ -843,18 +855,24 @@ include_once "include/page_header.php"; show_table_header(S_TEMPLATE_LINKAGE_BIG); $table = new CTableInfo(S_NO_LINKAGES); - $table->SetHeader(array(S_TEMPLATES,S_HOSTS)); - - $templates = DBSelect("select * from hosts where status=".HOST_STATUS_TEMPLATE. - " and hostid in (".$available_hosts.")". - " order by host"); - while($template = DBfetch($templates)) - { - $hosts = DBSelect("select h.* from hosts h, hosts_templates ht where ht.templateid=".$template["hostid"]. - " and ht.hostid=h.hostid ". - " and h.status not in (".HOST_STATUS_TEMPLATE.")". - " and h.hostid in (".$available_hosts.")". - " order by host"); + $table->SetHeader(array( + make_sorting_link(S_TEMPLATES,'h.host'), + S_HOSTS)); + + $templates = DBSelect('SELECT h.* '. + ' FROM hosts h'. + ' WHERE h.status='.HOST_STATUS_TEMPLATE. + ' AND h.hostid in ('.$available_hosts.') '. + order_by('h.host')); + + while($template = DBfetch($templates)){ + $hosts = DBSelect('SELECT h.* '. + ' FROM hosts h, hosts_templates ht '. + ' WHERE ht.templateid='.$template['hostid']. + ' AND ht.hostid=h.hostid '. + ' AND h.status not in ('.HOST_STATUS_TEMPLATE.') '. + ' AND h.hostid in ('.$available_hosts.') '. + ' ORDER BY host'); $host_list = array(); while($host = DBfetch($hosts)) { @@ -932,14 +950,17 @@ include_once "include/page_header.php"; $table = new CTableInfo(); $table->SetHeader(array( - array(new CCheckBox("all_applications",NULL, - "CheckAll('".$form->GetName()."','all_applications');"), + array(new CCheckBox("all_applications",NULL,"CheckAll('".$form->GetName()."','all_applications');"), SPACE, - S_APPLICATION), + make_sorting_link(S_APPLICATION,'a.name')), S_SHOW )); - $db_applications = DBselect("select * from applications where hostid=".$_REQUEST["hostid"]); + $db_applications = DBselect('SELECT a.* '. + ' FROM applications a'. + ' WHERE a.hostid='.$_REQUEST['hostid']. + order_by('a.name')); + while($db_app = DBfetch($db_applications)) { if($db_app["templateid"]==0) diff --git a/frontends/php/httpconf.php b/frontends/php/httpconf.php index a3b51d69..eac78aec 100644 --- a/frontends/php/httpconf.php +++ b/frontends/php/httpconf.php @@ -76,7 +76,8 @@ include_once "include/page_header.php"; $_REQUEST["showdisabled"] = get_request("showdisabled", get_profile("web.httpconf.showdisabled", 0)); check_fields($fields); - + validate_sort_and_sortorder(); + $showdisabled = get_request("showdisabled", 0); $accessible_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_WRITE,null,null,get_current_nodeid()); @@ -430,24 +431,27 @@ include_once "include/page_header.php"; $table->setHeader(array( array( $link, SPACE, new CCheckBox("all_httptests",null, "CheckAll('".$form->GetName()."','all_httptests');"), - S_NAME), + make_sorting_link(S_NAME,'wt.name')), S_NUMBER_OF_STEPS, S_UPDATE_INTERVAL, - S_STATUS)); + make_sorting_link(S_STATUS,'wt.status'))); $any_app_exist = false; - $db_applications = DBselect('select distinct h.host,h.hostid,a.* from applications a,hosts h '. - ' where a.hostid=h.hostid and h.hostid='.$_REQUEST['hostid']. - ' order by a.name,a.applicationid,h.host'); + $db_applications = DBselect('SELECT DISTINCT h.host,h.hostid,a.* '. + ' FROM applications a,hosts h '. + ' WHERE a.hostid=h.hostid '. + ' AND h.hostid='.$_REQUEST['hostid']. + ' order by a.name,a.applicationid,h.host'); while($db_app = DBfetch($db_applications)) { - $db_httptests = DBselect('select wt.*,a.name as application,h.host,h.hostid from httptest wt '. - ' left join applications a on wt.applicationid=a.applicationid '. - ' left join hosts h on h.hostid=a.hostid'. - ' where a.applicationid='.$db_app["applicationid"]. - ($showdisabled == 0 ? " and wt.status <> 1" : ""). - ' order by h.host,wt.name'); + $db_httptests = DBselect('SELECT wt.*,a.name as application,h.host,h.hostid '. + ' FROM httptest wt '. + ' LEFT JOIN applications a ON wt.applicationid=a.applicationid '. + ' LEFT JOIN hosts h ON h.hostid=a.hostid'. + ' WHERE a.applicationid='.$db_app["applicationid"]. + ($showdisabled == 0 ? " and wt.status <> 1" : ""). + order_by('wt.status,wt.name')); $app_rows = array(); $httptest_cnt = 0; diff --git a/frontends/php/httpmon.php b/frontends/php/httpmon.php index f3b65dff..2671a2eb 100644 --- a/frontends/php/httpmon.php +++ b/frontends/php/httpmon.php @@ -46,6 +46,7 @@ include_once "include/page_header.php"; ); check_fields($fields); + validate_sort_and_sortorder(); validate_group_with_host(PERM_READ_ONLY,array("allow_all_hosts","always_select_first_host","monitored_hosts")); ?> @@ -164,9 +165,9 @@ include_once "include/page_header.php"; $table = new CTableInfo(); $table->SetHeader(array( - is_show_subnodes() ? S_NODE : null, - $_REQUEST["hostid"] ==0 ? S_HOST : NULL, - array($link, SPACE, S_NAME), + is_show_subnodes() ? make_sorting_link(S_NODE,'h.hostid') : null, + $_REQUEST["hostid"] ==0 ? make_sorting_link(S_HOST,'h.host') : NULL, + array($link, SPACE, make_sorting_link(S_NAME,'wt.name')), S_NUMBER_OF_STEPS, S_STATE, S_LAST_CHECK, @@ -178,17 +179,19 @@ include_once "include/page_header.php"; $compare_host = " and h.hostid=".$_REQUEST["hostid"]; else $compare_host = " and h.hostid in (".$accessible_hosts.") "; - - $db_applications = DBselect('select distinct h.host,h.hostid,a.* from applications a,hosts h '. - ' where a.hostid=h.hostid '.$compare_host. - ' order by a.name,a.applicationid,h.host'); + + $db_applications = DBselect('SELECT DISTINCT h.host,h.hostid,a.* '. + ' FROM applications a,hosts h '. + ' WHERE a.hostid=h.hostid '.$compare_host. + order_by('a.applicationid,h.host,h.hostid','a.name') + ); while($db_app = DBfetch($db_applications)) { $db_httptests = DBselect('select wt.*,a.name as application,h.host,h.hostid from httptest wt '. ' left join applications a on wt.applicationid=a.applicationid '. ' left join hosts h on h.hostid=a.hostid'. ' where a.applicationid='.$db_app["applicationid"].' and wt.status <> 1'. - ' order by h.host,wt.name'); + order_by('wt.name','h.host')); $app_rows = array(); $httptest_cnt = 0; diff --git a/frontends/php/images/general/sort_downw.gif b/frontends/php/images/general/sort_downw.gif Binary files differnew file mode 100644 index 00000000..e3a3a83d --- /dev/null +++ b/frontends/php/images/general/sort_downw.gif diff --git a/frontends/php/images/general/sort_upw.gif b/frontends/php/images/general/sort_upw.gif Binary files differnew file mode 100644 index 00000000..8fddee29 --- /dev/null +++ b/frontends/php/images/general/sort_upw.gif diff --git a/frontends/php/include/actions.inc.php b/frontends/php/include/actions.inc.php index f58b5c6c..f7076a5f 100644 --- a/frontends/php/include/actions.inc.php +++ b/frontends/php/include/actions.inc.php @@ -778,27 +778,30 @@ include_once 'include/discovery.inc.php'; global $USER_DETAILS; $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_MODE_LT); - - $result=DBselect("select distinct a.alertid,a.clock,mt.description,a.sendto,a.subject,a.message,a.status,a.retries,". - "a.error from alerts a,media_type mt,functions f,items i ". - " where mt.mediatypeid=a.mediatypeid and a.triggerid=f.triggerid and f.itemid=i.itemid ". - " and i.hostid not in (".$denyed_hosts.")". - ' and '.DBin_node('a.alertid'). - " order by a.clock". - " desc", - 10*$start+$num); $table = new CTableInfo(S_NO_ACTIONS_FOUND); $table->SetHeader(array( - is_show_subnodes() ? S_NODES : null, - S_TIME, - S_TYPE, - S_STATUS, - S_RETRIES_LEFT, - S_RECIPIENTS, + is_show_subnodes() ? make_sorting_link(S_NODES,'a.alertid') : null, + make_sorting_link(S_TIME,'a.clock'), + make_sorting_link(S_TYPE,'mt.description'), + make_sorting_link(S_STATUS,'a.status'), + make_sorting_link(S_RETRIES_LEFT,'a.retries'), + make_sorting_link(S_RECIPIENTS,'a.sendto'), S_MESSAGE, S_ERROR )); + + + $result=DBselect('SELECT DISTINCT a.alertid,a.clock,mt.description,a.sendto,a.subject,a.message,a.status,a.retries,a.error '. + ' FROM alerts a,media_type mt,functions f,items i '. + ' WHERE mt.mediatypeid=a.mediatypeid '. + ' and a.triggerid=f.triggerid '. + ' and f.itemid=i.itemid '. + ' and i.hostid not in ('.$denyed_hosts.')'. + ' and '.DBin_node('a.alertid'). + order_by('a.clock,a.alertid,mt.description,a.sendto,a.status,a.retries'), + 10*$start+$num); + $col=0; $skip=$start; while(($row=DBfetch($result))&&($col<$num)) diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php index 24cec730..931c4497 100644 --- a/frontends/php/include/config.inc.php +++ b/frontends/php/include/config.inc.php @@ -1766,4 +1766,91 @@ function TODO($msg) { echo "TODO: ".$msg.BR; } // DEBUG INFO!!! } return $new; } + + + /* function: + * validate_sort_and_sortorder + * + * description: + * Checking,setting and saving sort params + * + * author: Aly + */ + function validate_sort_and_sortorder(){ + global $page; + + $_REQUEST['sort'] = get_request('sort',get_profile('web.'.$page["file"].'.sort',NULL)); + $_REQUEST['sortorder'] = get_request('sortorder',get_profile('web.'.$page["file"].'.sortorder',ZBX_SORT_UP)); + + if(!is_null($_REQUEST['sort'])){ + $_REQUEST['sort'] = eregi_replace('[^a-z\.\_]','',$_REQUEST['sort']); + update_profile('web.'.$page["file"].'.sort', $_REQUEST['sort']); + } + + if(!in_array($_REQUEST['sortorder'],array(ZBX_SORT_DOWN,ZBX_SORT_UP))) + $_REQUEST['sortorder'] = ZBX_SORT_UP; + + update_profile('web.'.$page["file"].'.sortorder', $_REQUEST['sortorder']); + } + + /* function: + * make_sorting_link + * + * description: + * Creates links for sorting in table header + * + * author: Aly + */ + function make_sorting_link($obj,$tabfield,$url=''){ + global $page; + + $sortorder = ($_REQUEST['sortorder'] == ZBX_SORT_UP)?ZBX_SORT_DOWN:ZBX_SORT_UP; + + if(empty($url)){ + $url='?'; + $url_params = explode('&',$_SERVER['QUERY_STRING']); + foreach($url_params as $id => $param){ + if(empty($param)) continue; + + list($name,$value) = explode('=',$param); + if(empty($name) || ($name == 'sort') || (($name == 'sortorder'))) continue; + $url.=$param.'&'; + } + } + else{ + $url.='&'; + } + + $link = new CLink($obj,$url.'sort='.$tabfield.'&sortorder='.$sortorder); + + if($tabfield == $_REQUEST['sort']){ + if($sortorder == ZBX_SORT_UP){ + $img = new CImg('images/general/sort_downw.gif','down',10,10); + } + else{ + $img = new CImg('images/general/sort_upw.gif','up',10,10); + } + + $img->AddOption('style','line-height: 18px; vertical-align: middle;'); + $link = array($link,SPACE,$img); + } + + return $link; + } + + function order_by($def,$allways=''){ + global $page; + + if(!empty($allways)) $allways = ','.$allways; + $sortable = explode(',',$def); + + $tabfield = get_request('sort',get_profile('web.'.$page["file"].'.sort',null)); + + if(is_null($tabfield)) return ' ORDER BY '.$def.$allways; + if(!in_array($tabfield,$sortable)) return ' ORDER BY '.$def.$allways; + + $sortorder = get_request('sortorder',get_profile('web.'.$page["file"].'.sortorder',ZBX_SORT_UP)); + + return ' ORDER BY '.$tabfield.' '.$sortorder.$allways; + } ?> diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php index 063c8662..a773d373 100644 --- a/frontends/php/include/defines.inc.php +++ b/frontends/php/include/defines.inc.php @@ -71,6 +71,9 @@ define('IMAGE_FORMAT_PNG', 'PNG'); define('IMAGE_FORMAT_JPEG', 'JPEG'); define('IMAGE_FORMAT_TEXT', 'JPEG'); + + define('ZBX_SORT_UP', 'ASC'); + define('ZBX_SORT_DOWN', 'DESC'); // END OF MISC PARAMETERS define('AUDIT_ACTION_ADD', 0); diff --git a/frontends/php/include/events.inc.php b/frontends/php/include/events.inc.php index 459b58e0..2e1f1c3b 100644 --- a/frontends/php/include/events.inc.php +++ b/frontends/php/include/events.inc.php @@ -51,24 +51,27 @@ $sql_cond.= ' AND e.value<>2 '; } - $result = DBselect('SELECT DISTINCT t.triggerid,t.priority,t.description,t.expression,h.host,e.clock,e.value '. + + + $table = new CTableInfo(S_NO_EVENTS_FOUND); + $table->SetHeader(array( + make_sorting_link(S_TIME,'e.clock'), + is_show_subnodes() ? make_sorting_link(S_NODE,'h.hostid') : null, + $hostid == 0 ? make_sorting_link(S_HOST,'h.host') : null, + make_sorting_link(S_DESCRIPTION,'t.description'), + make_sorting_link(S_VALUE,'e.value'), + make_sorting_link(S_SEVERITY,'t.priority') + )); + + $result = DBselect('SELECT DISTINCT t.triggerid,t.priority,t.description,t.expression,h.host,h.hostid,e.clock,e.value '. ' FROM events e, triggers t, functions f, items i, hosts h '.$sql_from. ' WHERE '.DBin_node('t.triggerid'). ' AND e.objectid=t.triggerid and e.object='.EVENT_OBJECT_TRIGGER. ' AND t.triggerid=f.triggerid and f.itemid=i.itemid '. ' AND i.hostid=h.hostid '.$sql_cond.' and h.status='.HOST_STATUS_MONITORED. - ' ORDER BY e.clock DESC,h.host,t.priority,t.description,t.triggerid ',10*($start+$num) + order_by('e.clock,h.host,h.hostid,t.priority,t.description,e.value','t.triggerid') + ,10*($start+$num) ); - - $table = new CTableInfo(S_NO_EVENTS_FOUND); - $table->SetHeader(array( - S_TIME, - is_show_subnodes() ? S_NODE : null, - $hostid == 0 ? S_HOST : null, - S_DESCRIPTION, - S_VALUE, - S_SEVERITY - )); $accessible_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY); diff --git a/frontends/php/include/validate.inc.php b/frontends/php/include/validate.inc.php index 46a03a1f..c30fa424 100644 --- a/frontends/php/include/validate.inc.php +++ b/frontends/php/include/validate.inc.php @@ -539,7 +539,9 @@ $system_fields=array( "sessionid"=> array(T_ZBX_STR, O_OPT, P_SYS, HEX(),NULL), "switch_node"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID,NULL), - "triggers_hash"=> array(T_ZBX_STR, O_OPT, P_SYS, NOT_EMPTY,NULL) + "triggers_hash"=> array(T_ZBX_STR, O_OPT, P_SYS, NOT_EMPTY,NULL), + 'sort'=> array(T_ZBX_STR, O_OPT, P_SYS, NULL,NULL), + 'sortorder'=> array(T_ZBX_STR, O_OPT, P_SYS, NULL,NULL) ); function invalid_url() diff --git a/frontends/php/items.php b/frontends/php/items.php index 88590e1a..f6aecf57 100644 --- a/frontends/php/items.php +++ b/frontends/php/items.php @@ -158,7 +158,8 @@ include_once "include/page_header.php"; $_REQUEST["showdisabled"] = get_request("showdisabled", get_profile("web.items.showdisabled", 0)); check_fields($fields); - + validate_sort_and_sortorder(); + $showdisabled = get_request("showdisabled", 0); $accessible_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_WRITE,null,null,get_current_nodeid()); @@ -739,23 +740,30 @@ include_once "include/page_header.php"; $table = new CTableInfo(); $table->SetHeader(array( - $show_host ? S_HOST : null, + $show_host ? make_sorting_link(S_HOST,'h.host') : null, array( new CCheckBox("all_items",null, "CheckAll('".$form->GetName()."','all_items');"), - S_DESCRIPTION), - S_KEY,nbsp(S_UPDATE_INTERVAL), - S_HISTORY,S_TRENDS,S_TYPE,S_STATUS, + make_sorting_link(S_DESCRIPTION,'i.description')), + make_sorting_link(S_KEY,'i.key_'), + make_sorting_link(nbsp(S_UPDATE_INTERVAL),'i.delay'), + make_sorting_link(S_HISTORY,'i.history'), + make_sorting_link(S_TRENDS,'i.trends'), + make_sorting_link(S_TYPE,'i.type'), + make_sorting_link(S_STATUS,'i.status'), $show_applications ? S_APPLICATIONS : null, S_ERROR)); $from_tables['i'] = 'items i'; /* NOTE: must be added as last element to use left join */ - $db_items = DBselect('select distinct th.host as template_host,th.hostid as template_hostid, h.host, i.* '. - ' from '.implode(',', $from_tables). - ' left join items ti on i.templateid=ti.itemid left join hosts th on ti.hostid=th.hostid '. - ' where '.implode(' and ', $where_case).' order by h.host,i.description,i.key_,i.itemid'); - while($db_item = DBfetch($db_items)) - { + $db_items = DBselect('SELECT DISTINCT th.host as template_host,th.hostid as template_hostid, h.host, i.* '. + ' FROM '.implode(',', $from_tables). + ' LEFT JOIN items ti ON i.templateid=ti.itemid '. + ' LEFT JOIN hosts th ON ti.hostid=th.hostid '. + ' WHERE '.implode(' and ', $where_case). + order_by('h.host,i.description,i.key_,i.delay,i.history,i.trends,i.type,i.status','i.itemid')); + + while($db_item = DBfetch($db_items)){ + $description = array(); $item_description = item_description($db_item["description"],$db_item["key_"]); diff --git a/frontends/php/latest.php b/frontends/php/latest.php index 5ce03428..b2abd625 100644 --- a/frontends/php/latest.php +++ b/frontends/php/latest.php @@ -47,6 +47,7 @@ include_once "include/page_header.php"; ); check_fields($fields); + validate_sort_and_sortorder(); $options = array("allow_all_hosts","always_select_first_host","monitored_hosts","with_monitored_items"); if(!$ZBX_WITH_SUBNODES) array_push($options,"only_current_node"); @@ -176,25 +177,34 @@ include_once "include/page_header.php"; $table=new CTableInfo(); $table->SetHeader(array( - is_show_subnodes() ? S_NODE : null, - $_REQUEST["hostid"] ==0 ? S_HOST : NULL, - ($link->ToString()).SPACE.S_DESCRIPTION, - S_LAST_CHECK,S_LAST_VALUE,S_CHANGE,S_HISTORY)); + is_show_subnodes() ? make_sorting_link(S_NODE,'h.hostid') : null, + $_REQUEST["hostid"] ==0 ? make_sorting_link(S_HOST,'h.host') : NULL, + array($link,SPACE,make_sorting_link(S_DESCRIPTION,'i.description')), + make_sorting_link(S_LAST_CHECK,'i.lastclock'), + S_LAST_VALUE, + S_CHANGE, + S_HISTORY)); $table->ShowStart(); $compare_host = ($_REQUEST["hostid"] > 0)?(' and h.hostid='.$_REQUEST['hostid']):''; $any_app_exist = false; - $db_applications = DBselect("select distinct h.host,h.hostid,a.* from applications a,hosts h ". - " where a.hostid=h.hostid".$compare_host.' and h.hostid in ('.$availiable_hosts.')'. - " and h.status=".HOST_STATUS_MONITORED." order by a.name,a.applicationid,h.host"); + $db_applications = DBselect('SELECT DISTINCT h.host,h.hostid,a.* '. + ' FROM applications a,hosts h '. + ' WHERE a.hostid=h.hostid'.$compare_host. + ' AND h.hostid IN ('.$availiable_hosts.')'. + ' AND h.status='.HOST_STATUS_MONITORED. + order_by('h.host,h.hostid','a.name,a.applicationid')); + while($db_app = DBfetch($db_applications)) { - $db_items = DBselect("select distinct i.* from items i,items_applications ia". - " where ia.applicationid=".$db_app["applicationid"]." and i.itemid=ia.itemid". - " and i.status=".ITEM_STATUS_ACTIVE. - " order by i.description, i.itemid"); + $db_items = DBselect('SELECT DISTINCT i.* '. + ' FROM items i,items_applications ia'. + ' WHERE ia.applicationid='.$db_app['applicationid']. + ' AND i.itemid=ia.itemid'. + ' AND i.status='.ITEM_STATUS_ACTIVE. + order_by('i.description,i.itemid,i.lastclock')); $app_rows = array(); $item_cnt = 0; diff --git a/frontends/php/media_types.php b/frontends/php/media_types.php index 46dd628f..9efd5d32 100644 --- a/frontends/php/media_types.php +++ b/frontends/php/media_types.php @@ -66,6 +66,7 @@ include_once "include/page_header.php"; ); check_fields($fields); + validate_sort_and_sortorder(); ?> <?php @@ -134,11 +135,16 @@ include_once "include/page_header.php"; else { $table=new CTableInfo(S_NO_MEDIA_TYPES_DEFINED); - $table->setHeader(array(S_TYPE,S_DESCRIPTION,S_DETAILS)); + $table->setHeader(array( + make_sorting_link(S_TYPE,'mt.type'), + make_sorting_link(S_DESCRIPTION,'mt.description'), + S_DETAILS + )); - $result=DBselect('select * from media_type '. - ' where '.DBin_node('mediatypeid'). - ' order by type, description'); + $result=DBselect('SELECT mt.* '. + ' FROM media_type mt'. + ' WHERE '.DBin_node('mt.mediatypeid'). + order_by('mt.type,mt.description')); while($row=DBfetch($result)) { switch($row['type']) diff --git a/frontends/php/nodes.php b/frontends/php/nodes.php index b98fa768..abf71c60 100644 --- a/frontends/php/nodes.php +++ b/frontends/php/nodes.php @@ -55,6 +55,7 @@ include_once "include/page_header.php"; ); check_fields($fields); + validate_sort_and_sortorder(); $accessible_nodes = get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_LIST,null,PERM_RES_IDS_ARRAY, get_current_nodeid(true)); @@ -118,12 +119,18 @@ include_once "include/page_header.php"; show_table_header(S_NODES_BIG,$form); $table=new CTableInfo(S_NO_NODES_DEFINED); - $table->SetHeader(array(S_ID,S_NAME,S_TYPE,S_TIME_ZONE,S_IP.':'.S_PORT)); + $table->SetHeader(array( + make_sorting_link(S_ID,'n.nodeid'), + make_sorting_link(S_NAME,'n.name'), + make_sorting_link(S_TYPE,'n.nodetype'), + make_sorting_link(S_TIME_ZONE,'n.timezone'), + make_sorting_link(S_IP.':'.S_PORT,'n.ip') + )); - $db_nodes = DBselect( - 'select * from nodes '. - ' where nodeid in ('.$accessible_nodes.') '. - ' order by nodetype desc, masterid, name ' + $db_nodes = DBselect('SELECT n.* '. + ' FROM nodes n'. + ' WHERE n.nodeid in ('.$accessible_nodes.') '. + order_by('n.nodeid,n.name,n.nodetype,n.timezone,n.ip','n.masterid') ); while($row=DBfetch($db_nodes)) { diff --git a/frontends/php/screenconf.php b/frontends/php/screenconf.php index 46ec8d65..c70f4d97 100644 --- a/frontends/php/screenconf.php +++ b/frontends/php/screenconf.php @@ -67,6 +67,7 @@ include_once "include/page_header.php"; ); check_fields($fields); + validate_sort_and_sortorder(); $config = $_REQUEST['config'] = get_request('config', 0); @@ -246,12 +247,17 @@ include_once "include/page_header.php"; show_table_header(S_SCREENS_BIG); $table = new CTableInfo(S_NO_SCREENS_DEFINED); - $table->SetHeader(array(S_NAME,S_DIMENSION_COLS_ROWS,S_SCREEN)); - - $result=DBselect('select screenid,name,hsize,vsize from screens where '.DBin_node('screenid'). - " order by name"); - while($row=DBfetch($result)) - { + $table->SetHeader(array( + make_sorting_link(S_NAME,'s.name'), + make_sorting_link(S_DIMENSION_COLS_ROWS,'size'), + S_SCREEN)); + + $result=DBselect('SELECT s.screenid,s.name,s.hsize,s.vsize,(s.hsize*s.vsize) as size '. + ' FROM screens s '. + ' WHERE '.DBin_node('s.screenid'). + order_by('s.name,size','s.screenid')); + while($row=DBfetch($result)){ + if(!screen_accessiable($row["screenid"], PERM_READ_WRITE)) continue; $table->AddRow(array( @@ -275,13 +281,19 @@ include_once "include/page_header.php"; show_table_header(S_SLIDESHOWS_BIG); $table = new CTableInfo(S_NO_SLIDESHOWS_DEFINED); - $table->SetHeader(array(S_NAME,S_DELAY,S_COUNT_OF_SLIDES)); - - $db_slides = DBselect('select s.slideshowid, s.name, s.delay, count(*) as cnt '. - ' from slideshows s left join slides sl on sl.slideshowid=s.slideshowid '. - ' where '.DBin_node('s.slideshowid'). - ' group by s.slideshowid,s.name,s.delay '. - ' order by s.name,s.slideshowid'); + $table->SetHeader(array( + make_sorting_link(S_NAME,'s.name'), + make_sorting_link(S_DELAY,'s.delay'), + make_sorting_link(S_COUNT_OF_SLIDES,'cnt') + )); + + $db_slides = DBselect('SELECT s.slideshowid, s.name, s.delay, count(*) as cnt '. + ' FROM slideshows s '. + ' left join slides sl on sl.slideshowid=s.slideshowid '. + ' WHERE '.DBin_node('s.slideshowid'). + ' GROUP BY s.slideshowid,s.name,s.delay '. + order_by('s.name,s.delay,cnt','s.slideshowid')); + while($slide_data = DBfetch($db_slides)) { if(!slideshow_accessiable($slide_data['slideshowid'], PERM_READ_WRITE)) continue; diff --git a/frontends/php/sysmaps.php b/frontends/php/sysmaps.php index 76198970..585e7f62 100644 --- a/frontends/php/sysmaps.php +++ b/frontends/php/sysmaps.php @@ -53,6 +53,7 @@ include_once "include/page_header.php"; ); check_fields($fields); + validate_sort_and_sortorder(); if(isset($_REQUEST["sysmapid"])) { @@ -115,10 +116,18 @@ include_once "include/page_header.php"; { show_table_header(S_MAPS_BIG); $table = new CTableInfo(S_NO_MAPS_DEFINED); - $table->SetHeader(array(S_NAME,S_WIDTH,S_HEIGHT,S_MAP)); + $table->SetHeader(array( + 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 sysmapid,name,width,height from sysmaps ". - ' where '.DBin_node('sysmapid').' order by name'); + $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_accessiable($row["sysmapid"],PERM_READ_WRITE)) continue; diff --git a/frontends/php/tr_status.php b/frontends/php/tr_status.php index 0cf94ab0..dcc8c49e 100644 --- a/frontends/php/tr_status.php +++ b/frontends/php/tr_status.php @@ -29,7 +29,7 @@ $page["file"] = "tr_status.php"; $page["title"] = "S_STATUS_OF_TRIGGERS"; $page['scripts'] = array('blink.js'); - $page['hist_arg'] = array('groupid','hostid','compact','onlytrue','noactions','sort','select'); + $page['hist_arg'] = array('groupid','hostid','compact','onlytrue','noactions','select'); ?> <?php @@ -93,7 +93,6 @@ include_once "include/page_header.php"; $fields=array( "groupid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), "hostid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), - "sort"=> array(T_ZBX_STR, O_OPT, null, IN('"host","priority","description","lastchange"'), null), "noactions"=> array(T_ZBX_STR, O_OPT, null, IN('"true","false"'), null), "compact"=> array(T_ZBX_STR, O_OPT, null, IN('"true","false"'), null), @@ -106,6 +105,7 @@ include_once "include/page_header.php"; ); check_fields($fields); + validate_sort_and_sortorder(); $_REQUEST['show_triggers'] = get_request('show_triggers', get_profile('web.tr_status.show_triggers', TRIGGERS_OPTION_ONLYTRUE)); $_REQUEST['show_events'] = get_request('show_events',get_profile('web.tr_status.show_events', EVENTS_OPTION_NOEVENT)); @@ -134,7 +134,7 @@ include_once "include/page_header.php"; } ?> <?php - $sort = get_request('sort', 'priority'); + $noactions = get_request('noactions', 'true'); $compact = get_request('compact', 'true'); $show_triggers = get_request('show_triggers', TRIGGERS_OPTION_ONLYTRUE); @@ -233,12 +233,11 @@ include_once "include/page_header.php"; $r_form->AddVar('noactions',$noactions); $r_form->AddVar('select',$select); $r_form->AddVar('txt_select',$txt_select); - $r_form->AddVar('sort',$sort); if(isset($_REQUEST['fullscreen'])) $r_form->AddVar('fullscreen',1); show_table_header( new CLink(SPACE.S_STATUS_OF_TRIGGERS_BIG.SPACE.date("[H:i:s]",time()),"tr_status.php?show_triggers=$show_triggers". - "&show_events=$show_events&noactions=$noactions&compact=$compact&sort=$sort". + "&show_events=$show_events&noactions=$noactions&compact=$compact". (!isset($_REQUEST["fullscreen"]) ? '&fullscreen=1' : '')), $r_form); @@ -294,17 +293,17 @@ include_once "include/page_header.php"; array_push($left_col, '[', new CLink($noactions != 'true' ? S_HIDE_ACTIONS : S_SHOW_ACTIONS, "tr_status.php?noactions=".($noactions != 'true' ? 'true' : 'false'). - "&show_triggers=$show_triggers&show_events=$show_events&compact=$compact&select=$select&txt_select=$txt_select&sort=$sort" + "&show_triggers=$show_triggers&show_events=$show_events&compact=$compact&select=$select&txt_select=$txt_select" ), ']'.SPACE); array_push($left_col, '[', new CLink($compact != 'true' ? S_HIDE_DETAILS: S_SHOW_DETAILS, "tr_status.php?compact=".($compact != 'true' ? 'true' : 'false'). - "&show_triggers=$show_triggers&show_events=$show_events&noactions=$noactions&select=$select&txt_select=$txt_select&sort=$sort" + "&show_triggers=$show_triggers&show_events=$show_events&noactions=$noactions&select=$select&txt_select=$txt_select" ), ']'.SPACE); array_push($left_col, '[', new CLink($select != 'true' ? S_SELECT : S_HIDE_SELECT, "tr_status.php?select=".($select != 'true' ? 'true' : 'false'). - "&show_triggers=$show_triggers&show_events=$show_events&noactions=$noactions&compact=$compact&txt_select=$txt_select&sort=$sort" + "&show_triggers=$show_triggers&show_events=$show_events&noactions=$noactions&compact=$compact&txt_select=$txt_select" ), ']'); if($select=='true') @@ -343,54 +342,23 @@ include_once "include/page_header.php"; $m_form->SetName('tr_status'); $table = new CTableInfo(); + $table->ShowStart(); + $header=array(); - $headers_array = array( - is_show_subnodes() ? array('simple_label'=>S_NODE) : null, - $_REQUEST['hostid'] > 0 ? null : - array('select_label'=>S_HOST_BIG , 'simple_label'=>S_HOST, 'sort'=>'host'), - array('simple_label'=> new CCheckBox("all_events",false, "CheckAll('".$m_form->GetName()."','all_events','events');")), - array('select_label'=>S_NAME_BIG , 'simple_label'=>S_NAME, 'sort'=>'description'), - array('simple_label'=>S_STATUS), - array('select_label'=>S_SEVERITY_BIG , 'simple_label'=>S_SEVERITY, 'sort'=>'priority'), - array('select_label'=>S_LAST_CHANGE_BIG , 'simple_label'=>S_LAST_CHANGE, 'sort'=>'lastchange'), - array('simple_label'=>($noactions!='true') ? S_ACTIONS : NULL), - array('simple_label'=>($config['ack_enable'])? S_ACKNOWLEDGED : NULL), - array('simple_label'=>S_COMMENTS) - ); - - $select_vars = (isset($sort) && $sort=="description") ? "&select=$select&txt_select=$txt_select" : ""; - foreach($headers_array as $el) - { - if(isset($el['sort']) && $sort == $el['sort']) - { - $descr = $el['select_label']; - } - else if(isset($el['sort'])) - { - $descr = new CLink($el['simple_label'],"tr_status.php?sort=".$el['sort']. - "&show_triggers=$show_triggers&show_events=$show_events&compact=$compact&select=$select&txt_select=$txt_select"); - } - else - { - $descr = $el['simple_label']; - } - array_push($header,$descr); - unset($el); - } - - $table->SetHeader($header); - unset($header); - - switch($sort) - { - case 'host': $sort=' order by h.host'; if($_REQUEST['hostid'] <= 0) break; /* else 'description' */ - case 'description': $sort=' order by t.description'; break; - case 'priority': $sort=' order by t.priority desc, t.description'; break; - case 'lastchange': $sort=' order by t.lastchange desc, t.priority'; break; - default: $sort=' order by t.priority desc, t.description'; - } - + $table->SetHeader(array( + is_show_subnodes() ? make_sorting_link(S_NODE,'h.hostid') : null, + $_REQUEST["hostid"] >0 ? null : make_sorting_link(S_HOST,'h.host'), + new CCheckBox("all_events",false, "CheckAll('".$m_form->GetName()."','all_events','events');"), + make_sorting_link(S_NAME,'t.description'), + S_STATUS, + make_sorting_link(S_SEVERITY,'t.priority'), + make_sorting_link(S_LAST_CHANGE,'t.lastchange'), + ($noactions!='true')?S_ACTIONS:NULL, + ($config['ack_enable'])? S_ACKNOWLEDGED : NULL, + S_COMMENTS + )); + $cond = ($_REQUEST['hostid'] > 0)?' AND h.hostid='.$_REQUEST['hostid'].' ':''; switch($show_triggers){ @@ -398,7 +366,6 @@ include_once "include/page_header.php"; $cond.=''; break; case TRIGGERS_OPTION_NOFALSEFORB: -// $cond.=' AND ((t.value='.TRIGGER_VALUE_TRUE.') OR ((t.value='.TRIGGER_VALUE_FALSE.') AND t.type='.TRIGGER_MULT_EVENT_DISABLED.'))'; $cond.=''; break; case TRIGGERS_OPTION_ONLYTRUE: @@ -414,7 +381,8 @@ include_once "include/page_header.php"; ' AND t.triggerid=f.triggerid AND t.status='.TRIGGER_STATUS_ENABLED. ' AND i.status='.ITEM_STATUS_ACTIVE.' AND '.DBin_node('t.triggerid'). ' AND h.hostid not in ('.get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY, PERM_MODE_LT).') '. - ' AND h.status='.HOST_STATUS_MONITORED.' '.$cond.' '.$sort; + ' AND h.status='.HOST_STATUS_MONITORED.' '.$cond. + order_by('h.host,h.hostid,t.description,t.priority,t.lastchange'); $result = DBselect($sql); diff --git a/frontends/php/triggers.php b/frontends/php/triggers.php index b8995b19..9ec4defa 100644 --- a/frontends/php/triggers.php +++ b/frontends/php/triggers.php @@ -82,7 +82,8 @@ include_once "include/page_header.php"; $_REQUEST["showdisabled"] = get_request("showdisabled", get_profile("web.triggers.showdisabled", 0)); check_fields($fields); - + validate_sort_and_sortorder(); + if(isset($_REQUEST["triggerid"])) if(!check_right_on_trigger_by_triggerid(PERM_READ_WRITE, $_REQUEST["triggerid"])) access_deny(); @@ -376,26 +377,30 @@ include_once "include/page_header.php"; $table = new CTableInfo(S_NO_TRIGGERS_DEFINED); $table->setHeader(array( - $_REQUEST["hostid"] > 0 ? NULL : S_HOST, + $_REQUEST["hostid"] > 0 ? NULL : make_sorting_link(S_HOST,'h.host'), array( new CCheckBox("all_triggers",NULL, "CheckAll('".$form->GetName()."','all_triggers');") - ,S_NAME + ,make_sorting_link(S_NAME,'t.description'), ), - S_EXPRESSION, S_SEVERITY, S_STATUS, S_ERROR)); - - $sql = 'select distinct h.hostid,h.host,t.*'. - ' from triggers t left join functions f on t.triggerid=f.triggerid '. - ' left join items i on f.itemid=i.itemid '. - ' left join hosts h on h.hostid=i.hostid '. - ' where '.DBin_node('t.triggerid'); + S_EXPRESSION, + make_sorting_link(S_SEVERITY,'t.priority'), + make_sorting_link(S_STATUS,'t.status'), + S_ERROR)); + + $sql = 'SELECT DISTINCT h.hostid,h.host,t.*'. + ' FROM triggers t '. + ' LEFT JOIN functions f ON t.triggerid=f.triggerid '. + ' LEFT JOIN items i ON f.itemid=i.itemid '. + ' LEFT JOIN hosts h ON h.hostid=i.hostid '. + ' WHERE '.DBin_node('t.triggerid'); if($showdisabled == 0) - $sql .= ' and t.status <> '.TRIGGER_STATUS_DISABLED; + $sql .= ' AND t.status <> '.TRIGGER_STATUS_DISABLED; if($_REQUEST['hostid'] > 0) - $sql .= ' and h.hostid='.$_REQUEST['hostid']; + $sql .= ' AND h.hostid='.$_REQUEST['hostid']; - $sql .= ' order by h.host,t.description'; + $sql .= order_by('h.host,t.description,t.priority,t.status'); $result=DBselect($sql); while($row=DBfetch($result)) diff --git a/frontends/php/users.php b/frontends/php/users.php index db4be063..4a780502 100644 --- a/frontends/php/users.php +++ b/frontends/php/users.php @@ -114,7 +114,7 @@ include_once "include/page_header.php"; check_fields($fields); - + validate_sort_and_sortorder(); ?> <?php if($_REQUEST["config"]==0) @@ -379,13 +379,18 @@ include_once "include/page_header.php"; $table->setHeader(array( array( new CCheckBox("all_users",NULL, "CheckAll('".$form->GetName()."','all_users');"), - S_ALIAS + make_sorting_link(S_ALIAS,'u.alias') ), - S_NAME,S_SURNAME,S_USER_TYPE,S_GROUPS,S_IS_ONLINE_Q)); + make_sorting_link(S_NAME,'u.name'), + make_sorting_link(S_SURNAME,'u.surname'), + make_sorting_link(S_USER_TYPE,'u.type'), + S_GROUPS, + S_IS_ONLINE_Q)); - $db_users=DBselect("select userid,alias,name,surname,type,autologout ". - ' from users where '.DBin_node('userid'). - " order by alias"); + $db_users=DBselect('SELECT u.userid,u.alias,u.name,u.surname,u.type,u.autologout '. + ' FROM users u'. + ' WHERE '.DBin_node('u.userid'). + order_by('u.alias,u.name,u.surname,u.type','u.userid')); while($db_user=DBfetch($db_users)) { $db_sessions = DBselect('select count(*) as count, max(s.lastaccess) as lastaccess'. @@ -442,19 +447,22 @@ include_once "include/page_header.php"; $table->setHeader(array( array( new CCheckBox("all_groups",NULL, "CheckAll('".$form->GetName()."','all_groups');"), - S_NAME), + make_sorting_link(S_NAME,'ug.name')), S_MEMBERS)); - $result=DBselect("select usrgrpid,name from usrgrp". - ' where '.DBin_node('usrgrpid'). - " order by name"); + $result=DBselect('SELECT ug.usrgrpid, ug.name '. + ' FROM usrgrp ug'. + ' WHERE '.DBin_node('ug.usrgrpid'). + order_by('ug.name')); while($row=DBfetch($result)) { $users = array(); - $db_users=DBselect("select distinct u.alias,u.userid from users u,users_groups ug ". - "where u.userid=ug.userid and ug.usrgrpid=".$row["usrgrpid"]. - " order by alias"); + $db_users=DBselect('SELECT DISTINCT u.alias,u.userid '. + ' FROM users u,users_groups ug '. + ' WHERE u.userid=ug.userid '. + ' AND ug.usrgrpid='.$row['usrgrpid']. + ' ORDER BY u.alias'); while($db_user=DBfetch($db_users)) $users[$db_user['userid']] = $db_user["alias"]; |