summaryrefslogtreecommitdiffstats
path: root/frontends/php/include
diff options
context:
space:
mode:
authorartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-11-12 10:20:29 +0000
committerartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-11-12 10:20:29 +0000
commitc0c1b50df1ec73e0cd6b72c7cc10197e6cc44a0a (patch)
tree43b9a3f70cc15cfcc674fafbd0c8a3829417331e /frontends/php/include
parentd7d135227396a5b3cede974e94c25032a1bc69d2 (diff)
downloadzabbix-c0c1b50df1ec73e0cd6b72c7cc10197e6cc44a0a.tar.gz
zabbix-c0c1b50df1ec73e0cd6b72c7cc10197e6cc44a0a.tar.xz
zabbix-c0c1b50df1ec73e0cd6b72c7cc10197e6cc44a0a.zip
- [DEV-66] added sorting to screens (Artem)
git-svn-id: svn://svn.zabbix.com/trunk@4996 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
-rw-r--r--frontends/php/include/actions.inc.php33
-rw-r--r--frontends/php/include/config.inc.php87
-rw-r--r--frontends/php/include/defines.inc.php3
-rw-r--r--frontends/php/include/events.inc.php27
-rw-r--r--frontends/php/include/validate.inc.php4
5 files changed, 126 insertions, 28 deletions
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()