diff options
| author | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-10-23 07:34:27 +0000 |
|---|---|---|
| committer | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-10-23 07:34:27 +0000 |
| commit | 28a09ed13e41ddbe5e30d63e92a1f5fb3395ef89 (patch) | |
| tree | 8281ccd48964ee0dd11c5ea689091fa3cef706fb /frontends/php/include/classes | |
| parent | 495799b2aa61aab23d74d7faa110a0cd09d59bf0 (diff) | |
- developed group permission system (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@3371 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include/classes')
| -rw-r--r-- | frontends/php/include/classes/cbutton.inc.php | 22 | ||||
| -rw-r--r-- | frontends/php/include/classes/cformtable.inc.php | 13 | ||||
| -rw-r--r-- | frontends/php/include/classes/clink.inc.php | 2 | ||||
| -rw-r--r-- | frontends/php/include/classes/clist.inc.php (renamed from frontends/php/include/classes/cpassbox.inc.php) | 45 | ||||
| -rw-r--r-- | frontends/php/include/classes/clistbox.inc.php | 25 | ||||
| -rw-r--r-- | frontends/php/include/classes/cserverinfo.mod.php | 2 | ||||
| -rw-r--r-- | frontends/php/include/classes/ctable.inc.php | 17 | ||||
| -rw-r--r-- | frontends/php/include/classes/ctag.inc.php | 55 | ||||
| -rw-r--r-- | frontends/php/include/classes/ctriggerinfo.mod.php | 87 | ||||
| -rw-r--r-- | frontends/php/include/classes/cvar.inc.php | 11 | ||||
| -rw-r--r-- | frontends/php/include/classes/graph.inc.php | 17 |
11 files changed, 197 insertions, 99 deletions
diff --git a/frontends/php/include/classes/cbutton.inc.php b/frontends/php/include/classes/cbutton.inc.php index 22104147..ce63f5ce 100644 --- a/frontends/php/include/classes/cbutton.inc.php +++ b/frontends/php/include/classes/cbutton.inc.php @@ -27,7 +27,7 @@ parent::CTag('input','no'); $this->tag_body_start = ''; $this->options['type'] = 'submit'; - $this->options['value'] = $caption; + $this->AddOption('value', $caption); // $this->options["type"] = "button"; $this->options['class'] = 'button'; $this->SetName($name); @@ -36,11 +36,11 @@ } function SetAction($value='submit()', $event='onClick') { - $this->options[$event] = $value; + $this->AddOption($event, $value); } function SetTitle($value='button title') { - $this->options['title'] = $value; + $this->AddOption('title', $value); } function SetAccessKey($value='B') { @@ -48,7 +48,7 @@ if(!isset($this->options['title'])) $this->SetTitle($this->options['value'].' [Alt+'.$value.']'); - return $this->options['accessKey'] = $value; + return $this->AddOption('accessKey', $value); } } @@ -82,12 +82,14 @@ var $vars; var $msg; var $name; + var $do_redirect; - function CButtonQMessage($name, $caption, $msg=NULL, $vars=NULL){ + function CButtonQMessage($name, $caption, $msg=NULL, $vars=NULL, $do_redirect=true){ $this->name = $name; parent::CButton($name,$caption); $this->SetMessage($msg); $this->SetVars($vars); + $this->do_redirect = $do_redirect; } function SetVars($value=NULL){ if(!is_string($value) && !is_null($value)){ @@ -113,7 +115,15 @@ global $page; $confirmation = "Confirm('".$this->msg."')"; - $redirect = "Redirect('".$page["file"]."?".$this->name."=1".$this->vars."')"; + + if($this->do_redirect) + { + $redirect = "Redirect('".$page["file"]."?".$this->name."=1".$this->vars."')"; + } + else + { + $redirect = 'true'; + } return parent::SetAction("if(".$confirmation.") return ".$redirect."; else return false;"); } diff --git a/frontends/php/include/classes/cformtable.inc.php b/frontends/php/include/classes/cformtable.inc.php index e2be6439..a0bf889d 100644 --- a/frontends/php/include/classes/cformtable.inc.php +++ b/frontends/php/include/classes/cformtable.inc.php @@ -56,7 +56,7 @@ $this->AddVar($form_variable, get_request($form_variable, 1)); $this->AddVar('form_refresh',get_request('form_refresh',0)+1); - $this->bottom_items = new CCol(NULL,'form_row_last'); + $this->bottom_items = new CCol(SPACE,'form_row_last'); $this->bottom_items->SetColSpan(2); } function SetAction($value) @@ -127,6 +127,9 @@ if(is_string($item1)) $item1=nbsp($item1); + if(is_null($item1)) $item1 = SPACE; + if(is_null($item2)) $item2 = SPACE; + $row = new CRow(array( new CCol($item1,'form_row_l'), new CCol($item2,'form_row_r') @@ -137,9 +140,15 @@ } function AddSpanRow($value, $class=NULL) { + if(is_string($value)) + $item1=nbsp($value); + + if(is_null($value)) $value = SPACE; + if(is_null($class)) $class = 'form_row_c'; + $col = new CCol($value,$class); $col->SetColSpan(2); - array_push($this->center_items,new CRow($col,$class)); + array_push($this->center_items,new CRow($col)); } function AddItemToBottomRow($value) { diff --git a/frontends/php/include/classes/clink.inc.php b/frontends/php/include/classes/clink.inc.php index 78c358eb..374453ca 100644 --- a/frontends/php/include/classes/clink.inc.php +++ b/frontends/php/include/classes/clink.inc.php @@ -40,7 +40,7 @@ if(is_null($value)) return $this->options['action'] = $page['file']; - return $this->options['onClick'] = $value; + return $this->options['onClick'] = htmlspecialchars($value); } function SetUrl($value) { diff --git a/frontends/php/include/classes/cpassbox.inc.php b/frontends/php/include/classes/clist.inc.php index 12a198cb..c5eb9b57 100644 --- a/frontends/php/include/classes/cpassbox.inc.php +++ b/frontends/php/include/classes/clist.inc.php @@ -19,9 +19,48 @@ **/ ?> <?php + class CListItem extends CTag + { +/* public */ + function CListItem($value) + { + parent::CTag('li','yes'); -// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -// TODO REMOVE THIS FILE FROM CVS -// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + $this->AddItem($value); + } + } + + class CList extends CTag + { +/* public */ + function CList($value=NULL,$class=NULL) + { + parent::CTag('ul','yes'); + $this->tag_end = ''; + $this->AddItem($value); + $this->SetClass($class); + } + function PrepareItem($value=NULL) + { + if(!is_null($value)) + { + $value = new CListItem($value); + } + return $value; + } + + function AddItem($value) + { + if(is_array($value)) + { + foreach($value as $el) + parent::AddItem($this->PrepareItem($el)); + } + else + { + parent::AddItem($this->PrepareItem($value)); + } + } + } ?> diff --git a/frontends/php/include/classes/clistbox.inc.php b/frontends/php/include/classes/clistbox.inc.php deleted file mode 100644 index 311535b7..00000000 --- a/frontends/php/include/classes/clistbox.inc.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php -/* -** ZABBIX -** Copyright (C) 2000-2005 SIA Zabbix -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -**/ -?> -<?php -// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -// TODO REMOVE THIS FILE FROM CVS !!! -// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -?> diff --git a/frontends/php/include/classes/cserverinfo.mod.php b/frontends/php/include/classes/cserverinfo.mod.php index 4315c701..3ebe1765 100644 --- a/frontends/php/include/classes/cserverinfo.mod.php +++ b/frontends/php/include/classes/cserverinfo.mod.php @@ -66,7 +66,7 @@ new CSpan($status["triggers_count_unknown"],"unknown"),"/", new CSpan($status["triggers_count_off"],"off"),"]" ))); - $this->AddRow(S_NUMBER_OF_ALARMS.": ".$status["alarms_count"]); + $this->AddRow(S_NUMBER_OF_ALARMS.": ".$status["events_count"]); $this->AddRow(S_NUMBER_OF_ALERTS.": ".$status["alerts_count"]); return parent::BodyToString(); diff --git a/frontends/php/include/classes/ctable.inc.php b/frontends/php/include/classes/ctable.inc.php index a0ab239c..10bb4d87 100644 --- a/frontends/php/include/classes/ctable.inc.php +++ b/frontends/php/include/classes/ctable.inc.php @@ -145,8 +145,7 @@ } elseif(is_a($item,'crow')) { - if(isset($rowClass)) - $item->options['class'] = $rowClass; + $item->SetClass($rowClass); } else { @@ -154,9 +153,9 @@ } if(!isset($item->options['class'])) { - $item->options['class'] = ($this->rownum % 2) ? - $this->evenRowClass: - $this->oddRowClass; + $item->SetClass(($this->rownum % 2) ? + $this->oddRowClass: + $this->evenRowClass); }/**/ return $item->ToString(); } @@ -166,7 +165,7 @@ if(is_a($value,'crow')) { - if(isset($class)) $value->SetClass($class); + if(!is_null($class)) $value->SetClass($class); }else{ $value = new CRow($value,$class); } @@ -181,13 +180,14 @@ } function AddRow($item,$rowClass=NULL) { + $item = $this->AddItem($this->PrepareRow($item,$rowClass)); ++$this->rownum; - return $this->AddItem($this->PrepareRow($item,$rowClass)); + return $item; } function ShowRow($item,$rowClass=NULL) { - ++$this->rownum; echo $this->PrepareRow($item,$rowClass); + ++$this->rownum; } /* protected */ function GetNumRows() @@ -206,7 +206,6 @@ $ret = ""; if($this->rownum == 0 && isset($this->message)) { - ++$this->rownum; $ret = $this->PrepareRow(new CCol($this->message,'message')); } $ret .= $this->footer; diff --git a/frontends/php/include/classes/ctag.inc.php b/frontends/php/include/classes/ctag.inc.php index c0ac82e1..c5cfc7c8 100644 --- a/frontends/php/include/classes/ctag.inc.php +++ b/frontends/php/include/classes/ctag.inc.php @@ -19,6 +19,17 @@ **/ ?> <?php + function destroy_objects() + { + global $GLOBALS; + + if(isset($GLOBALS)) foreach($GLOBALS as $name => $value) + { + if(!is_object($GLOBALS[$name])) continue; + unset($GLOBALS[$name]); + } + } + function unpack_object(&$item) { $res = ""; @@ -29,12 +40,13 @@ } elseif(is_array($item)) { - foreach($item as $i) - $res .= unpack_object($i); // Attention, recursion !!! + foreach($item as $id => $dat) + $res .= unpack_object($item[$id]); // Attention, recursion !!! } elseif(!is_null($item)) { $res = strval($item); + unset($item); } return $res; } @@ -42,6 +54,7 @@ class CTag { /* private */ + var $destroyable_object; var $tagname; var $options = array(); var $paired; @@ -78,7 +91,9 @@ function ShowStart() { echo $this->StartToString(); } function ShowBody() { echo $this->BodyToString(); } function ShowEnd() { echo $this->EndToString(); } - function Show() { echo $this->ToString(); } + function Show($destroy=true) { echo $this->ToString($destroy); } + + function Destroy() { $this = null; } function StartToString() { @@ -103,11 +118,14 @@ $res .= $this->tag_end; return $res; } - function ToString() + function ToString($destroy=true) { $res = $this->StartToString(); $res .= $this->BodyToString(); $res .= $this->EndToString(); + + if($destroy) $this->Destroy(); + return $res; } function SetName($value) @@ -122,7 +140,9 @@ } function SetClass($value) { - return $this->options['class'] = $value; + if(isset($value)) + $this->options['class'] = $value; + return $value; } function DelOption($name) { @@ -135,6 +155,31 @@ $ret =& $this->options[$name]; return $ret; } + + function SetHint($text, $width='', $class='') + { + if($width != '' || $class!= '') + { + $this->AddOption( + 'onMouseOver', + "show_hint_ext(this,'".$text."','".$width."','".$class."');" + ); + } + else + { + $this->AddOption( + 'onMouseOver', + "show_hint(this,'".$text."');" + ); + } + + } + + function OnClick($handle_code) + { + $this->AddOption('onClick', $handle_code); + } + function AddOption($name, $value) { $this->options[$name] = htmlspecialchars(strval($value)); diff --git a/frontends/php/include/classes/ctriggerinfo.mod.php b/frontends/php/include/classes/ctriggerinfo.mod.php index 8c10ec93..aa016b83 100644 --- a/frontends/php/include/classes/ctriggerinfo.mod.php +++ b/frontends/php/include/classes/ctriggerinfo.mod.php @@ -22,10 +22,17 @@ class CTriggersInfo extends CTable { var $style; + var $show_header; + var $nodeid; + function CTriggersInfo($style = STYLE_HORISONTAL) { + global $ZBX_CURNODEID; + parent::CTable(NULL,"triggers_info"); $this->SetOrientation($style); + $this->show_header = true; + $this->nodeid = $ZBX_CURNODEID; } function SetOrientation($value) @@ -36,47 +43,69 @@ $this->style = $value; } + function SetNodeid($nodeid) + { + $this->nodeid = (int)$nodeid; + } + + function HideHeader() + { + $this->show_header = false; + } + function BodyToString() { - $this->CleanItems(); + global $USER_DETAILS; - $uncn = $info = $warn = $avg = $high = $dis = 0; + $this->CleanItems(); - $db_priority = DBselect("select t.priority,count(*) as cnt from triggers t,hosts h,items i,functions f". - " where t.value=1 and t.status=0 and f.itemid=i.itemid and h.hostid=i.hostid". - " and h.status=".HOST_STATUS_MONITORED." and t.triggerid=f.triggerid and i.status=0 group by priority"); + $ok = $uncn = $info = $warn = $avg = $high = $dis = 0; + $db_priority = DBselect("select t.priority,t.value,count(*) as cnt from triggers t,hosts h,items i,functions f". + " where t.status=".TRIGGER_STATUS_ENABLED." and f.itemid=i.itemid ". + " and h.hostid=i.hostid and h.status=".HOST_STATUS_MONITORED." and t.triggerid=f.triggerid ". + " and i.status=".ITEM_STATUS_ACTIVE. + ' and h.hostid in ('.get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY, + null, null, $this->nodeid).') '. + " group by priority"); while($row=DBfetch($db_priority)) { - switch($row["priority"]) + switch($row["value"]) { - case 0: $uncn =$row["cnt"]; break; - case 1: $info =$row["cnt"]; break; - case 2: $warn =$row["cnt"]; break; - case 3: $avg =$row["cnt"]; break; - case 4: $high =$row["cnt"]; break; - case 5: $dis =$row["cnt"]; break; + case TRIGGER_VALUE_TRUE: + switch($row["priority"]) + { + case 1: $info += $row["cnt"]; break; + case 2: $warn += $row["cnt"]; break; + case 3: $avg += $row["cnt"]; break; + case 4: $high += $row["cnt"]; break; + case 5: $dis += $row["cnt"]; break; + default: + $uncn += $row["cnt"]; break; + } + break; + case TRIGGER_VALUE_FALSE: + $ok += $row["cnt"]; break; + default: + $uncn += $row["cnt"]; break; } } - $db_ok_cnt = DBselect("select count(*) as cnt from triggers t,hosts h,items i,functions f". - " where t.value=0 and t.status=0 and f.itemid=i.itemid and h.hostid=i.hostid". - " and h.status=".HOST_STATUS_MONITORED." and t.triggerid=f.triggerid and i.status=0"); - - $ok_cnt = DBfetch($db_ok_cnt); - - $header = new CCol(S_TRIGGERS_INFO,"header"); - if($this->style == STYLE_HORISONTAL) - $header->SetColspan(7); - $this->AddRow($header); + if($this->show_header) + { + $header = new CCol(S_TRIGGERS_INFO,"header"); + if($this->style == STYLE_HORISONTAL) + $header->SetColspan(7); + $this->AddRow($header); + } - $trok = new CCol($ok_cnt["cnt"]." ".S_OK, "trok"); - $uncn = new CCol($uncn." ".S_NOT_CLASSIFIED, "uncn"); - $info = new CCol($info." ".S_INFORMATION, "info"); - $warn = new CCol($warn." ".S_WARNING, "warn"); - $avg = new CCol($avg." ".S_AVERAGE, "avg"); - $high = new CCol($high." ".S_HIGH, "high"); - $dis = new CCol($dis." ".S_DISASTER, "dis"); + $trok = new CCol($ok.SPACE.S_OK, "normal"); + $uncn = new CCol($uncn.SPACE.S_NOT_CLASSIFIED,"uncnown"); + $info = new CCol($info.SPACE.S_INFORMATION, "information"); + $warn = new CCol($warn.SPACE.S_WARNING, "warning"); + $avg = new CCol($avg.SPACE.S_AVERAGE, "average"); + $high = new CCol($high.SPACE.S_HIGH, "high"); + $dis = new CCol($dis.SPACE.S_DISASTER, "disaster"); if($this->style == STYLE_HORISONTAL) diff --git a/frontends/php/include/classes/cvar.inc.php b/frontends/php/include/classes/cvar.inc.php index 7a86d0bf..384bf607 100644 --- a/frontends/php/include/classes/cvar.inc.php +++ b/frontends/php/include/classes/cvar.inc.php @@ -53,17 +53,22 @@ if(is_null($value)) return; + $this->ParseValue($this->var_name, $value); + } + + function ParseValue($name, $value) + { if(is_array($value)) { - foreach($value as $item) + foreach($value as $itemid => $item) { if( null == $item ) continue; - array_push($this->var_container, new CVarTag($this->var_name.'[]', $item)); + $this->ParseValue($name.'['.$itemid.']', $item); } return; } - array_push($this->var_container, new CVarTag($this->var_name, $value)); + array_push($this->var_container, new CVarTag($name, $value)); } function ToString() diff --git a/frontends/php/include/classes/graph.inc.php b/frontends/php/include/classes/graph.inc.php index 53e6fb6c..a7ab9537 100644 --- a/frontends/php/include/classes/graph.inc.php +++ b/frontends/php/include/classes/graph.inc.php @@ -19,6 +19,8 @@ **/ ?> <?php + require_once "include/items.inc.php"; + require_once "include/hosts.inc.php"; define("GRAPH_DRAW_TYPE_LINE",0); define("GRAPH_DRAW_TYPE_FILL",1); @@ -526,18 +528,6 @@ } - function checkPermissions() - { - if(!check_right("Item","R",$this->items[0]["itemid"])) - { - $this->drawGrid(); - ImageString($this->im, 2,$this->sizeX/2 -50,$this->sizeY+$this->shiftY+3, "NO PERMISSIONS" , $this->colors["Dark Red No Alpha"]); - ImageOut($this->im); - ImageDestroy($this->im); - exit; - } - } - function drawLogo() { ImageStringUp($this->im,0,$this->fullSizeX-10,$this->fullSizeY-50, "http://www.zabbix.com", $this->colors["Gray"]); @@ -1167,9 +1157,6 @@ // $this->noDataFound(); } - $this->checkPermissions(); - - $this->drawWorkPeriod(); $this->drawGrid(); |
