diff --git a/www/class/centreon-knowledge/wikiApi.class.php b/www/class/centreon-knowledge/wikiApi.class.php index 9ebc85caedb8cafbbc1f7abb587933872a60dbf8..ef707b3c924d3a316a87f29ee4337501694d3419 100644 --- a/www/class/centreon-knowledge/wikiApi.class.php +++ b/www/class/centreon-knowledge/wikiApi.class.php @@ -390,12 +390,13 @@ class WikiApi $resHost = $this->db->execute($stmt, array((string)$hostName)); $tuple = $resHost->fetchRow(); + $valueToAdd = './include/configuration/configKnowledge/proxy/proxy.php?host_name=$HOSTNAME$'; $queryUpdate = "UPDATE extended_host_information " - . "SET ehi_notes_url = '" . $valueToAdd . "' " + . "SET ehi_notes_url = ? " . "WHERE host_host_id = ?"; $stmt = $this->db->prepare($queryUpdate); - $this->db->execute($stmt, array((int)$tuple['host_id'])); + $this->db->execute($stmt, array((string)$valueToAdd, (int)$tuple['host_id'])); } /** @@ -413,16 +414,17 @@ class WikiApi $stmt = $this->db->prepare($query); - $resService =$this->db->execute($stmt, array((string)$hostName, (string)$serviceDescription)); + $resService = $this->db->execute($stmt, array((string)$hostName, (string)$serviceDescription)); $tuple = $resService->fetchRow(); $valueToAdd = './include/configuration/configKnowledge/proxy/proxy.php?' . 'host_name=$HOSTNAME$&service_description=$SERVICEDESC$'; $queryUpdate = "UPDATE extended_service_information " . - "SET esi_notes_url = '" . $valueToAdd . "' " . + "SET esi_notes_url = ? " . "WHERE service_service_id = ? "; $stmt = $this->db->prepare($queryUpdate); - $this->db->execute($stmt, array((int)$tuple['service_id'])); + $this->db->execute($stmt, array((string)$valueToAdd, (int)$tuple['service_id'])); + } /** @@ -438,10 +440,10 @@ class WikiApi $valueToAdd = './include/configuration/configKnowledge/proxy/proxy.php?' . 'host_name=$HOSTNAME$&service_description=$SERVICEDESC$'; $queryUpdate = "UPDATE extended_service_information " . - "SET esi_notes_url = '" . $valueToAdd . "' " . + "SET esi_notes_url = ? " . "WHERE service_service_id = ? "; $stmt = $this->db->prepare($queryUpdate); - $this->db->execute($stmt, array((int)$tuple['service_id'])); + $this->db->execute($stmt, array((string)$valueToAdd, (int)$tuple['service_id'])); } } diff --git a/www/include/configuration/configKnowledge/functions.php b/www/include/configuration/configKnowledge/functions.php index 27a854cd205abda8298dff203105adff3b174786..e7e55fcf27046ff204adfe74560e5ea15b9643ba 100644 --- a/www/include/configuration/configKnowledge/functions.php +++ b/www/include/configuration/configKnowledge/functions.php @@ -29,10 +29,11 @@ function versionCentreon($pearDB) function getWikiConfig($pearDB) { - $errorMsg = 'MediaWiki is not installed or configured. Please refer to the - <a href="https://documentation-fr.centreon.com/docs/centreon-knowledge-base/en/latest/" target="_blank" >documentation.</a>'; + $errorMsg = 'MediaWiki is not installed or configured. Please refer to the ' . + '<a href="https://documentation-fr.centreon.com/docs/centreon-knowledge-base/en/latest/" target="_blank" >' . + 'documentation.</a>'; - $mandatoryConfigKey = array('kb_db_name', 'kb_db_host', 'kb_WikiURL'); + $mandatoryConfigKey = array('kb_db_name', 'kb_db_host', 'kb_wiki_url'); if (is_null($pearDB)) { throw new \Exception($errorMsg); } @@ -45,6 +46,7 @@ function getWikiConfig($pearDB) $gopt = array(); while ($opt = $res->fetchRow()) { + if (!empty($opt["value"])) { $gopt[$opt["key"]] = html_entity_decode($opt["value"], ENT_QUOTES, "UTF-8"); } else { diff --git a/www/install/insertBaseConf.sql b/www/install/insertBaseConf.sql index c5b985d2900e9f51ded62e93f3d2fe3e9d5086ad..9edbad3873385f81f98d5b2de44aa77057b5dadc 100644 --- a/www/install/insertBaseConf.sql +++ b/www/install/insertBaseConf.sql @@ -1280,4 +1280,4 @@ VALUES ('kb_db_name', ''), ('kb_db_password', ''), ('kb_db_host', ''), ('kb_db_prefix', ''), -('kb_WikiURL', ''); +('kb_wiki_url', ''); diff --git a/www/install/php/Update-2.8.7_to_2.8.8.php b/www/install/php/Update-2.8.7_to_2.8.8.php new file mode 100644 index 0000000000000000000000000000000000000000..ee46f1519f82d9a71257eefe496345414677d5e4 --- /dev/null +++ b/www/install/php/Update-2.8.7_to_2.8.8.php @@ -0,0 +1,47 @@ +<?php +/* + * Copyright 2005-2016 Centreon + * Centreon is developped 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 + * + * + */ + +/* Update Wiki url */ +if (isset($pearDB)) { + $res = $pearDB->query('SELECT `kb_wiki_url` FROM `options`'); + if ($res->numRows() == 0) { + $query = 'UPDATE `options` SET `key` = "kb_wiki_url" WHERE `key` = "kb_WikiURL"'; + $pearDB->query($query); + } else { + $query = 'DELETE FROM `options` WHERE `key` = "kb_WikiURL"'; + $pearDB->query($query); + } +}