summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-03-19 17:56:41 +0000
committerartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-03-19 17:56:41 +0000
commit58aee2faa7ab32edcedaf68d346593de9ddb3cb6 (patch)
tree703f8e4d30b297df78d6123e4186045d4020c32f
parent8777958dc979627061016a85ad846507edf395e6 (diff)
downloadzabbix-58aee2faa7ab32edcedaf68d346593de9ddb3cb6.tar.gz
zabbix-58aee2faa7ab32edcedaf68d346593de9ddb3cb6.tar.xz
zabbix-58aee2faa7ab32edcedaf68d346593de9ddb3cb6.zip
- [DEV-139] added transaction functionality to frontend (Artem)
- many small fixes (Artem) git-svn-id: svn://svn.zabbix.com/trunk@5505 97f52cf1-0a1b-0410-bd0e-c28be96e8082
-rw-r--r--ChangeLog1
-rw-r--r--frontends/php/dashboard.php4
-rw-r--r--frontends/php/events.php52
-rw-r--r--frontends/php/hosts.php137
-rw-r--r--frontends/php/include/db.inc.php301
-rw-r--r--frontends/php/include/defines.inc.php3
-rw-r--r--frontends/php/include/discovery.inc.php21
-rw-r--r--frontends/php/include/events.inc.php235
-rw-r--r--frontends/php/include/import.inc.php2
-rw-r--r--frontends/php/include/locales/en_gb.inc.php2
-rw-r--r--frontends/php/include/page_header.php13
-rw-r--r--frontends/php/include/perm.inc.php85
-rw-r--r--frontends/php/include/profiles.inc.php13
-rw-r--r--frontends/php/js/calendar.js7
-rw-r--r--frontends/php/js/common.js33
-rw-r--r--frontends/php/js/dashboard.js30
-rw-r--r--frontends/php/scripts_exec.php7
-rw-r--r--frontends/php/tr_events.php378
-rw-r--r--frontends/php/users.php2
19 files changed, 789 insertions, 537 deletions
diff --git a/ChangeLog b/ChangeLog
index 2c77974c..b2e9cd54 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
Changes for 1.5.1:
+ - [DEV-139] added transaction functionality to frontend (Artem)
- [DEV-138] added support of update interval in icmp* simpe checks (Sasha)
- [DEV-137] increased max number of log file lines sent per second to 100 (Alexei)
diff --git a/frontends/php/dashboard.php b/frontends/php/dashboard.php
index 30dc2219..525301ac 100644
--- a/frontends/php/dashboard.php
+++ b/frontends/php/dashboard.php
@@ -30,7 +30,7 @@ require_once "include/blocks.inc.php";
$page["title"] = "S_DASHBOARD";
$page["file"] = "dashboard.php";
$page['hist_arg'] = array();
-$page['scripts'] = array('url.js','dashboard.js','showhint.js');
+$page['scripts'] = array('dashboard.js','showhint.js');
$page['type'] = detect_page_type(PAGE_TYPE_HTML);
@@ -329,7 +329,7 @@ include_once "include/page_header.php";
$drules = DBfetch(DBselect('SELECT COUNT(d.druleid) as cnt FROM drules d WHERE '.DBin_node('d.druleid').' AND d.status='.DRULE_STATUS_ACTIVE));
- if(($drules['cnt'] > 0) && (USER_TYPE_ZABBIX_ADMIN <= $USER_DETAILS['type'])){
+ if(($drules['cnt'] > 0) && check_right_on_discovery(PERM_READ_ONLY)){
$refresh_tab[] = array( 'id' => 'hat_dscvry','interval' => get_profile('web.dahsboard.rf_rate.hat_dscvry',60));
diff --git a/frontends/php/events.php b/frontends/php/events.php
index 927e10df..2c70b492 100644
--- a/frontends/php/events.php
+++ b/frontends/php/events.php
@@ -28,9 +28,13 @@
$page["title"] = "S_LATEST_EVENTS";
$page["file"] = "events.php";
$page['hist_arg'] = array('groupid','hostid');
- $page['scripts'] = array('url.js','calendar.js');
+ $page['scripts'] = array('calendar.js');
- define('ZBX_PAGE_DO_REFRESH', 1);
+ $page['type'] = detect_page_type(PAGE_TYPE_HTML);
+
+ if(PAGE_TYPE_HTML == $page['type']){
+ define('ZBX_PAGE_DO_REFRESH', 1);
+ }
include_once "include/page_header.php";
@@ -40,8 +44,9 @@ include_once "include/page_header.php";
$allowed_sources[] = EVENT_SOURCE_TRIGGERS;
if($allow_discovery) $allowed_sources[] = EVENT_SOURCE_DISCOVERY;
-
+
define('PAGE_SIZE', 100);
+
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
$fields=array(
"source"=> array(T_ZBX_INT, O_OPT, P_SYS, IN($allowed_sources), NULL),
@@ -69,8 +74,21 @@ include_once "include/page_header.php";
$_REQUEST['source'] = get_request('source', get_profile('web.events.source', 0));
check_fields($fields);
- validate_sort_and_sortorder('e.clock',ZBX_SORT_DOWN);
-// filter prepare
+
+/* AJAX */
+ if(isset($_REQUEST['favobj'])){
+ if('filter' == $_REQUEST['favobj']){
+// echo 'alert("'.$_REQUEST['favid'].' : '.$_REQUEST['state'].'");';
+ update_profile('web.events.filter.state',$_REQUEST['state']);
+ }
+ }
+
+ if((PAGE_TYPE_JS == $page['type']) || (PAGE_TYPE_HTML_BLOCK == $page['type'])){
+ exit();
+ }
+//--------
+
+/* FILTER */
if(isset($_REQUEST['filter_rst'])){
$_REQUEST['triggerid'] = 0;
$_REQUEST['show_unknown'] = 0;
@@ -100,21 +118,11 @@ include_once "include/page_header.php";
}
// --------------
+ validate_sort_and_sortorder('e.clock',ZBX_SORT_DOWN);
+
$source = get_request('source', EVENT_SOURCE_TRIGGERS);
update_profile('web.events.source',$source);
-
- if(isset($_REQUEST['favobj'])){
- if('filter' == $_REQUEST['favobj']){
-// echo 'alert("'.$_REQUEST['favid'].' : '.$_REQUEST['state'].'");';
- update_profile('web.events.filter.state',$_REQUEST['state']);
- }
- }
-
- if((PAGE_TYPE_JS == $page['type']) || (PAGE_TYPE_HTML_BLOCK == $page['type'])){
- exit();
- }
-
?>
<?php
$_REQUEST["start"] = get_request("start", 0);
@@ -219,7 +227,7 @@ include_once "include/page_header.php";
$cmbSource = new CComboBox('source', $source, 'submit()');
$cmbSource->AddItem(EVENT_SOURCE_TRIGGERS, S_TRIGGER);
$cmbSource->AddItem(EVENT_SOURCE_DISCOVERY, S_DISCOVERY);
- $r_form->AddItem(array(S_SOURCE, SPACE, $cmbSource));
+ $r_form->AddItem(array(SPACE.S_SOURCE.SPACE, $cmbSource));
}
show_table_header(S_HISTORY_OF_EVENTS_BIG.SPACE.date("[H:i:s]",time()),$r_form);
@@ -277,7 +285,7 @@ include_once "include/page_header.php";
is_show_subnodes() ? S_NODE : null,
$_REQUEST["hostid"] == 0 ? S_HOST : null,
S_DESCRIPTION,
- S_VALUE,
+ S_STATUS,
S_SEVERITY,
S_DURATION,
($config['event_ack_enable'])?S_ACK:NULL,
@@ -307,10 +315,10 @@ include_once "include/page_header.php";
}
if($row["value"] == TRIGGER_VALUE_FALSE){
- $value=new CCol(S_OFF,"off");
+ $value=new CCol(S_FALSE_BIG,"off");
}
elseif($row["value"] == TRIGGER_VALUE_TRUE){
- $value=new CCol(S_ON,"on");
+ $value=new CCol(S_TRUE_BIG,"on");
}
else{
$value=new CCol(S_UNKNOWN_BIG,"unknown");
@@ -413,7 +421,7 @@ include_once "include/page_header.php";
$table->AddRow(array(
date("Y.M.d H:i:s",$row["clock"]),
- get_node_name_by_elid($row['triggerid']),
+ is_show_subnodes() ? get_node_name_by_elid($row['triggerid']) : null,
$_REQUEST["hostid"] == 0 ? $row['host'] : null,
new CLink(
expand_trigger_description_by_data($row, ZBX_FLAG_EVENT),
diff --git a/frontends/php/hosts.php b/frontends/php/hosts.php
index 1cb07917..f9a07d13 100644
--- a/frontends/php/hosts.php
+++ b/frontends/php/hosts.php
@@ -45,8 +45,7 @@ include_once "include/page_header.php";
$available_hosts = implode(',', $available_hosts);
if(isset($_REQUEST["groupid"]) && $_REQUEST["groupid"] > 0){
- if(!uint_in_array($_REQUEST["groupid"], get_accessible_groups_by_user($USER_DETAILS,PERM_READ_WRITE,null,
- PERM_RES_IDS_ARRAY,get_current_nodeid())))
+ if(!uint_in_array($_REQUEST["groupid"], get_accessible_groups_by_user($USER_DETAILS,PERM_READ_WRITE,null,PERM_RES_IDS_ARRAY,get_current_nodeid())))
{
access_deny();
}
@@ -160,20 +159,16 @@ include_once "include/page_header.php";
elseif(($_REQUEST["config"]==0 || $_REQUEST["config"]==3) && isset($_REQUEST["save"]))
{
$useip = get_request("useip",0);
-
$groups=get_request("groups",array());
- if(count($groups) > 0)
- {
+ if(count($groups) > 0){
$accessible_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_WRITE,null,PERM_RES_IDS_ARRAY);
- foreach($groups as $gid)
- {
+ foreach($groups as $gid){
if(isset($accessible_groups[$gid])) continue;
access_deny();
}
}
- else
- {
+ else{
if(count(get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_MODE_LT,PERM_RES_IDS_ARRAY,get_current_nodeid())))
access_deny();
@@ -181,12 +176,9 @@ include_once "include/page_header.php";
$templates = get_request('templates', array());
- if(isset($_REQUEST["hostid"]))
- {
- if(isset($_REQUEST['clear_templates']))
- {
- foreach($_REQUEST['clear_templates'] as $id)
- {
+ if(isset($_REQUEST["hostid"])){
+ if(isset($_REQUEST['clear_templates'])) {
+ foreach($_REQUEST['clear_templates'] as $id){
unlink_template($_REQUEST["hostid"], $id, false);
}
}
@@ -200,7 +192,9 @@ include_once "include/page_header.php";
$audit_action = AUDIT_ACTION_UPDATE;
$hostid = $_REQUEST["hostid"];
- } else {
+ }
+ else {
+
$hostid = add_host(
$_REQUEST["host"],$_REQUEST["port"],$_REQUEST["status"],$useip,$_REQUEST["dns"],
$_REQUEST["ip"],$_REQUEST["proxy_hostid"],$templates,$_REQUEST["newgroup"],$groups);
@@ -283,8 +277,7 @@ include_once "include/page_header.php";
{
global $USER_DETAILS;
- if(!uint_in_array($_REQUEST['add_to_group'], get_accessible_groups_by_user($USER_DETAILS,PERM_READ_WRITE,null,
- PERM_RES_IDS_ARRAY,get_current_nodeid())))
+ if(!uint_in_array($_REQUEST['add_to_group'], get_accessible_groups_by_user($USER_DETAILS,PERM_READ_WRITE,null,PERM_RES_IDS_ARRAY,get_current_nodeid())))
{
access_deny();
}
@@ -298,8 +291,7 @@ include_once "include/page_header.php";
{
global $USER_DETAILS;
- if(!uint_in_array($_REQUEST['delete_from_group'], get_accessible_groups_by_user($USER_DETAILS,PERM_READ_WRITE,null,
- PERM_RES_IDS_ARRAY,get_current_nodeid())))
+ if(!uint_in_array($_REQUEST['delete_from_group'], get_accessible_groups_by_user($USER_DETAILS,PERM_READ_WRITE,null,PERM_RES_IDS_ARRAY,get_current_nodeid())))
{
access_deny();
}
@@ -646,7 +638,7 @@ include_once "include/page_header.php";
}
- $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_WRITE,null,null,get_current_nodeid()); /* update available_hosts after ACTIONS */
+ $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_WRITE,null,null,get_current_nodeid(),AVAILABLE_NOCACHE); /* update available_hosts after ACTIONS */
?>
<?php
$frmForm = new CForm();
@@ -699,10 +691,10 @@ include_once "include/page_header.php";
if($_REQUEST["config"]==3)
$show_only_tmp = 1;
- if(isset($_REQUEST["form"]))
- {
+ if(isset($_REQUEST["form"])){
insert_host_form($show_only_tmp);
- } else {
+ }
+ else {
if($show_only_tmp==1)
$status_filter = " and h.status in (".HOST_STATUS_TEMPLATE.") ";
else
@@ -722,8 +714,8 @@ include_once "include/page_header.php";
$cmbGroups->AddItem($row["groupid"],$row["name"]);
if((bccomp($row["groupid"], $_REQUEST["groupid"]) == 0)) $correct_host = 1;
}
- if(!isset($correct_host))
- {
+
+ if(!isset($correct_host)){
$_REQUEST["groupid"] = 0;
$cmbGroups->SetValue($_REQUEST["groupid"]);
}
@@ -759,8 +751,7 @@ include_once "include/page_header.php";
S_ACTIONS
));
- $sql='SELECT h.* '.
- ' FROM';
+ $sql='SELECT h.* FROM ';
if(isset($_REQUEST["groupid"])){
$sql.= ' hosts h,hosts_groups hg ';
@@ -769,27 +760,24 @@ include_once "include/page_header.php";
' AND';
}
- else $sql.= ' hosts h '.
- ' WHERE';
+ else{
+ $sql.= ' hosts h WHERE ';
+ }
- $sql.= ' h.hostid IN ('.$available_hosts.') '.
+ $sql.= ' h.hostid IN ('.$available_hosts.') '.
$status_filter.
order_by('h.host,h.port,h.ip,h.status,h.available,h.dns');
$result=DBselect($sql);
-
- while($row=DBfetch($result))
- {
+ while($row=DBfetch($result)){
$description = array();
- if ($row["proxy_hostid"]) {
+ if($row["proxy_hostid"]){
$proxy = get_host_by_hostid($row["proxy_hostid"]);
array_push($description,$proxy["host"],":");
}
- array_push($description,
- new CLink($row["host"], "hosts.php?form=update&hostid=".
- $row["hostid"].url_param("groupid").url_param("config"), 'action'));
+ array_push($description, new CLink($row["host"], "hosts.php?form=update&hostid=".$row["hostid"].url_param("groupid").url_param("config"), 'action'));
$add_to = array();
$delete_from = array();
@@ -802,8 +790,7 @@ include_once "include/page_header.php";
$description));
- if($show_only_tmp)
- {
+ if($show_only_tmp){
$dns = NULL;
$ip = NULL;
$port = NULL;
@@ -811,8 +798,7 @@ include_once "include/page_header.php";
$available = NULL;
$error = NULL;
}
- else
- {
+ else{
$dns = $row['dns'];
$ip = $row['ip'];
$port = $row["port"];
@@ -821,31 +807,33 @@ include_once "include/page_header.php";
$ip = bold($ip);
else
$dns = bold($dns);
+
+ switch($row['status']){
+ case HOST_STATUS_MONITORED:
+ $status=new CLink(S_MONITORED,'hosts.php?hosts%5B%5D='.$row['hostid'].'&disable=1'.url_param('config').url_param('groupid'),'off');
+ break;
+ case HOST_STATUS_NOT_MONITORED:
+ $status=new CLink(S_NOT_MONITORED,'hosts.php?hosts%5B%5D='.$row['hostid'].'&activate=1'.url_param('config').url_param('groupid'),'on');
+ break;
+ case HOST_STATUS_TEMPLAT:
+ $status=new CCol(S_TEMPLATE,'unknown');
+ break;
+ case HOST_STATUS_DELETED:
+ $status=new CCol(S_DELETED,'unknown');
+ break;
+ default:
+ $status=S_UNKNOWN;
+ }
- if($row["status"] == HOST_STATUS_MONITORED){
- $status=new CLink(S_MONITORED,"hosts.php?hosts%5B%5D=".$row["hostid"].
- "&disable=1".url_param("config").url_param("groupid"),
- "off");
- } else if($row["status"] == HOST_STATUS_NOT_MONITORED) {
- $status=new CLink(S_NOT_MONITORED,"hosts.php?hosts%5B%5D=".$row["hostid"].
- "&activate=1".url_param("config").url_param("groupid"),
- "on");
- } else if($row["status"] == HOST_STATUS_TEMPLATE)
- $status=new CCol(S_TEMPLATE,"unknown");
- else if($row["status"] == HOST_STATUS_DELETED)
- $status=new CCol(S_DELETED,"unknown");
- else
- $status=S_UNKNOWN;
-
- if($row["available"] == HOST_AVAILABLE_TRUE)
- $available=new CCol(S_AVAILABLE,"off");
- else if($row["available"] == HOST_AVAILABLE_FALSE)
- $available=new CCol(S_NOT_AVAILABLE,"on");
- else if($row["available"] == HOST_AVAILABLE_UNKNOWN)
- $available=new CCol(S_UNKNOWN,"unknown");
+ if($row['available'] == HOST_AVAILABLE_TRUE)
+ $available=new CCol(S_AVAILABLE,'off');
+ else if($row['available'] == HOST_AVAILABLE_FALSE)
+ $available=new CCol(S_NOT_AVAILABLE,'on');
+ else if($row['available'] == HOST_AVAILABLE_UNKNOWN)
+ $available=new CCol(S_UNKNOWN,'unknown');
- if($row["error"] == "") $error = new CCol(SPACE,"off");
- else $error = new CCol($row["error"],"on");
+ if($row['error'] == '') $error = new CCol(SPACE,'off');
+ else $error = new CCol($row['error'],'on');
}
@@ -859,8 +847,8 @@ include_once "include/page_header.php";
$db_groups = DBselect('select g.groupid, g.name from groups g left join hosts_groups hg '.
' on g.groupid=hg.groupid and hg.hostid='.$row['hostid'].
' where '.DBin_node('g.groupid').' AND hg.hostid is NULL order by g.name,g.groupid');
- while($group_data = DBfetch($db_groups))
- {
+
+ while($group_data = DBfetch($db_groups)){
$add_to[] = array($group_data['name'], '?'.
url_param($group_data['groupid'], false, 'add_to_group').
url_param($row['hostid'], false, 'hostid')
@@ -870,26 +858,25 @@ include_once "include/page_header.php";
$db_groups = DBselect('select g.groupid, g.name from groups g, hosts_groups hg '.
' where g.groupid=hg.groupid and hg.hostid='.$row['hostid'].
' order by g.name,g.groupid');
- while($group_data = DBfetch($db_groups))
- {
+
+ while($group_data = DBfetch($db_groups)){
$delete_from[] = array($group_data['name'], '?'.
url_param($group_data['groupid'], false, 'delete_from_group').
url_param($row['hostid'], false, 'hostid')
);
}
- if(count($add_to) > 0 || count($delete_from) > 0)
- {
+ if(count($add_to) > 0 || count($delete_from) > 0){
$popup_menu_actions[] = array(S_GROUPS, null, null,
array('outer'=> array('pum_oheader'), 'inner'=>array('pum_iheader')));
}
- if(count($add_to) > 0)
- {
+
+ if(count($add_to) > 0){
$popup_menu_actions[] = array_merge(array(S_ADD_TO_GROUP, null, null,
array('outer' => 'pum_o_submenu', 'inner'=>array('pum_i_submenu'))), $add_to);
}
- if(count($delete_from) > 0)
- {
+
+ if(count($delete_from) > 0){
$popup_menu_actions[] = array_merge(array(S_DELETE_FROM_GROUP, null, null,
array('outer' => 'pum_o_submenu', 'inner'=>array('pum_i_submenu'))), $delete_from);
}
diff --git a/frontends/php/include/db.inc.php b/frontends/php/include/db.inc.php
index a0bbaf4d..fda0e808 100644
--- a/frontends/php/include/db.inc.php
+++ b/frontends/php/include/db.inc.php
@@ -19,13 +19,13 @@
**/
?>
<?php
- global $DB, $DB_TYPE, $DB_SERVER, $DB_PORT, $DB_DATABASE, $DB_USER, $DB_PASSWORD;
+ global $DB, $DB_TYPE, $DB_SERVER, $DB_PORT, $DB_DATABASE, $DB_USER, $DB_PASSWORD, $DB_TRANSACTIONS;
function DBconnect(&$error)
{
$result = true;
- global $DB, $DB_TYPE, $DB_SERVER, $DB_PORT, $DB_DATABASE, $DB_USER, $DB_PASSWORD;
+ global $DB, $DB_TYPE, $DB_SERVER, $DB_PORT, $DB_DATABASE, $DB_USER, $DB_PASSWORD, $DB_TRANSACTIONS;
$DB = null;
@@ -82,49 +82,39 @@
}
break;
case "SQLITE3":
- if(!function_exists('init_db_access'))
- {
- function init_db_access()
- {
+ $DB_TRANSACTIONS = 0;
+ if(!function_exists('init_db_access')){
+ function init_db_access(){
global $DB_DATABASE, $ZBX_SEM_ID;
$ZBX_SEM_ID = false;
- if(function_exists('ftok') && function_exists('sem_get') &&
- file_exists($DB_DATABASE))
- {
+ if(function_exists('ftok') && function_exists('sem_get') && file_exists($DB_DATABASE)){
$ZBX_SEM_ID = sem_get(ftok($DB_DATABASE, 'z'), 1);
}
}
}
- if(!function_exists('lock_db_access'))
- {
- function lock_db_access()
- {
+ if(!function_exists('lock_db_access')){
+ function lock_db_access(){
global $ZBX_SEM_ID;
- if($ZBX_SEM_ID && function_exists('sem_acquire'))
- {
+ if($ZBX_SEM_ID && function_exists('sem_acquire')){
sem_acquire($ZBX_SEM_ID);
}
}
}
- if(!function_exists('unlock_db_access'))
- {
- function unlock_db_access()
- {
+ if(!function_exists('unlock_db_access')){
+ function unlock_db_access(){
global $ZBX_SEM_ID;
- if($ZBX_SEM_ID && function_exists('sem_release'))
+ if($ZBX_SEM_ID && function_exists('sem_release'))
sem_release($ZBX_SEM_ID);
}
}
- if(!function_exists('free_db_access'))
- {
- function free_db_access()
- {
+ if(!function_exists('free_db_access')){
+ function free_db_access(){
global $ZBX_SEM_ID;
if($ZBX_SEM_ID && function_exists('sem_remove'))
@@ -135,17 +125,14 @@
}
- if(file_exists($DB_DATABASE))
- {
+ if(file_exists($DB_DATABASE)){
$DB = sqlite3_open($DB_DATABASE);
- if(!$DB)
- {
+ if(!$DB){
$error = "Error connecting to database";
$result = false;
}
}
- else
- {
+ else{
$error = "Missed database";
$result = false;
}
@@ -163,19 +150,22 @@
return $result;
}
- function DBclose()
- {
- global $DB, $DB_TYPE, $DB_SERVER, $DB_PORT, $DB_DATABASE, $DB_USER, $DB_PASSWORD;
+ function DBclose(){
+ global $DB, $DB_TYPE, $DB_SERVER, $DB_PORT, $DB_DATABASE, $DB_USER, $DB_PASSWORD, $DB_TRANSACTIONS;
$result = false;
- if( isset($DB) && !empty($DB) )
- {
- switch($DB_TYPE)
- {
- case "MYSQL": $result = mysql_close($DB); break;
- case "POSTGRESQL": $result = pg_close($DB); break;
- case "ORACLE": $result = ocilogoff($DB); break;
+ if( isset($DB) && !empty($DB) ){
+ switch($DB_TYPE){
+ case "MYSQL":
+ $result = mysql_close($DB);
+ break;
+ case "POSTGRESQL":
+ $result = pg_close($DB);
+ break;
+ case "ORACLE":
+ $result = ocilogoff($DB);
+ break;
case "SQLITE3":
$result = true;
sqlite3_close($DB);
@@ -192,7 +182,8 @@
$GLOBALS['DB_PORT'],
$GLOBALS['DB_DATABASE'],
$GLOBALS['DB_USER'],
- $GLOBALS['DB_PASSWORD']
+ $GLOBALS['DB_PASSWORD'],
+ $GLOBALS['SQLITE_TRANSACTION']
);
return $result;
@@ -227,28 +218,119 @@
}
return true;
}
-
- function DBstart()
- {
- /* TODO *//* start transaction */
- // lock_db_access(); /* check DBselect & DBexecute */
+
+ function DBStart(){
+ global $DB,$DB_TYPE,$DB_TRANSACTIONS;
+//SDI('TRANSACTION STARTED');
+ $result = false;
+ if( isset($DB) && !empty($DB) )
+ switch($DB_TYPE){
+ case "MYSQL":
+ $result = DBexecute('begin;');
+ break;
+ case "POSTGRESQL":
+ $result = DBexecute('begin;');
+ break;
+ case "ORACLE":
+ $DB_TRANSACTIONS++;
+
+ if($DB_TRANSACTIONS>1){
+ info("POSSIBLE ERROR: Used incorect logic in database processing started subtransaction!");
+ }
+ $result = true;
+// TODO OCI_DEFAULT
+ break;
+ case "SQLITE3":
+ $DB_TRANSACTIONS++;
+
+ if(1 == $DB_TRANSACTIONS){
+ lock_db_access();
+ $result = DBexecute('begin;');
+ }
+ else{
+ error("POSSIBLE ERROR: Used incorect logic in database processing started subtransaction!");
+ }
+ break;
+ }
+ return $result;
}
- function DBend($result)
- {
- /* end transaction *//* TODO */
-
- if($result)
- { // OK
- /* commit TODO */
+
+ function DBend($result=true){
+ if($result){ // OK
+ $result = DBcommit();
}
- else
- { // FAIL
- /* rollback TODO */
+
+ if(!$result){ // FAIL
+ DBrollback();
+ }
+//SDI('TRANSACTION ENDED: '.$result);
+ return $result;
+ }
+
+ function DBcommit(){
+ global $DB,$DB_TYPE,$DB_TRANSACTIONS;
+//SDI('COMMITED!');
+ $result = false;
+ if( isset($DB) && !empty($DB) )
+ switch($DB_TYPE){
+ case "MYSQL":
+ $result = DBexecute('commit;');
+ break;
+ case "POSTGRESQL":
+ $result = DBexecute('commit;');
+ break;
+ case "ORACLE":
+ $result = ocicommit();
+ $DB_TRANSACTIONS = 0;
+ break;
+ case "SQLITE3":
+ if($DB_TRANSACTIONS>1)
+ $DB_TRANSACTIONS--;
+
+ if(1 == $DB_TRANSACTIONS){
+ $result = DBexecute('commit;');
+ $DB_TRANSACTIONS = 0;
+
+ unlock_db_access();
+ }
+ break;
+ }
+ return $result;
+ }
+
+ function DBrollback(){
+ global $DB,$DB_TYPE,$DB_TRANSACTIONS;
+//SDI('ROLLED BACK!');
+ $result = false;
+ if( isset($DB) && !empty($DB) )
+ switch($DB_TYPE){
+ case "MYSQL":
+ $result = DBexecute('rollback;');
+ break;
+ case "POSTGRESQL":
+ $result = DBexecute('rollback;');
+ break;
+ case "ORACLE":
+ $result = ocirollback();
+ $DB_TRANSACTIONS = 0;
+ break;
+ case "SQLITE3":
+ if($DB_TRANSACTIONS>1)
+ $DB_TRANSACTIONS--;
+
+ if(1 == $DB_TRANSACTIONS){
+ $result = DBexecute('rollback;');
+ $DB_TRANSACTIONS = 0;
+
+ unlock_db_access();
+ }
+ break;
}
- // unlock_db_access(); /* check DBselect & DBexecute */
+ return $result;
}
+
/* NOTE:
LIMIT and OFFSET records
@@ -266,72 +348,64 @@
function &DBselect($query, $limit='NO')
{
- global $DB, $DB_TYPE;
+ global $DB, $DB_TYPE, $DB_TRANSACTIONS;
//COpt::savesqlrequest($query);
$result = false;
if( isset($DB) && !empty($DB) )
- switch($DB_TYPE)
- {
+ switch($DB_TYPE){
case "MYSQL":
- if(is_numeric($limit))
- {
+ if(is_numeric($limit)){
$query .= ' limit '.intval($limit);
}
$result=mysql_query($query,$DB);
- if(!$result)
- {
+ if(!$result){
error("Error in query [$query] [".mysql_error()."]");
}
break;
case "POSTGRESQL":
- if(is_numeric($limit))
- {
+ if(is_numeric($limit)){
$query .= ' limit '.intval($limit);
}
- if(!($result = pg_query($DB,$query)))
- {
+ $result = pg_query($DB,$query);
+ if(!$result){
error("Error in query [$query] [".pg_last_error()."]");
}
break;
case "ORACLE":
- if(is_numeric($limit))
- {
+ if(is_numeric($limit)){
$query = 'select * from ('.$query.') where rownum<'.intval($limit);
}
$stid=OCIParse($DB,$query);
- if(!$stid)
- {
+ if(!$stid){
$e=@ocierror();
error("SQL error [".$e["message"]."] in [".$e["sqltext"]."]");
}
- $result=@OCIExecute($stid);
- if(!$result)
- {
+
+ $result=@OCIExecute($stid,($DB_TRANSACTIONS?OCI_DEFAULT:OCI_COMMIT_ON_SUCCESS));
+ if(!$result){
$e=ocierror($stid);
error("SQL error [".$e["message"]."] in [".$e["sqltext"]."]");
}
- else
- {
+ else{
$result = $stid;
}
break;
case "SQLITE3":
- lock_db_access();
- if(!($result = sqlite3_query($DB,$query)))
- {
- error("Error in query [$query] [".sqlite3_error($DB)."]");
- }
- else
- {
+ if(!$DB_TRANSACTIONS){
+ lock_db_access();
+ }
+
+ if(!($result = sqlite3_query($DB,$query))){
+ error("Error in query [$query] [".sqlite3_error($DB)."]");
+ }
+ else{
$data = array();
- while($row = sqlite3_fetch_array($result))
- {
- foreach($row as $id => $name)
- {
+ while($row = sqlite3_fetch_array($result)){
+ foreach($row as $id => $name){
if(!zbx_strstr($id,'.')) continue;
$ids = explode('.',$id);
$row[array_pop($ids)] = $row[$id];
@@ -344,69 +418,69 @@
$result = &$data;
}
- unlock_db_access();
+ if(!$DB_TRANSACTIONS){
+ unlock_db_access();
+ }
break;
}
return $result;
}
- function DBexecute($query, $skip_error_messages=0)
- {
- global $DB,$DB_TYPE;
+ function DBexecute($query, $skip_error_messages=0){
+ global $DB,$DB_TYPE,$DB_TRANSACTIONS;
//COpt::savesqlrequest($query);
$result = false;
if( isset($DB) && !empty($DB) )
- switch($DB_TYPE)
- {
+ switch($DB_TYPE){
case "MYSQL":
$result=mysql_query($query,$DB);
- if(!$result)
- {
+ if(!$result){
error("Error in query [$query] [".mysql_error()."]");
}
break;
case "POSTGRESQL":
- if(!($result = pg_query($DB,$query)))
- {
+ if(!($result = pg_query($DB,$query))){
error("Error in query [$query] [".pg_last_error()."]");
}
break;
case "ORACLE":
$result = DBselect($query);
- if(!$result)
- {
+ if(!$result){
$e = ocierror($stid);
error("SQL error [".$e["message"]."] in [".$e["sqltext"]."]");
}
break;
case "SQLITE3":
- lock_db_access();
+ if(!$DB_TRANSACTIONS){
+ lock_db_access();
+ }
+
$result = sqlite3_exec($DB, $query);
- if(!$result)
- {
+ if(!$result){
error("Error in query [$query] [".sqlite3_error($DB)."]");
}
- unlock_db_access();
+
+ if(!$DB_TRANSACTIONS){
+ unlock_db_access();
+ }
break;
}
- return $result;
+ return $result;
}
- function DBfetch(&$cursor)
- {
+ function DBfetch(&$cursor){
global $DB, $DB_TYPE;
$result = false;
- if( isset($DB) && !empty($DB) )
- switch($DB_TYPE)
- {
+ if(isset($DB) && !empty($DB))
+ switch($DB_TYPE){
case "MYSQL":
$result = mysql_fetch_assoc($cursor);
break;
@@ -422,17 +496,14 @@
}
break;
case "SQLITE3":
- if($cursor)
- {
+ if($cursor){
$result = array_shift($cursor);
-
if(is_null($result)) $result = false;
-
}
break;
}
- return $result;
+ return $result;
}
diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php
index ad34beff..eb8b0a16 100644
--- a/frontends/php/include/defines.inc.php
+++ b/frontends/php/include/defines.inc.php
@@ -440,6 +440,9 @@
define('DHOST_STATUS_ACTIVE', 0);
define('DHOST_STATUS_DISABLED', 1);
+ define('AVAILABLE_NOCACHE', 0); // take available objects not from cache
+
+
// define('BR', "<br/>\n");
define('SBR', "<br/>\n");
define('SPACE', '&nbsp;');
diff --git a/frontends/php/include/discovery.inc.php b/frontends/php/include/discovery.inc.php
index 10cd2565..673c9d40 100644
--- a/frontends/php/include/discovery.inc.php
+++ b/frontends/php/include/discovery.inc.php
@@ -21,27 +21,20 @@
?>
<?php
- function check_right_on_discovery($permission)
- {
+ function check_right_on_discovery($permission){
global $USER_DETAILS;
- if( $USER_DETAILS['type'] >= USER_TYPE_ZABBIX_ADMIN )
- {
- if ( 0 == count(
- get_accessible_nodes_by_user($USER_DETAILS, $permission, null, PERM_RES_IDS_ARRAY, get_current_nodeid())
- ))
+ if( $USER_DETAILS['type'] >= USER_TYPE_ZABBIX_ADMIN ){
+ if (0 < count(get_accessible_nodes_by_user($USER_DETAILS, $permission, null, PERM_RES_IDS_ARRAY, get_current_nodeid())))
return true;
}
-
- return false;
+ return false;
}
- function svc_default_port($type_int)
- {
+ function svc_default_port($type_int){
$port = 0;
- switch($type_int)
- {
+ switch($type_int){
case SVC_SSH: $port = 22; break;
case SVC_LDAP: $port = 389; break;
case SVC_SMTP: $port = 25; break;
@@ -56,7 +49,7 @@
case SVC_SNMPv2:$port = 161; break;
}
- return $port;
+ return $port;
}
function discovery_check_type2str($type_int)
diff --git a/frontends/php/include/events.inc.php b/frontends/php/include/events.inc.php
index bbfc2bc1..211c44d8 100644
--- a/frontends/php/include/events.inc.php
+++ b/frontends/php/include/events.inc.php
@@ -27,68 +27,6 @@
}
}
- 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)
- );
-
- $table = new CTableInfo(S_NO_EVENTS_FOUND);
- $table->SetHeader(array(S_TIME, S_IP, S_DESCRIPTION, S_STATUS));
- $col=0;
-
- $skip = $start;
- while(($event_data = DBfetch($db_events))&&($col<$num))
- {
- if($skip > 0)
- {
- $skip--;
- continue;
- }
-
- if($event_data["value"] == 0)
- {
- $value=new CCol(S_UP,"off");
- }
- elseif($event_data["value"] == 1)
- {
- $value=new CCol(S_DOWN,"on");
- }
- else
- {
- $value=new CCol(S_UNKNOWN_BIG,"unknown");
- }
-
-
- switch($event_data['object'])
- {
- case EVENT_OBJECT_DHOST:
- $object_data = DBfetch(DBselect('select ip from dhosts where dhostid='.$event_data['objectid']));
- $description = SPACE;
- break;
- case EVENT_OBJECT_DSERVICE:
- $object_data = DBfetch(DBselect('select h.ip,s.type,s.port from dhosts h,dservices s '.
- ' where h.dhostid=s.dhostid and s.dserviceid='.$event_data['objectid']));
- $description = S_SERVICE.': '.discovery_check_type2str($object_data['type']).'; '.
- S_PORT.': '.$object_data['port'];
- break;
- default:
- continue;
- }
-
- if(!$object_data) continue;
-
-
- $table->AddRow(array(
- date("Y.M.d H:i:s",$event_data["clock"]),
- $object_data['ip'],
- $description,
- $value));
-
- $col++;
- }
- return $table;
- }
/* function:
* event_initial_time
@@ -176,6 +114,14 @@ function first_initial_eventid($row,$show_unknown=0){
return false;
}
+/* function:
+ * get_latest_events
+ *
+ * description:
+ * return latest events by VALUE
+ *
+ * author: Aly
+ */
function get_latest_events($row,$show_unknown=0){
$eventz = array();
@@ -226,6 +172,14 @@ function get_latest_events($row,$show_unknown=0){
return $events;
}
+/* function:
+ * get_next_event
+ *
+ * description:
+ * return next event by value
+ *
+ * author: Aly
+ */
function get_next_event($row,$show_unknown=0){
$sql_cond=($show_unknown == 0)?' AND e.value<>'.TRIGGER_VALUE_UNKNOWN:'';
@@ -251,4 +205,161 @@ function get_next_event($row,$show_unknown=0){
$rez = DBfetch(DBselect($sql,1));
return $rez;
}
+
+
+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)
+ );
+
+ $table = new CTableInfo(S_NO_EVENTS_FOUND);
+ $table->SetHeader(array(S_TIME, S_IP, S_DESCRIPTION, S_STATUS));
+ $col=0;
+
+ $skip = $start;
+ while(($event_data = DBfetch($db_events))&&($col<$num)){
+ if($skip > 0){
+ $skip--;
+ continue;
+ }
+
+ if($event_data["value"] == 0){
+ $value=new CCol(S_UP,"off");
+ }
+ elseif($event_data["value"] == 1){
+ $value=new CCol(S_DOWN,"on");
+ }
+ else{
+ $value=new CCol(S_UNKNOWN_BIG,"unknown");
+ }
+
+
+ switch($event_data['object']){
+ case EVENT_OBJECT_DHOST:
+ $object_data = DBfetch(DBselect('select ip from dhosts where dhostid='.$event_data['objectid']));
+ $description = SPACE;
+ break;
+ case EVENT_OBJECT_DSERVICE:
+ $object_data = DBfetch(DBselect('select h.ip,s.type,s.port from dhosts h,dservices s '.
+ ' where h.dhostid=s.dhostid and s.dserviceid='.$event_data['objectid']));
+ $description = S_SERVICE.': '.discovery_check_type2str($object_data['type']).'; '.
+ S_PORT.': '.$object_data['port'];
+ break;
+ default:
+ continue;
+ }
+
+ if(!$object_data) continue;
+
+
+ $table->AddRow(array(
+ date("Y.M.d H:i:s",$event_data["clock"]),
+ $object_data['ip'],
+ $description,
+ $value));
+
+ $col++;
+ }
+return $table;
+}
+
+function make_event_details($triggerid,&$trigger_data){
+ $table = new CTableInfo();
+
+ if(is_show_subnodes()){
+ $table->AddRow(array(S_NODE, get_node_name_by_elid($triggerid)));
+ }
+
+ $table->AddRow(array(S_HOST, $trigger_data['host']));
+ $table->AddRow(array(S_TRIGGER, $trigger_data['exp_desc']));
+ $table->AddRow(array(S_SEVERITY, new CSpan(get_severity_description($trigger_data["priority"]), get_severity_style($trigger_data["priority"]))));
+ $table->AddRow(array(S_EXPRESSION, $trigger_data['exp_expr']));
+
+return $table;
+}
+
+function make_small_eventlist($triggerid,&$trigger_data,$show_unknown=0){
+ $sql_cond = '';
+ if(0 == $show_unknown){
+ $sql_cond = ' AND value<>2 ';
+ }
+
+ $table = new CTableInfo();
+ $table->SetHeader(array(S_TIME,S_STATUS,S_ACK,S_DURATION));
+
+ $sql = 'SELECT * '.
+ ' FROM events '.
+ ' WHERE objectid='.$triggerid.
+ ' AND object='.EVENT_OBJECT_TRIGGER.
+ $sql_cond.
+ ' ORDER BY clock DESC';
+
+ $result = DBselect($sql,10*($_REQUEST['start']+PAGE_SIZE));
+
+ $rows = array();
+ $count = 0;
+
+ $col=0;
+ $skip = $_REQUEST['start'];
+ while(($col<PAGE_SIZE) && ($row=DBfetch($result))){
+ if($skip > 0){
+ if((0 == $show_unknown) && ($row['value'] == TRIGGER_VALUE_UNKNOWN)) continue;
+ $skip--;
+ continue;
+ }
+
+ if(!empty($rows) && ($rows[$count]['value'] != $row['value'])){
+ $count++;
+ }
+ else if(!empty($rows) &&
+ ($rows[$count]['value'] == $row['value']) &&
+ ($trigger_data['type'] == TRIGGER_MULT_EVENT_ENABLED) &&
+ ($row['value'] == TRIGGER_VALUE_TRUE)
+ ){
+ $count++;
+ }
+ $rows[$count] = $row;
+ $col++;
+ }
+
+ $clock=time();
+
+ foreach($rows as $id => $row){
+ $lclock=$clock;
+ $clock=$row["clock"];
+
+ $duration = zbx_date2age($lclock,$clock);
+
+ if($row["value"] == TRIGGER_VALUE_FALSE){
+ $value=new CCol(S_FALSE_BIG,"off");
+ }
+ elseif($row["value"] == TRIGGER_VALUE_TRUE){
+ $value=new CCol(S_TRUE_BIG,"on");
+ }
+ else{
+ $value=new CCol(S_UNKNOWN_BIG,"unknown");
+ }
+
+ $ack = "-";
+ if($row["value"] == 1 && $row["acknowledged"] == 1){
+ $db_acks = get_acknowledges_by_eventid($row["eventid"]);
+ $rows=0;
+ while($a=DBfetch($db_acks)) $rows++;
+
+ $ack=array(
+ new CLink(new CSpan(S_YES,'off'),'acknow.php?eventid='.$row['eventid'],'action'),
+ SPACE.'('.$rows.')'
+ );
+ }
+
+ $table->AddRow(array(
+ date('Y.M.d H:i:s',$row['clock']),
+ $value,
+ $ack,
+ $duration
+ ));
+ }
+return $table;
+}
?>
diff --git a/frontends/php/include/import.inc.php b/frontends/php/include/import.inc.php
index e3697ac9..2fa6a977 100644
--- a/frontends/php/include/import.inc.php
+++ b/frontends/php/include/import.inc.php
@@ -131,7 +131,7 @@
0, /* useip */
"", /* dns */
"", /* ip */
- 0,
+ 0, /* proxy_hostid */
array(),
null,
array());
diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php
index e0b57341..d1be5d65 100644
--- a/frontends/php/include/locales/en_gb.inc.php
+++ b/frontends/php/include/locales/en_gb.inc.php
@@ -839,6 +839,8 @@
'S_PARAMS'=> 'Additional parameters',
// events.php
+ 'S_EVENT_DETAILS'=> 'Event details',
+ 'S_LIST'=> 'List',
'S_LATEST_EVENTS'=> 'Latest events',
'S_HISTORY_OF_EVENTS_BIG'=> 'HISTORY OF EVENTS',
'S_NO_EVENTS_FOUND'=> 'No events found',
diff --git a/frontends/php/include/page_header.php b/frontends/php/include/page_header.php
index d61de1c0..1bde9468 100644
--- a/frontends/php/include/page_header.php
+++ b/frontends/php/include/page_header.php
@@ -113,15 +113,21 @@ COpt::profiling_start("page");
"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"=>"latest.php",
+ "label"=>S_LATEST_DATA,
+ "sub_pages"=>array("history.php","chart.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"=>"events.php",
+ "label"=>S_EVENTS,
+ "sub_pages"=>array("tr_events.php")
+ ),
array(
"url"=>"actions.php",
"label"=>S_ACTIONS),
@@ -414,6 +420,7 @@ COpt::profiling_start("page");
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/prototype.js"></script>
+ <script type="text/javascript" src="js/url.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 e5f96bb3..c319448d 100644
--- a/frontends/php/include/perm.inc.php
+++ b/frontends/php/include/perm.inc.php
@@ -184,9 +184,9 @@
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,$cache=1){
static $available_hosts;
-
+
if(is_null($perm_res)) $perm_res = PERM_RES_STRING_LINE;
if($perm == PERM_READ_LIST) $perm = PERM_READ_ONLY;
@@ -201,7 +201,7 @@
$nodeid_str =(is_array($nodeid))?implode('',$nodeid):strval($nodeid);
- if(isset($available_hosts[$userid][$perm][$perm_mode][$perm_res][$nodeid_str])){
+ if($cache && isset($available_hosts[$userid][$perm][$perm_mode][$perm_res][$nodeid_str])){
return $available_hosts[$userid][$perm][$perm_mode][$perm_res][$nodeid_str];
}
@@ -221,39 +221,40 @@ COpt::counter_up('perm');
if ( !is_null($nodeid) ) array_push($where, DBin_node('h.hostid', $nodeid));
- if(is_array($hostid)) array_push($where, ' h.hostid in ('.implode(',', $hostid).') ');
- elseif(isset($hostid)) array_push($where, ' h.hostid in ('.$hostid.') ');
+// if(is_array($hostid)) array_push($where, ' h.hostid in ('.implode(',', $hostid).') ');
+// else if(!empty($hostid)) array_push($where, ' h.hostid in ('.$hostid.') ');
- if(count($where)) $where = ' where '.implode(' and ',$where);
- else $where = '';
+ if(count($where))
+ $where = ' where '.implode(' and ',$where);
+ else
+ $where = '';
- $sql = 'select distinct n.nodeid,n.name as node_name,h.hostid,h.host, min(r.permission) as permission,ug.userid '.
- ' from hosts h left join hosts_groups hg on hg.hostid=h.hostid '.
- ' left join groups g on g.groupid=hg.groupid '.
- ' left join rights r on r.id=g.groupid and r.type='.RESOURCE_TYPE_GROUP.
- ' left join users_groups ug on ug.usrgrpid=r.groupid and ug.userid='.$userid.
- ' left join nodes n on '.DBid2nodeid('h.hostid').'=n.nodeid '.
- $where.' group by h.hostid,n.nodeid,n.name,h.host,ug.userid '.
- ' order by n.name,n.nodeid, h.host, permission desc, userid desc';
+ $sql = 'SELECT DISTINCT n.nodeid,n.name as node_name,h.hostid,h.host, min(r.permission) as permission,ug.userid '.
+ ' FROM hosts h '.
+ ' LEFT JOIN hosts_groups hg ON hg.hostid=h.hostid '.
+ ' LEFT JOIN groups g ON g.groupid=hg.groupid '.
+ ' LEFT JOIN rights r ON r.id=g.groupid and r.type='.RESOURCE_TYPE_GROUP.
+ ' LEFT JOIN users_groups ug ON ug.usrgrpid=r.groupid and ug.userid='.$userid.
+ ' LEFT JOIN nodes n ON '.DBid2nodeid('h.hostid').'=n.nodeid '.
+ $where.
+ ' GROUP BY h.hostid,n.nodeid,n.name,h.host,ug.userid '.
+ ' ORDER BY n.name,n.nodeid, h.host, permission desc, userid desc';
$db_hosts = DBselect($sql);
$processed = array();
- while($host_data = DBfetch($db_hosts))
- {
+ while($host_data = DBfetch($db_hosts)){
// It seems that host details are not required by the logic
// $host_data += DBfetch(DBselect('select * from hosts where hostid='.$host_data['hostid']));
if(is_null($host_data['nodeid'])) $host_data['nodeid'] = id2nodeid($host_data['hostid']);
/* if no rights defined used node rights */
- if( (is_null($host_data['permission']) || is_null($host_data['userid'])) )
- {
+ if( (is_null($host_data['permission']) || is_null($host_data['userid'])) ){
if( isset($processed[$host_data['hostid']]) )
continue;
- if(!isset($nodes))
- {
+ if(!isset($nodes)){
$nodes = get_accessible_nodes_by_user($user_data,
PERM_DENY,PERM_MODE_GE,PERM_RES_DATA_ARRAY);
}
@@ -383,29 +384,32 @@ COpt::counter_up('perm');
COpt::counter_up('perm_nodes['.$userid.','.$perm.','.$perm_mode.','.$perm_res.','.$nodeid.']');
COpt::counter_up('perm');
- if(is_null($nodeid)) $where_nodeid = '';
- else if(is_array($nodeid)) $where_nodeid = ' where n.nodeid in ('.implode(',', $nodeid).') ';
- else $where_nodeid = ' where n.nodeid in ('.$nodeid.') ';
+ if(is_null($nodeid))
+ $where_nodeid = '';
+ else if(is_array($nodeid))
+ $where_nodeid = ' where n.nodeid in ('.implode(',', $nodeid).') ';
+ else
+ $where_nodeid = ' where n.nodeid in ('.$nodeid.') ';
- $db_nodes = DBselect('select n.nodeid,min(r.permission) as permission, g.userid'.
- ' from nodes n left join rights r on r.id=n.nodeid and r.type='.RESOURCE_TYPE_NODE.
- ' left join users_groups g on r.groupid=g.usrgrpid and g.userid='.$userid.
- $where_nodeid.' group by n.nodeid, g.userid order by nodeid desc, userid desc, permission desc');
+ $db_nodes = DBselect('SELECT n.nodeid,min(r.permission) as permission, g.userid'.
+ ' FROM nodes n '.
+ ' left join rights r on r.id=n.nodeid and r.type='.RESOURCE_TYPE_NODE.
+ ' left join users_groups g on r.groupid=g.usrgrpid and g.userid='.$userid.
+ $where_nodeid.
+ ' GROUP BY n.nodeid, g.userid '.
+ ' ORDER BY nodeid desc, userid desc, permission desc');
- while(($node_data = DBfetch($db_nodes)) || (!isset($do_break) && !ZBX_DISTRIBUTED))
- {
- if($node_data && $perm_res == PERM_RES_DATA_ARRAY)
- {
+ while(($node_data = DBfetch($db_nodes)) || (!isset($do_break) && !ZBX_DISTRIBUTED)){
+
+ if($node_data && ($perm_res == PERM_RES_DATA_ARRAY)){
$node_data += DBfetch(DBselect('select * from nodes where nodeid='.$node_data['nodeid']));
}
if($node_data && isset($processed_nodeids[$node_data["nodeid"]])) continue;
- if(!ZBX_DISTRIBUTED)
- {
- if(!$node_data)
- {
+ if(!ZBX_DISTRIBUTED){
+ if(!$node_data){
$node_data = array(
'nodeid' => $ZBX_LOCALNODEID,
'name' => 'local',
@@ -420,8 +424,7 @@ COpt::counter_up('perm');
}
else if(isset($nodeid) && (bccomp($node_data['nodeid'] ,$nodeid) != 0)) continue;
}
- else
- {
+ else{
$node_data['permission'] = PERM_DENY;
}
}
@@ -429,8 +432,7 @@ COpt::counter_up('perm');
$processed_nodeids[$node_data["nodeid"]] = $node_data["nodeid"];
/* deny if no rights defined (for local node read/write)*/
- if(is_null($node_data['permission']) || is_null($node_data['userid']))
- {
+ if(is_null($node_data['permission']) || is_null($node_data['userid'])){
if($user_type == USER_TYPE_SUPER_ADMIN)
$node_data['permission'] = PERM_READ_WRITE;
else
@@ -451,8 +453,7 @@ COpt::counter_up('perm');
$result[$node_data["nodeid"]]= ($perm_res == PERM_RES_DATA_ARRAY)?$node_data:$node_data["nodeid"];
}
- 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 dfd913a1..46685bf9 100644
--- a/frontends/php/include/profiles.inc.php
+++ b/frontends/php/include/profiles.inc.php
@@ -68,10 +68,12 @@ function update_profile($idx,$value,$type=PROFILE_TYPE_UNKNOWN){
if($type==PROFILE_TYPE_ARRAY && !is_array($value)) $value = array($value);
if(PROFILE_TYPE_ARRAY == $type){
+ DBstart();
$sql='DELETE FROM profiles WHERE userid='.$USER_DETAILS["userid"].' and idx='.zbx_dbstr($idx);
DBExecute($sql);
-
- insert_profile($idx,$value,$type);
+
+ $result = insert_profile($idx,$value,$type);
+ DBend($result);
}
else{
$row = DBfetch(DBselect('SELECT value FROM profiles WHERE userid='.$USER_DETAILS["userid"].' AND idx='.zbx_dbstr($idx)));
@@ -94,18 +96,19 @@ return true;
function insert_profile($idx,$value,$type=PROFILE_TYPE_UNKNOWN){
global $USER_DETAILS;
+ $result = true;
if(is_array($value)){
foreach($value as $key => $val){
- insert_profile($idx,$val,$type); // recursion!!!
+ $result&=insert_profile($idx,$val,$type); // recursion!!!
}
}
else{
$profileid = get_dbid('profiles', 'profileid');
$sql='INSERT INTO profiles (profileid,userid,idx,value,valuetype)'.
' VALUES ('.$profileid.','.$USER_DETAILS["userid"].','.zbx_dbstr($idx).','.zbx_dbstr($value).','.$type.')';
- DBexecute($sql);
+ $result = DBexecute($sql);
}
-
+return $result;
}
/***********************************/
diff --git a/frontends/php/js/calendar.js b/frontends/php/js/calendar.js
index 16a320fd..ab1fa0ec 100644
--- a/frontends/php/js/calendar.js
+++ b/frontends/php/js/calendar.js
@@ -569,11 +569,12 @@ createDaysTab: function(){
\*-------------------------------------------------------------------------------------------------*/
calendarcreate: function(){
this.clndr_calendar = document.createElement('div');
- document.body.appendChild(this.clndr_calendar);
-
+
Element.extend(this.clndr_calendar);
this.clndr_calendar.className = 'calendar';
- this.clndr_calendar.setStyle({display: 'none'});
+ this.clndr_calendar.hide();
+
+ document.body.appendChild(this.clndr_calendar);
addListener(this.clndr_calendar,'mousemove', deselectAll);
diff --git a/frontends/php/js/common.js b/frontends/php/js/common.js
index 9d7d859c..bfc8716f 100644
--- a/frontends/php/js/common.js
+++ b/frontends/php/js/common.js
@@ -408,6 +408,38 @@ function deselectAll(){
/************************************************************************************/
/* Pages stuff */
/************************************************************************************/
+function change_hat_state(icon, divid){
+ if((typeof(icon) == 'undefined') || (typeof(divid) == 'undefined')) throw "Function [change_hat_state()] awaits exactly 2 arguments.";
+
+ if(typeof(Ajax) == 'undefined'){
+ throw("Prototype.js lib is required!");
+ return false;
+ }
+
+ deselectAll();
+ var hat_state = ShowHide(divid);
+ switchElementsClass(icon,"arrowup","arrowdown");
+
+ if(false === hat_state) return false;
+
+ var params = {
+ 'favobj': 'hat',
+ 'favid': divid,
+ 'state': hat_state
+ }
+
+ var uri = new url(location.href);
+ new Ajax.Request(uri.getPath()+"?output=ajax",
+ {
+ 'method': 'post',
+ 'parameters':params,
+ 'onSuccess': function(resp){ },//alert(resp.responseText);
+ 'onFailure': function(){ document.location = uri.getPath()+'?'+Object.toQueryString(params); }
+ }
+ );
+
+}
+
function change_filter_state(icon, divid){
if((typeof(icon) == 'undefined') || (typeof(divid) == 'undefined')) throw "Function [change_filter_state()] awaits exactly 2 arguments.";
@@ -429,7 +461,6 @@ function change_filter_state(icon, divid){
}
var uri = new url(location.href);
-
new Ajax.Request(uri.getPath()+"?output=ajax",
{
'method': 'post',
diff --git a/frontends/php/js/dashboard.js b/frontends/php/js/dashboard.js
index 424e0ed3..7aa5bc81 100644
--- a/frontends/php/js/dashboard.js
+++ b/frontends/php/js/dashboard.js
@@ -22,36 +22,6 @@ function setRefreshRate(id,interval){
}
-function change_hat_state(icon, divid){
- if((typeof(icon) == 'undefined') || (typeof(divid) == 'undefined')) throw "Function [change_hat_state()] awaits exactly 2 arguments.";
-
- if(typeof(Ajax) == 'undefined'){
- throw("Prototype.js lib is required!");
- return false;
- }
-
- deselectAll();
- var hat_state = ShowHide(divid);
- switchElementsClass(icon,"arrowup","arrowdown");
-
- if(false === hat_state) return false;
-
- var params = {
- 'favobj': 'hat',
- 'favid': divid,
- 'state': hat_state
- }
-
- new Ajax.Request("dashboard.php?output=ajax",
- {
- 'method': 'post',
- 'parameters': params,
- 'onSuccess': function(resp){ },//alert(resp.responseText);
- 'onFailure': function(){ document.location = 'dashboard.php?'+Object.toQueryString(params);}
- }
- );
-}
-
function create_menu(e,id){
if (!e) var e = window.event;
id='menu_'+id;
diff --git a/frontends/php/scripts_exec.php b/frontends/php/scripts_exec.php
index c20f0ac5..279ecbd7 100644
--- a/frontends/php/scripts_exec.php
+++ b/frontends/php/scripts_exec.php
@@ -46,7 +46,7 @@ check_fields($fields);
if(isset($_REQUEST['execute'])){
if($script = get_script_by_scriptid($_REQUEST['scriptid'])){
if($script['host_access'] == SCRIPT_HOST_ACCESS_WRITE){
- $hosts_read_write = explode(',',get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_WRITE,null,null,null,$_REQUEST['hostid']));
+ $hosts_read_write = explode(',',get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_WRITE));
if(uint_in_array($_REQUEST['hostid'],$hosts_read_write)){
//SDI('WRITE: '.$_REQUEST['scriptid'].' : '.$_REQUEST['hostid']);
@@ -55,8 +55,9 @@ if(isset($_REQUEST['execute'])){
insert_command_result_form($_REQUEST['scriptid'],$_REQUEST['hostid']);
/* echo nl2br(htmlspecialchars($result));*/
}
- } else {
- $hosts_read_only = explode(',',get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,null,null,null,$_REQUEST['hostid']));
+ }
+ else {
+ $hosts_read_only = explode(',',get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY));
if(uint_in_array($_REQUEST['hostid'],$hosts_read_only)){
//SDI('READ: '.$_REQUEST['scriptid'].' : '.$_REQUEST['hostid']);
diff --git a/frontends/php/tr_events.php b/frontends/php/tr_events.php
index 86f2ccc5..7ea0608d 100644
--- a/frontends/php/tr_events.php
+++ b/frontends/php/tr_events.php
@@ -21,199 +21,261 @@
<?php
require_once "include/config.inc.php";
require_once "include/acknow.inc.php";
+ require_once "include/events.inc.php";
require_once "include/triggers.inc.php";
+ require_once "include/html.inc.php";
- $page["title"] = "S_ALARMS";
+ $page["title"] = "S_EVENT_DETAILS";
$page["file"] = "tr_events.php";
-
-include_once "include/page_header.php";
-
+ $page['hist_arg'] = array('triggerid');
+ $page['scripts'] = array('calendar.js');
+
+ $page['type'] = detect_page_type(PAGE_TYPE_HTML);
+
+ include_once "include/page_header.php";
?>
<?php
+ define('PAGE_SIZE', 100);
+
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
$fields=array(
- "triggerid"=> array(T_ZBX_INT, O_MAND, P_SYS, DB_ID, null),
- "limit"=> array(T_ZBX_STR, O_OPT, null, IN('"100","NO"'), null),
- "show_unknown"=> array(T_ZBX_INT, O_OPT, P_SYS, IN(array(0,1)), null),
+ "triggerid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, PAGE_TYPE_HTML.'=='.$page['type']),
- /* actions */
+ "start"=> array(T_ZBX_INT, O_OPT, P_SYS, BETWEEN(0,65535)."({}%".PAGE_SIZE."==0)", NULL),
+ "next"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL),
+ "prev"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL),
+
+/* actions */
"save"=> array(T_ZBX_STR,O_OPT, P_ACT|P_SYS, null, null),
- "cancel"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null)
+ "cancel"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null),
+
+// filter
+ "filter_rst"=> array(T_ZBX_INT, O_OPT, P_SYS, IN(array(0,1)), NULL),
+ "filter_set"=> array(T_ZBX_STR, O_OPT, P_SYS, null, NULL),
+
+ "show_unknown"=> array(T_ZBX_INT, O_OPT, P_SYS, IN(array(0,1)), NULL),
+
+ 'filter_timesince'=> array(T_ZBX_INT, O_OPT, P_UNSET_EMPTY, null, NULL),
+ 'filter_timetill'=> array(T_ZBX_INT, O_OPT, P_UNSET_EMPTY, null, NULL),
+
+// ajax
+ 'favobj'=> array(T_ZBX_STR, O_OPT, P_ACT, IN("'filter','hat'"), NULL),
+ 'favid'=> array(T_ZBX_STR, O_OPT, P_ACT, NOT_EMPTY, 'isset({favobj})'),
+ 'state'=> array(T_ZBX_INT, O_OPT, P_ACT, NOT_EMPTY, 'isset({favobj})'),
);
check_fields($fields);
-
- $show_unknown = get_request('show_unknown',get_profile('web.events.show_unknown',0));
- update_profile('web.events.show_unknown',$show_unknown);
-
+
+/* AJAX */
+ if(isset($_REQUEST['favobj'])){
+ if('hat' == $_REQUEST['favobj']){
+ update_profile('web.tr_events.hats.'.$_REQUEST['favid'].'.state',$_REQUEST['state']);
+ }
+ if('filter' == $_REQUEST['favobj']){
+// echo 'alert("'.$_REQUEST['favid'].' : '.$_REQUEST['state'].'");';
+ update_profile('web.tr_events.filter.state',$_REQUEST['state']);
+ }
+ }
+
+ if((PAGE_TYPE_JS == $page['type']) || (PAGE_TYPE_HTML_BLOCK == $page['type'])){
+ exit();
+ }
+//--------
+
if(!check_right_on_trigger_by_triggerid(PERM_READ_ONLY, $_REQUEST["triggerid"]))
access_deny();
+
+/* FILTER */
+ if(isset($_REQUEST['filter_rst'])){
+ $_REQUEST['show_unknown'] = 0;
+
+ $_REQUEST['filter_timesince'] = 0;
+ $_REQUEST['filter_timetill'] = 0;
+ }
+
+ $show_unknown = get_request('show_unknown',get_profile('web.tr_events.filter.show_unknown',0));
+
+ $_REQUEST['filter_timesince'] = get_request('filter_timesince',get_profile('web.tr_events.filter.timesince',0));
+ $_REQUEST['filter_timetill'] = get_request('filter_timetill',get_profile('web.tr_events.filter.timetill',0));
+
+ if(($_REQUEST['filter_timetill'] > 0) && ($_REQUEST['filter_timesince'] > $_REQUEST['filter_timetill'])){
+ $tmp = $_REQUEST['filter_timesince'];
+ $_REQUEST['filter_timesince'] = $_REQUEST['filter_timetill'];
+ $_REQUEST['filter_timetill'] = $tmp;
+ }
+
+ if(isset($_REQUEST['filter_set']) || isset($_REQUEST['filter_rst'])){
+ update_profile('web.tr_events.filter.show_unknown',$show_unknown);
+
+ update_profile('web.tr_events.filter.timesince',$_REQUEST['filter_timesince']);
+ update_profile('web.tr_events.filter.timetill',$_REQUEST['filter_timetill']);
+ }
+// --------------
+
$trigger_data = DBfetch(DBselect('SELECT h.host, t.* '.
' FROM hosts h, items i, functions f, triggers t '.
- ' WHERE i.itemid=f.itemid AND f.triggerid=t.triggerid '.
- ' AND t.triggerid='.$_REQUEST["triggerid"].
- ' AND h.hostid=i.hostid AND '.DBin_node('t.triggerid')));
+ ' WHERE i.itemid=f.itemid '.
+ ' AND f.triggerid=t.triggerid '.
+ ' AND t.triggerid='.$_REQUEST["triggerid"].
+ ' AND h.hostid=i.hostid '.
+ ' AND '.DBin_node('t.triggerid')));
?>
<?php
- $_REQUEST["limit"] = get_request("limit","NO");
+ $_REQUEST["start"] = get_request("start", 0);
+ $_REQUEST["start"]-=(isset($_REQUEST["prev"]))?PAGE_SIZE:0;
+ $_REQUEST["start"]+=(isset($_REQUEST["next"]))?PAGE_SIZE:0;
+ $_REQUEST["start"]=($_REQUEST["start"])?$_REQUEST["start"]:0;
- $expression = explode_exp($trigger_data["expression"],1);
- $description = expand_trigger_description_by_data($trigger_data);
-
- $form = new CForm();
- $form->AddOption('name','events_menu');
- $form->AddVar("triggerid",$_REQUEST["triggerid"]);
-
- $chkbox = new CCheckBox('sh_unknown',
- (($show_unknown == 0)?'no':'yes'),
- 'create_var("events_menu", "show_unknown", '.(($show_unknown == 0)?'1':'0').', true)'
- );
- $form->AddItem(array(S_SHOW_UNKNOWN, SPACE, $chkbox,SPACE, SPACE));
+ $trigger_data['exp_expr'] = explode_exp($trigger_data["expression"],1);
+ $trigger_data['exp_desc'] = expand_trigger_description_by_data($trigger_data);
+
+ show_table_header(array(S_EVENTS_BIG.': "'.$trigger_data['exp_desc'].'"',SPACE,$trigger_data['exp_expr']), null);
- $cmbLimit = new CComboBox("limit",$_REQUEST["limit"],"submit()");
- $cmbLimit->AddItem('NO',S_SHOW_ALL);
- $cmbLimit->AddItem("100",S_SHOW_ONLY_LAST_100);
- $form->AddItem($cmbLimit);
+ $table_eventlist = make_small_eventlist($_REQUEST['triggerid'],$trigger_data,$show_unknown);
+/************************* FILTER **************************/
+/***********************************************************/
- show_table_header(array(S_EVENTS_BIG.': "'.$description.'"',BR(),$expression), $form);
-?>
-<?php
- $sql_cond = '';
- if($show_unknown == 0){
- $sql_cond = ' AND value<>2 ';
+ $prev = 'Prev 100';
+ $next='Next 100';
+ if($_REQUEST["start"] > 0){
+ $prev = new Clink('Prev '.PAGE_SIZE, 'events.php?prev=1'.url_param('start'),'styled');
}
- $result=DBselect('SELECT * FROM events WHERE objectid='.$_REQUEST['triggerid'].
- ' AND object='.EVENT_OBJECT_TRIGGER.
- $sql_cond.
- ' ORDER BY clock DESC',$_REQUEST['limit']);
+ if($table_eventlist->GetNumRows() >= PAGE_SIZE){
+ $next = new Clink('Next '.PAGE_SIZE, 'events.php?next=1'.url_param('start'),'styled');
+ }
- $table = new CTableInfo();
- $table->SetHeader(array(S_TIME,S_STATUS,S_ACKNOWLEDGED,S_DURATION,S_SUM,"%"));
- $table->ShowStart();
+ $filterForm = new CFormTable(S_FILTER);//,'events.php?filter_set=1','POST',null,'sform');
+ $filterForm->AddOption('name','zbx_filter');
+ $filterForm->AddOption('id','zbx_filter');
+ $filterForm->SetMethod('get');
- $rows = array();
- $count = 0;
- while($row=DBfetch($result)){
- if(!empty($rows) && ($rows[$count]['value'] != $row['value'])){
- $count++;
- }
- else if(!empty($rows) &&
- ($rows[$count]['value'] == $row['value']) &&
- ($trigger_data['type'] == TRIGGER_MULT_EVENT_ENABLED) &&
- ($row['value'] == TRIGGER_VALUE_TRUE)
- ){
- $count++;
- }
- $rows[$count] = $row;
- }
-
- $truesum=0;
- $falsesum=0;
- $dissum=0;
- $clock=time();
-// while($row=DBfetch($result))
- foreach($rows as $id => $row)
- {
- $lclock=$clock;
- $clock=$row["clock"];
- $leng=$lclock-$row["clock"];
+ $script = new CScript("javascript: if(CLNDR['events_since'].clndr.setSDateFromOuterObj()){".
+ "$('filter_timesince').value = parseInt(CLNDR['events_since'].clndr.sdt.getTime()/1000);}".
+ "if(CLNDR['events_till'].clndr.setSDateFromOuterObj()){".
+ "$('filter_timetill').value = parseInt(CLNDR['events_till'].clndr.sdt.getTime()/1000);}"
+ );
+ $filterForm->AddAction('onsubmit',$script);
+
+ $filterForm->AddVar('filter_timesince',($_REQUEST['filter_timesince']>0)?$_REQUEST['filter_timesince']:'');
+ $filterForm->AddVar('filter_timetill',($_REQUEST['filter_timetill']>0)?$_REQUEST['filter_timetill']:'');
+
+ $clndr_icon = new CImg('images/general/bar/cal.gif','calendar', 16, 12, 'pointer');
+ $clndr_icon->AddAction('onclick',"javascript: var pos = getPosition(this); pos.top+=10; pos.left+=16; CLNDR['events_since'].clndr.clndrshow(pos.top,pos.left);");
+
+ $filtertimetab = new CTable();
+ $filtertimetab->AddOption('width','10%');
+ $filtertimetab->SetCellPadding(0);
+ $filtertimetab->SetCellSpacing(0);
+
+ $filtertimetab->AddRow(array(
+ S_FROM,
+ new CNumericBox('filter_since_day',(($_REQUEST['filter_timesince']>0)?date('d',$_REQUEST['filter_timesince']):''),2),
+ '/',
+ new CNumericBox('filter_since_month',(($_REQUEST['filter_timesince']>0)?date('m',$_REQUEST['filter_timesince']):''),2),
+ '/',
+ new CNumericBox('filter_since_year',(($_REQUEST['filter_timesince']>0)?date('Y',$_REQUEST['filter_timesince']):''),4),
+ new CNumericBox('filter_since_hour',(($_REQUEST['filter_timesince']>0)?date('H',$_REQUEST['filter_timesince']):''),2),
+ ':',
+ new CNumericBox('filter_since_minute',(($_REQUEST['filter_timesince']>0)?date('i',$_REQUEST['filter_timesince']):''),2),
+ $clndr_icon
+ ));
+ zbx_add_post_js('create_calendar(null,["filter_since_day","filter_since_month","filter_since_year","filter_since_hour","filter_since_minute"],"events_since");');
+ $clndr_icon->AddAction('onclick',"javascript: var pos = getPosition(this); pos.top+=10; pos.left+=16; CLNDR['events_till'].clndr.clndrshow(pos.top,pos.left);");
+ $filtertimetab->AddRow(array(
+ S_TILL,
+ new CNumericBox('filter_till_day',(($_REQUEST['filter_timetill']>0)?date('d',$_REQUEST['filter_timetill']):''),2),
+ '/',
+ new CNumericBox('filter_till_month',(($_REQUEST['filter_timetill']>0)?date('m',$_REQUEST['filter_timetill']):''),2),
+ '/',
+ new CNumericBox('filter_till_year',(($_REQUEST['filter_timetill']>0)?date('Y',$_REQUEST['filter_timetill']):''),4),
+ new CNumericBox('filter_till_hour',(($_REQUEST['filter_timetill']>0)?date('H',$_REQUEST['filter_timetill']):''),2),
+ ':',
+ new CNumericBox('filter_till_minute',(($_REQUEST['filter_timetill']>0)?date('i',$_REQUEST['filter_timetill']):''),2),
+ $clndr_icon
+ ));
+ zbx_add_post_js('create_calendar(null,["filter_till_day","filter_till_month","filter_till_year","filter_till_hour","filter_till_minute"],"events_till");');
+
+ zbx_add_post_js('addListener($("filter_icon"),"click",CLNDR[\'events_since\'].clndr.clndrhide.bindAsEventListener(CLNDR[\'events_since\'].clndr));'.
+ 'addListener($("filter_icon"),"click",CLNDR[\'events_till\'].clndr.clndrhide.bindAsEventListener(CLNDR[\'events_till\'].clndr));'
+ );
+
+ $filterForm->AddRow(S_PERIOD, $filtertimetab);
- if($row["value"]==1)
- {
- $istrue=new CCol(S_TRUE_BIG,"on");
- $truesum=$truesum+$leng;
- $sum=$truesum;
- }
- elseif($row["value"]==0)
- {
- $istrue=new CCol(S_FALSE_BIG,"off");
- $falsesum=$falsesum+$leng;
- $sum=$falsesum;
- }
- else
- {
- $istrue=new CCol(S_UNKNOWN_BIG,"unknown");
- $dissum=$dissum+$leng;
- $sum=$dissum;
- }
+ $filterForm->AddVar('show_unknown',$show_unknown);
- $proc=(100*$sum)/($falsesum+$truesum+$dissum);
- $proc=round($proc*100)/100;
- $proc="$proc%";
-
- if($leng>60*60*24)
- {
- $leng= round(($leng/86400)*10)/10;
- $leng="$leng days";
- }
- elseif ($leng>60*60)
- {
- $leng= round(($leng/3600)*10)/10;
- $leng="$leng hours";
- }
- elseif ($leng>60)
- {
- $leng= round(($leng/60)*10)/10;
- $leng="$leng mins";
- }
- else
- {
- $leng="$leng secs";
- }
+ $unkcbx = new CCheckBox('show_unk',$show_unknown,null,'1');
+ $unkcbx->SetAction('javascript: create_var("'.$filterForm->GetName().'", "show_unknown", (this.checked?1:0), 0); ');
+
+ $filterForm->AddRow(S_SHOW_UNKNOWN,$unkcbx);
- if($sum>86400)
- {
- $sum= round(($sum/86400)*10)/10;
- $sum="$sum days";
- }
- elseif ($sum>60*60)
- {
- $sum= round(($sum/3600)*10)/10;
- $sum="$sum hours";
- }
- elseif ($sum>60)
- {
- $sum= round(($sum/60)*10)/10;
- $sum="$sum mins";
- }
- else
- {
- $sum="$sum secs";
- }
-
- $ack = "-";
- if($row["value"] == 1 && $row["acknowledged"] == 1)
- {
- $db_acks = get_acknowledges_by_eventid($row["eventid"]);
- $rows=0;
- while($a=DBfetch($db_acks)) $rows++;
- $ack=array(
- new CSpan(S_YES,"off"),
- SPACE."(".$rows.SPACE,
- new CLink(S_SHOW,
- "acknow.php?eventid=".$row["eventid"],"action"),
- ")"
- );
- }
+ $reset = new CButton("filter_rst",S_RESET);
+ $reset->SetType('button');
+ $reset->SetAction('javascript: var uri = new url(location.href); uri.setArgument("filter_rst",1); location.href = uri.getUrl();');
- $table->ShowRow(array(
- date("Y.M.d H:i:s",$row["clock"]),
- $istrue,
- $ack,
- $leng,
- $sum,
- $proc
- ));
- }
- $table->ShowEnd();
-?>
+ $filterForm->AddItemToBottomRow($reset);
+ $filterForm->AddItemToBottomRow(new CButton("filter_set",S_FILTER));
+
+ $navigation = array(
+ new CSpan(array('&laquo; ',$prev),'textcolorstyles'),
+ new CSpan(' | ','divider'),
+ new CSpan(array($next,' &raquo;'),'textcolorstyles'));
+
+ $filter = create_filter(S_FILTER,$navigation,$filterForm,'tr_filter',get_profile('web.tr_events.filter.state',0));
+ $filter->Show();
+//-------
+
+
+$left_tab = new CTable();
+$left_tab->SetCellPadding(3);
+$left_tab->SetCellSpacing(3);
+
+$left_tab->AddOption('border',0);
+
+$left_tab->AddRow(create_hat(
+ S_EVENT_DETAILS,
+ make_event_details($_REQUEST['triggerid'],$trigger_data),//null,
+ null,
+ 'hat_eventdetails',
+ get_profile('web.tr_events.hats.hat_eventdetails.state',1)
+ ));
+
+$right_tab = new CTable();
+$right_tab->SetCellPadding(3);
+$right_tab->SetCellSpacing(3);
+
+$right_tab->AddOption('border',0);
+
+$right_tab->AddRow(create_hat(
+ S_EVENTS.SPACE.S_LIST,
+ $table_eventlist,//null,
+ null,
+ 'hat_eventlist',
+ get_profile('web.tr_events.hats.hat_eventlist.state',1)
+ ));
+
+
+$td_l = new CCol($left_tab);
+$td_l->AddOption('valign','top');
+$td_r = new CCol($right_tab);
+$td_r->AddOption('valign','top');
+
+$outer_table = new CTable();
+$outer_table->AddOption('border',0);
+$outer_table->SetCellPadding(1);
+$outer_table->SetCellSpacing(1);
+$outer_table->AddRow(array($td_l,$td_r));
+
+$outer_table->Show();
+
+show_thin_table_header(SPACE,$navigation);
+?>
<?php
include_once "include/page_footer.php";
diff --git a/frontends/php/users.php b/frontends/php/users.php
index 845f4142..2547484d 100644
--- a/frontends/php/users.php
+++ b/frontends/php/users.php
@@ -52,7 +52,7 @@ include_once "include/page_header.php";
'password1'=> array(T_ZBX_STR, O_OPT, null, null, '(isset({config})&&({config}==0))&&isset({save})&&(isset({form})&&({form}!="update"))&&isset({change_password})'),
"password2"=> array(T_ZBX_STR, O_OPT, null, null, '(isset({config})&&({config}==0))&&isset({save})&&(isset({form})&&({form}!="update"))&&isset({change_password})'),
'user_type'=> array(T_ZBX_INT, O_OPT, null, IN('1,2,3'), '(isset({config})&&({config}==0))&&isset({save})'),
- 'user_groups'=> array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, '(isset({config})&&({config}==0))&&isset({save})'),
+ 'user_groups'=> array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, null),//'(isset({config})&&({config}==0))&&isset({save})'),
'user_groups_to_del'=> array(T_ZBX_INT, O_OPT, null, DB_ID, null),
'user_medias'=> array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, null),
'user_medias_to_del'=> array(T_ZBX_STR, O_OPT, null, DB_ID, null),