diff options
author | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-07-20 10:49:40 +0000 |
---|---|---|
committer | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-07-20 10:49:40 +0000 |
commit | 6a035cf083ef6cf6927d9e3c58cec6c4e1778569 (patch) | |
tree | fa52756250c47cddd2c800c7354eae358f8d0631 /frontends/php/graphs.php | |
parent | 2691ad6741639192c107509983aa42a0fcd39141 (diff) | |
download | zabbix-6a035cf083ef6cf6927d9e3c58cec6c4e1778569.tar.gz zabbix-6a035cf083ef6cf6927d9e3c58cec6c4e1778569.tar.xz zabbix-6a035cf083ef6cf6927d9e3c58cec6c4e1778569.zip |
- developed group functionality for graphs (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@3069 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/graphs.php')
-rw-r--r-- | frontends/php/graphs.php | 88 |
1 files changed, 83 insertions, 5 deletions
diff --git a/frontends/php/graphs.php b/frontends/php/graphs.php index 92a735d2..5e3d19c7 100644 --- a/frontends/php/graphs.php +++ b/frontends/php/graphs.php @@ -32,6 +32,9 @@ "groupid"=> array(T_ZBX_INT, O_OPT, NULL, DB_ID, NULL), "hostid"=> array(T_ZBX_INT, O_OPT, NULL, DB_ID, NULL), + "copy_type" =>array(T_ZBX_INT, O_OPT, P_SYS, IN("0,1"),'isset({copy})'), + "copy_mode" =>array(T_ZBX_INT, O_OPT, P_SYS, IN("0"),NULL), + "graphid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, '{form}=="update"'), "name"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, 'isset({save})'), "width"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,65535), 'isset({save})'), @@ -43,12 +46,17 @@ "showworkperiod"=> array(T_ZBX_INT, O_OPT, NULL, IN("1"), NULL), "showtriggers"=> array(T_ZBX_INT, O_OPT, NULL, IN("1"), NULL), + "group_graphid"=> array(T_ZBX_INT, O_OPT, NULL, DB_ID, NULL), + "copy_targetid"=> array(T_ZBX_INT, O_OPT, NULL, DB_ID, NULL), + "filter_groupid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, 'isset({copy})&&{copy_type}==0'), /* actions */ "save"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL), + "copy"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL), "delete"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL), "cancel"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL), /* other */ "form"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL), + "form_copy_to"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL), "form_refresh"=> array(T_ZBX_INT, O_OPT, NULL, NULL, NULL) ); @@ -119,6 +127,54 @@ } show_messages($result, S_GRAPH_DELETED, S_CANNOT_DELETE_GRAPH); } + elseif(isset($_REQUEST["delete"])&&isset($_REQUEST["group_graphid"])) + { + foreach($_REQUEST["group_graphid"] as $id) + { + $graph=get_graph_by_graphid($id); + if($graph["templateid"]<>0) continue; + $result=delete_graph($id); + } + show_messages(TRUE, S_ITEMS_DELETED, S_CANNOT_DELETE_ITEMS); + } + elseif(isset($_REQUEST["copy"])&&isset($_REQUEST["group_graphid"])&&isset($_REQUEST["form_copy_to"])) + { + if(isset($_REQUEST['copy_targetid']) && $_REQUEST['copy_targetid'] > 0 && isset($_REQUEST['copy_type'])) + { + if(0 == $_REQUEST['copy_type']) + { /* hosts */ + $hosts_ids = $_REQUEST['copy_targetid']; + } + else + { /* groups */ + $hosts_ids = array(); + $group_ids = ""; + foreach($_REQUEST['copy_targetid'] as $group_id) + { + $group_ids .= $group_id.','; + } + $group_ids = trim($group_ids,','); + + $db_hosts = DBselect('select distinct h.hostid from hosts h, hosts_groups hg'. + ' where h.hostid=hg.hostid and hg.groupid in ('.$group_ids.')'); + while($db_host = DBfetch($db_hosts)) + { + array_push($hosts_ids, $db_host['hostid']); + } + } + foreach($_REQUEST["group_graphid"] as $graph_id) + foreach($hosts_ids as $host_id) + { + copy_graph_to_host($graph_id, $host_id, true); + } + unset($_REQUEST["form_copy_to"]); + } + else + { + error('No target selection.'); + } + show_messages(); + } ?> <?php $form = new CForm(); @@ -127,11 +183,15 @@ show_table_header(S_CONFIGURATION_OF_GRAPHS_BIG,$form); echo BR; - if(isset($_REQUEST["form"])) + if(isset($_REQUEST["form_copy_to"]) && isset($_REQUEST["group_graphid"])) + { + insert_copy_elements_to_forms("group_graphid"); + } + else if(isset($_REQUEST["form"])) { insert_graph_form(); } else { -/* HEADER */ +/* Table HEADER */ if(isset($_REQUEST["graphid"])&&($_REQUEST["graphid"]==0)) { unset($_REQUEST["graphid"]); @@ -196,8 +256,15 @@ show_header2(S_GRAPHS_BIG, $form); /* TABLE */ + $form = new CForm(); + $form->SetName('graphs'); + $form->AddVar('hostid',$_REQUEST["hostid"]); + $table = new CTableInfo(S_NO_GRAPHS_DEFINED); - $table->setHeader(array(S_ID, + $table->setHeader(array( + array( new CCheckBox("all_graphs",NULL, + "CheckAll('".$form->GetName()."','all_graphs');"), + S_ID), $_REQUEST["hostid"] != 0 ? NULL : S_HOSTS, S_NAME,S_WIDTH,S_HEIGHT,S_GRAPH)); if($_REQUEST["hostid"] > 0) @@ -260,8 +327,10 @@ $edit = SPACE; } + $chkBox = new CCheckBox("group_graphid[]",NULL,NULL,$row["graphid"]); + if($row["templateid"] > 0) $chkBox->SetEnabled(false); $table->AddRow(array( - $row["graphid"], + array($chkBox, $row["graphid"]), $host_list, $name, $row["width"], @@ -269,7 +338,16 @@ $edit )); } - $table->show(); + + $footerButtons = array(); + array_push($footerButtons, new CButton('delete','Delete selected', + "return Confirm('".S_DELETE_SELECTED_ITEMS_Q."');")); + array_push($footerButtons, SPACE); + array_push($footerButtons, new CButton('form_copy_to','Copy selected to ...')); + $table->SetFooter(new CCol($footerButtons)); + + $form->AddItem($table); + $form->Show(); } ?> |