Private GIT

Skip to content
Snippets Groups Projects
Commit 5a70350d authored by Julien Mathis's avatar Julien Mathis
Browse files

fix #3837

parent d80c27c5
Branches
Tags
No related merge requests found
...@@ -31,9 +31,6 @@ ...@@ -31,9 +31,6 @@
* *
* For more information : contact@centreon.com * For more information : contact@centreon.com
* *
* SVN : $URL$
* SVN : $Id$
*
*/ */
/** /**
...@@ -321,24 +318,32 @@ class Centreon_Traps { ...@@ -321,24 +318,32 @@ class Centreon_Traps {
FROM service s FROM service s
WHERE s.service_register = '0' WHERE s.service_register = '0'
AND s.service_id = traps_service_relation.service_id)"); AND s.service_id = traps_service_relation.service_id)");
print("DELETE FROM traps_service_relation
WHERE traps_id = " . $this->_db->escape($trapId). "
AND NOT EXISTS (SELECT s.service_id
FROM service s
WHERE s.service_register = '0'
AND s.service_id = traps_service_relation.service_id)");
$services = CentreonUtils::mergeWithInitialValues($this->_form, 'services'); $services = CentreonUtils::mergeWithInitialValues($this->_form, 'services');
$insertStr = ""; $insertStr = "";
$first = true; $first = true;
$already = array(); $already = array();
foreach ($services as $id) { foreach ($services as $id) {
$t = preg_split("/\-/", $id);
if (!isset($already[$t[1]])) {
if (!$first) { if (!$first) {
$insertStr .= ","; $insertStr .= ",";
} else { } else {
$first = false; $first = false;
} }
$t = preg_split("/\-/", $id);
if (!isset($already[$t[1]])) {
$insertStr .= "($trapId, $t[1])"; $insertStr .= "($trapId, $t[1])";
} }
$already[$t[1]] = true; $already[$t[1]] = true;
} }
if ($insertStr) { if ($insertStr) {
$this->_db->query("INSERT INTO traps_service_relation (traps_id, service_id) VALUES $insertStr"); $this->_db->query("INSERT INTO traps_service_relation (traps_id, service_id) VALUES $insertStr");
print("INSERT INTO traps_service_relation (traps_id, service_id) VALUES $insertStr");
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment