diff options
Diffstat (limited to 'frontends/php')
-rw-r--r-- | frontends/php/graphs.php | 88 | ||||
-rw-r--r-- | frontends/php/include/classes/clink.inc.php | 2 | ||||
-rw-r--r-- | frontends/php/include/classes/ctag.inc.php | 2 | ||||
-rw-r--r-- | frontends/php/include/classes/cvar.inc.php | 2 | ||||
-rw-r--r-- | frontends/php/include/config.inc.php | 1 | ||||
-rw-r--r-- | frontends/php/include/forms.inc.php | 2 | ||||
-rw-r--r-- | frontends/php/include/graphs.inc.php | 2 | ||||
-rw-r--r-- | frontends/php/include/triggers.inc.php | 11 | ||||
-rw-r--r-- | frontends/php/items.php | 14 | ||||
-rw-r--r-- | frontends/php/triggers.php | 16 |
10 files changed, 113 insertions, 27 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(); } ?> diff --git a/frontends/php/include/classes/clink.inc.php b/frontends/php/include/classes/clink.inc.php index 8435092f..0493076c 100644 --- a/frontends/php/include/classes/clink.inc.php +++ b/frontends/php/include/classes/clink.inc.php @@ -44,7 +44,7 @@ } function SetUrl($value) { - $this->options['href'] = $value; + parent::AddOption('href', $value); } function SetTarget($value=NULL) { diff --git a/frontends/php/include/classes/ctag.inc.php b/frontends/php/include/classes/ctag.inc.php index 7b37e14d..c0ac82e1 100644 --- a/frontends/php/include/classes/ctag.inc.php +++ b/frontends/php/include/classes/ctag.inc.php @@ -84,7 +84,9 @@ { $res = $this->tag_start.'<'.$this->tagname; foreach($this->options as $key => $value) + { $res .= ' '.$key.'="'.$value.'"'; + } $res .= ($this->paired=='yes') ? '>' : '/>'; return $res; } diff --git a/frontends/php/include/classes/cvar.inc.php b/frontends/php/include/classes/cvar.inc.php index 79a136b4..7a86d0bf 100644 --- a/frontends/php/include/classes/cvar.inc.php +++ b/frontends/php/include/classes/cvar.inc.php @@ -51,7 +51,7 @@ { $this->var_container = array(); - if(null == $value) return; + if(is_null($value)) return; if(is_array($value)) { diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php index 89665dfe..6709a496 100644 --- a/frontends/php/include/config.inc.php +++ b/frontends/php/include/config.inc.php @@ -2340,6 +2340,7 @@ COpt::profiling_stop("script"); { if(frmForm.elements[i].type != 'checkbox') continue; if(frmForm.elements[i].name == chkMain) continue; + if(frmForm.elements[i].disabled == true) continue; frmForm.elements[i].checked = value; } } diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php index 732f5b79..0eb22249 100644 --- a/frontends/php/include/forms.inc.php +++ b/frontends/php/include/forms.inc.php @@ -1001,7 +1001,7 @@ $frmGItem->AddItemToBottomRow(new CButton("save",S_SAVE)); $frmGItem->AddItemToBottomRow(SPACE); - if(isset($itemid)) + if(isset($_REQUEST["gitemid"])) { $frmGItem->AddItemToBottomRow(new CButtonDelete("Delete graph element?", url_param("gitemid").url_param("graphid"))); diff --git a/frontends/php/include/graphs.inc.php b/frontends/php/include/graphs.inc.php index 6f5c00f6..88103815 100644 --- a/frontends/php/include/graphs.inc.php +++ b/frontends/php/include/graphs.inc.php @@ -498,7 +498,7 @@ $result = copy_graphitems_for_host($graphid, $new_graphid, $hostid); if(!$result) { - delete_graph($graphid); + delete_graph($new_graphid); } return $result; } diff --git a/frontends/php/include/triggers.inc.php b/frontends/php/include/triggers.inc.php index a1345428..93e91246 100644 --- a/frontends/php/include/triggers.inc.php +++ b/frontends/php/include/triggers.inc.php @@ -464,7 +464,10 @@ if($expression[$i] == '}') { $state=''; - $sql="select h.host,i.key_,f.function,f.parameter,i.itemid from items i,functions f,hosts h where functionid=$functionid and i.itemid=f.itemid and h.hostid=i.hostid"; + $sql='select h.host,i.key_,f.function,f.parameter,i.itemid'. + ' from items i,functions f,hosts h'. + ' where functionid='.$functionid.' and i.itemid=f.itemid and h.hostid=i.hostid'; + $res1=DBselect($sql); $row1=DBfetch($res1); if($html == 0) @@ -473,15 +476,17 @@ } else { + $Link = new CLink($row1["host"].":".$row1["key_"]); $item=get_item_by_itemid($row1["itemid"]); if($item["value_type"] ==0) { - $exp=$exp."{<A HREF=\"history.php?action=showgraph&itemid=".$row1["itemid"]."\">".$row1["host"].":".$row1["key_"]."</A>.<B>".$row1["function"]."(</B>".$row1["parameter"]."<B>)</B>}"; + $Link->SetUrl('history.php?action=showgraph&itemid='.$row1['itemid']); } else { - $exp=$exp."{<A HREF=\"history.php?action=showvalues&period=3600&itemid=".$row1["itemid"]."\">".$row1["host"].":".$row1["key_"]."</A>.<B>".$row1["function"]."(</B>".$row1["parameter"]."<B>)</B>}"; + $Link->SetUrl('history.php?action=showvalues&period=3600&itemid='.$row1['itemid']); } + $exp .= $Link->ToString().'.'.bold($row1["function"].'(').$row1["parameter"].bold(')'); } continue; } diff --git a/frontends/php/items.php b/frontends/php/items.php index 0ff31f24..c25543db 100644 --- a/frontends/php/items.php +++ b/frontends/php/items.php @@ -300,7 +300,7 @@ { $item = get_item_by_itemid($id); if($item["templateid"]<>0) continue; - $result2=delete_item($id); + delete_item($id); } show_messages(TRUE, S_ITEMS_DELETED, S_CANNOT_DELETE_ITEMS); } @@ -309,7 +309,7 @@ $group_itemid = $_REQUEST["group_itemid"]; foreach($group_itemid as $id) { - $result2=activate_item($id); + activate_item($id); } show_messages(TRUE, S_ITEMS_ACTIVATED, S_CANNOT_ACTIVATE_ITEMS); } @@ -318,7 +318,7 @@ $group_itemid = $_REQUEST["group_itemid"]; foreach($group_itemid as $id) { - $result2=disable_item($id); + disable_item($id); } show_messages(TRUE, S_ITEMS_DISABLED, S_CANNOT_DISABLE_ITEMS); } @@ -515,11 +515,10 @@ $applications .= $db_app["name"].", "; } + $chkBox = new CCheckBox("group_itemid[]",NULL,NULL,$db_item["itemid"]); + if($db_item["templateid"] > 0) $chkBox->SetEnabled(false); $table->AddRow(array( - array( - new CCheckBox("group_itemid[]",NULL,NULL,$db_item["itemid"]), - $db_item["itemid"] - ), + array($chkBox, $db_item["itemid"]), $description, $db_item["key_"], $db_item["delay"], @@ -544,6 +543,7 @@ array_push($footerButtons, SPACE); array_push($footerButtons, new CButton('group_task','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)); diff --git a/frontends/php/triggers.php b/frontends/php/triggers.php index 91022bf0..074846b0 100644 --- a/frontends/php/triggers.php +++ b/frontends/php/triggers.php @@ -342,14 +342,14 @@ continue; } - $description = array( - new CCheckBox( - "g_triggerid[]", /* name */ - NULL, /* checked */ - NULL, /* action */ - $row["triggerid"]), /* value */ - SPACE - ); + $chkBox = new CCheckBox( + "g_triggerid[]", /* name */ + NULL, /* checked */ + NULL, /* action */ + $row["triggerid"]); /* value */ + + if($row["templateid"] > 0) $chkBox->SetEnabled(false); + $description = array($chkBox,SPACE); if($row["templateid"] == 0) { |