root/trunk/module-NagiosStatusMap/formStatusmap.php

Revision 3490, 4.5 kB (checked in by jmathis, 14 months ago)

replace <? by <?php

Line 
1<?php
2/**
3Oreon is developped with GPL Licence 2.0 :
4http://www.gnu.org/licenses/gpl.txt
5Developped by : Julien Mathis - Romain Le Merlus - Christophe Coraboeuf
6
7Adapted to Pear library by Merethis company, under direction of Cedrick Facon, Romain Le Merlus, Julien Mathis
8
9The Software is provided to you AS IS and WITH ALL FAULTS.
10OREON makes no representation and gives no warranty whatsoever,
11whether express or implied, and without limitation, with regard to the quality,
12safety, contents, performance, merchantability, non-infringement or suitability for
13any particular or intended purpose of the Software found on the OREON web site.
14In no event will OREON be liable for any direct, indirect, punitive, special,
15incidental or consequential damages however they may arise and even if OREON has
16been previously advised of the possibility of such damages.
17
18For information : contact@oreon-project.org
19*/
20
21        if (!isset($oreon))
22                exit();
23       
24/*      isset($_GET["gopt_id"]) ? $cG = $_GET["gopt_id"] : $cG = NULL;
25        isset($_POST["lca_id"]) ? $cP = $_POST["gopt_id"] : $cP = NULL;
26        $cG ? $gopt_id = $cG : $gopt_id = $cP;
27        */     
28        #Pear library
29        require_once "HTML/QuickForm.php";
30        require_once 'HTML/QuickForm/advmultiselect.php';
31        require_once 'HTML/QuickForm/Renderer/ArraySmarty.php';
32       
33        #Path to the configuration dir
34        global $path;
35        $path = "./modules/statusmap/";
36
37        #PHP functions
38        require_once $path."DB-Func.php";               
39               
40        #
41        ## Database retrieve information for LCA
42        #
43        $sopt = getStatusmapcgiOpt();
44        #
45        ## Database retrieve information for differents elements list we need on the page
46        #
47        #
48        # End of "database-retrieved" information
49        ##########################################################
50        ##########################################################
51        # Var information to format the element
52        #
53
54        $attrsText              = array("size"=>"40");
55        $attrsText2             = array("size"=>"20");
56        $attrsAdvSelect = null;
57        #
58        ## Form begin
59        #
60        $form = new HTML_QuickForm('Form', 'post', "?p=".$p);
61        $form->addElement('header', 'title', $lang["statusmapOpt_change"]);
62
63        $form->addElement('header', 'nagios_statusmapcgi', $lang["statusmapOpt"]);
64        $form->addElement('text', 'nagios_statusmapcgi_html_path', $lang["statusmapOpt_statusmapcgi_html_path"], $attrsText );
65        $form->addElement('text', 'nagios_statusmap_user', $lang["statusmapOpt_statusmap_user"],  $attrsText2);
66        $form->addElement('password', 'nagios_statusmap_password', $lang["statusmapOpt_statusmap_password"], $attrsText2);
67        $tab = array();
68        $tab[] = &HTML_QuickForm::createElement('radio', 'nagios_statusmap_use_lca', null, $lang["yes"], '1');
69        $tab[] = &HTML_QuickForm::createElement('radio', 'nagios_statusmap_use_lca', null, $lang["no"], '0');
70        $form->addGroup($tab, 'nagios_statusmap_use_lca', $lang["statusmapOpt_nagios_statusmap_use_lca"], '&nbsp;');
71        $form->setDefaults(array('nagios_statusmap_use_lca' => '0'));
72               
73       
74        $form->addElement('hidden', 'sopt_id');
75        $redirect =& $form->addElement('hidden', 'o');
76        $redirect->setValue($o);
77
78        #
79        ## Form Rules
80        #
81        function slash($elem = NULL)    {
82                if ($elem)
83                        return rtrim($elem, "/")."/";
84        }
85        $form->applyFilter('_ALL_', 'trim');
86
87
88        #
89        ##End of form definition
90        #
91
92        # Smarty template Init
93        $tpl = new Smarty();
94        $tpl = initSmartyTpl($path, $tpl);
95
96        $form->setDefaults($sopt);
97
98        $subC =& $form->addElement('submit', 'submitC', $lang["save"]);
99        $DBRESULT =& $form->addElement('reset', 'reset', $lang["reset"]);
100
101
102    $valid = false;
103        if ($form->validate())  {
104
105                # Update in DB
106                updateStatusmapcifConfigData($form->getSubmitValue("sopt_id"));
107                # Update in Oreon Object
108                $oreon->optGen = array();
109                $DBRESULT2 =& $pearDB->query("SELECT * FROM `statusmapcgi_opt` LIMIT 1");
110                $oreon->optGen = $DBRESULT2->fetchRow();
111                $o = "w";
112                $valid = true;
113                $form->freeze();
114
115        }
116        if (!$form->validate() && isset($_POST["gopt_id"]))     {
117            print("<div class='msg' align='center'>".$lang["quickFormError"]."</div>");
118        }
119
120        $form->addElement("button", "change", $lang['modify'], array("onClick"=>"javascript:window.location.href='?p=".$p."&o=statusmap'"));
121
122        #
123        ##Apply a template definition
124        #
125
126        $renderer =& new HTML_QuickForm_Renderer_ArraySmarty($tpl);
127        $renderer->setRequiredTemplate('{$label}&nbsp;<font color="red" size="1">*</font>');
128        $renderer->setErrorTemplate('<font color="red">{$error}</font><br />{$html}');
129        $form->accept($renderer);
130        $tpl->assign('form', $renderer->toArray());
131        $tpl->assign('o', $o);
132        $tpl->assign('valid', $valid);
133        $tpl->display("formStatusmap.ihtml");
134?>
Note: See TracBrowser for help on using the browser.