diff options
| author | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-01-11 13:33:50 +0000 |
|---|---|---|
| committer | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-01-11 13:33:50 +0000 |
| commit | b4b26e48b09f36c8b533412a1b19f1f23a447a9b (patch) | |
| tree | 065ba2d78e0a647be5e8fe7908c4417dfe4e1015 /frontends/php/include | |
| parent | 5fbc202c9ec11aac9d0ad9bf2f469a05deda8083 (diff) | |
| download | zabbix-b4b26e48b09f36c8b533412a1b19f1f23a447a9b.tar.gz zabbix-b4b26e48b09f36c8b533412a1b19f1f23a447a9b.tar.xz zabbix-b4b26e48b09f36c8b533412a1b19f1f23a447a9b.zip | |
- added HTML classes into PHP framework (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@2514 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
19 files changed, 1516 insertions, 242 deletions
diff --git a/frontends/php/include/actions.inc.php b/frontends/php/include/actions.inc.php index afa34a76..e2180fce 100644 --- a/frontends/php/include/actions.inc.php +++ b/frontends/php/include/actions.inc.php @@ -60,7 +60,7 @@ # Update Action - function update_action($actionid, $userid, $delay, $subject, $message, $recipient, $usrgrpid, $maxrepeats, $repeatdelay) + function update_action($actionid, $id, $delay, $subject, $message, $recipient, $maxrepeats, $repeatdelay) { // if(!check_right_on_trigger("U",$triggerid)) // { @@ -68,15 +68,6 @@ // return 0; // } - if($recipient == RECIPIENT_TYPE_USER) - { - $id = $userid; - } - else - { - $id = $usrgrpid; - } - $sql="update actions set userid=$id,delay=$delay,nextcheck=0,subject='$subject',message='$message',recipient=$recipient,maxrepeats=$maxrepeats, repeatdelay=$repeatdelay where actionid=$actionid"; $result=DBexecute($sql); return $result; @@ -254,7 +245,7 @@ { $host=get_host_by_hostid($row["hostid"]); $message=str_replace("{".$host_template["host"].":", "{".$host["host"].":", $action["message"]); - update_action($row3["actionid"], $row2["triggerid"], $action["userid"], $action["good"], $action["delay"], $action["subject"], $message, $action["scope"], $action["severity"], $action["recipient"], $action["userid"], $action["maxrepeats"],$action["repeatdelay"]); + update_action($row3["actionid"], $row2["triggerid"], $action["userid"], $action["good"], $action["delay"], $action["subject"], $message, $action["scope"], $action["severity"], $action["recipient"], $action["maxrepeats"],$action["repeatdelay"]); } } diff --git a/frontends/php/include/classes/cbutton.inc.php b/frontends/php/include/classes/cbutton.inc.php new file mode 100644 index 00000000..eb6443c7 --- /dev/null +++ b/frontends/php/include/classes/cbutton.inc.php @@ -0,0 +1,82 @@ +<?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 + class CButton extends CTag + { +/* public */ + function CButton($name="button", $caption="", $action=NULL) + { + parent::CTag("input","no"); + $this->tag_body_start = ""; + $this->AddOption("type","submit"); + $this->SetClass("button"); + $this->SetName($name); + $this->SetCaption($caption); + $this->SetAction($action); + } + function SetAction($value='submit()', $event='onClick') + { + if(is_null($value)) + return 1; + if(!is_string($value)) + return $this->error("Incorrect value for SetAction [$value]"); + if(!is_string($event)) + return $this->error("Incorrect event for SetAction [$event]"); + return $this->AddOption($event,$value); + } + function SetTitle($value='button title') + { + if(!is_string($value)) + { + return $this->error("Incorrect value for SetTitle [$value]"); + } + return $this->AddOption("title",$value); + } + function SetAccessKey($value='B') + { + if(!is_string($value)) + { + return $this->error("Incorrect value for SetAccessKey [$value]"); + } + + if($this->GetOption('title')==NULL) + $this->SetTitle($this->GetOption('value')." [Alt+$value]"); + + return $this->AddOption("accessKey",$value); + } + function SetName($value='button') + { + if(!is_string($value)) + { + return $this->error("Incorrect value for SetName [$value]"); + } + return $this->AddOption("name",$value); + } + function SetCaption($value="") + { + if(!is_string($value)) + { + return $this->error("Incorrect value for SetCaption [$value]"); + } + return $this->AddOption("value",$value); + } + } +?> diff --git a/frontends/php/include/classes/ccheckbox.inc.php b/frontends/php/include/classes/ccheckbox.inc.php new file mode 100644 index 00000000..0da3295e --- /dev/null +++ b/frontends/php/include/classes/ccheckbox.inc.php @@ -0,0 +1,50 @@ +<?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 + class CCheckBox extends CTag + { +/* public */ + function CCheckBox($name='checkbox',$value=NULL) + { + parent::CTag("input","no"); + $this->tag_body_start = ""; + $this->AddOption('type','checkbox'); + $this->SetName($name); + $this->SetCaption($value); + } + function SetName($value='checkbox') + { + if(!is_string($value)) + { + return $this->error("Incorrect value for SetName [$value]"); + } + return $this->AddOption("name",$value); + } + function SetCaption($value=NULL) + { + if(is_null($value)) + return 0; + elseif(is_string($value)) + return $this->AddItem(nbsp($value)); + return $this->error("Incorrect value for SetCaption [$value]"); + } + } +?> diff --git a/frontends/php/include/classes/ccombobox.inc.php b/frontends/php/include/classes/ccombobox.inc.php new file mode 100644 index 00000000..33d65256 --- /dev/null +++ b/frontends/php/include/classes/ccombobox.inc.php @@ -0,0 +1,144 @@ +<?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 + class CComboItem extends CTag + { +/* public */ + function CComboItem($value,$caption=NULL,$selected='no') + { + parent::CTag('option','yes'); + $this->tag_body_start = ""; + $this->SetCaption($caption); + $this->SetValue($value); + $this->SetSelected($selected); + } + function SetValue($value) + { + return parent::AddOption('value',$value); + } + function SetCaption($value=NULL) + { + if(is_null($value)) + return 0; + elseif(is_string($value)){ + parent::AddItem(nbsp($value)); + return 0; + } + return $this->error("Incorrect value for SetCaption [$value]"); + } + function SetEnable($value='yes') + { + if(is_string($value)) + { + if($value == 'yes') + return $this->DelOption('disabled'); + elseif($value == 'no') + return $this->AddOption('disabled','disabled'); + } + return $this->error("Incorrect value for SetEnable [$value]"); + } + function SetSelected($value) + { + if(is_string($value)) + { + if($value == 'yes') + return $this->AddOption('selected','selected'); + elseif($value == 'no') + return $this->DelOption('selected'); + } + return $this->error("Incorrect value for SetSelected [$value]"); + } + } + + class CComboBox extends CTag + { +/* private */ + var $caption; + var $value; + +/* public */ + function CComboBox($name='combobox',$value=NULL,$action=NULL) + { + parent::CTag("select","yes"); + $this->tag_end = ""; + $this->SetClass("biginput"); + $this->SetName($name); + $this->SetValue($value); + $this->AddOption("size",1); + $this->SetAction($action); + } + function SetAction($value='submit()', $event='onChange') + { + if(is_null($value)) + return 1; + if(!is_string($value)) + return $this->error("Incorrect value for SetAction [$value]"); + if(!is_string($event)) + return $this->error("Incorrect event for SetAction [$event]"); + return $this->AddOption($event,$value); + } + function SetName($value='combobox') + { + if(!is_string($value)) + { + return $this->error("Incorrect value for SetName [$value]"); + } + return $this->AddOption("name",$value); + } + function SetCaption($value=NULL) + { + if(is_null($value)) + unset($this->caption); + elseif(is_string($value)) + $this->caption = $value; + else + { + return $this->error("Incorrect value for SetCaption [$value]"); + } + return 0; + } + function SetValue($value=NULL) + { + $this->value = $value; + } + function AddItem($value, $caption, $enabled='yes') + { + $selected = 'no'; + if(!is_null($this->value)) + if($this->value==$value) + $selected = 'yes'; + +// if($enabled=='no') return; /* disable item method 1 */ + + $cmbItem = new CComboItem($value,$caption,$selected); + + $cmbItem->SetEnable($enabled); /* disable item method 2 */ + + parent::AddItem($cmbItem); + } + function Show() + { + if(isset($this->caption)) + print ($this->caption." "); + parent::Show(); + } + } +?> diff --git a/frontends/php/include/classes/cform.inc.php b/frontends/php/include/classes/cform.inc.php new file mode 100644 index 00000000..065185f9 --- /dev/null +++ b/frontends/php/include/classes/cform.inc.php @@ -0,0 +1,54 @@ +<?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 + class CForm extends CTag + { +/* public */ + function CForm($action=NULL, $method='get') + { + parent::CTag("form","yes"); + $this->SetMethod($method); + $this->SetAction($action); + } + function SetMethod($value='post') + { + if(!is_string($value)) + { + return $this->error("Incorrect value for SetMethod [$value]"); + } + return $this->AddOption("method",$value); + } + function SetAction($value=NULL) + { + if(is_null($value)) + return 1; + elseif(!is_string($value)) + { + return $this->error("Incorrect value for SetAction [$value]"); + } + return $this->AddOption("action",$value); + } + function AddVar($name, $value) + { + $this->AddItem(new CVar($name, $value)); + } + } +?> diff --git a/frontends/php/include/classes/cformtable.inc.php b/frontends/php/include/classes/cformtable.inc.php new file mode 100644 index 00000000..dbcfdb94 --- /dev/null +++ b/frontends/php/include/classes/cformtable.inc.php @@ -0,0 +1,128 @@ +<?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 + class CFormTable extends CForm + { +/* private */ + var $align; + var $title; + var $help; +/* protected */ + var $top_items = array(); + var $center_items = array(); + var $bottom_items = array(); +/* public */ + function CFormTable($title=NULL, $action=NULL, $method='get') + { + parent::CForm($action,$method); + $this->SetTitle($title); + $this->SetAlign('center'); + $this->SetHelp(); + + $this->bottom_items = new CCol(NULL,'form_row_last'); + $this->bottom_items->SetColSpan(2); + } + function SetAlign($value) + { + if(!is_string($value)) + { + return $this->error("Incorrect value for SetAlign [$value]"); + } + return $this->align = $value; + } + function SetTitle($value=NULL) + { + if(is_null($value)) + { + unset($this->title); + return 0; + } + elseif(!is_string($value)) + { + return $this->error("Incorrect value for SetTitle [$value]"); + } + $this->title = nbsp($value); + } + function SetHelp($value=NULL) + { + if(is_null($value)) + $this->help = new CHelp(); + elseif(is_a($value,'chelp')) + $this->help = $value; + elseif(is_string($value)) + $this->help = new CHelp($value); + else + { + return $this->error("Incorrect value for SetHelp [$value]"); + } + return 0; + } + function AddVar($name, $value) + { + $this->AddTopRow(new CVar($name, $value)); + } + function AddTopRow($value) + { + array_push($this->top_items, $value); + } + function AddRow($item1, $item2=NULL) + { + if(is_string($item1)) + $item1=nbsp($item1); + + $row = new CRow(array( + new CCol($item1,'form_row_l'), + new CCol($item2,'form_row_r') + ) + ); + array_push($this->center_items, $row); + } + function AddBottomRow($value) + { + $this->bottom_items->AddItem($value); + } +/* protected */ + function ShowTagBody() + { + parent::ShowTagBody(); + + $tbl = new CTable(NULL,'form'); + $tbl->SetOddRowClass('form_odd_row'); + $tbl->SetEvenRowClass('form_even_row'); + $tbl->SetCellSpacing(0); + $tbl->SetCellPadding(1); + $tbl->SetAlign($this->align); +# add center rows + foreach($this->center_items as $item) + $tbl->AddRow($item); +# add first row + $col = new CCol(NULL,'form_row_first'); + $col->SetColSpan(2); + if(isset($this->help)) $col->AddItem($this->help); + if(isset($this->title)) $col->AddItem($this->title); + foreach($this->top_items as $item) $col->AddItem($item); + $tbl->SetHeader($col); +# add last row + $tbl->SetFooter($this->bottom_items); + $tbl->Show(); + } + } +?> diff --git a/frontends/php/include/classes/chelp.inc.php b/frontends/php/include/classes/chelp.inc.php new file mode 100644 index 00000000..79055781 --- /dev/null +++ b/frontends/php/include/classes/chelp.inc.php @@ -0,0 +1,31 @@ +<?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 + class CHelp extends CLink + { +/* public */ + function CHelp($url="index.php") + { + parent::CLink(new CImg("images/general/help.gif",'?'), "http://www.zabbix.com/manual/v1.1/$url"); + $this->AddOption("style","float:right"); + } + } +?> diff --git a/frontends/php/include/classes/cimg.inc.php b/frontends/php/include/classes/cimg.inc.php new file mode 100644 index 00000000..c185337c --- /dev/null +++ b/frontends/php/include/classes/cimg.inc.php @@ -0,0 +1,49 @@ +<?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 + class CImg extends CTag + { +/* public */ + function CImg($src,$alt_text) + { + parent::CTag("img","no"); + $this->AddOption('border',0); + $this->SetAltText($alt_text); + $this->SetSrc($src); + } + function SetSrc($value) + { + if(!is_string($value)) + { + return $this->error("Incorrect value for SetSrc [$value]"); + } + return $this->AddOption("src",$value); + } + function SetAltText($value="picture") + { + if(!is_string($value)) + { + return $this->error("Incorrect value for SetText [$value]"); + } + return $this->AddOption("alt",$value); + } + } +?> diff --git a/frontends/php/include/classes/clink.inc.php b/frontends/php/include/classes/clink.inc.php new file mode 100644 index 00000000..12adc6ef --- /dev/null +++ b/frontends/php/include/classes/clink.inc.php @@ -0,0 +1,41 @@ +<?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 + class CLink extends CTag + { +/* public */ + function CLink($item="www.zabbix.com",$url="http://www.zabbix.com",$class=NULL) + { + parent::CTag("a","yes"); + $this->SetClass($class); + $this->AddItem($item); + $this->SetUrl($url); + } + function SetUrl($value) + { + if(!is_string($value)) + { + return $this->error("Incorrect value for SetUrl [$value]"); + } + $this->AddOption("href",$value); + } + } +?> diff --git a/frontends/php/include/classes/cpassbox.inc.php b/frontends/php/include/classes/cpassbox.inc.php new file mode 100644 index 00000000..2f51a9ee --- /dev/null +++ b/frontends/php/include/classes/cpassbox.inc.php @@ -0,0 +1,31 @@ +<?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 + class CPassBox extends CTextBox + { +/* public */ + function CPassBox($name="password",$value="",$size=20,$caption=NULL) + { + parent::CTextBox($name,$value,$size,$caption); + $this->AddOption("type","password"); + } + } +?> diff --git a/frontends/php/include/classes/ctable.inc.php b/frontends/php/include/classes/ctable.inc.php new file mode 100644 index 00000000..bcb1998d --- /dev/null +++ b/frontends/php/include/classes/ctable.inc.php @@ -0,0 +1,247 @@ +<?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 + class CCol extends CTag + { +/* public */ + function CCol($item=NULL,$calss=NULL) + { + parent::CTag("td","yes"); + $this->AddItem($item); + $this->SetClass($calss); + } + function SetAlign($value) + { + if(!is_string($value)) + { + return $this->error("Incorrect value for SetAlign [$value]"); + } + return $this->AddOption("align",$value); + } + function SetRowSpan($value) + { + if(!is_int($value)) + { + return $this->error("Incorrect value for SetRowSpan [$value]"); + return 1; + } + return $this->AddOption("rowspan",strval($value)); + } + function SetColSpan($value) + { + if(!is_int($value)) + { + return $this->error("Incorrect value for SetColSpan[$value]"); + } + return $this->AddOption("colspan",strval($value)); + } + } + + class CRow extends CTag + { +/* public */ + function CRow($item=NULL,$class=NULL) + { + parent::CTag("tr","yes"); + $this->AddItem($item); + $this->SetClass($class); + } + function SetAlign($value) + { + if(!is_string($value)) + { + return $this->error("Incorrect value for SetAlign [$value]"); + } + return $this->AddOption("align",$value); + } + function AddItem($item=NULL) + { + if(is_null($item)) + return 0; + elseif(is_a($item,'ccol')) + { + return parent::AddItem($item); + } + elseif(is_array($item)) + { + $ret = 0; + foreach($item as $el) + { + if(is_a($el,'ccol')) + { + $ret |= parent::AddItem($el); + } else { + $ret |= parent::AddItem(new CCol($el)); + } + } + return $ret; + } + return parent::AddItem(new CCol($item)); + } + } + + class CTable extends CTag + { +/* protected */ + var $oddRowClass; + var $evenRowClass; + var $header; + var $footer; +/* public */ + function CTable($message=NULL,$class=NULL) + { + parent::CTag("table","yes"); + $this->SetClass($class); + $this->message = $message; + $this->SetOddRowClass(); + $this->SetEvenRowClass(); + $this->SetHeader(); + $this->SetFooter(); + } + function SetHeader($value=NULL,$class=NULL) + { + if(is_null($value)){ + $this->header = NULL; + }elseif(is_a($value,'crow')) + { + if(isset($class)) + $value->SetClass($class); + $this->header = $value; + }else{ + $this->header = new CRow($value,$class); + } + } + function SetFooter($value=NULL,$class=NULL) + { + if(is_null($value)){ + $this->footer = NULL; + }elseif(is_a($value,'ccol')) + { + if(isset($this->header) && $value->GetOption('colspan')==NULL) + $value->SetColSpan(count($this->header->items)); + + $this->footer = new CRow($value,$class); + }elseif(is_a($value,'crow')) + { + if(isset($class)) + $value->SetClass($class); + $this->footer = $value; + }else{ + $this->footer = new CRow($value,$class); + } + } + function SetOddRowClass($value=NULL) + { + if(!is_string($value) && !is_null($value)) + { + return $this->error("Incorrect value for SetOddRowClass [$value]"); + } + $this->oddRowClass = $value; + } + function SetEvenRowClass($value=NULL) + { + if(!is_string($value) && !is_null($value)) + { + return $this->error("Incorrect value for SetEvenRowClass [$value]"); + } + $this->evenRowClass = $value; + } + function SetAlign($value) + { + if(!is_string($value)) + { + return $this->error("Incorrect value for SetAlign [$value]"); + } + return $this->AddOption("align",$value); + } + function SetCellPadding($value) + { + if(!is_int($value)) + { + return $this->error("Incorrect value for SetCellpadding [$value]"); + } + return $this->AddOption("cellpadding",strval($value)); + } + function SetCellSpacing($value) + { + if(!is_int($value)) + { + return $this->error("Incorrect value for SetCellSpacing [$value]"); + } + return $this->AddOption("cellspacing",strval($value)); + } + function AddRow($item,$rowClass=NULL) + { + if(is_null($item)){ + return 0; + }elseif(is_a($item,'ccol')) + { + if(isset($this->header) && $item->GetOption('colspan')==NULL) + $item->SetColSpan(count($this->header->items)); + + return $this->AddItem(new CRow($item,$rowClass)); + }elseif(is_a($item,'crow')) + { + if(isset($rowClass)) + $item->SetClass($rowClass); + + return $this->AddItem($item); + }else{ + return $this->AddItem(new CRow($item,$rowClass)); + } + } +/* protected */ + function ShowTagBody() + { + if(is_a($this->header,'crow')) + $this->header->Show(); + + if(count($this->items)==0) + { + if(isset($this->message)) + $this->AddRow(new CCol($this->message,'table_message'),$this->evenRowClass); + } + + parent::ShowTagBody(); + + if(is_a($this->footer,'crow')) + $this->footer->Show(); + } + function AddItem($value) + { + $cname="crow"; + if(!is_a($value,$cname)) + { + return $this->error("Incorrect value for AddItem [$value]"); + } + + if($value->GetOption('class')==NULL) + { + $value->SetClass( + ((count($this->items)+1)%2==1) ? + $this->evenRowClass : $this->oddRowClass + ); + } + + return parent::AddItem($value); + } + } +?> diff --git a/frontends/php/include/classes/ctableinfo.inc.php b/frontends/php/include/classes/ctableinfo.inc.php new file mode 100644 index 00000000..36f58ee7 --- /dev/null +++ b/frontends/php/include/classes/ctableinfo.inc.php @@ -0,0 +1,43 @@ +<?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 + class CTableInfo extends CTable + { +/* public */ + function CTableInfo($message='...',$class='tborder') + { + parent::CTable($message,$class); + $this->SetOddRowClass('table_odd_row'); + $this->SetEvenRowClass('table_even_row'); + $this->SetCellSpacing(1); + $this->SetCellPadding(3); + $this->SetHeader(); + } + function SetHeader($value=NULL,$class='table_header') + { + parent::SetHeader($value,$class); + } + function SetFooter($value=NULL,$class='table_header') + { + parent::SetFooter($value,$class); + } + } +?> diff --git a/frontends/php/include/classes/ctag.inc.php b/frontends/php/include/classes/ctag.inc.php new file mode 100644 index 00000000..50f3f0b9 --- /dev/null +++ b/frontends/php/include/classes/ctag.inc.php @@ -0,0 +1,175 @@ +<?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 + class CTag + { +/* private */ + var $name; + var $options = array(); + var $paired; +/* protected */ + var $items = array(); + + var $tag_body_start; + var $tag_body_end; + var $tag_start; + var $tag_end; + +/* public */ + function CTag($name=NULL, $paired='no') + { + $this->SetTagName($name); + $this->SetPaired($paired); + $this->tag_start= ""; + $this->tag_end = "\n"; + $this->tag_body_start = "\n"; + $this->tag_body_end = ""; + } + function Show() + { + $this->ShowTagStart(); + $this->ShowTagBody(); + $this->ShowTagEnd(); + } + function SetTagName($value=NULL) + { + if(!is_string($value)) + { + return $this->error("Incorrect value for SetTagName [$value]"); + } + $this->name=$value; + return 0; + } + function SetClass($value) + { + if(is_null($value)) + return 0; + + if(!is_string($value)) + { + return $this->error("Incorrect value for SetClass [$value]"); + } + return $this->AddOption("class",$value); + } + function SetPaired($value='no') + { + if($value == 'no') $this->paired=$value; + elseif($value == 'yes') $this->paired=$value; + else + { + return $this->error("Incorrect value for SetPaired [$value]"); + } + return 0; + } + function DelOption($name) + { + if(!is_string($name)) + { + return $this->error("Incorrect value for DelOption [$value]"); + } + unset($this->options[$name]); + return 0; + } + function &GetOption($name) + { + $ret = NULL; + if(is_string($name)) + if(isset($this->options[$name])) + $ret =& $this->options[$name]; + return $ret; + } + function AddOption($name, $value) + { + if(!is_string($name)) + { + return $this->error("Incorrect name for AddOption [$name]"); + } + if(!is_string($value) && !is_int($value) && !is_float($value)) + { + return $this->error("Incorrect value for AddOption [$value]"); + } + + $this->options[$name] = strval($value); + return 0; + } + function AddItem($value) + { + if(is_null($value)) + { + return 1; + } + elseif(is_array($value)) + { + foreach($value as $item) + array_push($this->items,$item); + } + else + { + array_push($this->items,$value); + } + return 0; + } +/* protected */ + function ShowTagStart() + { + print ($this->tag_start); + print("<".$this->name); + foreach($this->options as $key => $value) + { + print (" $key=\"$value\""); + } + + if($this->paired=='yes') + print (">"); + else + print ("/>"); + + print ($this->tag_body_start); + } + function ShowTagItem($item) + { + if(is_null($item)) return; + elseif(is_object($item))$item->Show(); + else print (strval($item)); + } + function ShowTagBody() + { + foreach($this->items as $item) + $this->ShowTagItem($item); + } + function ShowTagEnd() + { + print ($this->tag_body_end); + + if($this->paired=='yes') + { + print ("</".$this->name.">"); + print ($this->tag_end); + } + } + function error($value) + { + error("class(".get_class($this).") - ".$value); + return 1; + } + + } +?> diff --git a/frontends/php/include/classes/ctextarea.inc.php b/frontends/php/include/classes/ctextarea.inc.php new file mode 100644 index 00000000..d1d605e8 --- /dev/null +++ b/frontends/php/include/classes/ctextarea.inc.php @@ -0,0 +1,91 @@ +<?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 + class CTextArea extends CTag + { +/* private */ + var $caption; +/* public */ + function CTextArea($name='textarea',$value="",$cols=77,$rows=7,$caption=NULL) + { + parent::CTag("textarea","yes"); + $this->SetClass("biginput"); + $this->AddOption('wrap','soft'); + $this->SetName($name); + $this->SetCols($cols); + $this->SetRows($rows); + $this->SetCaption($caption); + $this->SetValue($value); + } + function Show() + { + if(isset($this->caption)) + print ($this->caption." "); + parent::Show(); + } + function SetName($value='textarea') + { + if(!is_string($value)) + { + return $this->error("Incorrect value for SetName [$value]"); + } + return $this->AddOption("name",$value); + } + function SetCaption($value=NULL) + { + if(is_null($value)) + unset($this->caption); + elseif(is_string($value)) + $this->caption = $value; + else + { + return $this->error("Incorrect value for SetCaption [$value]"); + } + return 0; + } + function SetValue($value="") + { + if(!is_string($value)) + { + return $this->error("Incorrect value for SetValue [$value]"); + } + return $this->AddItem($value); + } + function SetRows($value) + { + if(!is_int($value)) + { + return $this->error("Incorrect value for SetRows [$value]"); + } + return $this->AddOption("rows",strval($value)); + + } + function SetCols($value) + { + if(!is_int($value)) + { + return $this->error("Incorrect value for SetCols [$value]"); + } + return $this->AddOption("cols",strval($value)); + + } + } +?> diff --git a/frontends/php/include/classes/ctextbox.inc.php b/frontends/php/include/classes/ctextbox.inc.php new file mode 100644 index 00000000..0a00de40 --- /dev/null +++ b/frontends/php/include/classes/ctextbox.inc.php @@ -0,0 +1,95 @@ +<?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 + class CTextBox extends CTag + { +/* private */ + var $caption; +/* public */ + function CTextBox($name='textbox',$value="",$size=20,$caption=NULL) + { + parent::CTag("input","no"); + $this->SetClass("biginput"); + $this->SetName($name); + $this->SetSize($size); + $this->SetCaption($caption); + $this->SetValue($value); + } + function Show() + { + if(isset($this->caption)) + print ($this->caption." "); + parent::Show(); + } + function SetReadonly($value='yes') + { + if(is_string($value)) + { + if($value=='no') + return $this->DelOption("readonly"); + elseif($value=='yes') + return $this->AddOption("readonly",'readonly'); + } + return $this->error("Incorrect value for SetReadonly [$value]"); + } + function SetName($value='textbox') + { + if(!is_string($value)) + { + return $this->error("Incorrect value for SetName [$value]"); + } + return $this->AddOption("name",$value); + } + function SetCaption($value=NULL) + { + if(is_null($value)) + unset($this->caption); + elseif(is_string($value)) + $this->caption = $value; + else + { + return $this->error("Incorrect value for SetCaption [$value]"); + } + return 0; + } + function SetValue($value="") + { + if(is_int($value)) + { + return $this->AddOption("value",strval($value)); + } + elseif(is_string($value)) + { + return $this->AddOption("value",$value); + } + return $this->error("Incorrect value for SetValue [$value]"); + } + function SetSize($value) + { + if(!is_int($value)) + { + return $this->error("Incorrect value for SetSize [$value]"); + } + return $this->AddOption("size",strval($value)); + + } + } +?> diff --git a/frontends/php/include/classes/cvar.inc.php b/frontends/php/include/classes/cvar.inc.php new file mode 100644 index 00000000..b089f181 --- /dev/null +++ b/frontends/php/include/classes/cvar.inc.php @@ -0,0 +1,45 @@ +<?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 + class CVar extends CTag + { +/* public */ + function CVar($name="",$value="0") + { + parent::CTag("input","no"); + $this->AddOption("type","hidden"); + $this->SetName($name); + $this->SetValue($value); + } + function SetName($value) + { + if(!is_string($value)) + { + return $this->error("Incorrect value for SetName [$value]"); + } + return $this->AddOption("name",$value); + } + function SetValue($value) + { + return $this->AddOption("value",$value); + } + } +?> diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php index 7e8880e2..af7bfd5e 100644 --- a/frontends/php/include/config.inc.php +++ b/frontends/php/include/config.inc.php @@ -48,7 +48,23 @@ function SDI($msg) { echo "DEBUG INFO: $msg <br>"; } # DEBUG INFO!!! include_once "include/maps.inc.php"; include_once "include/media.inc.php"; - include_once "include/classes/table.inc.php"; +// Include Classes + include_once("include/classes/ctag.inc.php"); + include_once("include/classes/cvar.inc.php"); + include_once("include/classes/cimg.inc.php"); + include_once("include/classes/clink.inc.php"); + include_once("include/classes/chelp.inc.php"); + include_once("include/classes/cbutton.inc.php"); + include_once("include/classes/ccombobox.inc.php"); + include_once("include/classes/ctable.inc.php"); + include_once("include/classes/ctableinfo.inc.php"); + include_once("include/classes/ctextarea.inc.php"); + include_once("include/classes/ctextbox.inc.php"); + include_once("include/classes/cpassbox.inc.php"); + include_once("include/classes/cform.inc.php"); + include_once("include/classes/ccheckbox.inc.php"); + include_once("include/classes/cform.inc.php"); + include_once("include/classes/cformtable.inc.php"); function info($msg) { @@ -674,7 +690,7 @@ function SDI($msg) { echo "DEBUG INFO: $msg <br>"; } # DEBUG INFO!!! return $config; } - function show_messages($bool,$msg,$errmsg) + function show_messages($bool=TRUE,$msg=NULL,$errmsg=NULL) { global $ERROR_MSG; global $INFO_MSG; @@ -690,7 +706,8 @@ function SDI($msg) { echo "DEBUG INFO: $msg <br>"; } # DEBUG INFO!!! } echo "<p align=center>"; echo "<font color='$color'>"; - echo "<b>[$msg]</b>"; + if(isset($msg)) + echo "<b>[$msg]</b>"; echo "</font>"; echo "</p>"; diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php index 3db4adb4..c3bebfa5 100644 --- a/frontends/php/include/forms.inc.php +++ b/frontends/php/include/forms.inc.php @@ -874,30 +874,12 @@ function insert_login_form() { - global $_REQUEST; - - $col=0; - - show_form_begin("index.login"); - echo "Login"; - - show_table2_v_delimiter($col++); - echo "<form method=\"post\" action=\"index.php\">"; - - echo "Login name"; - show_table2_h_delimiter(); -// echo "<input name=\"name\" value=\"".$_REQUEST["name"]."\" size=20>"; - echo "<input class=\"biginput\" name=\"name\" value=\"\" size=20>"; - - show_table2_v_delimiter($col++); - echo "Password"; - show_table2_h_delimiter(); -// echo "<input type=\"password\" name=\"password\" value=\"$password\" size=20>"; - echo "<input class=\"biginput\" type=\"password\" name=\"password\" value=\"\" size=20>"; - - show_table2_v_delimiter2(); - echo "<input class=\"button\" type=\"submit\" name=\"register\" value=\"Enter\">"; - show_table2_header_end(); + $frmLogin = new CForm('Login','index.php'); + $frmLogin->SetHelp('web.index.login'); + $frmLogin->AddRow('Login name', new CTextBox('name')); + $frmLogin->AddRow('Password', new CPassBox('password')); + $frmLogin->AddBottomRow(new CButton('register','Enter')); + $frmLogin->Show(); } # Insert form for Problem @@ -1479,18 +1461,28 @@ { global $_REQUEST; + $uid=NULL; + + $frmAction = new CFormTable(S_ACTION,'actionconf.php'); + $frmAction->SetHelp('web.actions.action'); + if(isset($_REQUEST['form'])) + $frmAction->AddVar('form',$_REQUEST['form']); + + $conditiontype=@iif(isset($_REQUEST["conditiontype"]),$_REQUEST["conditiontype"],0); + if(isset($_REQUEST["actionid"])) { $action=get_action_by_actionid($_REQUEST["actionid"]); + $frmAction->AddVar('actionid',$_REQUEST["actionid"]); $actionid=$action["actionid"]; $actiontype=$action["actiontype"]; $source=$action["source"]; $delay=$action["delay"]; + $uid=$action["userid"]; // Otherwise symbols like ",' will not be shown $subject=htmlspecialchars($action["subject"]); $message=$action["message"]; - $uid=$action["userid"]; $recipient=@iif(isset($_REQUEST["recipient"]),$_REQUEST["recipient"],$action["recipient"]); $maxrepeats=$action["maxrepeats"]; $repeatdelay=$action["repeatdelay"]; @@ -1519,288 +1511,240 @@ } else { - $source=0; - $actiontype=0; - $filter_trigger_name=""; - $filter_triggerid=0; - $filter_groupid=0; - $filter_hostid=0; - $description=""; + $source=@iif(isset($_REQUEST["source"]),$_REQUEST["source"],0); + $actiontype=@iif(isset($_REQUEST["actiontype"]),$_REQUEST["actiontype"],0); - // $delay=30; $delay=@iif(isset($_REQUEST["delay"]),$_REQUEST["delay"],30); -// $subject=$description; $subject=@iif(isset($_REQUEST["subject"]),$_REQUEST["subject"],"{TRIGGER.NAME}: {STATUS}"); $message=@iif(isset($_REQUEST["message"]),$_REQUEST["message"],"{TRIGGER.NAME}: {STATUS}"); $scope=@iif(isset($_REQUEST["scope"]),$_REQUEST["scope"],0); $recipient=@iif(isset($_REQUEST["recipient"]),$_REQUEST["recipient"],RECIPIENT_TYPE_GROUP); -// $severity=0; $severity=@iif(isset($_REQUEST["severity"]),$_REQUEST["severity"],0); $maxrepeats=@iif(isset($_REQUEST["maxrepeats"]),$_REQUEST["maxrepeats"],0); $repeatdelay=@iif(isset($_REQUEST["repeatdelay"]),$_REQUEST["repeatdelay"],600); $repeat=@iif(isset($_REQUEST["repeat"]),$_REQUEST["repeat"],0); - } - - $conditiontype=@iif(isset($_REQUEST["conditiontype"]),$_REQUEST["conditiontype"],0); - - - show_form_begin("actions.action"); - echo nbsp(S_ACTION); - $col=0; - show_table2_v_delimiter($col++); - echo "<form name=\"action\" method=\"get\" action=\"actionconf.php\">"; - echo "<input name=\"form\" type=\"hidden\" value=\"0\">"; - if(isset($_REQUEST["actionid"])) - { - echo "<input name=\"actionid\" type=\"hidden\" value=".$_REQUEST["actionid"].">"; + if($recipient==RECIPIENT_TYPE_GROUP) + $uid=@iif(isset($_REQUEST["usrgrpid"]),$_REQUEST["usrgrpid"],NULL); + else + $uid=@iif(isset($_REQUEST["userid"]),$_REQUEST["userid"],NULL); } - echo nbsp(S_SOURCE); - show_table2_h_delimiter(); - echo "<select class=\"biginput\" name=\"source\" size=1>"; - echo "<OPTION VALUE=\"0\""; if($source==0) echo "SELECTED"; echo ">".S_TRIGGER; - echo "</SELECT>"; - show_table2_v_delimiter($col); - echo nbsp(S_CONDITIONS); - show_table2_h_delimiter(); - $found=0; - for($i=1;$i<=1000;$i++) - { - if(isset($_REQUEST["conditiontype$i"])) - { - echo "<input type=checkbox name=\"conditionchecked$i\">".get_condition_desc($_REQUEST["conditiontype$i"],$_REQUEST["conditionop$i"],$_REQUEST["conditionvalue$i"]); - echo "<br>"; - $found=1; - } - } - for($i=1;$i<=1000;$i++) +// prepare condition list + $cond_el=array(); + for($i=1; $i<=1000; $i++) { - if(isset($_REQUEST["conditiontype$i"])) - { - echo "<input name=\"conditiontype$i\" type=\"hidden\" value=\"".$_REQUEST["conditiontype$i"]."\">"; - echo "<input name=\"conditionop$i\" type=\"hidden\" value=\"".$_REQUEST["conditionop$i"]."\">"; - echo "<input name=\"conditionvalue$i\" type=\"hidden\" value=\"".$_REQUEST["conditionvalue$i"]."\">"; - } + if(!isset($_REQUEST["conditiontype$i"])) continue; + array_push($cond_el, + new CCheckBox( + "conditionchecked$i", + get_condition_desc( + $_REQUEST["conditiontype$i"], + $_REQUEST["conditionop$i"], + $_REQUEST["conditionvalue$i"] + ) + ), + BR + ); + $frmAction->AddVar("conditiontype$i", $_REQUEST["conditiontype$i"]); + $frmAction->AddVar("conditionop$i", $_REQUEST["conditionop$i"]); + $frmAction->AddVar("conditionvalue$i", $_REQUEST["conditionvalue$i"]); } - if($found==0) echo S_NO_CONDITIONS_DEFINED; - show_table2_v_delimiter($col++); - echo nbsp(" "); - show_table2_h_delimiter(); - echo "<input class=\"button\" type=\"submit\" name=\"register\" value=\"delete selected\">"; - -// show_table2_v_delimiter($col); -// echo nbsp(" "."Condition"); -// show_table2_h_delimiter(); - $h2="<select class=\"biginput\" name=\"conditiontype\" onChange=\"submit()\">"; - $h2=$h2.form_select("conditiontype",CONDITION_TYPE_GROUP,S_HOST_GROUP); - $h2=$h2.form_select("conditiontype",CONDITION_TYPE_HOST,S_HOST); - $h2=$h2.form_select("conditiontype",CONDITION_TYPE_TRIGGER,S_TRIGGER); - $h2=$h2.form_select("conditiontype",CONDITION_TYPE_TRIGGER_NAME,S_TRIGGER_NAME); - $h2=$h2.form_select("conditiontype",CONDITION_TYPE_TRIGGER_SEVERITY,S_TRIGGER_SEVERITY); - $h2=$h2.form_select("conditiontype",CONDITION_TYPE_TRIGGER_VALUE,S_TRIGGER_VALUE); - $h2=$h2.form_select("conditiontype",CONDITION_TYPE_TIME_PERIOD,S_TIME_PERIOD); - $h2=$h2."</SELECT>"; -// echo $h2; - - $h2=$h2."<select class=\"biginput\" name=\"operator\">"; - if(in_array($conditiontype,array(CONDITION_TYPE_GROUP, CONDITION_TYPE_HOST,CONDITION_TYPE_TRIGGER,CONDITION_TYPE_TRIGGER_SEVERITY,CONDITION_TYPE_TRIGGER_VALUE))) - $h2=$h2.form_select("operator",CONDITION_OPERATOR_EQUAL,"="); - if(in_array($conditiontype,array(CONDITION_TYPE_GROUP, CONDITION_TYPE_HOST,CONDITION_TYPE_TRIGGER,CONDITION_TYPE_TRIGGER_SEVERITY))) - $h2=$h2.form_select("operator",CONDITION_OPERATOR_NOT_EQUAL,"<>"); + if(count($cond_el)==0) + array_push($cond_el, S_NO_CONDITIONS_DEFINED); + else + array_push($cond_el, new CButton('register','delete selected')); +// end of condition list preparation + + $cmbSource = new CComboBox('source', $source); + $cmbSource->AddItem(0, S_TRIGGER); + $frmAction->AddRow(S_SOURCE, $cmbSource); + + $frmAction->AddRow(S_CONDITIONS, $cond_el); + +// prepare new condition + $rowCondition=array(); + +// add condition type + $cmbCondType = new CComboBox('conditiontype',$conditiontype,'submit()'); + $cmbCondType->AddItem(CONDITION_TYPE_GROUP, S_HOST_GROUP); + $cmbCondType->AddItem(CONDITION_TYPE_HOST, S_HOST); + $cmbCondType->AddItem(CONDITION_TYPE_TRIGGER, S_TRIGGER); + $cmbCondType->AddItem(CONDITION_TYPE_TRIGGER_NAME, S_TRIGGER_NAME); + $cmbCondType->AddItem(CONDITION_TYPE_TRIGGER_SEVERITY, S_TRIGGER_SEVERITY); + $cmbCondType->AddItem(CONDITION_TYPE_TRIGGER_VALUE, S_TRIGGER_VALUE); + $cmbCondType->AddItem(CONDITION_TYPE_TIME_PERIOD, S_TIME_PERIOD); + + array_push($rowCondition,$cmbCondType); + +// add condition operation + $cmbCondOp = new CComboBox('operator'); + if(in_array($conditiontype, array( + CONDITION_TYPE_GROUP, + CONDITION_TYPE_HOST, + CONDITION_TYPE_TRIGGER, + CONDITION_TYPE_TRIGGER_SEVERITY, + CONDITION_TYPE_TRIGGER_VALUE))) + $cmbCondOp->AddItem(CONDITION_OPERATOR_EQUAL, '='); + if(in_array($conditiontype,array( + CONDITION_TYPE_GROUP, + CONDITION_TYPE_HOST, + CONDITION_TYPE_TRIGGER, + CONDITION_TYPE_TRIGGER_SEVERITY))) + $cmbCondOp->AddItem(CONDITION_OPERATOR_NOT_EQUAL, '<>'); if(in_array($conditiontype,array(CONDITION_TYPE_TRIGGER_NAME))) - $h2=$h2.form_select("operator",CONDITION_OPERATOR_LIKE,"like"); + $cmbCondOp->AddItem(CONDITION_OPERATOR_LIKE, 'like'); if(in_array($conditiontype,array(CONDITION_TYPE_TRIGGER_NAME))) - $h2=$h2.form_select("operator",CONDITION_OPERATOR_NOT_LIKE,"not like"); + $cmbCondOp->AddItem(CONDITION_OPERATOR_NOT_LIKE, 'not like'); if(in_array($conditiontype,array(CONDITION_TYPE_TIME_PERIOD))) - $h2=$h2.form_select("operator",CONDITION_OPERATOR_IN,"in"); + $cmbCondOp->AddItem(CONDITION_OPERATOR_IN, 'in'); if(in_array($conditiontype,array(CONDITION_TYPE_TRIGGER_SEVERITY))) - $h2=$h2.form_select("operator",CONDITION_OPERATOR_MORE_EQUAL,">="); - $h2=$h2."</SELECT>"; + $cmbCondOp->AddItem(CONDITION_OPERATOR_MORE_EQUAL, '>='); + + array_push($rowCondition,$cmbCondOp); - show_table2_v_delimiter($col); - echo nbsp(S_CONDITION); - show_table2_h_delimiter(); +// add condition value if($conditiontype == CONDITION_TYPE_GROUP) { - $h2=$h2."<select class=\"biginput\" name=\"value\">"; - $result=DBselect("select groupid,name from groups order by name"); - while($row=DBfetch($result)) + $cmbCondVal = new CComboBox('value'); + $groups = DBselect("select groupid,name from groups order by name"); + while($group = DBfetch($groups)) { - $h2=$h2.form_select("value",$row["groupid"],$row["name"]); + $cmbCondVal->AddItem($group["groupid"],$group["name"]); } - $h2=$h2."</SELECT>"; + array_push($rowCondition,$cmbCondVal); } else if($conditiontype == CONDITION_TYPE_HOST) { - echo "<input name=\"value\" type=\"hidden\" value=\"0\">"; - $h2=$h2."<input class=\"biginput\" readonly name=\"host\" value=\"\" size=20>"; - $h2=$h2."<input title=\"Select [Alt+T]\" accessKey=\"T\" type=\"button\" class=\"button\" value='Select' name=\"btn1\" onclick=\"window.open('popup.php?form=action&field1=value&field2=host','new_win','width=450,height=450,resizable=1,scrollbars=1');\">"; -// $h2=$h2."<select class=\"biginput\" name=\"value\">"; -// $result=DBselect("select hostid,host from hosts order by host"); -// while($row=DBfetch($result)) + $frmAction->AddVar('value','0'); + + $txtCondVal = new CTextBox('host','',20); + $txtCondVal->SetReadonly('yes'); + + $btnSelect = new CButton('btn1','Select',"window.open('popup.php?form=action&field1=value&field2=host','new_win','width=450,height=450,resizable=1,scrollbars=1');"); + $btnSelect->SetAccessKey('T'); + + array_push($rowCondition, $txtCondVal, $btnSelect); +// $cmbCondVal = new CComboBox('value'); +// $hosts = DBselect("select hostid,host from hosts order by host"); +// while($host = DBfetch($hosts)) // { -// $h2=$h2.form_select("value",$row["hostid"],$row["host"]); +// $cmbCondVal->AddItem($host["hostid"],$host["host"]); // } -// $h2=$h2."</SELECT>"; } else if($conditiontype == CONDITION_TYPE_TRIGGER) { - $h2=$h2."<select class=\"biginput\" name=\"value\">"; - $result=DBselect("select distinct h.host,t.triggerid,t.description from triggers t, functions f,items i, hosts h where t.triggerid=f.triggerid and f.itemid=i.itemid and h.hostid=i.hostid order by h.host"); - while($row=DBfetch($result)) + $cmbCondVal = new CComboBox('value'); + $triggers = DBselect("select distinct h.host,t.triggerid,t.description from triggers t, functions f,items i, hosts h where t.triggerid=f.triggerid and f.itemid=i.itemid and h.hostid=i.hostid order by h.host"); + while($trigger = DBfetch($triggers)) { - $h2=$h2.form_select("value",$row["triggerid"],$row["host"].": ".$row["description"]); + $cmbCondVal->AddItem($trigger["triggerid"],$trigger["host"].": ".$trigger["description"]); } - $h2=$h2."</SELECT>"; + array_push($rowCondition,$cmbCondVal); } else if($conditiontype == CONDITION_TYPE_TRIGGER_NAME) { - $h2=$h2."<input class=\"biginput\" name=\"value\" value=\"\" size=40>"; + array_push($rowCondition, new CTextBox('value', "", 40)); } else if($conditiontype == CONDITION_TYPE_TRIGGER_VALUE) { - $h2=$h2."<select class=\"biginput\" name=\"value\">"; - $h2=$h2.form_select("value",0,"OFF"); - $h2=$h2.form_select("value",1,"ON"); - $h2=$h2."</SELECT>"; + $cmbCondVal = new CComboBox('value'); + $cmbCondVal->AddItem(0,"OFF"); + $cmbCondVal->AddItem(1,"ON"); + array_push($rowCondition,$cmbCondVal); } else if($conditiontype == CONDITION_TYPE_TIME_PERIOD) { - $h2=$h2."<input class=\"biginput\" name=\"value\" value=\"1-7,00:00-23:59\" size=40>"; + array_push($rowCondition, new CTextBox('value', "1-7,00:00-23:59", 40)); } else if($conditiontype == CONDITION_TYPE_TRIGGER_SEVERITY) { - $h2=$h2."<select class=\"biginput\" name=\"severity\" size=1>"; - $h2=$h2."<OPTION VALUE=\"0\">".S_NOT_CLASSIFIED; - $h2=$h2."<OPTION VALUE=\"1\">".S_INFORMATION; - $h2=$h2."<OPTION VALUE=\"2\">".S_WARNING; - $h2=$h2."<OPTION VALUE=\"3\">".S_AVERAGE; - $h2=$h2."<OPTION VALUE=\"4\">".S_HIGH; - $h2=$h2."<OPTION VALUE=\"5\">".S_DISASTER; - $h2=$h2."</SELECT>"; + $cmbCondVal = new CComboBox('value'); + $cmbCondVal->AddItem(0,S_NOT_CLASSIFIED); + $cmbCondVal->AddItem(1,S_INFORMATION); + $cmbCondVal->AddItem(2,S_WARNING); + $cmbCondVal->AddItem(3,S_AVERAGE); + $cmbCondVal->AddItem(4,S_HIGH); + $cmbCondVal->AddItem(5,S_DISASTER); + array_push($rowCondition,$cmbCondVal); } - echo $h2; +// add condition button + array_push($rowCondition,BR,new CButton('register','add condition')); - show_table2_v_delimiter($col++); - echo nbsp(" "); - show_table2_h_delimiter(); - echo "<input class=\"button\" type=\"submit\" name=\"register\" value=\"add condition\">"; +// end of new condition preparation + $frmAction->AddRow(S_CONDITION, $rowCondition); - show_table2_v_delimiter($col++); - echo nbsp(S_ACTION_TYPE); - show_table2_h_delimiter(); - echo "<select class=\"biginput\" name=\"actiontype\" size=\"1\" onChange=\"submit()\">"; - echo "<option value=\"0\""; if($actiontype==0) echo " selected"; echo ">".S_SEND_MESSAGE; - echo "<option value=\"1\" disabled "; if($actiontype==1) echo " selected"; echo ">".S_REMOTE_COMMAND; - echo "</select>"; + $cmbActionType = new CComboBox('actiontype', $actiontype,'submit()'); + $cmbActionType->AddItem(0,S_SEND_MESSAGE); + $cmbActionType->AddItem(1,S_REMOTE_COMMAND,'no'); + $frmAction->AddRow(S_ACTION_TYPE, $cmbActionType); - show_table2_v_delimiter($col++); - echo nbsp(S_SEND_MESSAGE_TO); - show_table2_h_delimiter(); - echo "<select class=\"biginput\" name=\"recipient\" size=\"1\" onChange=\"submit()\">"; + $cmbRecipient = new CComboBox('recipient', $recipient,'submit()'); + $cmbRecipient->AddItem(0,S_SINGLE_USER); + $cmbRecipient->AddItem(1,S_USER_GROUP); - echo "<option value=\"0\""; if($recipient==RECIPIENT_TYPE_USER) echo " selected"; echo ">".S_SINGLE_USER; - echo "<option value=\"1\""; if($recipient==RECIPIENT_TYPE_GROUP) echo " selected"; echo ">".S_USER_GROUP; - echo "</select>"; + $frmAction->AddRow(S_SEND_MESSAGE_TO, $cmbRecipient); if($recipient==RECIPIENT_TYPE_GROUP) { - show_table2_v_delimiter($col++); - echo nbsp(S_GROUP); - show_table2_h_delimiter(); - echo "<select class=\"biginput\" name=\"usrgrpid\" size=\"1\">"; + + $cmbGroups = new CComboBox('usrgrpid', $uid); $sql="select usrgrpid,name from usrgrp order by name"; - $result=DBselect($sql); - while($row=DBfetch($result)) + $groups=DBselect($sql); + while($group=DBfetch($groups)) { -// if(isset($usrgrpid) && ($row["usrgrpid"] == $usrgrpid)) - if(isset($uid) && ($row["usrgrpid"] == $uid)) - { - echo "<option value=\"".$row["usrgrpid"]."\" selected>".$row["name"]; - } - else - { - echo "<option value=\"".$row["usrgrpid"]."\">".$row["name"]; - } + $cmbGroups->AddItem($group['usrgrpid'],$group['name']); } - echo "</select>"; + + $frmAction->AddRow(S_GROUP, $cmbGroups); } else { - show_table2_v_delimiter($col++); - echo nbsp(S_USER); - show_table2_h_delimiter(); - echo "<select class=\"biginput\" name=\"userid\" size=\"1\">"; - + $cmbUser = new CComboBox('userid', $uid); + $sql="select userid,alias from users order by alias"; - $result=DBselect($sql); - while($row=DBfetch($result)) + $users=DBselect($sql); + while($user=DBfetch($users)) { - if(isset($uid) && ($row["userid"] == $uid)) - { - echo "<option value=\"".$row["userid"]."\" selected>".$row["alias"]; - } - else - { - echo "<option value=\"".$row["userid"]."\">".$row["alias"]; - } + $cmbUser->AddItem($user['userid'],$user['alias']); } - echo "</select>"; - } - - show_table2_v_delimiter($col++); - echo nbsp(S_DELAY_BETWEEN_MESSAGES_IN_SEC); - show_table2_h_delimiter(); - echo "<input class=\"biginput\" name=\"delay\" value=\"$delay\" size=5>"; - - show_table2_v_delimiter($col++); - echo S_SUBJECT; - show_table2_h_delimiter(); - echo "<input class=\"biginput\" name=\"subject\" value=\"$subject\" size=80>"; + $frmAction->AddRow(S_USER, $cmbUser); + } - show_table2_v_delimiter($col++); - echo S_MESSAGE; - show_table2_h_delimiter(); - echo "<textarea class=\"biginput\" name=\"message\" cols=77 ROWS=\"7\" wrap=\"soft\">$message</TEXTAREA>"; + $frmAction->AddRow(S_DELAY_BETWEEN_MESSAGES_IN_SEC, new CTextBox('delay',$delay,5)); + $frmAction->AddRow(S_SUBJECT, new CTextBox('subject',$subject,80)); + $frmAction->AddRow(S_MESSAGE, new CTextArea('message',$message,77,7)); - show_table2_v_delimiter($col++); - echo nbsp(S_REPEAT); - show_table2_h_delimiter(); - echo "<select class=\"biginput\" name=\"repeat\" size=\"1\" onChange=\"submit()\">"; - - echo "<option value=\"0\""; if($repeat==0) echo " selected"; echo ">".S_NO_REPEATS; - echo "<option value=\"1\""; if($repeat==1) echo " selected"; echo ">".S_REPEAT; - echo "</select>"; + $cmbRepeat = new CComboBox('repeat',$repeat,'submit()'); + $cmbRepeat->AddItem(0,S_NO_REPEATS); + $cmbRepeat->AddItem(1,S_REPEAT); + $frmAction->AddRow(S_REPEAT, $cmbRepeat); if($repeat>0) { - show_table2_v_delimiter($col++); - echo S_NUMBER_OF_REPEATS; - show_table2_h_delimiter(); - echo "<input class=\"biginput\" name=\"maxrepeats\" value=\"$maxrepeats\" size=2>"; - - show_table2_v_delimiter($col++); - echo S_DELAY_BETWEEN_REPEATS; - show_table2_h_delimiter(); - echo "<input class=\"biginput\" name=\"repeatdelay\" value=\"$repeatdelay\" size=2>"; + $frmAction->AddRow(S_NUMBER_OF_REPEATS, new CTextBox('maxrepeats',$maxrepeats,2)); + $frmAction->AddRow(S_DELAY_BETWEEN_REPEATS, new CTextBox('repeatdelay',$repeatdelay,2)); } - - show_table2_v_delimiter2(); - echo "<input class=\"button\" type=\"submit\" name=\"register\" value=\"add\">"; + + $bottomRow = array(); if(isset($actionid)) { - echo "<input class=\"button\" type=\"submit\" name=\"register\" value=\"update\">"; - echo "<input class=\"button\" type=\"submit\" name=\"register\" value=\"delete\" onClick=\"return Confirm('Delete selected action?');\">"; + array_push($bottomRow,new CButton('register','update')); + array_push($bottomRow,SPACE,new CButton('register','delete','return Confirm("Delete selected action?");')); + } else { + array_push($bottomRow,new CButton('register','add')); } + array_push($bottomRow,SPACE,new CButton('register','cancel')); + + $frmAction->AddBottomRow($bottomRow); - show_table2_header_end(); + $frmAction->Show(); } function insert_media_type_form() diff --git a/frontends/php/include/html.inc.php b/frontends/php/include/html.inc.php index b2c729d2..8d7f6e41 100644 --- a/frontends/php/include/html.inc.php +++ b/frontends/php/include/html.inc.php @@ -19,6 +19,22 @@ **/ ?> <?php + define("BR","<br/>\n"); + define("SPACE"," "); + + function bold($str) + { + if(is_array($str)) + { + foreach($str as $key => $val) + if(is_string($val)) + $str[$key] = "<b>$val</b>"; + return $str; + } + if(is_string($str)) + return "<b>$str</b>"; + } + function nbsp($str) { return str_replace(" "," ",$str);; |
