Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

feat(widget): upgrade poller preference of engine-status widget #7820

Merged
merged 3 commits into from
Sep 10, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions doc/en/release_notes/centreon-19.10/centreon-19.10.0-beta.4.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
===========================
Centreon Web 19.10.0-beta.4
===========================

New features
------------

Enhancements
------------

Performance
-----------

Bug fixes
---------

Technical
---------
1 change: 1 addition & 0 deletions doc/en/release_notes/centreon-19.10/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 18 additions & 0 deletions doc/fr/release_notes/centreon-19.10/centreon-19.10.0-beta.4.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
===========================
Centreon Web 19.10.0-beta.4
===========================

New features
------------

Enhancements
------------

Performance
-----------

Bug fixes
---------

Technical
---------
1 change: 1 addition & 0 deletions doc/fr/release_notes/centreon-19.10/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion www/install/insertBaseConf.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
74 changes: 74 additions & 0 deletions www/install/php/Update-19.10.0-beta.4.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php
/*
* Copyright 2005-2019 Centreon
* Centreon is developed by : Julien Mathis and Romain Le Merlus under
* GPL Licence 2.0.
*
* 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.
*
* 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, see <http://www.gnu.org/licenses>.
*
* 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();
}