summaryrefslogtreecommitdiffstats
path: root/frontends/php/events.php
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-10-23 07:34:27 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-10-23 07:34:27 +0000
commit28a09ed13e41ddbe5e30d63e92a1f5fb3395ef89 (patch)
tree8281ccd48964ee0dd11c5ea689091fa3cef706fb /frontends/php/events.php
parent495799b2aa61aab23d74d7faa110a0cd09d59bf0 (diff)
downloadzabbix-28a09ed13e41ddbe5e30d63e92a1f5fb3395ef89.tar.gz
zabbix-28a09ed13e41ddbe5e30d63e92a1f5fb3395ef89.tar.xz
zabbix-28a09ed13e41ddbe5e30d63e92a1f5fb3395ef89.zip
- developed group permission system (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@3371 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/events.php')
-rw-r--r--frontends/php/events.php154
1 files changed, 64 insertions, 90 deletions
diff --git a/frontends/php/events.php b/frontends/php/events.php
index 8cdce0e4..dd04f3cb 100644
--- a/frontends/php/events.php
+++ b/frontends/php/events.php
@@ -19,135 +19,109 @@
**/
?>
<?php
- include "include/config.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/hosts.inc.php";
+ require_once "include/events.inc.php";
+
$page["title"] = "S_LATEST_EVENTS";
$page["file"] = "events.php";
- show_header($page["title"],1,0);
-?>
+
+ define('ZBX_PAGE_DO_REFRESH', 1);
+include_once "include/page_header.php";
+
+?>
<?php
+ define('PAGE_SIZE', 100);
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
$fields=array(
- "groupid"=> array(T_ZBX_INT, O_OPT, P_SYS, BETWEEN(0,65535), NULL),
- "hostid"=> array(T_ZBX_INT, O_OPT, P_SYS, BETWEEN(0,65535), NULL),
- "start"=> array(T_ZBX_INT, O_OPT, P_SYS, BETWEEN(0,65535)."({}%100==0)", NULL),
+ "groupid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL),
+ "hostid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL),
+ "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)
);
check_fields($fields);
- validate_group_with_host("R", array("allow_all_hosts","always_select_first_host","monitored_hosts","with_items"));
-
- update_profile("web.menu.view.last",$page["file"]);
+ validate_group_with_host(PERM_READ_ONLY, array("allow_all_hosts","always_select_first_host","monitored_hosts","with_items"));
?>
-
-
<?php
- if(isset($_REQUEST["start"])&&isset($_REQUEST["prev"]))
+ $_REQUEST["start"] = get_request("start", 0);
+ if(isset($_REQUEST["prev"]))
{
- $_REQUEST["start"]-=100;
- if($_REQUEST["start"]<=0) unset($_REQUEST["start"]);
+ $_REQUEST["start"] -= PAGE_SIZE;
}
if(isset($_REQUEST["next"]))
{
- if(isset($_REQUEST["start"]))
- {
- $_REQUEST["start"]+=100;
- }
- else
- {
- $_REQUEST["start"]=100;
- }
+ $_REQUEST["start"] += PAGE_SIZE;
}
+ if($_REQUEST["start"] < 0) $_REQUEST["start"] = 0;
?>
-
-
<?php
- $h1=SPACE.S_HISTORY_OF_EVENTS_BIG;
-
- $h2=S_GROUP.SPACE;
- $h2=$h2."<select class=\"biginput\" name=\"groupid\" onChange=\"submit()\">";
- $h2=$h2.form_select("groupid",0,S_ALL_SMALL);
- $result=DBselect("select groupid,name from groups where mod(groupid,100)=$ZBX_CURNODEID order by name");
+ $table = get_history_of_events($_REQUEST["start"],100,$_REQUEST["groupid"],$_REQUEST["hostid"]);
+
+ $r_form = new CForm();
+
+ $cmbGroup = new CComboBox("groupid",$_REQUEST["groupid"],"submit()");
+ $cmbHosts = new CComboBox("hostid",$_REQUEST["hostid"],"submit()");
+
+ $cmbGroup->AddItem(0,S_ALL_SMALL);
+
+ $availiable_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_LIST, null, null, $ZBX_CURNODEID);
+
+ $result=DBselect("select distinct g.groupid,g.name from groups g, hosts_groups hg, hosts h, items i ".
+ " where h.hostid in (".$availiable_hosts.") ".
+ " and hg.groupid=g.groupid and h.status=".HOST_STATUS_MONITORED.
+ " and h.hostid=i.hostid and hg.hostid=h.hostid ".
+ " order by g.name");
while($row=DBfetch($result))
{
-// Check if at least one host with read permission exists for this group
- $result2=DBselect("select h.hostid,h.host from hosts h,items i,hosts_groups hg where h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid and hg.groupid=".$row["groupid"]." and hg.hostid=h.hostid group by h.hostid,h.host order by h.host");
- $cnt=0;
- while($row2=DBfetch($result2))
- {
- if(!check_right("Host","R",$row2["hostid"]))
- {
- continue;
- }
- $cnt=1; break;
- }
- if($cnt!=0)
- {
- $h2=$h2.form_select("groupid",$row["groupid"],$row["name"]);
- }
+ $cmbGroup->AddItem($row["groupid"],$row["name"]);
}
- $h2=$h2."</select>";
-
- $h2=$h2.SPACE.S_HOST.SPACE;
- $h2=$h2."<select class=\"biginput\" name=\"hostid\" onChange=\"submit()\">";
-
- if($_REQUEST["groupid"] == 0)
- $h2=$h2.form_select("hostid",0,S_ALL_SMALL);
-
+ $r_form->AddItem(array(S_GROUP.SPACE,$cmbGroup));
+
if($_REQUEST["groupid"] > 0)
{
- $sql="select h.hostid,h.host from hosts h,items i,hosts_groups hg where h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid and hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid group by h.hostid,h.host order by h.host";
+ $sql="select h.hostid,h.host from hosts h,items i,hosts_groups hg where h.status=".HOST_STATUS_MONITORED.
+ " and h.hostid=i.hostid and hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid".
+ " and h.hostid in (".$availiable_hosts.") ".
+ " group by h.hostid,h.host order by h.host";
}
else
{
- $sql="select h.hostid,h.host from hosts h,items i where h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid and mod(h.hostid,100)=$ZBX_CURNODEID group by h.hostid,h.host order by h.host";
+ $cmbHosts->AddItem(0,S_ALL_SMALL);
+ $sql="select h.hostid,h.host from hosts h,items i where h.status=".HOST_STATUS_MONITORED.
+ " and h.hostid=i.hostid".
+ " and h.hostid in (".$availiable_hosts.") ".
+ " group by h.hostid,h.host order by h.host";
}
-
$result=DBselect($sql);
while($row=DBfetch($result))
{
- if(!check_right("Host","R",$row["hostid"]))
- {
- continue;
- }
- $h2=$h2.form_select("hostid",$row["hostid"],$row["host"]);
+ $cmbHosts->AddItem($row["hostid"],$row["host"]);
}
- $h2=$h2."</select>".SPACE;
- if(isset($_REQUEST["start"]))
- {
- $h2=$h2."<input class=\"biginput\" name=\"start\" type=hidden value=".$_REQUEST["start"]." size=8>";
- $h2=$h2."<input class=\"button\" type=\"submit\" name=\"prev\" value=\"<< Prev 100\">";
- }
- else
- {
- $h2=$h2."<input class=\"button\" type=\"submit\" disabled name=\"prev\" value=\"<< Prev 100\">";
- }
- $h2=$h2."<input class=\"button\" type=\"submit\" name=\"next\" value=\"Next 100 >>\">";
+ $r_form->AddItem(array(SPACE.S_HOST.SPACE,$cmbHosts));
+
+ $r_form->AddVar("start",$_REQUEST["start"]);
- show_header2($h1,$h2,"<form name=\"form2\" method=\"get\" action=\"events.php\">","</form>");
-?>
+ $btnPrev = new CButton("prev","<< Prev ".PAGE_SIZE);
+ if($_REQUEST["start"] <= 0)
+ $btnPrev->SetEnabled('no');
+ $r_form->AddItem($btnPrev);
-<?php
- if(!isset($_REQUEST["start"]))
- {
- $_REQUEST["start"]=0;
- }
- if(!isset($_REQUEST["hostid"]))
- {
- $_REQUEST["hostid"]=0;
- }
- if(!isset($_REQUEST["groupid"]))
- {
- $_REQUEST["groupid"]=0;
- }
- $table=get_history_of_events($_REQUEST["start"],100,$_REQUEST["groupid"],$_REQUEST["hostid"]);
+ $btnNext = new CButton("next","Next ".PAGE_SIZE." >>");
+ if($table->GetNumRows() < PAGE_SIZE)
+ $btnNext->SetEnabled('no');
+ $r_form->AddItem($btnNext);
+
+ show_table_header(S_HISTORY_OF_EVENTS_BIG,$r_form);
$table->Show();
?>
-
<?php
- show_page_footer();
+
+include_once "include/page_footer.php";
+
?>