diff options
| author | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-11-29 09:17:03 +0000 |
|---|---|---|
| committer | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-11-29 09:17:03 +0000 |
| commit | 25fe20d517ee1553fd569fba2f6c33ee5a9a446a (patch) | |
| tree | 74c7002f7eb1c9bd518128352a2711d1723dfa2c /frontends/php/include | |
| parent | 4df0316c5b609a2a609d9c6a6cd539ded33351d6 (diff) | |
| download | zabbix-25fe20d517ee1553fd569fba2f6c33ee5a9a446a.tar.gz zabbix-25fe20d517ee1553fd569fba2f6c33ee5a9a446a.tar.xz zabbix-25fe20d517ee1553fd569fba2f6c33ee5a9a446a.zip | |
- [DEV-55] Screen elements('graph','simple graph','plain text') are extended, added new field in DB,table 'screens_items' 'dynamic' (Artem)
git-svn-id: svn://svn.zabbix.com/trunk@5116 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
| -rw-r--r-- | frontends/php/include/config.inc.php | 55 | ||||
| -rw-r--r-- | frontends/php/include/defines.inc.php | 3 | ||||
| -rw-r--r-- | frontends/php/include/forms.inc.php | 32 | ||||
| -rw-r--r-- | frontends/php/include/graphs.inc.php | 238 | ||||
| -rw-r--r-- | frontends/php/include/hosts.inc.php | 2 | ||||
| -rw-r--r-- | frontends/php/include/html.inc.php | 6 | ||||
| -rw-r--r-- | frontends/php/include/items.inc.php | 46 | ||||
| -rw-r--r-- | frontends/php/include/locales/en_gb.inc.php | 2 | ||||
| -rw-r--r-- | frontends/php/include/screens.inc.php | 210 |
9 files changed, 404 insertions, 190 deletions
diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php index 52d69e90..5840f8c3 100644 --- a/frontends/php/include/config.inc.php +++ b/frontends/php/include/config.inc.php @@ -922,61 +922,6 @@ function TODO($msg) { echo "TODO: ".$msg.BR; } // DEBUG INFO!!! else return validate_float($str); } - # Show screen cell containing plain text values - function& get_screen_plaintext($itemid,$elements) - { - global $DB_TYPE; - - $item=get_item_by_itemid($itemid); - switch($item["value_type"]) - { - case ITEM_VALUE_TYPE_FLOAT: $history_table = "history"; break; - case ITEM_VALUE_TYPE_UINT64: $history_table = "history_uint"; break; - case ITEM_VALUE_TYPE_TEXT: $history_table = "history_text"; break; - default: $history_table = "history_str"; break; - } - - $sql="select h.clock,h.value,i.valuemapid from ".$history_table." h, items i where". - " h.itemid=i.itemid and i.itemid=$itemid order by clock desc"; - - $result=DBselect($sql,$elements); - - $table = new CTableInfo(); - $table->SetHeader(array(S_TIMESTAMP,item_description($item["description"],$item["key_"]))); - while($row=DBfetch($result)) - { - switch($item["value_type"]) - { - case ITEM_VALUE_TYPE_TEXT: - if($DB_TYPE == "ORACLE") - { - if(isset($row["value"])) - { - $row["value"] = $row["value"]->load(); - } - else - { - $row["value"] = ""; - } - } - /* do not use break */ - case ITEM_VALUE_TYPE_STR: - $value = nl2br(nbsp(htmlspecialchars($row["value"]))); - break; - - default: - $value = $row["value"]; - break; - } - - if($row["valuemapid"] > 0) - $value = replace_value_by_map($value, $row["valuemapid"]); - - $table->AddRow(array(date(S_DATE_FORMAT_YMDHMS,$row["clock"]), $value)); - } - return $table; - } - # Add event function get_event_by_eventid($eventid) diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php index a773d373..67dd6531 100644 --- a/frontends/php/include/defines.inc.php +++ b/frontends/php/include/defines.inc.php @@ -266,6 +266,9 @@ define('LOGFILE_SEVERITY_AUDIT_SUCCESS',6); define('LOGFILE_SEVERITY_AUDIT_FAILURE',7); + define('SCREEN_SIMPLE_ITEM',0); + define('SCREEN_DYNAMIC_ITEM',1); + define('SCREEN_RESOURCE_GRAPH', 0); define('SCREEN_RESOURCE_SIMPLE_GRAPH', 1); define('SCREEN_RESOURCE_MAP', 2); diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php index 484fad75..08de9df0 100644 --- a/frontends/php/include/forms.inc.php +++ b/frontends/php/include/forms.inc.php @@ -3576,27 +3576,28 @@ include_once 'include/discovery.inc.php'; $frmScr->Show(); } - function& get_screen_item_form(){ + function get_screen_item_form(){ global $USER_DETAILS; $form = new CFormTable(S_SCREEN_CELL_CONFIGURATION,'screenedit.php#form'); $form->SetHelp('web.screenedit.cell.php'); - if(isset($_REQUEST["screenitemid"])) - { - $iresult=DBSelect("select * FROM screens_items". - " WHERE screenid=".$_REQUEST["screenid"]. - " AND screenitemid=".$_REQUEST["screenitemid"]); + if(isset($_REQUEST["screenitemid"])){ + $iresult=DBSelect('SELECT * FROM screens_items'. + ' WHERE screenid='.$_REQUEST['screenid']. + ' AND screenitemid='.$_REQUEST['screenitemid'] + ); $form->AddVar("screenitemid",$_REQUEST["screenitemid"]); - } else { + } + else{ $form->AddVar("x",$_REQUEST["x"]); $form->AddVar("y",$_REQUEST["y"]); } - if(isset($_REQUEST["screenitemid"]) && !isset($_REQUEST["form_refresh"])) - { + if(isset($_REQUEST["screenitemid"]) && !isset($_REQUEST["form_refresh"])){ + $irow = DBfetch($iresult); $resourcetype = $irow["resourcetype"]; $resourceid = $irow["resourceid"]; @@ -3609,9 +3610,9 @@ include_once 'include/discovery.inc.php'; $halign = $irow["halign"]; $style = $irow["style"]; $url = $irow["url"]; + $dynamic = $irow['dynamic']; } - else - { + else{ $resourcetype = get_request("resourcetype", 0); $resourceid = get_request("resourceid", 0); $width = get_request("width", 500); @@ -3623,6 +3624,7 @@ include_once 'include/discovery.inc.php'; $halign = get_request("halign", HALIGN_DEFAULT); $style = get_request("style", 0); $url = get_request("url", ""); + $dynamic = get_request("dynamic", SCREEN_SIMPLE_ITEM); } $form->AddVar("screenid",$_REQUEST["screenid"]); @@ -3958,9 +3960,13 @@ include_once 'include/discovery.inc.php'; $form->AddRow(S_COLUMN_SPAN, new CNumericBox("colspan",$colspan,2)); $form->AddRow(S_ROW_SPAN, new CNumericBox("rowspan",$rowspan,2)); +// dynamic AddOn + if(in_array($resourcetype,array(SCREEN_RESOURCE_GRAPH,SCREEN_RESOURCE_SIMPLE_GRAPH,SCREEN_RESOURCE_PLAIN_TEXT))){ + $form->AddRow(S_DYNAMIC_ITEM, new CCheckBox("dynamic",$dynamic,null,1)); + } + $form->AddItemToBottomRow(new CButton("save",S_SAVE)); - if(isset($_REQUEST["screenitemid"])) - { + if(isset($_REQUEST["screenitemid"])){ $form->AddItemToBottomRow(SPACE); $form->AddItemToBottomRow(new CButtonDelete(null, url_param("form").url_param("screenid").url_param("screenitemid"))); diff --git a/frontends/php/include/graphs.inc.php b/frontends/php/include/graphs.inc.php index df1e621e..b4d1bde0 100644 --- a/frontends/php/include/graphs.inc.php +++ b/frontends/php/include/graphs.inc.php @@ -19,16 +19,16 @@ **/ ?> <?php - /* - * Function: graph_item_type2str - * - * Description: - * Represent integer value of graph item type into the string - * - * Author: - * Eugene Grigorjev - * - */ +/* + * Function: graph_item_type2str + * + * Description: + * Represent integer value of graph item type into the string + * + * Author: + * Eugene Grigorjev + * + */ function graph_item_type2str($type,$count=null) { switch($type){ @@ -46,16 +46,16 @@ return $type; } - /* - * Function: graph_item_drawtypes - * - * Description: - * Return available drawing types for graph item - * - * Author: - * Eugene Grigorjev - * - */ +/* + * Function: graph_item_drawtypes + * + * Description: + * Return available drawing types for graph item + * + * Author: + * Eugene Grigorjev + * + */ function graph_item_drawtypes() { return array( @@ -67,42 +67,42 @@ ); } - /* - * Function: graph_item_drawtype2str - * - * Description: - * Represent integer value of graph item drawing type into the string - * - * Author: - * Eugene Grigorjev - * - */ - function graph_item_drawtype2str($drawtype,$type=null) - { - if($type == GRAPH_ITEM_AGGREGATED) return '-'; +/* + * Function: graph_item_drawtype2str + * + * Description: + * Represent integer value of graph item drawing type into the string + * + * Author: + * Eugene Grigorjev + * + */ + function graph_item_drawtype2str($drawtype,$type=null) + { + if($type == GRAPH_ITEM_AGGREGATED) return '-'; - switch($drawtype) - { - case GRAPH_ITEM_DRAWTYPE_LINE: $drawtype = "Line"; break; - case GRAPH_ITEM_DRAWTYPE_FILLED_REGION: $drawtype = "Filled region"; break; - case GRAPH_ITEM_DRAWTYPE_BOLD_LINE: $drawtype = "Bold line"; break; - case GRAPH_ITEM_DRAWTYPE_DOT: $drawtype = "Dot"; break; - case GRAPH_ITEM_DRAWTYPE_DASHED_LINE: $drawtype = "Dashed line"; break; - default: $drawtype = S_UNKNOWN; break; - } - return $drawtype; - } + switch($drawtype) + { + case GRAPH_ITEM_DRAWTYPE_LINE: $drawtype = "Line"; break; + case GRAPH_ITEM_DRAWTYPE_FILLED_REGION: $drawtype = "Filled region"; break; + case GRAPH_ITEM_DRAWTYPE_BOLD_LINE: $drawtype = "Bold line"; break; + case GRAPH_ITEM_DRAWTYPE_DOT: $drawtype = "Dot"; break; + case GRAPH_ITEM_DRAWTYPE_DASHED_LINE: $drawtype = "Dashed line"; break; + default: $drawtype = S_UNKNOWN; break; + } + return $drawtype; + } - /* - * Function: graph_item_calc_fnc2str - * - * Description: - * Represent integer value of calculation function into the string - * - * Author: - * Eugene Grigorjev - * - */ +/* + * Function: graph_item_calc_fnc2str + * + * Description: + * Represent integer value of calculation function into the string + * + * Author: + * Eugene Grigorjev + * + */ function graph_item_calc_fnc2str($calc_fnc, $type=null) { if($type == GRAPH_ITEM_AGGREGATED) return '-'; @@ -161,7 +161,7 @@ * Return the time of the 1st apearance of items included in graph in trends * * Author: - * Artem Suharev + * Aly * */ function get_min_itemclock_by_graphid($graphid){ @@ -182,7 +182,7 @@ * Return the time of the 1st apearance of item in trends * * Author: - * Artem Suharev + * Aly * */ function get_min_itemclock_by_itemid($itemid){ @@ -236,36 +236,44 @@ return DBselect("SELECT * FROM graphs WHERE templateid=$templateid"); } - /* - * Function: get_same_graphitems_for_host - * - * Description: - * Replace items for specified host - * - * Author: - * Eugene Grigorjev - * - * Comments: !!! Don't forget sync code with C !!! - * - */ - function get_same_graphitems_for_host($gitems, $dest_hostid) +/* + * Function: get_same_graphitems_for_host + * + * Description: + * Replace items for specified host + * + * Author: + * Eugene Grigorjev + * + * Comments: !!! Don't forget sync code with C !!! + * Only PHP: + * $error= true : rise Error if item doesn't exists(error generated), false: special processing (NO error generated) + */ + function get_same_graphitems_for_host($gitems, $dest_hostid, $error=true) { $result = array(); foreach($gitems as $gitem) { - if ( !($db_item = DBfetch(DBselect('select src.itemid from items src, items dest '. - ' where dest.itemid='.$gitem['itemid']. - ' and src.key_=dest.key_ and src.hostid='.$dest_hostid))) ) - { - + $sql = 'SELECT src.itemid '. + ' FROM items src, items dest '. + ' WHERE dest.itemid='.zbx_dbstr($gitem['itemid']). + ' AND src.key_=dest.key_ '. + ' AND src.hostid='.$dest_hostid; + $db_item = DBfetch(DBselect($sql)); + if (!$db_item && $error){ $item = get_item_by_itemid($gitem['itemid']); $host = get_host_by_hostid($dest_hostid); error('Missed key "'.$item['key_'].'" for host "'.$host['host'].'"'); return false; } - - $gitem['itemid'] = $db_item['itemid']; + else if(!$db_item){ + continue; +// $gitem['itemid'] = 0; + } + else{ + $gitem['itemid'] = $db_item['itemid']; + } $result[] = $gitem; } @@ -922,4 +930,82 @@ return; } + + /* + * Function: + * make_array_from_gitems + * + * Description: + * Creates array with items params for preapare_url function + * + * Author: + * Aly + * + * Comments + * + */ + function make_url_from_gitems($gitems){ + + $gurl=array(); + $ifields = array( + 'itemid' => 1, + 'drawtype' => 1, + 'sortorder' => 1, + 'color' => 1, + 'yaxisside' => 1, + 'calc_fnc' => 1, + 'type' => 1, + 'periods_cnt'=>1 + ); + + foreach($gitems as $gitem){ + foreach($gitem as $name => $value){ + if(isset($ifields[$name])){ + $gurl['items['.$gitem['itemid'].']['.$name.']']=$value; + } + } + } + + return prepare_url($gurl); + } + + /* + * Function: + * make_array_from_graphid + * + * Description: + * Creates array with graph params for preapare_url function + * + * Author: + * Aly + * + * Comments + * $full= false: for screens(WITHOUT width && height), true=all params + */ + function make_url_from_graphid($graphid,$full=false){ + + $gurl=array(); + if($full){ + $gparams = array(); + } + else{ + $gparams = array( + 'height'=> 1, + 'width' => 1 + ); + } + + $graph=get_graph_by_graphid($graphid); + if($graph){ + foreach($graph as $name => $value){ + if(!is_numeric($name) && !isset($gparams[$name])) $gurl[$name]=$value; + } + } + + $url = prepare_url($gurl); + if(!empty($url)){ + $url=((($gurl['graphtype']==GRAPH_TYPE_PIE) || ($gurl['graphtype']==GRAPH_TYPE_EXPLODED))?'chart7.php?':'chart3.php?').trim($url,'&'); + } + return $url; + } ?> diff --git a/frontends/php/include/hosts.inc.php b/frontends/php/include/hosts.inc.php index 2b393934..d245d3e1 100644 --- a/frontends/php/include/hosts.inc.php +++ b/frontends/php/include/hosts.inc.php @@ -493,7 +493,7 @@ require_once "include/items.inc.php"; return false; } - function get_host_by_itemid($itemid) + function get_host_by_itemid($itemid) { $sql="select h.* from hosts h, items i where i.hostid=h.hostid and i.itemid=$itemid"; $result=DBselect($sql); diff --git a/frontends/php/include/html.inc.php b/frontends/php/include/html.inc.php index 49204077..7233eb6e 100644 --- a/frontends/php/include/html.inc.php +++ b/frontends/php/include/html.inc.php @@ -65,12 +65,12 @@ if(isset($_REQUEST[$var])&&$_REQUEST[$var]==$value) $selected = "selected"; } - return "<option value=\"$value\" $selected>$label"; + return '<option value="'.$value.'" '.$selected.'>'.$label; } function form_input($name, $value, $size) { - return "<input class=\"biginput\" name=\"$name\" size=$size value=\"$value\">"; + return '<input class="'.biginput.'" name="'.$name.'" size="'.$size.'" value="'.$value.'">'; } function form_textarea($name, $value, $cols, $rows) @@ -92,7 +92,7 @@ } } - function prepare_url(&$var, $varname) + function prepare_url(&$var, $varname=null) { $result = ""; diff --git a/frontends/php/include/items.inc.php b/frontends/php/include/items.inc.php index d0d0dd96..e2c4365b 100644 --- a/frontends/php/include/items.inc.php +++ b/frontends/php/include/items.inc.php @@ -724,6 +724,52 @@ error("No item with itemid=[$itemid]"); return FALSE; } + +/* + * Function: get_same_items_for_host + * + * Description: + * Replace items for specified host + * + * Author: + * Aly + * + * Comments: + * $error= true : rise Error if item doesn't exists(error generated), false: special processing (NO error generated) + */ + function get_same_item_for_host($item,$dest_hostid, $error=true){ + + if(!is_array($item)){ + $itemid = $item; + } + else if(isset($item['itemid'])){ + $itemid = $item['itemid']; + } + + if(isset($itemid)){ + $sql = 'SELECT src.itemid '. + ' FROM items src, items dest '. + ' WHERE dest.itemid='.zbx_dbstr($itemid). + ' AND src.key_=dest.key_ '. + ' AND src.hostid='.$dest_hostid; + + $db_item = DBfetch(DBselect($sql)); + if (!$db_item && $error){ + $item = get_item_by_itemid($db_item['itemid']); + $host = get_host_by_hostid($dest_hostid); + error('Missed key "'.$item['key_'].'" for host "'.$host['host'].'"'); + } + else{ + if(is_array($item)){ + return get_item_by_itemid($db_item['itemid']); + } + else{ + return $db_item['itemid']; + } + } + } + return false; + } /****************************************************************************** * * diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php index 145dd274..097e1f9f 100644 --- a/frontends/php/include/locales/en_gb.inc.php +++ b/frontends/php/include/locales/en_gb.inc.php @@ -497,6 +497,7 @@ 'S_ITEM_ADDED'=> 'Item added', 'S_ITEM_UPDATED'=> 'Item updated', 'S_ITEMS_UPDATED'=> 'Items updated', + 'S_ITEM_NOT_EXISTS'=> 'Item not exists', 'S_SORT_ORDER_UPDATED'=> 'Sort order updated', 'S_CANNOT_UPDATE_SORT_ORDER'=> 'Cannot update sort order', 'S_DISPLAYED_PARAMETERS_BIG'=> 'DISPLAYED PARAMETERS', @@ -1018,6 +1019,7 @@ 'S_HEIGHT'=> 'Height', 'S_CREATE_SCREEN'=> 'Create Screen', 'S_EDIT'=> 'Edit', + 'S_DYNAMIC_ITEM'=> 'Dynamic item', 'S_DIMENSION_COLS_ROWS'=> 'Dimension (cols x rows)', 'S_SLIDESHOWS'=> 'Slide shows', diff --git a/frontends/php/include/screens.inc.php b/frontends/php/include/screens.inc.php index 4cbe09bf..115c439a 100644 --- a/frontends/php/include/screens.inc.php +++ b/frontends/php/include/screens.inc.php @@ -106,42 +106,41 @@ return DBexecute($sql); } - function delete_screen($screenid) - { - $result=DBexecute("delete from screens_items where screenid=$screenid"); - if(!$result) return $result; - - $result=DBexecute("delete from screens_items where resourceid=$screenid and resourcetype=".SCREEN_RESOURCE_SCREEN); - if(!$result) return $result; - - $result=DBexecute('delete from slides where screenid='.$screenid); - if(!$result) return $result; + function delete_screen($screenid){ + $result=DBexecute("delete from screens_items where screenid=$screenid"); + if(!$result) return $result; + + $result=DBexecute("delete from screens_items where resourceid=$screenid and resourcetype=".SCREEN_RESOURCE_SCREEN); + if(!$result) return $result; - return DBexecute("delete from screens where screenid=$screenid"); + $result=DBexecute('delete from slides where screenid='.$screenid); + if(!$result) return $result; + + return DBexecute("delete from screens where screenid=$screenid"); } - function add_screen_item($resourcetype,$screenid,$x,$y,$resourceid,$width,$height,$colspan,$rowspan,$elements,$valign,$halign,$style,$url) - { - $sql="delete from screens_items where screenid=$screenid and x=$x and y=$y"; - DBexecute($sql); - $screenitemid=get_dbid("screens_items","screenitemid"); - $result=DBexecute("insert into screens_items (screenitemid,resourcetype,screenid,x,y,resourceid,width,height,". - " colspan,rowspan,elements,valign,halign,style,url) ". - " values ($screenitemid,$resourcetype,$screenid,$x,$y,$resourceid,". - " $width,$height,$colspan,$rowspan,$elements,$valign,$halign,$style,". - zbx_dbstr($url).")"); - - if(!$result) - return $result; - + function add_screen_item($resourcetype,$screenid,$x,$y,$resourceid,$width,$height,$colspan,$rowspan,$elements,$valign,$halign,$style,$url,$dynamic){ + $sql="DELETE FROM screens_items WHERE screenid=$screenid and x=$x and y=$y"; + DBexecute($sql); + + $screenitemid=get_dbid("screens_items","screenitemid"); + $result=DBexecute('INSERT INTO screens_items '. + '(screenitemid,resourcetype,screenid,x,y,resourceid,width,height,'. + ' colspan,rowspan,elements,valign,halign,style,url) '. + ' VALUES '. + "($screenitemid,$resourcetype,$screenid,$x,$y,$resourceid,$width,$height,$colspan,". + "$rowspan,$elements,$valign,$halign,$style,".zbx_dbstr($url).",$dynamic)"); + + if(!$result) return $result; return $screenitemid; } - function update_screen_item($screenitemid,$resourcetype,$resourceid,$width,$height,$colspan,$rowspan,$elements,$valign,$halign,$style,$url) - { - return DBexecute("update screens_items set resourcetype=$resourcetype,resourceid=$resourceid,". - "width=$width,height=$height,colspan=$colspan,rowspan=$rowspan,elements=$elements,valign=$valign,". - "halign=$halign,style=$style,url=".zbx_dbstr($url)." where screenitemid=$screenitemid"); + function update_screen_item($screenitemid,$resourcetype,$resourceid,$width,$height,$colspan,$rowspan,$elements,$valign,$halign,$style,$url,$dynamic){ + return DBexecute("UPDATE screens_items SET ". + "resourcetype=$resourcetype,"."resourceid=$resourceid,"."width=$width,". + "height=$height,colspan=$colspan,rowspan=$rowspan,elements=$elements,". + "valign=$valign,halign=$halign,style=$style,url=".zbx_dbstr($url).",dynamic=$dynamic". + " WHERE screenitemid=$screenitemid"); } function delete_screen_item($screenitemid) @@ -162,8 +161,7 @@ return FALSE; } - function check_screen_recursion($mother_screenid, $child_screenid) - { + function check_screen_recursion($mother_screenid, $child_screenid){ if($mother_screenid == $child_screenid) return TRUE; $db_scr_items = DBselect("select resourceid from screens_items where". @@ -227,7 +225,7 @@ access_deny(); if(is_null($effectiveperiod)) - $effectiveperiod = 3600; + $effectiveperiod = ZBX_MIN_PERIOD; $result=DBselect('SELECT name,hsize,vsize FROM screens WHERE screenid='.$screenid); $row=DBfetch($result); @@ -289,11 +287,11 @@ $halign = $irow["halign"]; $style = $irow["style"]; $url = $irow["url"]; + $dynamic = $irow['dynamic']; } else { $screenitemid = 0; - $screenitemid = 0; $resourcetype = 0; $resourceid = 0; $width = 0; @@ -305,6 +303,7 @@ $halign = HALIGN_DEFAULT; $style = 0; $url = ""; + $dynamic = 0; } if($editmode == 1 && $screenitemid!=0) @@ -335,7 +334,7 @@ $graphtype = GRAPH_TYPE_NORMAL; $yaxis = 0; -// GRAPH & ZOOM featers +// GRAPH & ZOOM features $sql = 'SELECT MAX(g.graphid) as graphid, MAX(g.graphtype) as graphtype, MIN(gi.yaxisside) as yaxissidel, MAX(gi.yaxisside) as yaxissider'. ' FROM graphs g, graphs_items gi '. ' WHERE g.graphid='.$resourceid. @@ -361,18 +360,40 @@ $shiftXright = 60; } //------------- +// Host feature + if(($dynamic == SCREEN_DYNAMIC_ITEM) && isset($_REQUEST['hostid']) && ($_REQUEST['hostid']>0)){ + $def_items = array(); + $di_res = get_graphitems_by_graphid($resourceid); + while( $gitem = DBfetch($di_res)){ + $def_items[] = $gitem; + }; + + $url=''; + if($new_items = get_same_graphitems_for_host($def_items, $_REQUEST['hostid'], false)){ + $url.= make_url_from_gitems($new_items); + } + + $url= make_url_from_graphid($resourceid,false).$url; + } +//------------- if(($graphtype == GRAPH_TYPE_PIE) || ($graphtype == GRAPH_TYPE_EXPLODED)){ + if(($dynamic==SCREEN_SIMPLE_ITEM) || empty($url)){ + $url="chart6.php?graphid=$resourceid"; + } $item = new CLink( - new CImg("chart6.php?graphid=$resourceid&width=$width&height=$height"."&period=$effectiveperiod".url_param("stime")), + new CImg($url."&width=$width&height=$height"."&period=$effectiveperiod".url_param("stime")), $action ); } else { - + if(($dynamic==SCREEN_SIMPLE_ITEM) || empty($url)){ + $url="chart2.php?graphid=$resourceid"; + } + $dom_graph_id = 'graph_'.$screenitemid.'_'.$resourceid; - $g_img = new CImg("chart2.php?graphid=$resourceid&width=$width&height=$height"."&period=$effectiveperiod".url_param("stime")); + $g_img = new CImg($url."&width=$width&height=$height"."&period=$effectiveperiod".url_param("stime")); $g_img->AddOPtion('id',$dom_graph_id); $item = new CLink($g_img,$action); @@ -399,9 +420,19 @@ $action = "history.php?action=showgraph&itemid=$resourceid". url_param("period").url_param("inc").url_param("dec"); +// Host feature + if(($dynamic == SCREEN_DYNAMIC_ITEM) && isset($_REQUEST['hostid']) && ($_REQUEST['hostid']>0)){ + if($newitemid = get_same_item_for_host($resourceid,$_REQUEST['hostid'],false)){ + $resourceid = $newitemid; + } + else{ + $resourceid=''; + } + } +//------------- + $url = (empty($resourceid))?'chart3.php?':"chart.php?itemid=$resourceid&"; $item = new CLink( - new CImg("chart.php?itemid=$resourceid&width=$width&height=$height". - "&period=$effectiveperiod".url_param("stime")), + new CImg($url."width=$width&height=$height"."&period=$effectiveperiod".url_param("stime")), $action ); } @@ -418,8 +449,17 @@ $item = new CLink($image_map, $action); } } - elseif( ($screenitemid!=0) && ($resourcetype==SCREEN_RESOURCE_PLAIN_TEXT) ) - { + elseif( ($screenitemid!=0) && ($resourcetype==SCREEN_RESOURCE_PLAIN_TEXT) ){ +// Host feature + if(($dynamic == SCREEN_DYNAMIC_ITEM) && isset($_REQUEST['hostid']) && ($_REQUEST['hostid']>0)){ + if($newitemid = get_same_item_for_host($resourceid,$_REQUEST['hostid'],false)){ + $resourceid = $newitemid; + } + else{ + $resourceid=0; + } + } +//------------- $item = array(get_screen_plaintext($resourceid,$elements)); if($editmode == 1) array_push($item,new CLink(S_CHANGE,$action)); } @@ -596,5 +636,91 @@ DBexecute('delete from slides where slideshowid='.$slideshowid) ); } + + + # Show screen cell containing plain text values + function get_screen_plaintext($itemid,$elements){ + + if($itemid == 0){ + $table = new CTableInfo(S_ITEM_NOT_EXISTS); + $table->SetHeader(array(S_TIMESTAMP,S_ITEM)); + return $table; + } + + global $DB_TYPE; + + $item=get_item_by_itemid($itemid); + switch($item["value_type"]) + { + case ITEM_VALUE_TYPE_FLOAT: $history_table = "history"; break; + case ITEM_VALUE_TYPE_UINT64: $history_table = "history_uint"; break; + case ITEM_VALUE_TYPE_TEXT: $history_table = "history_text"; break; + default: $history_table = "history_str"; break; + } + + $sql='SELECT h.clock,h.value,i.valuemapid '. + ' FROM '.$history_table.' h, items i '. + ' WHERE h.itemid=i.itemid '. + ' AND i.itemid='.$itemid. + ' ORDER BY h.clock DESC'; + + $result=DBselect($sql,$elements); + + $host = get_host_by_itemid($itemid); + + $table = new CTableInfo(); + $table->SetHeader(array(S_TIMESTAMP,item_description($host['host'].': '.$item["description"],$item["key_"]))); + + while($row=DBfetch($result)){ + switch($item["value_type"]) + { + case ITEM_VALUE_TYPE_TEXT: + if($DB_TYPE == "ORACLE") + { + if(isset($row["value"])) + { + $row["value"] = $row["value"]->load(); + } + else + { + $row["value"] = ""; + } + } + /* do not use break */ + case ITEM_VALUE_TYPE_STR: + $value = nl2br(nbsp(htmlspecialchars($row["value"]))); + break; + + default: + $value = $row["value"]; + break; + } + + if($row["valuemapid"] > 0) + $value = replace_value_by_map($value, $row["valuemapid"]); + + $table->AddRow(array(date(S_DATE_FORMAT_YMDHMS,$row["clock"]), $value)); + } + return $table; + } +/* +* Function: +* check_dynamic_items +* +* Description: +* Check if in screen are dynamic items, if so return TRUE, esle FALSE +* +* Author: +* Aly +*/ + + function check_dynamic_items($screenid){ + $sql = 'SELECT screenitemid '. + ' FROM screens_items '. + ' WHERE screenid='.$screenid. + ' AND dynamic='.SCREEN_DYNAMIC_ITEM; + if(DBfetch(DBselect($sql,1))) return TRUE; + return FALSE; + } ?> |
