summaryrefslogtreecommitdiffstats
path: root/frontends/php/include
diff options
context:
space:
mode:
authorartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-03-11 11:21:34 +0000
committerartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-03-11 11:21:34 +0000
commit419b228afeba243106a8757543cde23bbdd03189 (patch)
tree331a7c47e32f2ca254ca261e6bf650b596c54383 /frontends/php/include
parent9b1c6e98efe2a2a793b959df384db1a337a212ff (diff)
downloadzabbix-419b228afeba243106a8757543cde23bbdd03189.tar.gz
zabbix-419b228afeba243106a8757543cde23bbdd03189.tar.xz
zabbix-419b228afeba243106a8757543cde23bbdd03189.zip
- Zabbix1.5.b commit (Artem)
git-svn-id: svn://svn.zabbix.com/trunk@5468 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
-rw-r--r--frontends/php/include/blocks.inc.php4
-rw-r--r--frontends/php/include/config.inc.php68
-rw-r--r--frontends/php/include/events.inc.php216
-rw-r--r--frontends/php/include/hosts.inc.php181
-rw-r--r--frontends/php/include/html.inc.php136
-rw-r--r--frontends/php/include/locales/en_gb.inc.php1
-rw-r--r--frontends/php/include/maps.inc.php2
-rw-r--r--frontends/php/include/page_header.php54
-rw-r--r--frontends/php/include/perm.inc.php69
-rw-r--r--frontends/php/include/profiles.inc.php39
-rw-r--r--frontends/php/include/triggers.inc.php2
11 files changed, 335 insertions, 437 deletions
diff --git a/frontends/php/include/blocks.inc.php b/frontends/php/include/blocks.inc.php
index c6a094a7..fb4925b9 100644
--- a/frontends/php/include/blocks.inc.php
+++ b/frontends/php/include/blocks.inc.php
@@ -640,7 +640,7 @@ function make_latest_issues($available_hosts=false){
get_node_name_by_elid($row['triggerid']),
$host,
new CCol($description,get_severity_style($row["priority"])),
- new CLink(zbx_date2str(S_DATE_FORMAT_YMDHMS,$row_event['clock']),"tr_events.php?triggerid=".$row["triggerid"],"action"),
+ new CLink(zbx_date2str(S_DATE_FORMAT_YMDHMS,$row_event['clock']),"events.php?triggerid=".$row["triggerid"],"action"),
zbx_date2age($row_event['clock']),
($config['event_ack_enable'])?(new CCol($ack,"center")):NULL,
$actions
@@ -839,7 +839,7 @@ function make_graph_menu(&$menu,&$submenu){
'dstfrm=fav_form&'.
'dstfld1=favobj&'.
'dstfld2=favid&'.
- 'srcfld1=description&'.
+ 'srcfld1=name&'.
"srcfld2=graphid',800,450);".
"void(0);",
null,
diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php
index 13c50189..11e9c650 100644
--- a/frontends/php/include/config.inc.php
+++ b/frontends/php/include/config.inc.php
@@ -766,12 +766,12 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!!
$lst_error->AddItem($msg['message'], $msg['type']);
//message scroll if needed
$msg_show = 6;
- $msg_font_size = 8;
+ $msg_font_size = 7;
$msg_count = count($ZBX_MESSAGES);
if($msg_count > $msg_show) $msg_count = $msg_show;
- $msg_count = ($msg_count * $msg_font_size *4) + 2;
+ $msg_count = ($msg_count * $msg_font_size * 4) + 2;
$lst_error->AddOption('style','font-size: '.$msg_font_size.'pt; height: '.$msg_count.'px;');
//---
$lst_error->Show();
@@ -1053,64 +1053,6 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!!
return DBexecute('update config set '.implode(',',$update).' where '.DBin_node('configid', get_current_nodeid(false)));
}
-/* Function:
- * hide_form_items()
- *
- * Desc:
- * Searches items/objects for Form tags like "<input"/Form classes like CForm, and makes it empty
- *
- * Author:
- * Aly
- */
- function hide_form_items(&$obj){
- if(is_array($obj)){
- foreach($obj as $id => $item){
- hide_form_items($obj[$id]); // Attention recursion;
- }
- }
- else if(is_object($obj)){
- if(str_in_array(strtolower(get_class($obj)),array('cform','ccheckbox','cselect','cbutton','cbuttonqmessage','cbuttondelete','cbuttoncancel'))){
- $obj=SPACE;
- }
- if(isset($obj->items) && !empty($obj->items)){
- foreach($obj->items as $id => $item){
- hide_form_items($obj->items[$id]); // Recursion
- }
- }
- }
- else{
- foreach(array('<form','<input','<select') as $item){
- if(strpos($obj,$item) !== FALSE) $obj = SPACE;
- }
- }
- }
-
- function get_table_header($col1, $col2=SPACE){
- if(isset($_REQUEST['print'])){
- hide_form_items($col1);
- hide_form_items($col2);
- //if empty header than do not show it
- if(($col1 == SPACE) && ($col2 == SPACE)) return new CScript('');
- }
-
- $table = new CTable(NULL,"header");
-// $table->AddOption('border',1);
- $table->SetCellSpacing(0);
- $table->SetCellPadding(1);
-
- $td_r = new CCol($col2,"header_r");
- $td_r->AddOption('align','right');
-
- $table->AddRow(array(new CCol($col1,"header_l"), $td_r));
- return $table;
- }
-
- function show_table_header($col1, $col2=SPACE)
- {
- $table = get_table_header($col1, $col2);
- $table->Show();
- }
-
# Show History Graph
function show_history($itemid,$from,$stime,$period){
@@ -1703,11 +1645,11 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!!
*
* author: Aly
*/
- function validate_sort_and_sortorder(){
+ function validate_sort_and_sortorder($sort=NULL,$sortorder=ZBX_SORT_UP){
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));
+ $_REQUEST['sort'] = get_request('sort',get_profile('web.'.$page["file"].'.sort',$sort));
+ $_REQUEST['sortorder'] = get_request('sortorder',get_profile('web.'.$page["file"].'.sortorder',$sortorder));
if(!is_null($_REQUEST['sort'])){
$_REQUEST['sort'] = eregi_replace('[^a-z\.\_]','',$_REQUEST['sort']);
diff --git a/frontends/php/include/events.inc.php b/frontends/php/include/events.inc.php
index 452238c6..bbfc2bc1 100644
--- a/frontends/php/include/events.inc.php
+++ b/frontends/php/include/events.inc.php
@@ -19,225 +19,15 @@
**/
?>
<?php
- function event_source2str($sourceid)
- {
- switch($sourceid)
- {
+ function event_source2str($sourceid){
+ switch($sourceid){
case EVENT_SOURCE_TRIGGERS: return S_TRIGGERS;
case EVENT_SOURCE_DISCOVERY: return S_DISCOVERY;
default: return S_UNKNOWN;
}
}
- function get_history_of_triggers_events($start,$num, $groupid=0, $hostid=0){
- global $USER_DETAILS;
- $config = select_config();
-
- $show_unknown = get_profile('web.events.show_unknown',0);
-
- $sql_from = $sql_cond = "";
-
- $availiable_groups= get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST, null, null, get_current_nodeid());
- $availiable_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_LIST, null, null, get_current_nodeid());
-
- if($hostid > 0){
- $sql_cond = " and h.hostid=".$hostid;
- }
- elseif($groupid > 0){
- $sql_from = ", hosts_groups hg ";
- $sql_cond = " and h.hostid=hg.hostid and hg.groupid=".$groupid;
- }
- else{
- $sql_from = ", hosts_groups hg ";
- $sql_cond = " and h.hostid in (".$availiable_hosts.") ";
- }
-
-//---
- $triggers = array();
- $trigger_list = '';
-
- $sql = 'SELECT DISTINCT t.triggerid,t.priority,t.description,t.expression,h.host,t.type '.
- ' FROM triggers t, functions f, items i, hosts h '.$sql_from.
- ' WHERE '.DBin_node('t.triggerid').
- ' AND t.triggerid=f.triggerid '.
- ' AND f.itemid=i.itemid '.
- ' AND i.hostid=h.hostid '.
- ' AND h.status='.HOST_STATUS_MONITORED.
- $sql_cond;
-
- $rez = DBselect($sql);
- while($rowz = DBfetch($rez)){
- $triggers[$rowz['triggerid']] = $rowz;
- $trigger_list.=$rowz['triggerid'].',';
- }
-
- $trigger_list = '('.trim($trigger_list,',').')';
- $sql_cond=($show_unknown == 0)?(' AND e.value<>'.TRIGGER_VALUE_UNKNOWN.' '):('');
-
- $table = new CTableInfo(S_NO_EVENTS_FOUND);
- $table->SetHeader(array(
- make_sorting_link(S_TIME,'e.eventid'),
- is_show_subnodes() ? S_NODE : null,
- $hostid == 0 ? S_HOST : null,
- S_DESCRIPTION,
- S_VALUE,
- S_SEVERITY,
- S_DURATION,
- ($config['event_ack_enable'])?S_ACK:NULL,
- S_ACTIONS
- ));
-
- if(!empty($triggers)){
- $sql = 'SELECT e.eventid, e.objectid as triggerid, e.clock, e.value, e.acknowledged '.
- ' FROM events e '.
- ' WHERE '.zbx_sql_mod('e.object',1000).'='.EVENT_OBJECT_TRIGGER.
- ' AND e.objectid IN '.$trigger_list.
- $sql_cond.
- order_by('e.eventid');
-
- $result = DBselect($sql,10*($start+$num));
- }
-
- $accessible_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY);
-
- $col=0;
- $skip = $start;
-
- while(!empty($triggers) && ($col<$num) && ($row=DBfetch($result))){
-
- if($skip > 0){
- if(($show_unknown == 0) && ($row['value'] == TRIGGER_VALUE_UNKNOWN)) continue;
- $skip--;
- continue;
- }
-
- if($row["value"] == TRIGGER_VALUE_FALSE){
- $value=new CCol(S_OFF,"off");
- }
- elseif($row["value"] == TRIGGER_VALUE_TRUE){
- $value=new CCol(S_ON,"on");
- }
- else{
- $value=new CCol(S_UNKNOWN_BIG,"unknown");
- }
-
- $row = array_merge($triggers[$row['triggerid']],$row);
- if((0 == $show_unknown) && (!event_initial_time($row,$show_unknown))) continue;
-
- $duration = zbx_date2age($row['clock']);
- if($next_event = get_next_event($row,$show_unknown)){
- $duration = zbx_date2age($row['clock'],$next_event['clock']);
- }
-//actions
- $actions= new CTable(' - ');
-
- $sql='SELECT COUNT(a.alertid) as all'.
- ' FROM alerts a,functions f,items i,events e'.
- ' WHERE a.eventid='.$row['eventid'].
- ' AND e.eventid = a.eventid'.
- ' AND f.triggerid=e.objectid '.
- ' AND i.itemid=f.itemid '.
- ' AND i.hostid IN ('.$available_hosts.') ';
-
-
- $alerts=DBfetch(DBselect($sql));
-
- if(isset($alerts['all']) && ($alerts['all'] > 0)){
- $mixed = 0;
-// Sent
- $sql='SELECT COUNT(a.alertid) as sent '.
- ' FROM alerts a,functions f,items i,events e'.
- ' WHERE a.eventid='.$row['eventid'].
- ' AND a.status='.ALERT_STATUS_SENT.
- ' AND e.eventid = a.eventid'.
- ' AND f.triggerid=e.objectid '.
- ' AND i.itemid=f.itemid '.
- ' AND i.hostid IN ('.$available_hosts.') ';
-
- $tmp=DBfetch(DBselect($sql));
- $alerts['sent'] = $tmp['sent'];
- $mixed+=($alerts['sent'])?ALERT_STATUS_SENT:0;
-// In progress
- $sql='SELECT COUNT(a.alertid) as inprogress '.
- ' FROM alerts a,functions f,items i,events e'.
- ' WHERE a.eventid='.$row['eventid'].
- ' AND a.status='.ALERT_STATUS_NOT_SENT.
- ' AND e.eventid = a.eventid'.
- ' AND f.triggerid=e.objectid '.
- ' AND i.itemid=f.itemid '.
- ' AND i.hostid IN ('.$available_hosts.') ';
-
- $tmp=DBfetch(DBselect($sql));
- $alerts['inprogress'] = $tmp['inprogress'];
-// Failed
- $sql='SELECT COUNT(a.alertid) as failed '.
- ' FROM alerts a,functions f,items i,events e'.
- ' WHERE a.eventid='.$row['eventid'].
- ' AND a.status='.ALERT_STATUS_FAILED.
- ' AND e.eventid = a.eventid'.
- ' AND f.triggerid=e.objectid '.
- ' AND i.itemid=f.itemid '.
- ' AND i.hostid IN ('.$available_hosts.') ';
-
- $tmp=DBfetch(DBselect($sql));
- $alerts['failed'] = $tmp['failed'];
- $mixed+=($alerts['failed'])?ALERT_STATUS_FAILED:0;
-
-
- if($alerts['inprogress']){
- $status = new CSpan(S_IN_PROGRESS,'orange');
- }
- else if(ALERT_STATUS_SENT == $mixed){
- $status = new CSpan(S_OK,'green');
- }
- else if(ALERT_STATUS_FAILED == $mixed){
- $status = new CSpan(S_FAILED,'red');
- }
- else{
- $tdl = new CCol(($alerts['sent'])?(new CSpan($alerts['sent'],'green')):SPACE);
- $tdl->AddOption('width','10');
-
- $tdr = new CCol(($alerts['failed'])?(new CSpan($alerts['failed'],'red')):SPACE);
- $tdr->AddOption('width','10');
-
- $status = new CRow(array($tdl,$tdr));
- }
-
- $actions->AddRow($status);
- }
-//--------
-
- if($config['event_ack_enable']){
- if($row['acknowledged'] == 1){
- $ack=new CLink(S_YES,'acknow.php?eventid='.$row['eventid'],'action');
- }
- else{
- $ack= new CLink(S_NO,'acknow.php?eventid='.$row['eventid'],'on');
- }
- }
-
- $table->AddRow(array(
- date("Y.M.d H:i:s",$row["clock"]),
- get_node_name_by_elid($row['triggerid']),
- $hostid == 0 ? $row['host'] : null,
- new CLink(
- expand_trigger_description_by_data($row, ZBX_FLAG_EVENT),
- "tr_events.php?triggerid=".$row["triggerid"],"action"
- ),
- $value,
- new CCol(get_severity_description($row["priority"]), get_severity_style($row["priority"])),
- $duration,
- ($config['event_ack_enable'])?$ack:NULL,
- $actions
- ));
-
- $col++;
- }
- return $table;
- }
-
- function get_history_of_discovery_events($start,$num)
- {
+ function get_history_of_discovery_events($start,$num){
$db_events = DBselect('select distinct e.source,e.object,e.objectid,e.clock,e.value from events e'.
' where e.source='.EVENT_SOURCE_DISCOVERY.' order by e.clock desc',
10*($start+$num)
diff --git a/frontends/php/include/hosts.inc.php b/frontends/php/include/hosts.inc.php
index 81ac6b60..5973d7e6 100644
--- a/frontends/php/include/hosts.inc.php
+++ b/frontends/php/include/hosts.inc.php
@@ -708,10 +708,8 @@ require_once "include/items.inc.php";
* Comments:
*
*/
- function get_correct_group_and_host($a_groupid=null, $a_hostid=null, $perm=PERM_READ_WRITE, $options = array())
- {
- if(!is_array($options))
- {
+ function get_correct_group_and_host($a_groupid=null, $a_hostid=null, $perm=PERM_READ_WRITE, $options = array()){
+ if(!is_array($options)){
fatal_error("Incorrest options for get_correct_group_and_host");
}
@@ -723,99 +721,98 @@ require_once "include/items.inc.php";
$always_select_first_host = str_in_array("always_select_first_host",$options) ? 1 : 0;
$only_current_node = str_in_array("only_current_node",$options) ? 1 : 0;
- if(str_in_array("monitored_hosts",$options))
- $with_host_status = " and h.status=".HOST_STATUS_MONITORED;
- elseif(str_in_array('real_hosts',$options))
- $with_host_status = " and h.status<>".HOST_STATUS_TEMPLATE;
- elseif(str_in_array('templated_hosts',$options))
- $with_host_status = " and h.status=".HOST_STATUS_TEMPLATE;
+ if(str_in_array('monitored_hosts',$options))
+ $with_host_status = ' AND h.status='.HOST_STATUS_MONITORED;
+ else if(str_in_array('real_hosts',$options))
+ $with_host_status = ' AND h.status<>'.HOST_STATUS_TEMPLATE;
+ else if(str_in_array('templated_hosts',$options))
+ $with_host_status = ' AND h.status='.HOST_STATUS_TEMPLATE;
else
- $with_host_status = "";
-
- if(str_in_array("with_monitored_items",$options)){
- $item_table = ",items i"; $with_items = " and h.hostid=i.hostid and i.status=".ITEM_STATUS_ACTIVE;
- }else if(str_in_array("with_items",$options)){
- $item_table = ",items i"; $with_items = " and h.hostid=i.hostid";
- } else {
- $item_table = "";
- $with_items = "";
- }
+ $with_host_status = '';
- $with_node = "";
+ if(str_in_array('with_monitored_items',$options)){
+ $item_table = ',items i'; $with_items = ' AND h.hostid=i.hostid AND i.status='.ITEM_STATUS_ACTIVE;
+ }
+ else if(str_in_array("with_items",$options)){
+ $item_table = ',items i'; $with_items = ' AND h.hostid=i.hostid';
+ }
+ else {
+ $item_table = '';
+ $with_items = '';
+ }
- $accessed_hosts = get_accessible_hosts_by_user($USER_DETAILS,$perm,null,null,get_current_nodeid(!$only_current_node));
+ $with_node = '';
-//SDI(get_current_nodeid(!$only_current_node));
-//SDI($accessed_hosts);
+ $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,$perm,null,null,get_current_nodeid(!$only_current_node));
- if(is_null($a_groupid))
- {
+ if(is_null($a_groupid)){
$groupid = 0;
}
- else
- {
+ else{
$groupid = $a_groupid;
- if($groupid > 0)
- {
- $with_node = " and ".DBin_node('g.groupid', get_current_nodeid(!$only_current_node));
+ if($groupid > 0){
+ $with_node = ' AND '.DBin_node('g.groupid', get_current_nodeid(!$only_current_node));
if(!DBfetch(DBselect('SELECT DISTINCT g.groupid '.
' FROM groups g, hosts_groups hg, hosts h'.$item_table.
' WHERE hg.groupid=g.groupid '.
' AND h.hostid=hg.hostid '.
- ' AND h.hostid in ('.$accessed_hosts.') '.
+ ' AND h.hostid in ('.$available_hosts.') '.
' AND g.groupid='.$groupid.$with_host_status.$with_items.$with_node)))
{
$groupid = 0;
}
}
-
}
- if(is_null($a_hostid))
- {
+ if(is_null($a_hostid)){
$hostid = 0;
}
- else
- {
+ else{
$hostid = $a_hostid;
- if(!($hostid == 0 && $allow_all_hosts == 1)) /* is not 'All' selected */
- {
- $group_table = "";
- $witth_group = "";
+/* is not 'All' selected */
+ if(!($hostid == 0 && $allow_all_hosts == 1)) {
+ $group_table = '';
+ $witth_group = '';
- if($groupid != 0)
- {
- $with_node = " and ".DBin_node('hg.hostid', get_current_nodeid(!$only_current_node));
+ if($groupid != 0){
+ $with_node = ' AND '.DBin_node('hg.hostid', get_current_nodeid(!$only_current_node));
- if(!DBfetch(DBselect("select hg.hostid from hosts_groups hg".
- " where hg.groupid=".$groupid." and hg.hostid=".$hostid.$with_node)))
- {
+ if(!DBfetch(DBselect('SELECT hg.hostid FROM hosts_groups hg'.
+ ' WHERE hg.groupid='.$groupid.' AND hg.hostid='.$hostid.$with_node))){
$hostid = 0;
}
- $group_table = " ,hosts_groups hg ";
- $witth_group = " and hg.hostid=h.hostid and hg.groupid=".$groupid;
+ $group_table = ' ,hosts_groups hg ';
+ $witth_group = ' AND hg.hostid=h.hostid AND hg.groupid='.$groupid;
}
- $with_node = " and ".DBin_node('h.hostid',get_current_nodeid(!$only_current_node));
+ $with_node = ' AND '.DBin_node('h.hostid',get_current_nodeid(!$only_current_node));
//SDI('C: '.$a_groupid.' : '.$a_hostid);
- if($db_host = DBfetch(DBselect("select distinct h.hostid,h.host from hosts h ".$item_table.$group_table.
- " where h.hostid in (".$accessed_hosts.") "
- .$with_host_status.$with_items.$witth_group.$with_node.
- " order by h.host")))
+ if($db_host = DBfetch(DBselect('SELECT DISTINCT h.hostid,h.host FROM hosts h '.
+ $item_table.
+ $group_table.
+ ' WHERE h.hostid IN ('.$available_hosts.') '.
+ $with_host_status.
+ $with_items.
+ $witth_group.
+ $with_node.
+ ' ORDER BY h.host')))
{
$first_hostid_in_group = $db_host["hostid"];
}
- if($first_hostid_in_group == 0) $hostid = 0; /* no hosts in selected grpore */
+ if($first_hostid_in_group == 0) $hostid = 0; /* no hosts in selected groupe */
- if($hostid > 0)
- {
- if(!DBfetch(DBselect("select distinct h.hostid from hosts h".$item_table.
- " where h.hostid=".$hostid.$with_host_status.$with_items.$with_node.
- " and h.hostid in (".$accessed_hosts.") ")))
+ if($hostid > 0){
+ if(!DBfetch(DBselect('SELECT DISTINCT h.hostid '.
+ ' FROM hosts h '.$item_table.
+ ' WHERE h.hostid='.$hostid.
+ ' AND h.hostid IN ('.$available_hosts.') '.
+ $with_host_status.
+ $with_items.
+ $with_node)))
{
$hostid = 0;
}
@@ -838,19 +835,19 @@ require_once "include/items.inc.php";
);
}
- /*
- * Function: validate_group_with_host
- *
- * Description:
- * Check available groups and host by user permission
- * and check current group an host relations
- *
- * Author:
- * Eugene Grigorjev (eugene.grigorjev@zabbix.com)
- *
- * Comments:
- *
- */
+/*
+ * Function: validate_group_with_host
+ *
+ * Description:
+ * Check available groups and host by user permission
+ * and check current group an host relations
+ *
+ * Author:
+ * Eugene Grigorjev (eugene.grigorjev@zabbix.com)
+ *
+ * Comments:
+ *
+ */
function validate_group_with_host($perm, $options = array(),$group_var=null,$host_var=null)
{
if(is_null($group_var)) $group_var = "web.latest.groupid";
@@ -859,20 +856,17 @@ require_once "include/items.inc.php";
$_REQUEST["groupid"] = get_request("groupid", -1 );
$_REQUEST["hostid"] = get_request("hostid", get_profile($host_var,0));
- if($_REQUEST["groupid"] == -1)
- {
+ if(-1 == $_REQUEST["groupid"]){
$_REQUEST["groupid"] = get_profile($group_var,0);
if(!in_node($_REQUEST["groupid"])) $_REQUEST["groupid"] = 0;
- if ($_REQUEST["hostid"] > 0 && !DBfetch(DBselect('select groupid from hosts_groups '.
- ' where hostid='.$_REQUEST["hostid"].' and groupid='.$_REQUEST["groupid"])))
- {
- $_REQUEST["groupid"] = 0;
+ if(($_REQUEST["hostid"] > 0) && !DBfetch(DBselect('SELECT groupid FROM hosts_groups WHERE hostid='.$_REQUEST["hostid"].' AND groupid='.$_REQUEST["groupid"]))){
+ $_REQUEST["groupid"] = 0;
}
}
- if(uint_in_array("always_select_first_host",$options) && $_REQUEST["hostid"] == 0 && $_REQUEST["groupid"] != 0)
+ if(str_in_array("always_select_first_host",$options) && ($_REQUEST["hostid"] == 0) && ($_REQUEST["groupid"] != 0))
$_REQUEST["hostid"] = -1;
$result = get_correct_group_and_host($_REQUEST["groupid"],$_REQUEST["hostid"], $perm, $options);
@@ -884,20 +878,19 @@ require_once "include/items.inc.php";
update_profile($group_var,$_REQUEST["groupid"]);
}
- /*
- * Function: validate_group
- *
- * Description:
- * Check available groups by user permisions
- *
- * Author:
- * Eugene Grigorjev (eugene.grigorjev@zabbix.com)
- *
- * Comments:
- *
- */
- function validate_group($perm, $options = array(),$group_var=null)
- {
+/*
+ * Function: validate_group
+ *
+ * Description:
+ * Check available groups by user permisions
+ *
+ * Author:
+ * Eugene Grigorjev (eugene.grigorjev@zabbix.com)
+ *
+ * Comments:
+ *
+ */
+ function validate_group($perm, $options = array(),$group_var=null){
if(is_null($group_var)) $group_var = "web.latest.groupid";
$_REQUEST["groupid"] = get_request("groupid",get_profile($group_var,0));
diff --git a/frontends/php/include/html.inc.php b/frontends/php/include/html.inc.php
index 825053ad..37d5dfbf 100644
--- a/frontends/php/include/html.inc.php
+++ b/frontends/php/include/html.inc.php
@@ -147,4 +147,140 @@
$table->AddRow($div);
return $table;
}
+
+ function create_filter($col_l,$col_r,$items,$id='zbx_filter',$state=1){
+
+ if(isset($_REQUEST['print'])) $state = 0;
+
+ $table = new CTable();
+ $table->AddOption('width','100%');
+ $table->SetCellPadding(0);
+ $table->SetCellSpacing(0);
+ $table->AddOption('border',0);
+
+ $icon = new CDiv(SPACE,($state)?'filteropened':'filterclosed');
+ $icon->AddAction('onclick',new CScript("javascript: change_filter_state(this,'".$id."');"));
+ $icon->AddOption('title',S_SHOW.'/'.S_HIDE.' '.S_FILTER);
+
+ $td_icon = new CCol($icon);
+ $td_icon->AddOption('valign','bottom');
+
+ $icons_row = array($td_icon,SPACE);
+ $icons_row[] = $col_l;
+
+ $icon_tab = new CTable();
+ $icon_tab->SetCellSpacing(0);
+ $icon_tab->SetCellPadding(0);
+
+ $icon_tab->AddRow($icons_row);
+
+ $table->AddRow(get_thin_table_header($icon_tab,$col_r));
+
+ $div = new CDiv($items);
+ $div->AddOption('id',$id);
+ if(!$state) $div->AddOption('style','display: none;');
+
+ $tab = new CTable();
+ $tab->AddRow($div);
+
+// $table->AddRow($tab);
+ $table->AddRow($div);
+
+ return $table;
+ }
+
+ function create_filter_hat($col_l,$col_r,$items,$id,$state=1){
+
+ $table = new CTable(NULL,"filter");
+ $table->SetCellSpacing(0);
+ $table->SetCellPadding(1);
+
+
+
+ $td_l = new CCol($icon_tab,"filter_l");
+
+ $td_r = new CCol($col_r,"filter_r");
+ $td_r->AddOption('align','right');
+
+ $table->AddRow(array($td_l, $td_r));
+ return $table;
+ }
+
+
+/* Function:
+ * hide_form_items()
+ *
+ * Desc:
+ * Searches items/objects for Form tags like "<input"/Form classes like CForm, and makes it empty
+ *
+ * Author:
+ * Aly
+ */
+ function hide_form_items(&$obj){
+ if(is_array($obj)){
+ foreach($obj as $id => $item){
+ hide_form_items($obj[$id]); // Attention recursion;
+ }
+ }
+ else if(is_object($obj)){
+ if(str_in_array(strtolower(get_class($obj)),array('cform','ccheckbox','cselect','cbutton','cbuttonqmessage','cbuttondelete','cbuttoncancel'))){
+ $obj=SPACE;
+ }
+ if(isset($obj->items) && !empty($obj->items)){
+ foreach($obj->items as $id => $item){
+ hide_form_items($obj->items[$id]); // Recursion
+ }
+ }
+ }
+ else{
+ foreach(array('<form','<input','<select') as $item){
+ if(strpos($obj,$item) !== FALSE) $obj = SPACE;
+ }
+ }
+ }
+
+ function get_thin_table_header($col1, $col2=SPACE){
+
+ $table = new CTable(NULL,"filter");
+// $table->AddOption('border',1);
+ $table->SetCellSpacing(0);
+ $table->SetCellPadding(1);
+
+ $td_r = new CCol($col2,"filter_r");
+ $td_r->AddOption('align','right');
+
+ $table->AddRow(array(new CCol($col1,"filter_l"), $td_r));
+ return $table;
+ }
+
+ function show_thin_table_header($col1, $col2=SPACE){
+ $table = get_thin_table_header($col1, $col2);
+ $table->Show();
+ }
+
+ function get_table_header($col1, $col2=SPACE){
+ if(isset($_REQUEST['print'])){
+ hide_form_items($col1);
+ hide_form_items($col2);
+ //if empty header than do not show it
+ if(($col1 == SPACE) && ($col2 == SPACE)) return new CScript('');
+ }
+
+ $table = new CTable(NULL,"header");
+// $table->AddOption('border',1);
+ $table->SetCellSpacing(0);
+ $table->SetCellPadding(1);
+
+ $td_r = new CCol($col2,"header_r");
+ $td_r->AddOption('align','right');
+
+ $table->AddRow(array(new CCol($col1,"header_l"), $td_r));
+ return $table;
+ }
+
+ function show_table_header($col1, $col2=SPACE)
+ {
+ $table = get_table_header($col1, $col2);
+ $table->Show();
+ }
?> \ No newline at end of file
diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php
index 1610bb4d..0c87f44a 100644
--- a/frontends/php/include/locales/en_gb.inc.php
+++ b/frontends/php/include/locales/en_gb.inc.php
@@ -945,6 +945,7 @@
'S_EVERY'=> 'Every',
'S_REFRESHED'=> 'Refreshed',
'S_MENU'=> 'Menu',
+ 'S_RESET'=> 'Reset',
// overview.php
'S_SELECT_GROUP_DOT_DOT_DOT'=> 'Select group ...',
diff --git a/frontends/php/include/maps.inc.php b/frontends/php/include/maps.inc.php
index dc1874e4..8b57a225 100644
--- a/frontends/php/include/maps.inc.php
+++ b/frontends/php/include/maps.inc.php
@@ -653,7 +653,7 @@
elseif($db_element["elementtype"] == SYSMAP_ELEMENT_TYPE_TRIGGER)
{
if(empty($url) && $db_element["elementid"]!=0)
- $url="tr_events.php?triggerid=".$db_element["elementid"];
+ $url="events.php?triggerid=".$db_element["elementid"];
}
elseif($db_element["elementtype"] == SYSMAP_ELEMENT_TYPE_HOST_GROUP)
{
diff --git a/frontends/php/include/page_header.php b/frontends/php/include/page_header.php
index b7911c4c..d61de1c0 100644
--- a/frontends/php/include/page_header.php
+++ b/frontends/php/include/page_header.php
@@ -108,21 +108,32 @@ COpt::profiling_start("page");
"sub_pages"=>array("chart2.php","charts.php","screens.php","maps.php","map.php")
),
array("url"=>"overview.php" ,"label"=>S_OVERVIEW ),
- array("url"=>"httpmon.php" ,"label"=>S_WEB ,
- "sub_pages"=>array("httpdetails.php")
+ array(
+ "url"=>"httpmon.php",
+ "label"=>S_WEB,
+ "sub_pages"=>array("httpdetails.php")
),
array("url"=>"latest.php" ,"label"=>S_LATEST_DATA ,
"sub_pages"=>array("history.php","chart.php")
),
- array("url"=>"tr_status.php" ,"label"=>S_TRIGGERS ,
- "sub_pages"=>array("tr_events.php","acknow.php","tr_comments.php",
- "chart4.php","scripts_exec.php")
+ array(
+ "url"=>"tr_status.php",
+ "label"=>S_TRIGGERS,
+ "sub_pages"=>array("acknow.php","tr_comments.php","chart4.php","scripts_exec.php")
),
array("url"=>"events.php" ,"label"=>S_EVENTS ),
- array("url"=>"actions.php" ,"label"=>S_ACTIONS ),
- array("url"=>"discovery.php" ,"label"=>S_DISCOVERY , "user_type"=>USER_TYPE_ZABBIX_ADMIN),
- array("url"=>"srv_status.php" ,"label"=>S_IT_SERVICES , 'forse_disable_subnodes' => true,
- "sub_pages"=>array("report3.php","chart_sla.php","chart5.php")
+ array(
+ "url"=>"actions.php",
+ "label"=>S_ACTIONS),
+ array(
+ "url"=>"discovery.php",
+ "label"=>S_DISCOVERY,
+ "user_type"=>USER_TYPE_ZABBIX_ADMIN),
+ array(
+ "url"=>"srv_status.php",
+ "label"=>S_IT_SERVICES,
+ 'forse_disable_subnodes' => true,
+ "sub_pages"=>array("report3.php","chart_sla.php","chart5.php")
),
array("url"=>"vtext.php"),
array("url"=>"chart3.php")
@@ -153,18 +164,26 @@ COpt::profiling_start("page");
"default_page_id" => 0,
"forse_disable_subnodes"=> true,
"pages"=>array(
- array("url"=>"config.php" ,"label"=>S_GENERAL,
- "sub_pages"=>array("image.php")
+ array(
+ "url"=>"config.php",
+ "label"=>S_GENERAL,
+ "sub_pages"=>array("image.php")
),
- array("url"=>"httpconf.php" ,"label"=>S_WEB,
- "sub_pages"=>array("popup_httpstep.php")
+ array(
+ "url"=>"httpconf.php",
+ "label"=>S_WEB,
+ "sub_pages"=>array("popup_httpstep.php")
),
array("url"=>"hosts.php" ,"label"=>S_HOSTS),
- array("url"=>"items.php" ,"label"=>S_ITEMS,
- "sub_pages"=>array("tr_logform.php")
+ array(
+ "url"=>"items.php",
+ "label"=>S_ITEMS,
+ "sub_pages"=>array("tr_logform.php")
),
- array("url"=>"triggers.php" ,"label"=>S_TRIGGERS,
- "sub_pages"=>array("popup_trexpr.php")
+ array(
+ "url"=>"triggers.php",
+ "label"=>S_TRIGGERS,
+ "sub_pages"=>array("popup_trexpr.php")
),
array("url"=>"actionconf.php" ,"label"=>S_ACTIONS),
array("url"=>"sysmaps.php" ,"label"=>S_MAPS,
@@ -394,6 +413,7 @@ COpt::profiling_start("page");
?>
<script type="text/javascript" src="js/common.js"></script>
+ <script type="text/javascript" src="js/prototype.js"></script>
<?php
if(isset($page['scripts']) && is_array($page['scripts'])){
foreach($page['scripts'] as $id => $script){
diff --git a/frontends/php/include/perm.inc.php b/frontends/php/include/perm.inc.php
index f6510d83..e5f96bb3 100644
--- a/frontends/php/include/perm.inc.php
+++ b/frontends/php/include/perm.inc.php
@@ -184,10 +184,13 @@
return $perm_mode;
}
- function get_accessible_hosts_by_user(&$user_data,$perm,$perm_mode=null,$perm_res=null,$nodeid=null,$hostid=null)
- {
+ function get_accessible_hosts_by_user(&$user_data,$perm,$perm_mode=null,$perm_res=null,$nodeid=null,$hostid=null){
+ static $available_hosts;
+
if(is_null($perm_res)) $perm_res = PERM_RES_STRING_LINE;
if($perm == PERM_READ_LIST) $perm = PERM_READ_ONLY;
+
+ if(is_null($perm_mode)) $perm_mode = PERM_MODE_GE;
$result = array();
@@ -195,11 +198,20 @@
$user_type =& $user_data['type'];
if(!isset($userid)) fatal_error('Incorrect user data in "get_accessible_hosts_by_user"');
+
+ $nodeid_str =(is_array($nodeid))?implode('',$nodeid):strval($nodeid);
+
+ if(isset($available_hosts[$userid][$perm][$perm_mode][$perm_res][$nodeid_str])){
+ return $available_hosts[$userid][$perm][$perm_mode][$perm_res][$nodeid_str];
+ }
- switch($perm_res)
- {
- case PERM_RES_DATA_ARRAY: $resdata = '$host_data'; break;
- default: $resdata = '$host_data["hostid"]'; break;
+ switch($perm_res){
+ case PERM_RES_DATA_ARRAY:
+ $resdata = '$host_data';
+ break;
+ default:
+ $resdata = '$host_data["hostid"]';
+ break;
}
COpt::counter_up('perm_host['.$userid.','.$perm.','.$perm_mode.','.$perm_res.','.$nodeid.']');
@@ -261,15 +273,15 @@ COpt::counter_up('perm');
unset($processed, $host_data, $db_hosts);
- if($perm_res == PERM_RES_STRING_LINE)
- {
+ if(PERM_RES_STRING_LINE == $perm_res){
if(count($result) == 0)
$result = '-1';
else
$result = implode(',',$result);
}
-
- return $result;
+
+ $available_hosts[$userid][$perm][$perm_mode][$perm_res][$nodeid_str] = $result;
+ return $result;
}
function get_accessible_groups_by_user($user_data,$perm,$perm_mode=null,$perm_res=null,$nodeid=null)
@@ -285,10 +297,13 @@ COpt::counter_up('perm');
if(!isset($userid)) fatal_error('Incorrect user data in "get_accessible_groups_by_user"');
$user_type =& $user_data['type'];
- switch($perm_res)
- {
- case PERM_RES_DATA_ARRAY: $resdata = '$group_data'; break;
- default: $resdata = '$group_data["groupid"]'; break;
+ switch($perm_res){
+ case PERM_RES_DATA_ARRAY:
+ $resdata = '$group_data';
+ break;
+ default:
+ $resdata = '$group_data["groupid"]';
+ break;
}
COpt::counter_up('perm_group['.$userid.','.$perm.','.$perm_mode.','.$perm_res.','.$nodeid.']');
@@ -302,26 +317,25 @@ COpt::counter_up('perm');
else $where = '';
/* if no rights defined used node rights */
- $db_groups = DBselect('select n.nodeid as nodeid,n.name as node_name,hg.groupid,hg.name,min(r.permission) as permission,g.userid'.
- ' from groups hg left join rights r on r.id=hg.groupid and r.type='.RESOURCE_TYPE_GROUP.
- ' left join users_groups g on r.groupid=g.usrgrpid and g.userid='.$userid.
- ' left join nodes n on '.DBid2nodeid('hg.groupid').'=n.nodeid '.
- $where.' group by n.nodeid, n.name, hg.groupid, hg.name, g.userid, g.userid '.
- ' order by n.name, hg.name, permission desc');
+ $db_groups = DBselect('SELECT n.nodeid as nodeid,n.name as node_name,hg.groupid,hg.name,min(r.permission) as permission,g.userid'.
+ ' FROM groups hg '.
+ ' LEFT JOIN rights r ON r.id=hg.groupid AND r.type='.RESOURCE_TYPE_GROUP.
+ ' LEFT JOIN users_groups g ON r.groupid=g.usrgrpid AND g.userid='.$userid.
+ ' LEFT JOIN nodes n ON '.DBid2nodeid('hg.groupid').'=n.nodeid '.
+ $where.
+ ' GROUP BY n.nodeid, n.name, hg.groupid, hg.name, g.userid, g.userid '.
+ ' ORDER BY n.name, hg.name, permission desc');
$processed = array();
- while($group_data = DBfetch($db_groups))
- {
+ while($group_data = DBfetch($db_groups)){
if(is_null($group_data['nodeid'])) $group_data['nodeid'] = id2nodeid($group_data['groupid']);
/* deny if no rights defined */
- if( is_null($group_data['permission']) || is_null($group_data['userid']) )
- {
+ if( is_null($group_data['permission']) || is_null($group_data['userid']) ){
if(isset($processed[$group_data['groupid']]))
continue;
- if(!isset($nodes))
- {
+ if(!isset($nodes)){
$nodes = get_accessible_nodes_by_user($user_data,
PERM_DENY,PERM_MODE_GE,PERM_RES_DATA_ARRAY);
}
@@ -343,8 +357,7 @@ COpt::counter_up('perm');
unset($processed, $group_data, $db_groups);
- if($perm_res == PERM_RES_STRING_LINE)
- {
+ if($perm_res == PERM_RES_STRING_LINE) {
if(count($result) == 0)
$result = '-1';
else
diff --git a/frontends/php/include/profiles.inc.php b/frontends/php/include/profiles.inc.php
index 889b09dc..dfd913a1 100644
--- a/frontends/php/include/profiles.inc.php
+++ b/frontends/php/include/profiles.inc.php
@@ -25,31 +25,34 @@
function get_profile($idx,$default_value=null,$type=PROFILE_TYPE_UNKNOWN){
global $USER_DETAILS;
- $result = array();
-// $result = $default_value;
+ $result = $default_value;
if($USER_DETAILS["alias"]!=ZBX_GUEST_USER){
$db_profiles = DBselect('SELECT * FROM profiles WHERE userid='.$USER_DETAILS["userid"].' AND idx='.zbx_dbstr($idx));
- while($profile=DBfetch($db_profiles)){
- if($type==PROFILE_TYPE_UNKNOWN) $type = $profile["valuetype"];
-
- switch($type){
- case PROFILE_TYPE_INT:
- $result[] = intval($profile["value"]);
- break;
- case PROFILE_TYPE_STR:
- default:
- $result[] = strval($profile["value"]);
+ if($profile=DBfetch($db_profiles)){
+
+ if(PROFILE_TYPE_UNKNOWN == $type) $type = $profile["valuetype"];
+
+ if(PROFILE_TYPE_ARRAY == $type){
+ $result[] = $profile['value'];
+ while($profile=DBfetch($db_profiles)){
+ $result[] = $profile['value'];
+ }
+ }
+ else{
+ switch($type){
+ case PROFILE_TYPE_INT:
+ $result = intval($profile["value"]);
+ break;
+ case PROFILE_TYPE_STR:
+ default:
+ $result = strval($profile["value"]);
+ }
}
}
}
- $result = array_filter($result, "not_empty");
-
- if(isset($result[0]) && (PROFILE_TYPE_ARRAY != $type)) $result = $result[0];
- if(empty($result)) $result = $default_value;
-
return $result;
}
@@ -145,6 +148,7 @@ function add_user_history($page){
$curr = 0;
$profile = array();
for($i = 0; $i < ZBX_HISTORY_COUNT; $i++){
+ $history = get_profile('web.history.'.$i,false);
if($history = get_profile('web.history.'.$i,false)){
if($history[0] != $title){
$profile[$curr] = $history;
@@ -154,7 +158,6 @@ function add_user_history($page){
}
$history = array($title,$url);
-
if($curr < ZBX_HISTORY_COUNT){
for($i = 0; $i < $curr; $i++){
update_profile('web.history.'.$i,$profile[$i],PROFILE_TYPE_ARRAY);
diff --git a/frontends/php/include/triggers.inc.php b/frontends/php/include/triggers.inc.php
index ceb48861..61b421e1 100644
--- a/frontends/php/include/triggers.inc.php
+++ b/frontends/php/include/triggers.inc.php
@@ -1889,7 +1889,7 @@
array(S_TRIGGER, null, null,
array('outer'=> array('pum_oheader'), 'inner'=>array('pum_iheader'))
),
- array(S_EVENTS, 'tr_events.php?triggerid='.$trhosts[$hostname]['triggerid'], array('tw'=>'_blank'))
+ array(S_EVENTS, 'events.php?triggerid='.$trhosts[$hostname]['triggerid'], array('tw'=>'_blank'))
);
if(isset($ack_menu)) $tr_ov_menu[] = $ack_menu;