From abe3586b08afbf1ccf9403160f225cca7fe0ebdd Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Fri, 30 Aug 2019 11:48:54 +0200 Subject: [PATCH 1/2] feat(widget): upgrade poller preference of engine-status widget --- .../centreon-19.10.0-beta.4.rst | 18 +++++ doc/en/release_notes/centreon-19.10/index.rst | 1 + .../centreon-19.10.0-beta.4.rst | 18 +++++ doc/fr/release_notes/centreon-19.10/index.rst | 1 + www/install/insertBaseConf.sql | 2 +- www/install/php/Update-19.10.0-beta.4.php | 74 +++++++++++++++++++ 6 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 doc/en/release_notes/centreon-19.10/centreon-19.10.0-beta.4.rst create mode 100644 doc/fr/release_notes/centreon-19.10/centreon-19.10.0-beta.4.rst create mode 100644 www/install/php/Update-19.10.0-beta.4.php diff --git a/doc/en/release_notes/centreon-19.10/centreon-19.10.0-beta.4.rst b/doc/en/release_notes/centreon-19.10/centreon-19.10.0-beta.4.rst new file mode 100644 index 00000000000..f56e173f372 --- /dev/null +++ b/doc/en/release_notes/centreon-19.10/centreon-19.10.0-beta.4.rst @@ -0,0 +1,18 @@ +=========================== +Centreon Web 19.10.0-beta.4 +=========================== + +New features +------------ + +Enhancements +------------ + +Performance +----------- + +Bug fixes +--------- + +Technical +--------- diff --git a/doc/en/release_notes/centreon-19.10/index.rst b/doc/en/release_notes/centreon-19.10/index.rst index 894cd2cb9c1..b6bb2ca397d 100644 --- a/doc/en/release_notes/centreon-19.10/index.rst +++ b/doc/en/release_notes/centreon-19.10/index.rst @@ -10,6 +10,7 @@ Please find here the release notes dedicated to the last 19.10.x version of Cent .. toctree:: :maxdepth: 1 + centreon-19.10.0-beta.4 centreon-19.10.0-beta.3 centreon-19.10.0-beta.2 centreon-19.10.0-beta.1 diff --git a/doc/fr/release_notes/centreon-19.10/centreon-19.10.0-beta.4.rst b/doc/fr/release_notes/centreon-19.10/centreon-19.10.0-beta.4.rst new file mode 100644 index 00000000000..f56e173f372 --- /dev/null +++ b/doc/fr/release_notes/centreon-19.10/centreon-19.10.0-beta.4.rst @@ -0,0 +1,18 @@ +=========================== +Centreon Web 19.10.0-beta.4 +=========================== + +New features +------------ + +Enhancements +------------ + +Performance +----------- + +Bug fixes +--------- + +Technical +--------- diff --git a/doc/fr/release_notes/centreon-19.10/index.rst b/doc/fr/release_notes/centreon-19.10/index.rst index 41df1a19d86..232eb39f43a 100644 --- a/doc/fr/release_notes/centreon-19.10/index.rst +++ b/doc/fr/release_notes/centreon-19.10/index.rst @@ -10,6 +10,7 @@ Please find here the release notes dedicated to the last 19.10.x version of Cent .. toctree:: :maxdepth: 1 + centreon-19.10.0-beta.4 centreon-19.10.0-beta.3 centreon-19.10.0-beta.2 centreon-19.10.0-beta.1 diff --git a/www/install/insertBaseConf.sql b/www/install/insertBaseConf.sql index faa82abcf90..f12978e194e 100644 --- a/www/install/insertBaseConf.sql +++ b/www/install/insertBaseConf.sql @@ -2,7 +2,7 @@ -- Insert version -- -INSERT INTO `informations` (`key` ,`value`) VALUES ('version', '19.10.0-beta.3'); +INSERT INTO `informations` (`key` ,`value`) VALUES ('version', '19.10.0-beta.4'); -- -- Contenu de la table `contact` diff --git a/www/install/php/Update-19.10.0-beta.4.php b/www/install/php/Update-19.10.0-beta.4.php new file mode 100644 index 00000000000..c0818cd7778 --- /dev/null +++ b/www/install/php/Update-19.10.0-beta.4.php @@ -0,0 +1,74 @@ +. + * + * Linking this program statically or dynamically with other modules is making a + * combined work based on this program. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this program give Centreon + * permission to link this program with independent modules to produce an executable, + * regardless of the license terms of these independent modules, and to copy and + * distribute the resulting executable under terms of Centreon choice, provided that + * Centreon also meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module which is not + * derived from this program. If you modify this program, you may extend this + * exception to your version of the program, but you are not obliged to do so. If you + * do not wish to do so, delete this exception statement from your version. + * + * For more information : contact@centreon.com + * + * + */ + +// set cache for pollers +$pollers = []; +$result = $pearDB->query('SELECT id, name FROM nagios_server'); +while ($row = $result->fetch()) { + $pollerName = strtolower($row['name']); + $pollers[$pollerName] = $row['id']; +} + +// get poller preferences of engine-status widget +$result = $pearDB->query( + 'SELECT wpr.widget_view_id, wpr.parameter_id, wpr.preference_value, wpr.user_id + FROM widget_preferences wpr + INNER JOIN widget_parameters wpa ON wpa.parameter_id = wpr.parameter_id + AND wpa.parameter_code_name = \'poller\' + INNER JOIN widget_models wm ON wm.widget_model_id = wpa.widget_model_id + AND wm.title = \'Engine-Status\'' +); + +$statement = $pearDB->prepare( + 'UPDATE widget_preferences + SET preference_value= :value + WHERE widget_view_id = :view_id + AND parameter_id = :parameter_id + AND user_id = :user_id' +); + +// update poller preferences from name to id +while ($row = $result->fetch()) { + $pollerId = isset($pollers[$row['preference_value']]) + ? $pollers[$row['preference_value']] + : ''; + + $statement->bindValue(':value', $pollerId, \PDO::PARAM_STR); + $statement->bindValue(':view_id', $row['widget_view_id'], \PDO::PARAM_INT); + $statement->bindValue(':parameter_id', $row['parameter_id'], \PDO::PARAM_INT); + $statement->bindValue(':user_id', $row['user_id'], \PDO::PARAM_INT); + $statement->execute(); +} From 70cd46a54664dd2c3e32f7d04937b8db129c010a Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Tue, 10 Sep 2019 15:30:23 +0200 Subject: [PATCH 2/2] downgrade to beta.4 --- .../centreon-19.10.0-beta.4.rst | 18 ----- doc/en/release_notes/centreon-19.10/index.rst | 1 - .../centreon-19.10.0-beta.4.rst | 18 ----- doc/fr/release_notes/centreon-19.10/index.rst | 1 - www/install/insertBaseConf.sql | 2 +- www/install/php/Update-19.10.0-beta.3.php | 44 +++++++++++ www/install/php/Update-19.10.0-beta.4.php | 74 ------------------- 7 files changed, 45 insertions(+), 113 deletions(-) delete mode 100644 doc/en/release_notes/centreon-19.10/centreon-19.10.0-beta.4.rst delete mode 100644 doc/fr/release_notes/centreon-19.10/centreon-19.10.0-beta.4.rst delete mode 100644 www/install/php/Update-19.10.0-beta.4.php diff --git a/doc/en/release_notes/centreon-19.10/centreon-19.10.0-beta.4.rst b/doc/en/release_notes/centreon-19.10/centreon-19.10.0-beta.4.rst deleted file mode 100644 index f56e173f372..00000000000 --- a/doc/en/release_notes/centreon-19.10/centreon-19.10.0-beta.4.rst +++ /dev/null @@ -1,18 +0,0 @@ -=========================== -Centreon Web 19.10.0-beta.4 -=========================== - -New features ------------- - -Enhancements ------------- - -Performance ------------ - -Bug fixes ---------- - -Technical ---------- diff --git a/doc/en/release_notes/centreon-19.10/index.rst b/doc/en/release_notes/centreon-19.10/index.rst index b6bb2ca397d..894cd2cb9c1 100644 --- a/doc/en/release_notes/centreon-19.10/index.rst +++ b/doc/en/release_notes/centreon-19.10/index.rst @@ -10,7 +10,6 @@ Please find here the release notes dedicated to the last 19.10.x version of Cent .. toctree:: :maxdepth: 1 - centreon-19.10.0-beta.4 centreon-19.10.0-beta.3 centreon-19.10.0-beta.2 centreon-19.10.0-beta.1 diff --git a/doc/fr/release_notes/centreon-19.10/centreon-19.10.0-beta.4.rst b/doc/fr/release_notes/centreon-19.10/centreon-19.10.0-beta.4.rst deleted file mode 100644 index f56e173f372..00000000000 --- a/doc/fr/release_notes/centreon-19.10/centreon-19.10.0-beta.4.rst +++ /dev/null @@ -1,18 +0,0 @@ -=========================== -Centreon Web 19.10.0-beta.4 -=========================== - -New features ------------- - -Enhancements ------------- - -Performance ------------ - -Bug fixes ---------- - -Technical ---------- diff --git a/doc/fr/release_notes/centreon-19.10/index.rst b/doc/fr/release_notes/centreon-19.10/index.rst index 232eb39f43a..41df1a19d86 100644 --- a/doc/fr/release_notes/centreon-19.10/index.rst +++ b/doc/fr/release_notes/centreon-19.10/index.rst @@ -10,7 +10,6 @@ Please find here the release notes dedicated to the last 19.10.x version of Cent .. toctree:: :maxdepth: 1 - centreon-19.10.0-beta.4 centreon-19.10.0-beta.3 centreon-19.10.0-beta.2 centreon-19.10.0-beta.1 diff --git a/www/install/insertBaseConf.sql b/www/install/insertBaseConf.sql index f12978e194e..faa82abcf90 100644 --- a/www/install/insertBaseConf.sql +++ b/www/install/insertBaseConf.sql @@ -2,7 +2,7 @@ -- Insert version -- -INSERT INTO `informations` (`key` ,`value`) VALUES ('version', '19.10.0-beta.4'); +INSERT INTO `informations` (`key` ,`value`) VALUES ('version', '19.10.0-beta.3'); -- -- Contenu de la table `contact` diff --git a/www/install/php/Update-19.10.0-beta.3.php b/www/install/php/Update-19.10.0-beta.3.php index 8a713bbaaf6..fa33010e4e3 100644 --- a/www/install/php/Update-19.10.0-beta.3.php +++ b/www/install/php/Update-19.10.0-beta.3.php @@ -146,3 +146,47 @@ "UPGRADE : 19.10.0-beta.3 Unable to modify regexp matching in the database" ); } + +/** + * Manage upgrade of widget preferences + */ + +// set cache for pollers +$pollers = []; +$result = $pearDB->query('SELECT id, name FROM nagios_server'); +while ($row = $result->fetch()) { + $pollerName = strtolower($row['name']); + $pollers[$pollerName] = $row['id']; +} + +// get poller preferences of engine-status widget +$result = $pearDB->query( + 'SELECT wpr.widget_view_id, wpr.parameter_id, wpr.preference_value, wpr.user_id + FROM widget_preferences wpr + INNER JOIN widget_parameters wpa ON wpa.parameter_id = wpr.parameter_id + AND wpa.parameter_code_name = \'poller\' + INNER JOIN widget_models wm ON wm.widget_model_id = wpa.widget_model_id + AND wm.title = \'Engine-Status\'' +); + +$statement = $pearDB->prepare( + 'UPDATE widget_preferences + SET preference_value= :value + WHERE widget_view_id = :view_id + AND parameter_id = :parameter_id + AND user_id = :user_id' +); + +// update poller preferences from name to id +while ($row = $result->fetch()) { + $pollerName = strtolower($row['preference_value']); + $pollerId = isset($pollers[$pollerName]) + ? $pollers[$pollerName] + : ''; + + $statement->bindValue(':value', $pollerId, \PDO::PARAM_STR); + $statement->bindValue(':view_id', $row['widget_view_id'], \PDO::PARAM_INT); + $statement->bindValue(':parameter_id', $row['parameter_id'], \PDO::PARAM_INT); + $statement->bindValue(':user_id', $row['user_id'], \PDO::PARAM_INT); + $statement->execute(); +} diff --git a/www/install/php/Update-19.10.0-beta.4.php b/www/install/php/Update-19.10.0-beta.4.php deleted file mode 100644 index c0818cd7778..00000000000 --- a/www/install/php/Update-19.10.0-beta.4.php +++ /dev/null @@ -1,74 +0,0 @@ -. - * - * Linking this program statically or dynamically with other modules is making a - * combined work based on this program. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this program give Centreon - * permission to link this program with independent modules to produce an executable, - * regardless of the license terms of these independent modules, and to copy and - * distribute the resulting executable under terms of Centreon choice, provided that - * Centreon also meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module which is not - * derived from this program. If you modify this program, you may extend this - * exception to your version of the program, but you are not obliged to do so. If you - * do not wish to do so, delete this exception statement from your version. - * - * For more information : contact@centreon.com - * - * - */ - -// set cache for pollers -$pollers = []; -$result = $pearDB->query('SELECT id, name FROM nagios_server'); -while ($row = $result->fetch()) { - $pollerName = strtolower($row['name']); - $pollers[$pollerName] = $row['id']; -} - -// get poller preferences of engine-status widget -$result = $pearDB->query( - 'SELECT wpr.widget_view_id, wpr.parameter_id, wpr.preference_value, wpr.user_id - FROM widget_preferences wpr - INNER JOIN widget_parameters wpa ON wpa.parameter_id = wpr.parameter_id - AND wpa.parameter_code_name = \'poller\' - INNER JOIN widget_models wm ON wm.widget_model_id = wpa.widget_model_id - AND wm.title = \'Engine-Status\'' -); - -$statement = $pearDB->prepare( - 'UPDATE widget_preferences - SET preference_value= :value - WHERE widget_view_id = :view_id - AND parameter_id = :parameter_id - AND user_id = :user_id' -); - -// update poller preferences from name to id -while ($row = $result->fetch()) { - $pollerId = isset($pollers[$row['preference_value']]) - ? $pollers[$row['preference_value']] - : ''; - - $statement->bindValue(':value', $pollerId, \PDO::PARAM_STR); - $statement->bindValue(':view_id', $row['widget_view_id'], \PDO::PARAM_INT); - $statement->bindValue(':parameter_id', $row['parameter_id'], \PDO::PARAM_INT); - $statement->bindValue(':user_id', $row['user_id'], \PDO::PARAM_INT); - $statement->execute(); -}