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

Commit

Permalink
fix(ui): correct pagination filters of knowledge base (#7397)
Browse files Browse the repository at this point in the history
* fix(ui): pagination file of knowledge base
* enh(BE): replacing oreon with centreon
* fix(log): removing array to string conversion notice
* fix(KB): broken service template called url and undefined path
  • Loading branch information
sc979 committed Apr 12, 2019
1 parent 849b826 commit 9bcce72
Show file tree
Hide file tree
Showing 16 changed files with 388 additions and 356 deletions.
117 changes: 68 additions & 49 deletions www/class/centreon-knowledge/procedures.class.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
* Copyright 2005-2011 MERETHIS
* Centreon is developped by : Julien Mathis and Romain Le Merlus under
* 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
Expand All @@ -19,11 +19,11 @@
* 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 MERETHIS
* 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 MERETHIS choice, provided that
* MERETHIS also meet, for each linked independent module, the terms and conditions
* 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
Expand Down Expand Up @@ -151,11 +151,12 @@ public function getDiff($selection, $type = null)
*/
public function getMyHostID($host_name = null)
{
$query = "SELECT host_id FROM host " .
$dbResult = $this->centreon_DB->query(
"SELECT host_id FROM host " .
"WHERE host_name = '" . $host_name . "' " .
"LIMIT 1 ";
$DBRESULT = $this->centreon_DB->query($query);
$row = $DBRESULT->fetchRow();
"LIMIT 1 "
);
$row = $dbResult->fetch();
if ($row["host_id"]) {
return $row["host_id"];
}
Expand All @@ -171,22 +172,26 @@ public function getMyServiceTemplateModels($service_id = null)
{
$tplArr = array();

$DBRESULT = $this->centreon_DB->query("SELECT service_description, service_template_model_stm_id
FROM service
WHERE service_id = '" . $service_id . "' LIMIT 1");
$row = $DBRESULT->fetchRow();
$dbResult = $this->centreon_DB->query(
"SELECT service_description, service_template_model_stm_id " .
"FROM service " .
"WHERE service_id = '" . $service_id . "' LIMIT 1"
);
$row = $dbResult->fetch();
if (isset($row['service_template_model_stm_id']) && $row['service_template_model_stm_id'] != "") {
$DBRESULT->closeCursor();
$dbResult->closeCursor();
$service_id = $row["service_template_model_stm_id"];
if ($row["service_description"]) {
$tplArr[$service_id] = html_entity_decode($row["service_description"], ENT_QUOTES);
}
while (1) {
$DBRESULT = $this->centreon_DB->query("SELECT service_description, service_template_model_stm_id
FROM service
WHERE service_id = '" . $service_id . "' LIMIT 1");
$row = $DBRESULT->fetchRow();
$DBRESULT->closeCursor();
$dbResult = $this->centreon_DB->query(
"SELECT service_description, service_template_model_stm_id " .
"FROM service " .
"WHERE service_id = '" . $service_id . "' LIMIT 1"
);
$row = $dbResult->fetch();
$dbResult->closeCursor();
if ($row["service_description"]) {
$tplArr[$service_id] = html_entity_decode($row["service_description"], ENT_QUOTES);
} else {
Expand Down Expand Up @@ -215,15 +220,19 @@ public function getMyHostMultipleTemplateModels($host_id = null)
}

$tplArr = array();
$DBRESULT = $this->centreon_DB->query("SELECT host_tpl_id
FROM `host_template_relation`
WHERE host_host_id = '" . $host_id . "'
ORDER BY `order`");
while ($row = $DBRESULT->fetchRow()) {
$DBRESULT2 = $this->centreon_DB->query("SELECT host_name
FROM host
WHERE host_id = '" . $row['host_tpl_id'] . "' LIMIT 1");
$hTpl = $DBRESULT2->fetchRow();
$dbResult = $this->centreon_DB->query(
"SELECT host_tpl_id " .
"FROM `host_template_relation` " .
"WHERE host_host_id = '" . $host_id . "' " .
"ORDER BY `order`"
);
while ($row = $dbResult->fetch()) {
$dbResult2 = $this->centreon_DB->query(
"SELECT host_name " .
"FROM host " .
"WHERE host_id = '" . $row['host_tpl_id'] . "' LIMIT 1"
);
$hTpl = $dbResult2->fetch();
$tplArr[$row['host_tpl_id']] = html_entity_decode($hTpl["host_name"], ENT_QUOTES);
}
unset($row);
Expand All @@ -241,20 +250,22 @@ public function setHostInformations()
/*
* Get Host Informations
*/
$DBRESULT = $this->centreon_DB->query("SELECT host_name, host_id, host_register, ehi_icon_image
FROM host, extended_host_information ehi
WHERE host.host_id = ehi.host_host_id
ORDER BY host_name");
while ($data = $DBRESULT->fetchRow()) {
$dbResult = $this->centreon_DB->query(
"SELECT host_name, host_id, host_register, ehi_icon_image " .
"FROM host, extended_host_information ehi " .
"WHERE host.host_id = ehi.host_host_id " .
"ORDER BY host_name"
);
while ($data = $dbResult->fetch()) {
if ($data["host_register"] == 1) {
$this->hostList[$data["host_name"]] = $data["host_id"];
} else {
$this->hostTplList[$data["host_name"]] = $data["host_id"];
}
$this->hostIconeList["Host_:_" . $data["host_name"]] =
"./img/media/" . $this->getImageFilePath($data["ehi_icon_image"]);
$this->hostIconeList["Host_:_" . $data["host_name"]]
= "./img/media/" . $this->getImageFilePath($data["ehi_icon_image"]);
}
$DBRESULT->closeCursor();
$dbResult->closeCursor();
unset($data);
}

Expand All @@ -267,16 +278,22 @@ public function setHostInformations()
public function getImageFilePath($image_id)
{
if (isset($image_id) && $image_id) {
$DBRESULT2 = $this->centreon_DB->query("SELECT img_path, dir_alias
FROM view_img vi, view_img_dir vid, view_img_dir_relation vidr
WHERE vi.img_id = " . $image_id . "
AND vidr.img_img_id = vi.img_id
AND vid.dir_id = vidr.dir_dir_parent_id LIMIT 1");
$row2 = $DBRESULT2->fetchRow();
if (isset($row2["dir_alias"]) && isset($row2["img_path"]) && $row2["dir_alias"] && $row2["img_path"]) {
$dbResult2 = $this->centreon_DB->query(
"SELECT img_path, dir_alias " .
"FROM view_img vi, view_img_dir vid, view_img_dir_relation vidr " .
"WHERE vi.img_id = " . $image_id . " " .
"AND vidr.img_img_id = vi.img_id " .
"AND vid.dir_id = vidr.dir_dir_parent_id LIMIT 1"
);
$row2 = $dbResult2->fetch();
if (isset($row2["dir_alias"])
&& isset($row2["img_path"])
&& $row2["dir_alias"]
&& $row2["img_path"]
) {
return $row2["dir_alias"] . "/" . $row2["img_path"];
}
$DBRESULT2->closeCursor();
$dbResult2->closeCursor();
unset($row2);
} else {
return "../icones/16x16/server_network.gif";
Expand All @@ -290,13 +307,15 @@ public function getImageFilePath($image_id)
*/
public function setServiceInformations()
{
$DBRESULT = $this->centreon_DB->query("SELECT service_description, service_id, service_register
FROM service WHERE service_register = '0'
ORDER BY service_description");
while ($data = $DBRESULT->fetchRow()) {
$dbResult = $this->centreon_DB->query(
"SELECT service_description, service_id, service_register " .
"FROM service WHERE service_register = '0' " .
"ORDER BY service_description"
);
while ($data = $dbResult->fetch()) {
$this->serviceTplList["Service_:_" . $data["service_description"]] = $data["service_id"];
}
$DBRESULT->closeCursor();
$dbResult->closeCursor();
unset($data);
}

Expand Down
56 changes: 41 additions & 15 deletions www/class/centreon-knowledge/procedures_Proxy.class.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,35 @@
<?php
/*
* MERETHIS
* Copyright 2005-2019 CENTREON
* Centreon is developed by : Julien Mathis and Romain Le Merlus under
* GPL Licence 2.0.
*
* Source Copyright 2005-2010 MERETHIS
* 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.
*
* Unauthorized reproduction, copy and distribution
* are not allowed.
* 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.
*
* For more information : contact@merethis.com
* 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
*
*/

Expand Down Expand Up @@ -61,8 +83,10 @@ public function __construct($pearDB, $host_name, $service_description = null)
*/
private function getHostId($hostName)
{
$result = $this->DB->query("SELECT host_id FROM host WHERE host_name LIKE '" . $hostName . "' ");
$row = $result->fetchRow();
$result = $this->DB->query(
"SELECT host_id FROM host WHERE host_name LIKE '" . $hostName . "' "
);
$row = $result->fetch();
$hostId = 0;
if ($row["host_id"]) {
$hostId = $row["host_id"];
Expand All @@ -80,29 +104,31 @@ private function getServiceId($hostName, $serviceDescription)
/*
* Get Services attached to hosts
*/
$query = "SELECT s.service_id " .
$result = $this->DB->query(
"SELECT s.service_id " .
"FROM host h, service s, host_service_relation hsr " .
"WHERE hsr.host_host_id = h.host_id " .
"AND hsr.service_service_id = service_id " .
"AND h.host_name LIKE '" . $hostName . "' " .
"AND s.service_description LIKE '" . $serviceDescription . "' ";
$result = $this->DB->query($query);
while ($row = $result->fetchRow()) {
"AND s.service_description LIKE '" . $serviceDescription . "' "
);
while ($row = $result->fetch()) {
return $row["service_id"];
}
$result->closeCursor();
/*
* Get Services attached to hostgroups
*/
$query = "SELECT s.service_id " .
$result = $this->DB->query(
"SELECT s.service_id " .
"FROM hostgroup_relation hgr, host h, service s, host_service_relation hsr " .
"WHERE hgr.host_host_id = h.host_id " .
"AND hsr.hostgroup_hg_id = hgr.hostgroup_hg_id " .
"AND h.host_name LIKE '" . $hostName . "' " .
"AND service_id = hsr.service_service_id " .
"AND service_description LIKZ '" . $serviceDescription . "' ";
$result = $this->DB->query($query);
while ($row = $result->fetchRow()) {
"AND service_description LIKE '" . $serviceDescription . "' "
);
while ($row = $result->fetch()) {
return $row["service_id"];
}
$result->closeCursor();
Expand Down
18 changes: 10 additions & 8 deletions www/class/centreon-knowledge/wiki.class.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
* Copyright 2005-2017 Centreon
* Centreon is developped by : Julien Mathis and Romain Le Merlus under
* 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
Expand All @@ -19,11 +19,11 @@
* 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
* 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
* 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
Expand All @@ -33,7 +33,7 @@
*
*/

require_once realpath(dirname(__FILE__) . "/../../../config/centreon.config.php");
require_once realpath(__DIR__ . "/../../../config/centreon.config.php");
require_once _CENTREON_PATH_ . "/www/class/centreonDB.class.php";

class Wiki
Expand All @@ -58,8 +58,10 @@ public function getWikiConfig()

$options = array();

$res = $this->db->query("SELECT * FROM `options` WHERE options.key LIKE 'kb_%'");
while ($opt = $res->fetchRow()) {
$res = $this->db->query(
"SELECT * FROM `options` WHERE options.key LIKE 'kb_%'"
);
while ($opt = $res->fetch()) {
$options[$opt["key"]] = html_entity_decode($opt["value"], ENT_QUOTES, "UTF-8");
}
$res->closeCursor();
Expand Down
Loading

0 comments on commit 9bcce72

Please sign in to comment.