summaryrefslogtreecommitdiffstats
path: root/frontends/php
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-09-13 12:58:10 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-09-13 12:58:10 +0000
commit8ca8c03346090ece96b4c4b3da5fe2d41b04eb3e (patch)
treecb08b1a7223db8f51791bb5c4b9ba551721f55c4 /frontends/php
parentaf0a329b812599d79e26a59d9d8eaaa4312c2034 (diff)
- fixed trigger description substitution in action comporation (Eugene)
- fixed trigger description substitution in message subject and body (Eugene) git-svn-id: svn://svn.zabbix.com/trunk@3299 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php')
-rw-r--r--frontends/php/include/copt.lib.php4
-rw-r--r--frontends/php/include/forms.inc.php13
-rw-r--r--frontends/php/tr_status.php116
3 files changed, 131 insertions, 2 deletions
diff --git a/frontends/php/include/copt.lib.php b/frontends/php/include/copt.lib.php
index ea3accf2..0144ab92 100644
--- a/frontends/php/include/copt.lib.php
+++ b/frontends/php/include/copt.lib.php
@@ -86,8 +86,8 @@
** Eugene Grigorjev (eugene.grigorjev@zabbix.com)
**/
-// define("USE_PROFILING",1);
-// define("USE_TIME_PROF",1);
+ define("USE_PROFILING",1);
+ define("USE_TIME_PROF",1);
// define("USE_MEM_PROF",1);
// define("USE_SQLREQUEST_PROF",1);
// define("SHOW_SQLREQUEST_DETAILS",1);
diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php
index 14230e9b..441b04ea 100644
--- a/frontends/php/include/forms.inc.php
+++ b/frontends/php/include/forms.inc.php
@@ -75,6 +75,13 @@
$autologout = $user["autologout"];
$lang = $user["lang"];
$refresh = $user["refresh"];
+ $user_groups = array();
+
+ $db_user_groups = DBselect('select g.* from usrgrp g, users_groups ug where ug.usrgrpid=g.usrgrpid and ug.userid='.$userid);
+ while($db_group = DBfetch($db_user_groups))
+ {
+ $user_groups[$db_group['usrgrpid']] = $db_group['name'];
+ }
}
else
{
@@ -86,6 +93,7 @@
$autologout = get_request("autologout","900");
$lang = get_request("lang","en_gb");
$refresh = get_request("refresh","30");
+ $user_groups = get_request("user_groups",array());
}
$frmUser = new CFormTable($frm_title);
@@ -109,6 +117,11 @@
$frmUser->AddRow(S_PASSWORD, new CPassBox("password1",$password,20));
$frmUser->AddRow(S_PASSWORD_ONCE_AGAIN, new CPassBox("password2",$password,20));
+ foreach($user_groups as $groupid => $group_name)
+ {
+ $frmUser->AddRow(S_GROUPS, $group_name);
+ }
+
$cmbLang = new CcomboBox('lang',$lang);
$cmbLang->AddItem("en_gb",S_ENGLISH_GB);
$cmbLang->AddItem("cn_zh",S_CHINESE_CN);
diff --git a/frontends/php/tr_status.php b/frontends/php/tr_status.php
index 2806bad5..2e35700e 100644
--- a/frontends/php/tr_status.php
+++ b/frontends/php/tr_status.php
@@ -649,6 +649,122 @@
$table->show();
show_table_header(S_TOTAL.":$col");
+
+
+################################################
+# NEW permission system #
+################################################
+
+
+ function accessiable_host_id_list($requested_right='H')
+ {
+$CURRENT_USER_ID = 4;
+
+COpt::profiling_start("host_id_list");
+
+ $requested_right = permission2int($requested_right);
+
+ $result = array();
+
+ $hosts_rights = DBselect('select r.permission from rights r where r.userid='.$CURRENT_USER_ID.' AND r.name=\'User Type\'');
+ if($right = DBfetch($hosts_rights))
+ if(permission2int($right['permission']) >= $requested_right)
+ {
+ $arr_rights = array();
+
+ $group_rights = DBselect('select h.hostid, r.permission from hosts_groups hg, hosts h, rights r '.
+ 'where r.userid='.$CURRENT_USER_ID.' AND hg.hostid=h.hostid AND r.name=\'Host Group\' AND r.id=hg.groupid');
+ while($right = DBfetch($group_rights))
+ $arr_rights[$right['hostid']] = isset($arr_rights[$right['hostid']]) ?
+ MIN($arr_rights[$right['hostid']], permission2int($right['permission'])) :
+ permission2int($right['permission']);
+
+ $hosts_rights = DBselect('select h.hostid, r.permission from hosts h, rights r '.
+ 'where r.userid='.$CURRENT_USER_ID.' AND r.name=\'Host\' AND r.id=h.hostid');
+ while($right = DBfetch($hosts_rights)) $arr_rights[$right['hostid']] = permission2int($right['permission']);
+
+
+ foreach($arr_rights as $hostid => $right)
+ {
+ if($right >= $requested_right) array_push($result, $hostid);
+ }
+ }
+
+ if(count($result) == 0) array_push($result, -1);
+
+COpt::profiling_stop("host_id_list");
+
+ return $result;
+ }
+
+ function process_hosts($function, &$args, $select_params)
+ {
+ /*
+ $result=DBselect("select distinct t.triggerid,t.status,t.description,t.expression,t.priority,".
+ "t.lastchange,t.comments,t.url,t.value from triggers t,hosts h,items i,functions f".$groupname.
+ " where t.value=1 and t.status=0 and f.itemid=i.itemid and h.hostid=i.hostid and t.description".
+ " $select_cond and t.triggerid=f.triggerid and i.status=".ITEM_STATUS_ACTIVE.
+ " and h.status=".HOST_STATUS_MONITORED." $cond $groupcond $sort");
+ */
+
+ $select_data = array('h.*');
+ $select_from = array('hosts h');
+ $select_where = array('h.hostid in '.'('.implode(',',accessiable_host_id_list()).')'); /* Node selection */
+
+ if(isset($select_params['hostid']))
+ array_push($select_where, 'h.hostid='.$select_params['hostid']);
+
+ if(isset($select_params['groupid']))
+ {
+ array_push($select_from,'hosts_groups hg');
+ array_push($select_where,'h.hostid=hg.hostid AND hg.groupid='.$select_params['groupid']);
+ }
+
+ if(isset($select_params['status']))
+ {
+ array_push($select_where,'h.status='.$select_params['status']);
+ }
+
+ $db_hosts = DBselect(
+ 'select '.implode(',',$select_data).' '.
+ 'from '.implode(',',$select_from).' '.
+ (count($select_where) > 0 ? 'where '.implode(' AND ', $select_where) : ''));
+
+ for(
+ $ret = true;
+ $ret == true && $db_host_row = DBfetch($db_hosts);
+ $ret = $function($args, $db_host_row)
+ );
+
+ return $ret;
+ }
+
+ function add_hot_to_table(&$args, $db_row)
+ {
+ if(!is_object($args)) return false;
+
+ $args->AddRow(array($db_row['hostid'], $db_row['host'], $db_row['ip']));
+
+ return true;
+ }
+
+ $host_table = new CTableInfo();
+ $host_table->SetHeader(array(S_ID, S_HOST, S_IP));
+
+ process_hosts('add_hot_to_table', $host_table,
+ array(
+// 'groupid' => 3,
+// 'hostid' => 10024,
+// 'status' => HOST_STATUS_MONITORED
+ )
+ );
+
+ $host_table->Show();
+
+
+
+################################################
+
?>
<?php