| 1 | <?php |
|---|
| 2 | /** |
|---|
| 3 | Oreon is developped with GPL Licence 2.0 : |
|---|
| 4 | http://www.gnu.org/licenses/gpl.txt |
|---|
| 5 | Developped by : Julien Mathis - Romain Le Merlus |
|---|
| 6 | |
|---|
| 7 | Adapted to Pear library by Merethis company, under direction of Cedrick Facon, Romain Le Merlus, Julien Mathis |
|---|
| 8 | |
|---|
| 9 | The Software is provided to you AS IS and WITH ALL FAULTS. |
|---|
| 10 | OREON makes no representation and gives no warranty whatsoever, |
|---|
| 11 | whether express or implied, and without limitation, with regard to the quality, |
|---|
| 12 | safety, contents, performance, merchantability, non-infringement or suitability for |
|---|
| 13 | any particular or intended purpose of the Software found on the OREON web site. |
|---|
| 14 | In no event will OREON be liable for any direct, indirect, punitive, special, |
|---|
| 15 | incidental or consequential damages however they may arise and even if OREON has |
|---|
| 16 | been previously advised of the possibility of such damages. |
|---|
| 17 | |
|---|
| 18 | For information : contact@oreon-project.org |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | if (!isset($oreon)) |
|---|
| 22 | exit(); |
|---|
| 23 | |
|---|
| 24 | isset($_GET["sopt_id"]) ? $sG = $_GET["sopt_id"] : $sG = NULL; |
|---|
| 25 | isset($_POST["sopt_id"]) ? $sP = $_POST["sopt_id"] : $sP = NULL; |
|---|
| 26 | $sG ? $sopt_id = $sG : $sopt_id = $sP; |
|---|
| 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/statusmap3D/"; |
|---|
| 36 | |
|---|
| 37 | #PHP functions |
|---|
| 38 | require_once $path."DB-Func.php"; |
|---|
| 39 | |
|---|
| 40 | # |
|---|
| 41 | ## Database retrieve information for LCA |
|---|
| 42 | # |
|---|
| 43 | $sopt = getStatusmap3DcgiOpt(); |
|---|
| 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"=>"50"); |
|---|
| 55 | $attrsText2 = array("size"=>"20"); |
|---|
| 56 | $attrsText3 = array("size"=>"10"); |
|---|
| 57 | $attrsAdvSelect = null; |
|---|
| 58 | # |
|---|
| 59 | ## Form begin |
|---|
| 60 | # |
|---|
| 61 | $form = new HTML_QuickForm('Form', 'post', "?p=".$p); |
|---|
| 62 | $form->addElement('header', 'title', $lang["statusmap3DOpt_change"]); |
|---|
| 63 | |
|---|
| 64 | $form->addElement('header', 'nagios_statusmap3Dcgi', $lang["statusmap3DOpt"]); |
|---|
| 65 | $form->addElement('text', 'nagios_statusmap3D_html_path', $lang["statusmap3DOpt_html_path"], $attrsText ); |
|---|
| 66 | $form->addElement('text', 'nagios_statusmap3D_width', $lang["statusmap3DOpt_width"], $attrsText3 ); |
|---|
| 67 | $form->addElement('text', 'nagios_statusmap3D_height', $lang["statusmap3DOpt_height"], $attrsText3 ); |
|---|
| 68 | $form->addElement('text', 'nagios_statusmap3D_user', $lang["statusmap3DOpt_user"], $attrsText2); |
|---|
| 69 | $form->addElement('password', 'nagios_statusmap3D_password', $lang["statusmap3DOpt_password"], $attrsText2); |
|---|
| 70 | |
|---|
| 71 | $form->addElement('hidden', 'sopt_id'); |
|---|
| 72 | $redirect =& $form->addElement('hidden', 'o'); |
|---|
| 73 | $redirect->setValue($o); |
|---|
| 74 | |
|---|
| 75 | # |
|---|
| 76 | ## Form Rules |
|---|
| 77 | # |
|---|
| 78 | function slash($elem = NULL) { |
|---|
| 79 | if ($elem) |
|---|
| 80 | return rtrim($elem, "/")."/"; |
|---|
| 81 | } |
|---|
| 82 | $form->applyFilter('_ALL_', 'trim'); |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | # |
|---|
| 86 | ##End of form definition |
|---|
| 87 | # |
|---|
| 88 | |
|---|
| 89 | # Smarty template Init |
|---|
| 90 | $tpl = new Smarty(); |
|---|
| 91 | $tpl = initSmartyTpl($path, $tpl); |
|---|
| 92 | |
|---|
| 93 | $form->setDefaults($sopt); |
|---|
| 94 | |
|---|
| 95 | $subC =& $form->addElement('submit', 'submitC', $lang["save"]); |
|---|
| 96 | $DBRESULT =& $form->addElement('reset', 'reset', $lang["reset"]); |
|---|
| 97 | |
|---|
| 98 | |
|---|
| 99 | $valid = false; |
|---|
| 100 | if ($form->validate()) { |
|---|
| 101 | |
|---|
| 102 | # Update in DB |
|---|
| 103 | updateStatusmap3DcgiConfigData($form->getSubmitValue("sopt_id")); |
|---|
| 104 | # Update in Oreon Object |
|---|
| 105 | // $oreon->optGen = array(); |
|---|
| 106 | // $DBRESULT2 =& $pearDB->query("SELECT * FROM `3Dstatusmapcgi_opt` LIMIT 1"); |
|---|
| 107 | // $oreon->optGen = $DBRESULT2->fetchRow(); |
|---|
| 108 | $o = "w"; |
|---|
| 109 | $valid = true; |
|---|
| 110 | $form->freeze(); |
|---|
| 111 | |
|---|
| 112 | } |
|---|
| 113 | if (!$form->validate() && isset($_POST["sopt_id"])) { |
|---|
| 114 | print("<div class='msg' align='center'>".$lang["quickFormError"]."</div>"); |
|---|
| 115 | } |
|---|
| 116 | |
|---|
| 117 | $form->addElement("button", "change", $lang['modify'], array("onClick"=>"javascript:window.location.href='?p=".$p."&o=statusmap3D'")); |
|---|
| 118 | |
|---|
| 119 | # |
|---|
| 120 | ##Apply a template definition |
|---|
| 121 | # |
|---|
| 122 | |
|---|
| 123 | $renderer =& new HTML_QuickForm_Renderer_ArraySmarty($tpl); |
|---|
| 124 | $renderer->setRequiredTemplate('{$label} <font color="red" size="1">*</font>'); |
|---|
| 125 | $renderer->setErrorTemplate('<font color="red">{$error}</font><br />{$html}'); |
|---|
| 126 | $form->accept($renderer); |
|---|
| 127 | $tpl->assign('form', $renderer->toArray()); |
|---|
| 128 | $tpl->assign('o', $o); |
|---|
| 129 | $tpl->assign('valid', $valid); |
|---|
| 130 | $tpl->display("formStatusmap3D.ihtml"); |
|---|
| 131 | ?> |
|---|