diff options
author | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-01-20 15:18:53 +0000 |
---|---|---|
committer | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-01-20 15:18:53 +0000 |
commit | ae36471561342aae64fb974f2b8029cac0b92419 (patch) | |
tree | 331f4e7b66b1d3ccf192ad24fd32c422320d53e9 | |
parent | d8f01baf1d0e053dc44f90ef5eff77028edb4225 (diff) | |
download | zabbix-ae36471561342aae64fb974f2b8029cac0b92419.tar.gz zabbix-ae36471561342aae64fb974f2b8029cac0b92419.tar.xz zabbix-ae36471561342aae64fb974f2b8029cac0b92419.zip |
- Frontend improvements (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@2549 97f52cf1-0a1b-0410-bd0e-c28be96e8082
-rw-r--r-- | frontends/php/hosts.php | 175 | ||||
-rw-r--r-- | frontends/php/include/forms.inc.php | 23 | ||||
-rw-r--r-- | frontends/php/items.php | 345 |
3 files changed, 251 insertions, 292 deletions
diff --git a/frontends/php/hosts.php b/frontends/php/hosts.php index 7046ddf5..292c28c9 100644 --- a/frontends/php/hosts.php +++ b/frontends/php/hosts.php @@ -351,72 +351,98 @@ <?php if($_REQUEST["config"]==2) { - $h1=S_CONFIGURATION_OF_TEMPLATES_LINKAGE; - - if(isset($_REQUEST["groupid"])&&($_REQUEST["groupid"]==0)) - { - unset($_REQUEST["groupid"]); - } - if(isset($_REQUEST["hostid"])&&($_REQUEST["hostid"]==0)) - { - unset($_REQUEST["hostid"]); - } + if(isset($_REQUEST["groupid"])&&($_REQUEST["groupid"]==0)) + { + unset($_REQUEST["groupid"]); + } + if(isset($_REQUEST["hostid"])&&($_REQUEST["hostid"]==0)) + { + unset($_REQUEST["hostid"]); + } - $h2=S_GROUP." "; - $h2=$h2."<input class=\"biginput\" name=\"config\" type=\"hidden\" value=\"".$_REQUEST["config"]."\">"; - if(isset($_REQUEST["hostid"])) - { - $h2=$h2."<input class=\"biginput\" name=\"hostid\" type=\"hidden\" value=\"".$_REQUEST["hostid"]."\">"; - } - $h2=$h2."<select class=\"biginput\" name=\"groupid\" onChange=\"submit()\">"; - $h2=$h2.form_select("groupid",0,S_ALL_SMALL); + $form = new CForm("hosts.php"); + $form->AddVar("config",$_REQUEST["config"]); + if(isset($_REQUEST["hostid"])) + { + $form->AddVar("hostid",$_REQUEST["hostid"]); + } + $cmbGroup = new CComboBox("groupid",get_request("groupid",0),"submit()"); + $cmbGroup->AddItem(0,S_ALL_SMALL); - $result=DBselect("select groupid,name from groups order by 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,hosts_groups hg where hg.groupid=".$row["groupid"]." and hg.hostid=h.hostid and h.status not in (".HOST_STATUS_DELETED.") group by h.hostid,h.host order by h.host"); - $cnt=0; - while($row2=DBfetch($result2)) + $result=DBselect("select groupid,name from groups order by name"); + while($row=DBfetch($result)) { - if(!check_right("Host","U",$row2["hostid"])) + // Check if at least one host with read permission exists for this group + $result2=DBselect("select h.hostid,h.host from hosts h,hosts_groups hg". + " where hg.groupid=".$row["groupid"]." and hg.hostid=h.hostid and". + " h.status<>".HOST_STATUS_DELETED." group by h.hostid,h.host order by h.host"); + while($row2=DBfetch($result2)) { - continue; + if(!check_right("Host","U",$row2["hostid"])) continue; + $cmbGroup->AddItem($row["groupid"],$row["name"]); + break; } - $cnt=1; break; } - if($cnt!=0) + $form->AddItem(S_GROUP.SPACE); + $form->AddItem($cmbGroup); + + $cmbHosts = new CComboBox("hostid",get_request("hostid",0),"submit()"); + $cmbHosts->AddItem(0,S_SELECT_HOST_DOT_DOT_DOT); + if(isset($_REQUEST["groupid"])){ + $sql="select h.hostid,h.host from hosts h,hosts_groups hg". + " where hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid". + " and h.status not in (".HOST_STATUS_DELETED.") group by h.hostid,h.host". + " order by h.host"; + } else { + $sql="select h.hostid,h.host from hosts h where h.status<>".HOST_STATUS_DELETED. + " group by h.hostid,h.host order by h.host"; + } + + $correct_hostid = 'no'; + $result=DBselect($sql); + while($row=DBfetch($result)) { - $h2=$h2.form_select("groupid",$row["groupid"],$row["name"]); + if(!check_right("Host","U",$row["hostid"])) continue; + $cmbHosts->AddItem($row["hostid"],$row["host"]); + if(isset($_REQUEST["hostid"])) + if($_REQUEST["hostid"]==$row["hostid"]) + $correct_hostid = 'ok'; } - } - $h2=$h2."</select>"; + if($correct_hostid!='ok') + unset($_REQUEST["hostid"]); - $h2=$h2." ".S_HOST." "; - $h2=$h2."<select class=\"biginput\" name=\"hostid\" onChange=\"submit()\">"; - $h2=$h2.form_select("hostid",0,S_SELECT_HOST_DOT_DOT_DOT); + $form->AddItem(SPACE.S_HOST.SPACE); + $form->AddItem($cmbHosts); - if(isset($_REQUEST["groupid"])) - { - $sql="select h.hostid,h.host from hosts h,hosts_groups hg where hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid and h.status not in (".HOST_STATUS_DELETED.") group by h.hostid,h.host order by h.host"; - } - else - { - $sql="select h.hostid,h.host from hosts h where h.status not in (".HOST_STATUS_DELETED.") group by h.hostid,h.host order by h.host"; - } + show_header2(S_CONFIGURATION_OF_TEMPLATES_LINKAGE, $form); - $result=DBselect($sql); - while($row=DBfetch($result)) - { - if(!check_right("Host","U",$row["hostid"])) + if(isset($_REQUEST["hostid"])) { - continue; - } - $h2=$h2.form_select("hostid",$row["hostid"],$row["host"]); - } - $h2=$h2."</select>"; + echo BR; + @insert_template_form($_REQUEST["hostid"], $_REQUEST["hosttemplateid"]); + echo BR; + + $table = new CTableInfo(S_NO_LINKAGES_DEFINED); + $table->setHeader(array(S_HOST,S_TEMPLATE,S_ITEMS,S_TRIGGERS,S_GRAPHS,S_ACTIONS)); + + $result=DBselect("select * from hosts_templates where hostid=".$_REQUEST["hostid"]); + while($row=DBfetch($result)) + { + $host=get_host_by_hostid($row["hostid"]); + $template=get_host_by_hostid($row["templateid"]); + $actions="<a href=\"hosts.php?config=2&hostid=".$row["hostid"]."&hosttemplateid=".$row["hosttemplateid"]."\">".S_CHANGE."</a>"; - show_header2($h1, $h2, "<form name=\"form2\" method=\"get\" action=\"hosts.php\">", "</form>"); + $table->addRow(array( + $host["host"], + $template["host"], + get_template_permission_str($row["items"]), + get_template_permission_str($row["triggers"]), + get_template_permission_str($row["graphs"]), + $actions + )); + } + $table->show(); + } } ?> <?php @@ -477,46 +503,6 @@ } } ?> - -<?php - if(isset($_REQUEST["groupid"])&&($_REQUEST["groupid"]==0)) - { - unset($_REQUEST["groupid"]); - } -?> - -<?php - if(isset($_REQUEST["hostid"])&&$_REQUEST["config"]==2) - { - @insert_template_form($_REQUEST["hostid"], $_REQUEST["hosttemplateid"]); - } - if(isset($_REQUEST["hostid"])&&($_REQUEST["config"]==2)) - { - $table = new CTableInfo(S_NO_LINKAGES_DEFINED); - $table->setHeader(array(S_HOST,S_TEMPLATE,S_ITEMS,S_TRIGGERS,S_GRAPHS,S_ACTIONS)); - - $result=DBselect("select * from hosts_templates where hostid=".$_REQUEST["hostid"]); - while($row=DBfetch($result)) - { - $host=get_host_by_hostid($row["hostid"]); - $template=get_host_by_hostid($row["templateid"]); -// $members=array("hide"=>1,"value"=>""); -# $actions="<A HREF=\"hosts.php?config=".$_REQUEST["config"]."&groupid=".$row["groupid"]."#form\">".S_CHANGE."</A>"; - $actions="<a href=\"hosts.php?config=2&hostid=".$row["hostid"]."&hosttemplateid=".$row["hosttemplateid"]."\">".S_CHANGE."</a>"; - - $table->addRow(array( - $host["host"], - $template["host"], - get_template_permission_str($row["items"]), - get_template_permission_str($row["triggers"]), - get_template_permission_str($row["graphs"]), - $actions - )); - } - $table->show(); - } -?> - <?php if($_REQUEST["config"]==0) { @@ -646,9 +632,6 @@ } } ?> - -<?php -?> <?php show_page_footer(); ?> diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php index 2a48d08e..6175d4ce 100644 --- a/frontends/php/include/forms.inc.php +++ b/frontends/php/include/forms.inc.php @@ -249,9 +249,9 @@ { global $_REQUEST; + $hostid=@iif(isset($_REQUEST["hostid"]),$_REQUEST["hostid"],0); $description=@iif(isset($_REQUEST["description"]),$_REQUEST["description"],""); $key=@iif(isset($_REQUEST["key"]),$_REQUEST["key"],""); - $host=@iif(isset($_REQUEST["host"]),$_REQUEST["host"],""); $port=@iif(isset($_REQUEST["port"]),$_REQUEST["port"],10050); $delay=@iif(isset($_REQUEST["delay"]),$_REQUEST["delay"],30); $history=@iif(isset($_REQUEST["history"]),$_REQUEST["history"],90); @@ -265,7 +265,6 @@ $snmp_port=@iif(isset($_REQUEST["snmp_port"]),$_REQUEST["snmp_port"],161); $units=@iif(isset($_REQUEST["units"]),$_REQUEST["units"],''); $multiplier=@iif(isset($_REQUEST["multiplier"]),$_REQUEST["multiplier"],0); - $hostid=@iif(isset($_REQUEST["hostid"]),$_REQUEST["hostid"],0); $delta=@iif(isset($_REQUEST["delta"]),$_REQUEST["delta"],0); $snmpv3_securityname=@iif(isset($_REQUEST["snmpv3_securityname"]),$_REQUEST["snmpv3_securityname"],""); @@ -277,7 +276,13 @@ $logtimefmt=@iif(isset($_REQUEST["logtimefmt"]),$_REQUEST["logtimefmt"],""); $groupid=@iif(isset($_REQUEST["groupid"]),$_REQUEST["groupid"],0); - if(isset($_REQUEST["register"])&&($_REQUEST["register"] == "change")) + $host=@iif(isset($_REQUEST["host"]),$_REQUEST["host"],NULL); + if(is_null($host)&&$hostid>0){ + $host_info = get_host_by_hostid($hostid); + $host = $host_info["host"]; + } + + if(isset($_REQUEST["itemid"])&&($_REQUEST["form"] != 1)) { $result=DBselect("select i.description, i.key_, h.host, h.port, i.delay, i.history, i.status, i.type, i.snmp_community,i.snmp_oid,i.value_type,i.trapper_hosts,i.snmp_port,i.units,i.multiplier,h.hostid,i.delta,i.trends,i.snmpv3_securityname,i.snmpv3_securitylevel,i.snmpv3_authpassphrase,i.snmpv3_privpassphrase,i.formula,i.logtimefmt from items i,hosts h where i.itemid=".$_REQUEST["itemid"]." and h.hostid=i.hostid"); $row=DBfetch($result); @@ -480,6 +485,10 @@ new CButton("register","delete","return Confirm('Delete selected item?');") ); } + array_push($frmRow, + SPACE, + new CButtonCancel(url_param("groupid").url_param("hostid"))); + $frmItem->AddSpanRow($frmRow,"form_row_last"); $cmbGroups = new CComboBox("groupid",$groupid,"submit()"); @@ -491,11 +500,9 @@ $hosts=DBselect("select h.hostid,h.host from hosts h,hosts_groups hg where hg.groupid=".$group["groupid"]." and hg.hostid=h.hostid and h.status<>".HOST_STATUS_DELETED." group by h.hostid,h.host order by h.host"); while($host=DBfetch($hosts)) { - if(check_right("Host","U",$host["hostid"])) - { - $cmbGroups->AddItem($group["groupid"],$group["name"]); - break; - } + if(!check_right("Host","U",$host["hostid"])) continue; + $cmbGroups->AddItem($group["groupid"],$group["name"]); + break; } } $frmItem->AddRow(S_GROUP,$cmbGroups); diff --git a/frontends/php/items.php b/frontends/php/items.php index 46681d41..13cf7522 100644 --- a/frontends/php/items.php +++ b/frontends/php/items.php @@ -40,23 +40,6 @@ <?php - function BETWEEN($min,$max) - { - return "({}>=$min&&{}<=$max)&&"; - } - - function GT($value) - { - return "({}>=$value)&&"; - } - - function IN($array) - { - return "({} in_array($array))&&"; - } - - define("NOT_EMPTY","({}!='')&&"); - // VAR TYPE OPTIONAL TABLE FIELD OPTIONAL VALIDATION EXCEPTION $fields=array( "description"=> array(T_ZBX_STR, O_MAND, "items", NULL, NOT_EMPTY, NULL), @@ -93,11 +76,11 @@ <?php if(isset($_REQUEST["groupid"])&&($_REQUEST["groupid"]==0)) { - unset($_REQUEST["groupid"]); +// unset($_REQUEST["groupid"]); } if(isset($_REQUEST["hostid"])&&($_REQUEST["hostid"]==0)) { - unset($_REQUEST["hostid"]); +// unset($_REQUEST["hostid"]); } ?> @@ -225,203 +208,189 @@ <?php - if(!isset($_REQUEST["register"])) - { - - $h1=S_CONFIGURATION_OF_ITEMS_BIG; - - if(isset($_REQUEST["groupid"])&&($_REQUEST["groupid"]==0)) - { - unset($_REQUEST["groupid"]); - } - - $h2=S_GROUP." "; - $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 order by name"); - while($row=DBfetch($result)) + $db_hosts=DBselect("select hostid from hosts"); + if(isset($_REQUEST["form"])&&isset($_REQUEST["hostid"])&&DBnum_rows($db_hosts)>0) { -// Check if at least one host with read permission exists for this group - $result2=DBselect("select h.hostid,h.host from hosts h,hosts_groups hg where hg.groupid=".$row["groupid"]." and hg.hostid=h.hostid and h.status<>".HOST_STATUS_DELETED." group by h.hostid,h.host order by h.host"); - $cnt=0; - while($row2=DBfetch($result2)) + insert_item_form(); + } else { + $form = new CForm(); + + $_REQUEST["groupid"] = get_request("groupid",0); + $cmbGroup = new CComboBox("groupid",$_REQUEST["groupid"],"submit();"); + $cmbGroup->AddItem(0,S_ALL_SMALL); + $result=DBselect("select groupid,name from groups order by name"); + while($row=DBfetch($result)) { - if(!check_right("Host","U",$row2["hostid"])) + // Check if at least one host with read permission exists for this group + $result2=DBselect("select h.hostid,h.host from hosts h,hosts_groups hg". + " where hg.groupid=".$row["groupid"]." and hg.hostid=h.hostid and". + " h.status<>".HOST_STATUS_DELETED." group by h.hostid,h.host order by h.host"); + while($row2=DBfetch($result2)) { - continue; + if(!check_right("Host","U",$row2["hostid"])) continue; + $cmbGroup->AddItem($row["groupid"],$row["name"]); + break; } - $cnt=1; break; } - if($cnt!=0) + $form->AddItem(S_GROUP.SPACE); + $form->AddItem($cmbGroup); + + if(isset($_REQUEST["groupid"]) && $_REQUEST["groupid"]>0) { - $h2=$h2.form_select("groupid",$row["groupid"],$row["name"]); + $sql="select h.hostid,h.host from hosts h,hosts_groups hg". + " where hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid and". + " h.status<>".HOST_STATUS_DELETED." group by h.hostid,h.host order by h.host"; } - } - $h2=$h2."</select>"; - - $h2=$h2." ".S_HOST." "; - $h2=$h2."<select class=\"biginput\" name=\"hostid\" onChange=\"submit()\">"; - $h2=$h2.form_select("hostid",0,S_SELECT_HOST_DOT_DOT_DOT); - - if(isset($_REQUEST["groupid"])) - { - $sql="select h.hostid,h.host from hosts h,hosts_groups hg where hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid and h.status<>".HOST_STATUS_DELETED." group by h.hostid,h.host order by h.host"; - } - else - { - $sql="select h.hostid,h.host from hosts h where h.status<>".HOST_STATUS_DELETED." group by h.hostid,h.host order by h.host"; - } - - $result=DBselect($sql); - while($row=DBfetch($result)) - { - if(!check_right("Host","U",$row["hostid"])) + else { - continue; + $sql="select h.hostid,h.host from hosts h where h.status<>".HOST_STATUS_DELETED. + " group by h.hostid,h.host order by h.host"; } - $h2=$h2.form_select("hostid",$row["hostid"],$row["host"]); - } - $h2=$h2."</select>"; - $h2=$h2." | "; - $h2=$h2."<input class=\"button\" type=\"submit\" name=\"register\" value=\"".S_CREATE_ITEM."\">"; - - show_header2($h1, $h2, "<form name=\"form2\" method=\"get\" action=\"items.php\">", "</form>"); -?> + $result=DBselect($sql); -<?php - - if(isset($_REQUEST["hostid"])) - { - $table = new CTableInfo(); - $table->setHeader(array(S_ID,S_KEY,S_DESCRIPTION,nbsp(S_UPDATE_INTERVAL),S_HISTORY,S_TRENDS,S_TYPE,S_STATUS,S_ERROR)); -// $h="<form method=\"get\" action=\"items.php\">"; -// $h=$h."<input class=\"biginput\" name=\"hostid\" type=hidden value=".$_REQUEST["hostid"]." size=8>"; - -// $table->setAfterHeader($h); + $_REQUEST["hostid"] = get_request("hostid",0); + $cmbHosts = new CComboBox("hostid",$_REQUEST["hostid"],"submit();"); - $result=DBselect("select h.host,i.key_,i.itemid,i.description,h.port,i.delay,i.history,i.lastvalue,i.lastclock,i.status,i.nextcheck,h.hostid,i.type,i.trends,i.error from hosts h,items i where h.hostid=i.hostid and h.hostid=".$_REQUEST["hostid"]." order by h.host,i.key_,i.description"); - $col=0; + $correct_hostid='no'; + $first_hostid = -1; while($row=DBfetch($result)) { - if(!check_right("Item","R",$row["itemid"])) - { - continue; + if(!check_right("Host","U",$row["hostid"])) continue; + $cmbHosts->AddItem($row["hostid"],$row["host"]); + + if($_REQUEST["hostid"]!=0){ + if($_REQUEST["hostid"]==$row["hostid"]) + $correct_hostid = 'ok'; } + if($first_hostid <= 0) + $first_hostid = $row["hostid"]; + } + if($correct_hostid!='ok') + $_REQUEST["hostid"] = $first_hostid; - $key=iif(check_right("Item","U",$row["itemid"]), - "<A HREF=\"items.php?register=change&itemid=".$row["itemid"].url_param("hostid").url_param("groupid")."#form\">".$row["key_"]."</A>",$row["key_"]); + $form->AddItem(SPACE.S_HOST.SPACE); + $form->AddItem($cmbHosts); + $form->AddItem(SPACE."|".SPACE); + $form->AddItem(new CButton("form",S_CREATE_ITEM)); + + show_header2(S_CONFIGURATION_OF_ITEMS_BIG, $form); + ?> - $input="<INPUT TYPE=\"CHECKBOX\" class=\"biginput\" NAME=\"".$row["itemid"]."\"> ".$row["itemid"]; - switch($row["type"]) - { - case 0: - $type=S_ZABBIX_AGENT; - break; - case 7: - $type=S_ZABBIX_AGENT_ACTIVE; - break; - case 1: - $type=S_SNMPV1_AGENT; - break; - case 2: - $type=S_ZABBIX_TRAPPER; - break; - case 3: - $type=S_SIMPLE_CHECK; - break; - case 4: - $type=S_SNMPV2_AGENT; - break; - case 6: - $type=S_SNMPV3_AGENT; - break; - case 5: - $type=S_ZABBIX_INTERNAL; - break; - default: - $type=S_UNKNOWN; - break; - } - - - switch($row["status"]) - { - case 0: - $status=new CCol(new CLink(S_ACTIVE, "items.php?itemid=".$row["itemid"]."&hostid=".$_REQUEST["hostid"]."®ister=changestatus&status=1","off"),"off"); - break; - case 1: - $status=new CCol(new CLink(S_ACTIVE, "items.php?itemid=".$row["itemid"]."&hostid=".$_REQUEST["hostid"]."®ister=changestatus&status=0","on"),"on"); - break; - case 3: - $status=new CCol(S_NOT_SUPPORTED,"unknown"); - break; - default: - $status=S_UNKNOWN; - } - - if($row["error"] == "") - { - $error=new CCol(" ","off"); - } - else - { - $error=new CCol($row["error"],"on"); - } - $table->AddRow(array( - $input, - $key, - $row["description"], - $row["delay"], - $row["history"], - $row["trends"], - $type, - $status, - $error - )); - } -// $table->show(); + <?php - $footerButtons = array(); - array_push($footerButtons, new CButton('register','Activate selected', - "return Confirm('".S_ACTIVATE_SELECTED_ITEMS_Q."');")); - array_push($footerButtons, new CButton('register','Disable selected', - "return Confirm('".S_DISABLE_SELECTED_ITEMS_Q."');")); - array_push($footerButtons, new CButton('register','Delete selected', - "return Confirm('".S_DELETE_SELECTED_ITEMS_Q."');")); - $table->SetFooter(new CCol($footerButtons),'table_footer'); + if(isset($_REQUEST["hostid"])) + { + $table = new CTableInfo(); + $table->setHeader(array(S_ID,S_KEY,S_DESCRIPTION,nbsp(S_UPDATE_INTERVAL),S_HISTORY,S_TRENDS,S_TYPE,S_STATUS,S_ERROR)); + // $h="<form method=\"get\" action=\"items.php\">"; + // $h=$h."<input class=\"biginput\" name=\"hostid\" type=hidden value=".$_REQUEST["hostid"]." size=8>"; - $form = new CForm('items.php'); - $form->AddVar('hostid',$_REQUEST["hostid"]); - $form->AddItem($table); - $form->Show(); + // $table->setAfterHeader($h); + $result=DBselect("select h.host,i.key_,i.itemid,i.description,h.port,i.delay,i.history,i.lastvalue,i.lastclock,i.status,i.nextcheck,h.hostid,i.type,i.trends,i.error from hosts h,items i where h.hostid=i.hostid and h.hostid=".$_REQUEST["hostid"]." order by h.host,i.key_,i.description"); + $col=0; + while($row=DBfetch($result)) + { + if(!check_right("Item","R",$row["itemid"])) + { + continue; + } -// $h="<input class=\"button\" type=\"submit\" name=\"register\" value=\"Activate selected\" onClick=\"return Confirm('".S_ACTIVATE_SELECTED_ITEMS_Q."');\">"; -// $h=$h."<input class=\"button\" type=\"submit\" name=\"register\" value=\"Disable selected\" onClick=\"return Confirm('".S_DISABLE_SELECTED_ITEMS_Q."');\">"; -// $h=$h."<input class=\"button\" type=\"submit\" name=\"register\" value=\"Delete selected\" onClick=\"return Confirm('".S_DELETE_SELECTED_ITEMS_Q."');\">"; -// $h=$h."</form>"; + $key=iif(check_right("Item","U",$row["itemid"]), + "<A HREF=\"items.php?form=0&itemid=".$row["itemid"].url_param("hostid").url_param("groupid")."\">".$row["key_"]."</A>",$row["key_"]); -// show_table_header($h); - } + $input="<INPUT TYPE=\"CHECKBOX\" class=\"biginput\" NAME=\"".$row["itemid"]."\"> ".$row["itemid"]; - } -?> + switch($row["type"]) + { + case 0: + $type=S_ZABBIX_AGENT; + break; + case 7: + $type=S_ZABBIX_AGENT_ACTIVE; + break; + case 1: + $type=S_SNMPV1_AGENT; + break; + case 2: + $type=S_ZABBIX_TRAPPER; + break; + case 3: + $type=S_SIMPLE_CHECK; + break; + case 4: + $type=S_SNMPV2_AGENT; + break; + case 6: + $type=S_SNMPV3_AGENT; + break; + case 5: + $type=S_ZABBIX_INTERNAL; + break; + default: + $type=S_UNKNOWN; + break; + } -<?php - if(isset($_REQUEST["register"])&&(in_array($_REQUEST["register"],array(S_CREATE_ITEM,"change")))) - { - $result=DBselect("select count(*) as cnt from hosts"); - $row=DBfetch($result); - if($row["cnt"]>0) - { - insert_item_form(); + + switch($row["status"]) + { + case 0: + $status=new CCol(new CLink(S_ACTIVE, "items.php?itemid=".$row["itemid"]."&hostid=".$_REQUEST["hostid"]."®ister=changestatus&status=1","off"),"off"); + break; + case 1: + $status=new CCol(new CLink(S_ACTIVE, "items.php?itemid=".$row["itemid"]."&hostid=".$_REQUEST["hostid"]."®ister=changestatus&status=0","on"),"on"); + break; + case 3: + $status=new CCol(S_NOT_SUPPORTED,"unknown"); + break; + default: + $status=S_UNKNOWN; + } + + if($row["error"] == "") + { + $error=new CCol(" ","off"); + } + else + { + $error=new CCol($row["error"],"on"); + } + $table->AddRow(array( + $input, + $key, + $row["description"], + $row["delay"], + $row["history"], + $row["trends"], + $type, + $status, + $error + )); + } + // $table->show(); + + $footerButtons = array(); + array_push($footerButtons, new CButton('register','Activate selected', + "return Confirm('".S_ACTIVATE_SELECTED_ITEMS_Q."');")); + array_push($footerButtons, SPACE); + array_push($footerButtons, new CButton('register','Disable selected', + "return Confirm('".S_DISABLE_SELECTED_ITEMS_Q."');")); + array_push($footerButtons, SPACE); + array_push($footerButtons, new CButton('register','Delete selected', + "return Confirm('".S_DELETE_SELECTED_ITEMS_Q."');")); + $table->SetFooter(new CCol($footerButtons),'table_footer'); + + $form = new CForm('items.php'); + $form->AddVar('hostid',$_REQUEST["hostid"]); + $form->AddItem($table); + $form->Show(); } + } ?> - <?php show_page_footer(); ?> |