From 95d31515f8e7c11bfc65839fd86e1a3bd1ba9fa4 Mon Sep 17 00:00:00 2001 From: Lionel Assepo Date: Fri, 23 Oct 2015 11:14:46 +0200 Subject: [PATCH] * refs #3846 : Fix issue with token on update module page Conflicts: www/include/options/oreon/modules/formModule.php --- .../options/oreon/modules/formModule.ihtml | 6 +-- .../options/oreon/modules/formModule.php | 46 +++++++++---------- www/include/options/oreon/modules/modules.php | 9 +++- .../sql/centreon/Update-DB-2.6.5_to_2.6.6.sql | 2 + ...2.7.0.sql => Update-DB-2.6.6_to_2.7.0.sql} | 0 5 files changed, 36 insertions(+), 27 deletions(-) create mode 100644 www/install/sql/centreon/Update-DB-2.6.5_to_2.6.6.sql rename www/install/sql/centreon/{Update-DB-2.6.5_to_2.7.0.sql => Update-DB-2.6.6_to_2.7.0.sql} (100%) diff --git a/www/include/options/oreon/modules/formModule.ihtml b/www/include/options/oreon/modules/formModule.ihtml index f5f619b30fd..1381fd772e6 100644 --- a/www/include/options/oreon/modules/formModule.ihtml +++ b/www/include/options/oreon/modules/formModule.ihtml @@ -49,12 +49,12 @@ {/if} - {if $form2.list.html} + {if $form.list.html} -
+
- {$form2.list.html} + {$form.list.html}
diff --git a/www/include/options/oreon/modules/formModule.php b/www/include/options/oreon/modules/formModule.php index 4fb5c14876f..aaee48ccc85 100644 --- a/www/include/options/oreon/modules/formModule.php +++ b/www/include/options/oreon/modules/formModule.php @@ -56,11 +56,11 @@ $tpl->assign("headerMenu_infos", _("Additionnal Information")); $tpl->assign("headerMenu_isinstalled", _("Installed")); $tpl->assign("headerMenu_isvalid", _("Valid for an upgrade")); - + /* * "Name" case, it's not a module which is installed */ - if ($name) { + if ($operationType === 'install') { $flag = false; include_once(_CENTREON_PATH_ . "www/modules/".$name."/conf.php"); $tpl->assign("module_rname", $module_conf[$name]["rname"]); @@ -71,8 +71,9 @@ $infos_streams = file(_CENTREON_PATH_ . "www/modules/".$name."/infos/infos.txt"); $infos_streams = implode("
", $infos_streams); $tpl->assign("module_infosTxt", $infos_streams); - } else + } else { $tpl->assign("module_infosTxt", false); + } $form1 = new HTML_QuickForm('Form', 'post', "?p=".$p); @@ -121,7 +122,7 @@ $renderer = new HTML_QuickForm_Renderer_ArraySmarty($tpl); $form1->accept($renderer); $tpl->assign('form1', $renderer->toArray()); - } else if ($id) { + } elseif ($operationType === 'upgrade') { /* * "ID" case, it's an installed module @@ -129,6 +130,10 @@ $moduleinfo = getModuleInfoInDB(NULL, $id); $elemArr = array(); + $form = new HTML_QuickForm('Form', 'post', "?p=".$p); + $form->addElement('submit', 'list', _("Back")); + if (is_dir($centreon_path . "www/modules/".$moduleinfo["name"]."/UPGRADE")) { + $handle = opendir($centreon_path . "www/modules/".$moduleinfo["name"]."/UPGRADE"); if (is_dir(_CENTREON_PATH_ . "www/modules/".$moduleinfo["name"]."/UPGRADE")) { $handle = opendir(_CENTREON_PATH_ . "www/modules/".$moduleinfo["name"]."/UPGRADE"); $i = 0; @@ -137,7 +142,7 @@ if (substr($filename, 0, 1) != "." && strstr($filename, $moduleinfo["name"]."-")) { include_once(_CENTREON_PATH_ . "www/modules/".$moduleinfo["name"]."/UPGRADE/".$filename."/conf.php"); if ($moduleinfo["mod_release"] == $upgrade_conf[$moduleinfo["name"]]["release_from"]) { - $form = new HTML_QuickForm('Form', 'post', "?p=".$p); + $upgrade_ok = false; # Upgrade if ($form->validate()) { @@ -195,32 +200,27 @@ $hid_id->setValue($id); $up_name = $form->addElement('hidden', 'filename'); $up_name->setValue($filename); - $form->addElement('submit', 'list', _("Back"), array("class" => "btc bt_default")); - $renderer = new HTML_QuickForm_Renderer_ArraySmarty($tpl); - $form->accept($renderer); - $tpl->assign('form', $renderer->toArray()); + } } } closedir($handle); } - $moduleinfo = array(); - $moduleinfo = getModuleInfoInDB(NULL, $id); - $tpl->assign("module_rname", $moduleinfo["rname"]); - $tpl->assign("module_release", $moduleinfo["mod_release"]); - $tpl->assign("module_author", $moduleinfo["author"]); - $tpl->assign("module_infos", $moduleinfo["infos"]); - $tpl->assign("module_isinstalled", _("Yes")); - $tpl->assign("elemArr", $elemArr); - $form2 = new HTML_QuickForm('Form', 'post', "?p=".$p); - $form2->addElement('submit', 'list', _("Back"), array("class" => "btc bt_default")); - $renderer = new HTML_QuickForm_Renderer_ArraySmarty($tpl); - $form2->accept($renderer); - $tpl->assign('form2', $renderer->toArray()); + $moduleinfo = array(); + $moduleinfo = getModuleInfoInDB(NULL, $id); + $tpl->assign("module_rname", $moduleinfo["rname"]); + $tpl->assign("module_release", $moduleinfo["mod_release"]); + $tpl->assign("module_author", $moduleinfo["author"]); + $tpl->assign("module_infos", $moduleinfo["infos"]); + $tpl->assign("module_isinstalled", _("Yes")); + $tpl->assign("elemArr", $elemArr); + $renderer = new HTML_QuickForm_Renderer_ArraySmarty($tpl); + $form->accept($renderer); + $tpl->assign('form', $renderer->toArray()); } /** * Display form */ $tpl->display("formModule.ihtml"); -?> \ No newline at end of file +?> diff --git a/www/include/options/oreon/modules/modules.php b/www/include/options/oreon/modules/modules.php index f4108945373..f79ce6b3454 100644 --- a/www/include/options/oreon/modules/modules.php +++ b/www/include/options/oreon/modules/modules.php @@ -50,7 +50,14 @@ isset($_GET["name"]) ? $nameG = $_GET["name"] : $nameG = NULL; isset($_POST["name"]) ? $nameP = $_POST["name"] : $nameP = NULL; $nameG ? $name = $nameG : $name = $nameP; - + + $operationType = ''; + if ($name !== NULL) { + $operationType = 'install'; + } elseif ($id !== NULL) { + $operationType = 'upgrade'; + } + /* * Pear library */ diff --git a/www/install/sql/centreon/Update-DB-2.6.5_to_2.6.6.sql b/www/install/sql/centreon/Update-DB-2.6.5_to_2.6.6.sql new file mode 100644 index 00000000000..f5e5ab27bb0 --- /dev/null +++ b/www/install/sql/centreon/Update-DB-2.6.5_to_2.6.6.sql @@ -0,0 +1,2 @@ +-- Change version of Centreon +UPDATE `informations` SET `value` = '2.6.6' WHERE CONVERT( `informations`.`key` USING utf8 ) = 'version' AND CONVERT ( `informations`.`value` USING utf8 ) = '2.6.5' LIMIT 1; diff --git a/www/install/sql/centreon/Update-DB-2.6.5_to_2.7.0.sql b/www/install/sql/centreon/Update-DB-2.6.6_to_2.7.0.sql similarity index 100% rename from www/install/sql/centreon/Update-DB-2.6.5_to_2.7.0.sql rename to www/install/sql/centreon/Update-DB-2.6.6_to_2.7.0.sql