diff --git a/behat.yml b/behat.yml index 0281eabf5b659ec2ef221a272038b54448e2cae1..392a686109f6a74919d31d6eee597c4a31c8ba0a 100644 --- a/behat.yml +++ b/behat.yml @@ -189,6 +189,11 @@ default: contexts: - ContactGroupConfigurationContext + host_template_basics_operations: + paths: [ %paths.base%/features/HostTemplateBasicsOperations.feature ] + contexts: + - HostTemplateBasicsOperationsContext + ldap_configuration: paths: [ %paths.base%/features/LdapConfiguration.feature ] contexts: @@ -253,7 +258,7 @@ default: paths: [ %paths.base%/features/MassiveChangeServices.feature ] contexts: - MassiveChangeServicesContext - + virtual_metric_handle: paths: [ %paths.base%/features/VirtualMetricHandle.feature ] contexts: @@ -314,6 +319,11 @@ default: contexts: - HostDependencyConfigurationContext + service_dependency_configuration: + paths: [ %paths.base%/features/ServiceDependencyConfiguration.feature ] + contexts: + - ServiceDependencyConfigurationContext + service_group_dependency_configuration: paths: [ %paths.base%/features/ServiceGroupDependencyConfiguration.feature ] contexts: @@ -328,3 +338,13 @@ default: paths: [ %paths.base%/features/VendorConfiguration.feature ] contexts: - VendorConfigurationContext + + first_notification_delay: + paths: [ %paths.base%/features/FirstNotificationDelay.feature ] + contexts: + - FirstNotificationDelayContext + + meta_service_dependency_configuration: + paths: [ %paths.base%/features/MetaServiceDependencyConfiguration.feature ] + contexts: + - MetaServiceDependencyConfigurationContext \ No newline at end of file diff --git a/cron/centreon-backup-mysql.sh b/cron/centreon-backup-mysql.sh index e62495831cc9804d605278c992603e7ac227d330..6213b958af0b89f2ddaa54137d8753c4ced5fccb 100644 --- a/cron/centreon-backup-mysql.sh +++ b/cron/centreon-backup-mysql.sh @@ -82,6 +82,10 @@ output_log() { ### if [ -n "$process" ] ; then datadir=$(echo "$process" | awk '{ for (i = 1; i < NF; i++) { if (match($i, "--datadir")) { print $i } } }' | awk -F\= '{ print $2 }') + ### New version CentOS7/MariaDB : datadir not present in ps + if [ -z "$datadir" ] ; then + datadir=$(mysqld --verbose --help 2> /dev/null | egrep "^datadir" | awk -F' ' '{print $2}') + fi started=1 fi if [ -z "$datadir" ] ; then diff --git a/doc/en/release_notes/centreon-2.8/centreon-2.8.12.rst b/doc/en/release_notes/centreon-2.8/centreon-2.8.12.rst new file mode 100644 index 0000000000000000000000000000000000000000..00ccd97246acce3ae35c557fa04a3c370018b380 --- /dev/null +++ b/doc/en/release_notes/centreon-2.8/centreon-2.8.12.rst @@ -0,0 +1,10 @@ +################### +Centreon Web 2.8.12 +################### + +Enhancements +============ + +Bugfix +====== + diff --git a/doc/en/release_notes/centreon-2.8/index.rst b/doc/en/release_notes/centreon-2.8/index.rst index 188ac21b3d0aeb6b8f7cb89bc4e72936acba41b4..2ea00ac173c786872c32933037fe33c3ed9b24ee 100644 --- a/doc/en/release_notes/centreon-2.8/index.rst +++ b/doc/en/release_notes/centreon-2.8/index.rst @@ -18,3 +18,4 @@ Please find here the release notes dedicated to the last 2.8.x version of Centre centreon-2.8.9 centreon-2.8.10 centreon-2.8.11 + centreon-2.8.12 diff --git a/doc/fr/release_notes/centreon-2.8/centreon-2.8.12.rst b/doc/fr/release_notes/centreon-2.8/centreon-2.8.12.rst new file mode 100644 index 0000000000000000000000000000000000000000..00ccd97246acce3ae35c557fa04a3c370018b380 --- /dev/null +++ b/doc/fr/release_notes/centreon-2.8/centreon-2.8.12.rst @@ -0,0 +1,10 @@ +################### +Centreon Web 2.8.12 +################### + +Enhancements +============ + +Bugfix +====== + diff --git a/doc/fr/release_notes/centreon-2.8/index.rst b/doc/fr/release_notes/centreon-2.8/index.rst index 188ac21b3d0aeb6b8f7cb89bc4e72936acba41b4..2ea00ac173c786872c32933037fe33c3ed9b24ee 100644 --- a/doc/fr/release_notes/centreon-2.8/index.rst +++ b/doc/fr/release_notes/centreon-2.8/index.rst @@ -18,3 +18,4 @@ Please find here the release notes dedicated to the last 2.8.x version of Centre centreon-2.8.9 centreon-2.8.10 centreon-2.8.11 + centreon-2.8.12 diff --git a/features/FirstNotificationDelay.feature b/features/FirstNotificationDelay.feature new file mode 100644 index 0000000000000000000000000000000000000000..38276575d6f52a7ec9c60a398d1b292973f6b378 --- /dev/null +++ b/features/FirstNotificationDelay.feature @@ -0,0 +1,44 @@ +Feature: Recovery notification delay + As a Centreon user + I want to discard notifications of nodes that did not stay long enough in a non-OK state + So that I am not polluted with non-important notifications + + Background: + Given I am logged in a Centreon server + + Scenario: Host first notification disabled before delay + Given a host configured with first notification delay + And the host is not UP + When the host is still not UP before the first notification delay + Then no notification is sent + + Scenario: Service first notification disabled before delay + Given a service configured with first notification delay + And the host is UP + And the service is not OK + When the service is still not OK before the first notification delay + Then no notification is sent + + Scenario: Host first notification enabled after delay + Given a host configured with first notification delay + And the host is not UP + When the host is still not UP after the first notification delay + Then a notification is sent + When the host is UP + Then a notification is sent + When the host is not UP + And the host is still not UP before the first notification delay + Then no notification is sent + + Scenario: Service first notification enabled after delay + Given a service configured with first notification delay + And the host is UP + And the service is not OK + When the service is still not OK after the first notification delay + Then a notification is sent + When the service is OK + Then a notification is sent + When the service is not OK + And the service is still not OK before the first notification delay + Then no notification is sent + diff --git a/features/HostTemplateBasicsOperations.feature b/features/HostTemplateBasicsOperations.feature new file mode 100644 index 0000000000000000000000000000000000000000..7a12c0e274ae5fde9097604e2cd326a3db8a6f48 --- /dev/null +++ b/features/HostTemplateBasicsOperations.feature @@ -0,0 +1,20 @@ +Feature: HostTemplateBasicsOperations + As a Centreon admin + I want to manipulate a host template + To see if all simples manipulations work + + Background: + Given I am logged in a Centreon server + And a host template is configured + + Scenario: I test the modification of a host template properties + When I change the properties of a host template + Then the properties are updated + + Scenario: I test the duplication of a host template + When I duplicate a host template + Then the new host template has the same properties + + Scenario: I test the deletion of a host template + When I delete a host template + Then the deleted host is not displayed in the host list diff --git a/features/MetaServiceDependencyConfiguration.feature b/features/MetaServiceDependencyConfiguration.feature new file mode 100644 index 0000000000000000000000000000000000000000..cd4c0bda38d6b060e66381e0ee677ca75c6d8489 --- /dev/null +++ b/features/MetaServiceDependencyConfiguration.feature @@ -0,0 +1,20 @@ +Feature: Edit a meta service dependency + As a Centreon user + I want to manipulate a meta service dependency + To see if all simples manipulations work + + Background: + Given I am logged in a Centreon server + And a meta service dependency + + Scenario: Change the properties of a meta service dependency + When I change the properties of a meta service dependency + Then the properties are updated + + Scenario: Duplicate one existing meta service dependency + When I duplicate a meta service dependency + Then the new object has the same properties + + Scenario: Delete one existing meta service dependency + When I delete a meta service dependency + Then the deleted object is not displayed in the list diff --git a/features/ServiceDependencyConfiguration.feature b/features/ServiceDependencyConfiguration.feature new file mode 100644 index 0000000000000000000000000000000000000000..9b4bdbcef32e42353745707f77fdadfede8c6fd1 --- /dev/null +++ b/features/ServiceDependencyConfiguration.feature @@ -0,0 +1,20 @@ +Feature: Edit a service dependency + As a Centreon user + I want to manipulate a service dependency + To see if all simples manipulations work + + Background: + Given I am logged in a Centreon server + And a service dependency is configured + + Scenario: Change the properties of a service dependency + When I change the properties of a service dependency + Then the properties are updated + + Scenario: Duplicate one existing service dependency + When I duplicate a service dependency + Then the new object has the same properties + + Scenario: Delete one existing service dependency + When I delete a service dependency + Then the deleted object is not displayed in the list diff --git a/features/bootstrap/ContactConfigurationContext.php b/features/bootstrap/ContactConfigurationContext.php index 90c9c8f61dcb83c07bcc45cd37ca7f1100322eac..0d6797c8768aaaa82e1679fd05cecf4c2ea6e344 100644 --- a/features/bootstrap/ContactConfigurationContext.php +++ b/features/bootstrap/ContactConfigurationContext.php @@ -1,4 +1,5 @@ <?php + use Centreon\Test\Behat\CentreonContext; use Centreon\Test\Behat\Configuration\ContactConfigurationPage; use Centreon\Test\Behat\Configuration\ContactConfigurationListingPage; @@ -176,11 +177,11 @@ class ContactConfigurationContext extends CentreonContext if ($key != 'password' && $key != 'password2') { if ($key != 'name' && $key != 'alias' && $value != $object[$key]) { if (is_array($value)) { - $value = implode(' ', $value); - } + $value = implode(' ', $value); + } if ($value != $object[$key]) { $this->tableau[] = $key; - + } } if (($key == 'name' || $key == 'alias') && $value . '_1' != $object[$key]) { diff --git a/features/bootstrap/FirstNotificationDelayContext.php b/features/bootstrap/FirstNotificationDelayContext.php new file mode 100644 index 0000000000000000000000000000000000000000..ee532149b099371cd1be8aac76e6aa447fb31617 --- /dev/null +++ b/features/bootstrap/FirstNotificationDelayContext.php @@ -0,0 +1,227 @@ +<?php + +use Centreon\Test\Behat\CentreonContext; +use Centreon\Test\Behat\Configuration\ContactConfigurationListingPage; +use Centreon\Test\Behat\Configuration\CommandConfigurationPage; +use Centreon\Test\Behat\Configuration\HostConfigurationPage; +use Centreon\Test\Behat\Configuration\ServiceConfigurationPage; + +class FirstNotificationDelayContext extends CentreonContext +{ + private $hostName; + private $serviceName; + + public function __construct() + { + parent::__construct(); + $this->hostName = 'FirstNotificationDelayTestHost'; + $this->serviceName = 'FirstNotificationDelayTestService'; + } + + /** + * @Given a host configured with first notification delay + */ + public function aHostConfiguredWithFirstNotificationDelay() + { + // Create notification command. + $this->createNotificationCommand(); + + // Update notifications on admin contact + $this->updateContactNotification(); + + // Create host. + $this->createHostWithFirstNotificationDelay(); + + // Restart all pollers. + $this->reloadAllPollers(); + } + + /** + * @Given a service configured with first notification delay + */ + public function aServiceConfiguredWithFirstNotificationDelay() + { + // Create notification command. + $this->createNotificationCommand(); + + // Update notifications on admin contact + $this->updateContactNotification(); + + // Create service. + $this->createHostWithFirstNotificationDelay(); + $this->createServiceWithFirstNotificationDelay(); + + // Restart all pollers. + $this->reloadAllPollers(); + } + + /** + * @Given the host is UP + */ + public function theHostIsUp() + { + $this->execute('rm -f /tmp/acceptance_notification.tmp', 'web', false); + $this->submitHostResult($this->hostName, 0, __FUNCTION__); + } + + /** + * @Given the host is not UP + */ + public function theHostIsNotUp() + { + $this->execute('rm -f /tmp/acceptance_notification.tmp', 'web', false); + $this->submitHostResult($this->hostName, 1, __FUNCTION__); + } + + /** + * @Given the service is OK + */ + public function theServiceIsOK() + { + $this->execute('rm -f /tmp/acceptance_notification.tmp', 'web', false); + $this->submitServiceResult($this->hostName, $this->serviceName, 0, __FUNCTION__); + } + + /** + * @Given the service is not OK + */ + public function theServiceIsNotOK() + { + $this->execute('rm -f /tmp/acceptance_notification.tmp', 'web', false); + $this->submitServiceResult($this->hostName, $this->serviceName, 2, __FUNCTION__); + } + + /** + * @When the host is still not UP before the first notification delay + */ + public function theHostIsStillNotUPBeforeFirstNotificationDelay() + { + sleep(25); + $this->submitHostResult($this->hostName, 1, __FUNCTION__); + } + + /** + * @When the host is still not UP after the first notification delay + */ + public function theHostIsStillNotUPAfterFirstNotificationDelay() + { + sleep(65); + $this->submitHostResult($this->hostName, 1, __FUNCTION__); + } + + /** + * @When the service is still not OK before the first notification delay + */ + public function theServiceIsStillNotOKBeforeTheFirstNotificationDelay() + { + sleep(25); + $this->submitServiceResult($this->hostName, $this->serviceName, 2, __FUNCTION__); + } + + /** + * @When the service is still not OK after the first notification delay + */ + public function theServiceIsStillNotOKAfterTheFirstNotificationDelay() + { + sleep(65); + $this->submitServiceResult($this->hostName, $this->serviceName, 2, __FUNCTION__); + } + + /** + * @Then no notification is sent + */ + public function noNotificationIsSent() + { + sleep(10); + $retval = $this->execute('ls /tmp/acceptance_notification.tmp 2>/dev/null', 'web', false); + if ($retval['exit_code'] == 0) { + throw new \Exception('Notification was sent out.'); + } + } + + /** + * @Then a notification is sent + */ + public function aNotificationIsSent() + { + $this->spin( + function ($context) { + $retval = $context->execute('ls /tmp/acceptance_notification.tmp 2>/dev/null', 'web', false); + return ($retval['exit_code'] == 0); + }, + 'error: No notification was sent out.', + 10 + ); + } + + private function createNotificationCommand() + { + $page = new CommandConfigurationPage($this, true, 1); + $page->setProperties(array( + 'command_name' => 'acceptance_notification_command', + 'command_line' => 'touch /tmp/acceptance_notification.tmp' + )); + $page->save(); + } + + private function updateContactNotification() + { + $page = new ContactConfigurationListingPage($this); + $contact = $page->inspect('admin'); + $contact->setProperties(array( + 'notifications_enabled' => 1, + 'host_notify_on_recovery' => 1, + 'host_notify_on_down' => 1, + 'host_notification_command' => 'acceptance_notification_command', + 'service_notify_on_recovery' => 1, + 'service_notify_on_critical' => 1, + 'service_notification_command' => 'acceptance_notification_command' + )); + $contact->save(); + } + + public function createHostWithFirstNotificationDelay() + { + $page = new HostConfigurationPage($this); + $page->setProperties(array( + 'name' => $this->hostName, + 'alias' => $this->hostName, + 'address' => 'localhost', + 'max_check_attempts' => 1, + 'normal_check_interval' => 1, + 'retry_check_interval' => 1, + 'active_checks_enabled' => 0, + 'passive_checks_enabled' => 1, + 'notifications_enabled' => 1, + 'notify_on_recovery' => 1, + 'notify_on_down' => 1, + 'first_notification_delay' => 1, + 'cs' => 'admin_admin' + )); + $page->save(); + } + + public function createServiceWithFirstNotificationDelay() + { + $page = new ServiceConfigurationPage($this); + $page->setProperties(array( + 'hosts' => $this->hostName, + 'description' => $this->serviceName, + 'templates' => 'generic-service', + 'check_command' => 'check_centreon_dummy', + 'check_period' => '24x7', + 'max_check_attempts' => 1, + 'normal_check_interval' => 1, + 'retry_check_interval' => 1, + 'active_checks_enabled' => 0, + 'passive_checks_enabled' => 1, + 'notifications_enabled' => 1, + 'notify_on_recovery' => 1, + 'notify_on_critical' => 1, + 'first_notification_delay' => 1, + 'recovery_notification_delay' => 0, + 'cs' => 'admin_admin' + )); + $page->save(); + } +} diff --git a/features/bootstrap/HostConfigurationContext.php b/features/bootstrap/HostConfigurationContext.php index 2d3c3daf108485d32cd423386d16f242dd7e0728..feeb5202f9d9dce061a620b4f8b118f0f3276fa9 100644 --- a/features/bootstrap/HostConfigurationContext.php +++ b/features/bootstrap/HostConfigurationContext.php @@ -194,7 +194,7 @@ class HostConfigurationContext extends CentreonContext 'address' => 'hostChanged@localhost', 'snmp_community' => 'hostSnmpCommunitychanged', 'snmp_version' => '3', - 'macros' => array( + 'macros' => array( 'HOSTMACROCHANGED' => 5 ), 'location' => 'Europe/Paris', @@ -222,7 +222,7 @@ class HostConfigurationContext extends CentreonContext 'notify_on_downtime_scheduled' => 0, 'notification_interval' => 34, 'notification_period' => 'workhours', - 'first_notification_delay' => 7, + 'first_notification_delay' => 7, 'recovery_notification_delay' => 4, 'parent_host_groups' => 'hostGroupName2', 'parent_host_categories' => 'hostCategoryName3', diff --git a/features/bootstrap/HostTemplateBasicsOperationsContext.php b/features/bootstrap/HostTemplateBasicsOperationsContext.php new file mode 100644 index 0000000000000000000000000000000000000000..ecbe6eef326f2f2ba5c91278ecbb0e1765c16f0a --- /dev/null +++ b/features/bootstrap/HostTemplateBasicsOperationsContext.php @@ -0,0 +1,445 @@ +<?php + +use Centreon\Test\Behat\CentreonContext; +use Centreon\Test\Behat\Configuration\HostTemplateConfigurationPage; +use Centreon\Test\Behat\Configuration\HostTemplateConfigurationListingPage; +use Centreon\Test\Behat\Configuration\HostCategoryConfigurationPage; + +class HostTemplateBasicsOperationsContext extends CentreonContext +{ + protected $currentPage; + + protected $hostCategory1 = array( + 'name' => 'hostCategory1Name', + 'alias' => 'hostCategory1Alias', + 'severity' => 1, + 'severity_level' => 2, + 'severity_icon' => ' centreon (png)' + ); + + protected $hostCategory2 = array( + 'name' => 'hostCategory2Name', + 'alias' => 'hostCategory2Alias', + 'severity' => 1, + 'severity_level' => 13, + 'severity_icon' => ' centreon (png)' + ); + + protected $hostCategory3 = array( + 'name' => 'hostCategory3Name', + 'alias' => 'hostCategory3Alias' + ); + + protected $hostCategory4 = array( + 'name' => 'hostCategory4Name', + 'alias' => 'hostCategory4Alias' + ); + + protected $initialProperties = array( + 'name' => 'hostTemplateName', + 'alias' => 'hostTemplateAlias', + 'address' => 'hostTemplate@localhost', + 'snmp_community' => 'snmp', + 'snmp_version' => '2c', + 'location' => 'Europe/Paris', + 'templates' => array( + 'generic-host' + ), + 'check_command' => 'check_http', + 'command_arguments' => 'hostTemplateCommandArgument', + 'macros' => array( + 'HOSTTEMPLATEMACRONAME' => '22' + ), + 'check_period' => 'workhours', + 'max_check_attempts' => 34, + 'normal_check_interval' => 5, + 'retry_check_interval' => 10, + 'active_checks_enabled' => 2, + 'passive_checks_enabled' => 0, + 'notifications_enabled' => 1, + 'contact_additive_inheritance' => 1, + 'contacts' => 'Guest', + 'contact_group_additive_inheritance' => 0, + 'contact_groups' => 'Supervisors', + 'notify_on_down' => 1, + 'notify_on_unreachable' => 1, + 'notify_on_recovery' => 1, + 'notify_on_flapping' => 1, + 'notify_on_downtime_scheduled' => 1, + 'notify_on_none' => 0, + 'notification_interval' => 17, + 'notification_period' => 'none', + 'first_notification_delay' => 4, + 'recovery_notification_delay' => 3, + 'service_templates' => 'generic-service', + 'parent_host_categories' => 'hostCategory3Name', + 'obsess_over_host' => 2, + 'acknowledgement_timeout' => 2, + 'check_freshness' => 0, + 'freshness_threshold' => 34, + 'flap_detection_enabled' => 1, + 'low_flap_threshold' => 67, + 'high_flap_threshold' => 85, + 'retain_status_information' => 2, + 'retain_non_status_information' => 0, + 'stalking_option_on_up' => 1, + 'stalking_option_on_down' => 0, + 'stalking_option_on_unreachable' => 1, + 'event_handler_enabled' => 2, + 'event_handler' => 'check_https', + 'event_handler_arguments' => 'event_handler_arguments', + 'url' => 'hostTemplateChangeUrl', + 'notes' => 'hostTemplateChangeNotes', + 'action_url' => 'hostTemplateChangeActionUrl', + 'icon' => ' centreon (png)', + 'alt_icon' => 'hostTemplateChangeIcon', + 'status_map_image' => '', + '2d_coords' => '15,84', + '3d_coords' => '15,84,76', + 'severity_level' => 'hostCategory1Name (2)', + 'enabled' => 1, + 'comments' => 'hostTemplateChangeComments' + ); + + protected $duplicatedProperties = array( + 'name' => 'hostTemplateName_1', + 'alias' => 'hostTemplateAlias', + 'address' => 'hostTemplate@localhost', + 'snmp_community' => 'snmp', + 'snmp_version' => '2c', + 'location' => 'Europe/Paris', + 'templates' => array( + 'generic-host' + ), + 'check_command' => 'check_http', + 'command_arguments' => 'hostTemplateCommandArgument', + 'macros' => array( + 'HOSTTEMPLATEMACRONAME' => '22' + ), + 'check_period' => 'workhours', + 'max_check_attempts' => 34, + 'normal_check_interval' => 5, + 'retry_check_interval' => 10, + 'active_checks_enabled' => 2, + 'passive_checks_enabled' => 0, + 'notifications_enabled' => 1, + 'contact_additive_inheritance' => 1, + 'contacts' => 'Guest', + 'contact_group_additive_inheritance' => 0, + 'contact_groups' => 'Supervisors', + 'notify_on_down' => 1, + 'notify_on_unreachable' => 1, + 'notify_on_recovery' => 1, + 'notify_on_flapping' => 1, + 'notify_on_downtime_scheduled' => 1, + 'notify_on_none' => 0, + 'notification_interval' => 17, + 'notification_period' => 'none', + 'first_notification_delay' => 4, + 'recovery_notification_delay' => 3, + 'service_templates' => 'generic-service', + 'parent_host_categories' => 'hostCategory3Name', + 'obsess_over_host' => 2, + 'acknowledgement_timeout' => 2, + 'check_freshness' => 0, + 'freshness_threshold' => 34, + 'flap_detection_enabled' => 1, + 'low_flap_threshold' => 67, + 'high_flap_threshold' => 85, + 'retain_status_information' => 2, + 'retain_non_status_information' => 0, + 'stalking_option_on_up' => 1, + 'stalking_option_on_down' => 0, + 'stalking_option_on_unreachable' => 1, + 'event_handler_enabled' => 2, + 'event_handler' => 'check_https', + 'event_handler_arguments' => 'event_handler_arguments', + 'url' => 'hostTemplateChangeUrl', + 'notes' => 'hostTemplateChangeNotes', + 'action_url' => 'hostTemplateChangeActionUrl', + 'icon' => ' centreon (png)', + 'alt_icon' => 'hostTemplateChangeIcon', + 'status_map_image' => '', + '2d_coords' => '15,84', + '3d_coords' => '15,84,76', + 'severity_level' => 'hostCategory1Name (2)', + 'enabled' => 1, + 'comments' => 'hostTemplateChangeComments' + ); + + protected $update = array( + 'name' => 'hostTemplateNameChanged', + 'alias' => 'hostTemplateAliasChanged', + 'address' => 'hostTemplate@localhostChanged', + 'snmp_community' => 'snmpChanged', + 'snmp_version' => '3', + 'location' => 'Europe/Paris', + 'templates' => array( + 'Printers' + ), + 'check_command' => 'check_https', + 'command_arguments' => 'hostTemplateCommandArgumentChanged', + 'macros' => array( + 'HOSTTEMPLATEMACRONAMECHANGED' => '11' + ), + 'check_period' => 'nonworkhours', + 'max_check_attempts' => 34, + 'normal_check_interval' => 9, + 'retry_check_interval' => 4, + 'active_checks_enabled' => 1, + 'passive_checks_enabled' => 1, + 'notifications_enabled' => 0, + 'contact_additive_inheritance' => 0, + 'contacts' => 'User', + 'contact_group_additive_inheritance' => 1, + 'contact_groups' => 'Guest', + 'notify_on_down' => 0, + 'notify_on_unreachable' => 0, + 'notify_on_recovery' => 0, + 'notify_on_flapping' => 0, + 'notify_on_downtime_scheduled' => 0, + 'notify_on_none' => 0, + 'notification_interval' => 49, + 'notification_period' => 'workhours', + 'first_notification_delay' => 7, + 'recovery_notification_delay' => 8, + 'service_templates' => 'Ping-LAN', + 'parent_host_categories' => 'hostCategory4Name', + 'obsess_over_host' => 1, + 'acknowledgement_timeout' => 0, + 'check_freshness' => 1, + 'freshness_threshold' => 15, + 'flap_detection_enabled' => 0, + 'low_flap_threshold' => 25, + 'high_flap_threshold' => 34, + 'retain_status_information' => 1, + 'retain_non_status_information' => 1, + 'stalking_option_on_up' => 0, + 'stalking_option_on_down' => 1, + 'stalking_option_on_unreachable' => 0, + 'event_handler_enabled' => 1, + 'event_handler' => 'check_http', + 'event_handler_arguments' => 'event_handler_argumentsChanged', + 'url' => 'hostTemplateChangeUrlChanged', + 'notes' => 'hostTemplateChangeNotesChanged', + 'action_url' => 'hostTemplateChangeActionUrlChanged', + 'icon' => '', + 'alt_icon' => 'hostTemplateChangeIconChanged', + 'status_map_image' => ' centreon (png)', + '2d_coords' => '48,29', + '3d_coords' => '09,25,27', + 'severity_level' => 'hostCategory2Name (13)', + 'enabled' => 1, + 'comments' => 'hostTemplateChangeCommentsChanged' + ); + + protected $updatedProperties = array( + 'name' => 'hostTemplateNameChanged', + 'alias' => 'hostTemplateAliasChanged', + 'address' => 'hostTemplate@localhostChanged', + 'snmp_community' => 'snmpChanged', + 'snmp_version' => '3', + 'location' => 'Europe/Paris', + 'templates' => array( + 'Printers' + ), + 'check_command' => 'check_https', + 'command_arguments' => 'hostTemplateCommandArgumentChanged', + 'macros' => array( + 'HOSTTEMPLATEMACRONAME' => '22', + 'HOSTTEMPLATEMACRONAMECHANGED' => '11' + ), + 'check_period' => 'nonworkhours', + 'max_check_attempts' => 34, + 'normal_check_interval' => 9, + 'retry_check_interval' => 4, + 'active_checks_enabled' => 1, + 'passive_checks_enabled' => 1, + 'notifications_enabled' => 0, + 'contact_additive_inheritance' => 0, + 'contacts' => 'User', + 'contact_group_additive_inheritance' => 1, + 'contact_groups' => 'Guest', + 'notify_on_down' => 0, + 'notify_on_unreachable' => 0, + 'notify_on_recovery' => 0, + 'notify_on_flapping' => 0, + 'notify_on_downtime_scheduled' => 0, + 'notify_on_none' => 0, + 'notification_interval' => 49, + 'notification_period' => 'workhours', + 'first_notification_delay' => 7, + 'recovery_notification_delay' => 8, + 'service_templates' => 'Ping-LAN', + 'parent_host_categories' => 'hostCategory4Name', + 'obsess_over_host' => 1, + 'acknowledgement_timeout' => 0, + 'check_freshness' => 1, + 'freshness_threshold' => 15, + 'flap_detection_enabled' => 0, + 'low_flap_threshold' => 25, + 'high_flap_threshold' => 34, + 'retain_status_information' => 1, + 'retain_non_status_information' => 1, + 'stalking_option_on_up' => 0, + 'stalking_option_on_down' => 1, + 'stalking_option_on_unreachable' => 0, + 'event_handler_enabled' => 1, + 'event_handler' => 'check_http', + 'event_handler_arguments' => 'event_handler_argumentsChanged', + 'url' => 'hostTemplateChangeUrlChanged', + 'notes' => 'hostTemplateChangeNotesChanged', + 'action_url' => 'hostTemplateChangeActionUrlChanged', + 'icon' => '', + 'alt_icon' => 'hostTemplateChangeIconChanged', + 'status_map_image' => ' centreon (png)', + '2d_coords' => '48,29', + '3d_coords' => '09,25,27', + 'severity_level' => 'hostCategory2Name (13)', + 'enabled' => 1, + 'comments' => 'hostTemplateChangeCommentsChanged' + ); + + /** + * @Given a host template is configured + */ + public function aHostTemplateIsConfigured() + { + $this->currentPage = new HostCategoryConfigurationPage($this); + $this->currentPage->setProperties($this->hostCategory1); + $this->currentPage->save(); + $this->currentPage = new HostCategoryConfigurationPage($this); + $this->currentPage->setProperties($this->hostCategory2); + $this->currentPage->save(); + $this->currentPage = new HostCategoryConfigurationPage($this); + $this->currentPage->setProperties($this->hostCategory3); + $this->currentPage->save(); + $this->currentPage = new HostCategoryConfigurationPage($this); + $this->currentPage->setProperties($this->hostCategory4); + $this->currentPage->save(); + $this->currentPage = new HostTemplateConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + } + + /** + * @When I change the properties of a host template + */ + public function iChangeThePropertiesOfAHostTemplate() + { + $this->currentPage = new HostTemplateConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name']); + $this->currentPage->setProperties($this->update); + $this->currentPage->save(); + } + + /** + * @Then the properties are updated + */ + public function thePropertiesAreUpdated() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new HostTemplateConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->updatedProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->updatedProperties as $key => $value) { + if ($value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I duplicate a host template + */ + public function iDuplicateAHostTemplate() + { + $this->currentPage = new HostTemplateConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Duplicate'); + } + + /** + * @Then the new host template has the same properties + */ + public function theNewHostTemplateHasTheSameProperties() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new HostTemplateConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->duplicatedProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->duplicatedProperties as $key => $value) { + if ($value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I delete a host template + */ + public function iDeleteAHostTemplate() + { + $this->currentPage = new HostTemplateConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Delete'); + } + + /** + * @Then the deleted host is not displayed in the host list + */ + public function theDeletedHostIsNotDisplayedInTheHostList() + { + $this->spin( + function ($context) { + $this->currentPage = new HostTemplateConfigurationListingPage($this); + $object = $this->currentPage->getEntries(); + $bool = true; + foreach ($object as $value) { + $bool = $bool && $value['name'] != $this->initialProperties['name']; + } + return $bool; + }, + "The host category is not being deleted.", + 5 + ); + } +} diff --git a/features/bootstrap/LdapConfigurationContext.php b/features/bootstrap/LdapConfigurationContext.php index 2dbb049f789ccbdb47e9a2830f8baabca6c14297..ea5e35d5c2611b2e37f542f5b96dd188fea9e9a7 100644 --- a/features/bootstrap/LdapConfigurationContext.php +++ b/features/bootstrap/LdapConfigurationContext.php @@ -23,7 +23,6 @@ class LdapConfigurationContext extends CentreonContext 'enable_authentication' => 1, 'template' => 'Posix' )); - } @@ -46,7 +45,6 @@ class LdapConfigurationContext extends CentreonContext $this->page = $this->page->inspect($this->configuration_name); $this->page->setProperties(array('configuration_name' => $this->newConfigurationName)); $this->page->save(); - } /** @@ -54,15 +52,12 @@ class LdapConfigurationContext extends CentreonContext */ public function allChangesAreSaved() { - $this->page = new LdapConfigurationListingPage($this); $object = $this->page->getEntry($this->newConfigurationName); if ($object['configuration_name'] != $this->newConfigurationName) { - throw new \Exception('the Configuration has not changed.'); } - } /** @@ -77,7 +72,6 @@ class LdapConfigurationContext extends CentreonContext $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); $this->setConfirmBox(true); $this->selectInList('select[name="o1"]', 'Delete'); - } /** @@ -89,7 +83,6 @@ class LdapConfigurationContext extends CentreonContext $object = $this->page->getEntries(); if (isset($object[$this->configuration_name])) { - throw new \Exception('the Configuration is not deleted.'); } } diff --git a/features/bootstrap/MetaServiceConfigurationContext.php b/features/bootstrap/MetaServiceConfigurationContext.php index 31ba533720b1f31f8339c21551943ce6d505ad82..c7c909a9e1789d02dd8d8627cd4c83c0c0f92712 100644 --- a/features/bootstrap/MetaServiceConfigurationContext.php +++ b/features/bootstrap/MetaServiceConfigurationContext.php @@ -17,7 +17,7 @@ class MetaServiceConfigurationContext extends CentreonContext 'data_source_type' => 'ABSOLUTE', 'selection_mode' => 2, 'sql_like_clause_expression' => 'metaServiceExpression', - 'metric' => '', + 'metric' => '', 'check_period' => 'workhours', 'max_check_attempts' => 10, 'normal_check_interval' => 15, @@ -154,8 +154,8 @@ class MetaServiceConfigurationContext extends CentreonContext if ($value != $object[$key]) { $this->tableau[] = $key; } - } - if ($key == 'name'&& $value . '_1' != $object[$key]) { + } + if ($key == 'name' && $value . '_1' != $object[$key]) { $this->tableau[] = $key; } } diff --git a/features/bootstrap/MetaServiceDependencyConfigurationContext.php b/features/bootstrap/MetaServiceDependencyConfigurationContext.php new file mode 100644 index 0000000000000000000000000000000000000000..6aa16b60432154863ab4e42a1743bb7ab004ca7c --- /dev/null +++ b/features/bootstrap/MetaServiceDependencyConfigurationContext.php @@ -0,0 +1,238 @@ +<?php + +use Centreon\Test\Behat\CentreonContext; +use Centreon\Test\Behat\Configuration\MetaServiceDependencyConfigurationPage; +use Centreon\Test\Behat\Configuration\MetaServiceDependencyConfigurationListingPage; +use Centreon\Test\Behat\Configuration\MetaServiceConfigurationPage; + +class MetaServiceDependencyConfigurationContext extends CentreonContext +{ + protected $currentPage; + + protected $metaService1 = array( + 'name' => 'metaService1Name', + 'max_check_attempts' => 12 + ); + + protected $metaService2 = array( + 'name' => 'metaService2Name', + 'max_check_attempts' => 3 + ); + + protected $metaService3 = array( + 'name' => 'metaService3Name', + 'max_check_attempts' => 40 + ); + + protected $metaService4 = array( + 'name' => 'metaService4Name', + 'max_check_attempts' => 9 + ); + + protected $metaService5 = array( + 'name' => 'metaService5Name', + 'max_check_attempts' => 21 + ); + + protected $metaService6 = array( + 'name' => 'metaService6Name', + 'max_check_attempts' => 4 + ); + + protected $initialProperties = array( + 'name' => 'metaServiceDependencyName', + 'description' => 'metaServiceDependencyDescription', + 'parent_relationship' => 0, + 'execution_fails_on_ok' => 1, + 'execution_fails_on_warning' => 1, + 'execution_fails_on_unknown' => 1, + 'execution_fails_on_critical' => 1, + 'execution_fails_on_pending' => 1, + 'execution_fails_on_none' => 0, + 'notification_fails_on_none' => 1, + 'notification_fails_on_ok' => 0, + 'notification_fails_on_warning' => 0, + 'notification_fails_on_unknown' => 0, + 'notification_fails_on_critical' => 0, + 'notification_fails_on_pending' => 0, + 'meta_services' => array( + 'metaService1Name', + 'metaService2Name' + ), + 'dependent_meta_services' => 'metaService3Name', + 'comment' => 'metaServiceDependencyComment' + ); + + protected $updatedProperties = array( + 'name' => 'metaServiceDependencyNameChanged', + 'description' => 'metaServiceDependencyDescriptionChanged', + 'parent_relationship' => 1, + 'execution_fails_on_pending' => 0, + 'execution_fails_on_none' => 1, + 'execution_fails_on_ok' => 0, + 'execution_fails_on_warning' => 0, + 'execution_fails_on_unknown' => 0, + 'execution_fails_on_critical' => 0, + 'notification_fails_on_ok' => 1, + 'notification_fails_on_warning' => 1, + 'notification_fails_on_unknown' => 1, + 'notification_fails_on_critical' => 1, + 'notification_fails_on_pending' => 1, + 'notification_fails_on_none' => 0, + 'meta_services' => 'metaService4Name', + 'dependent_meta_services' => array( + 'metaService5Name', + 'metaService6Name' + ), + 'comment' => 'metaServiceDependencyCommentChanged' + ); + + /** + * @Given a meta service dependency + */ + public function aMetaServiceDependency() + { + $this->currentPage = new MetaServiceConfigurationPage($this); + $this->currentPage->setProperties($this->metaService1); + $this->currentPage->save(); + $this->currentPage = new MetaServiceConfigurationPage($this); + $this->currentPage->setProperties($this->metaService2); + $this->currentPage->save(); + $this->currentPage = new MetaServiceConfigurationPage($this); + $this->currentPage->setProperties($this->metaService3); + $this->currentPage->save(); + $this->currentPage = new MetaServiceConfigurationPage($this); + $this->currentPage->setProperties($this->metaService4); + $this->currentPage->save(); + $this->currentPage = new MetaServiceConfigurationPage($this); + $this->currentPage->setProperties($this->metaService5); + $this->currentPage->save(); + $this->currentPage = new MetaServiceConfigurationPage($this); + $this->currentPage->setProperties($this->metaService6); + $this->currentPage->save(); + $this->currentPage = new MetaServiceDependencyConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + } + + /** + * @When I change the properties of a meta service dependency + */ + public function iChangeThePropertiesOfAMetaServiceDependency() + { + $this->currentPage = new MetaServiceDependencyConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name']); + $this->currentPage->setProperties($this->updatedProperties); + $this->currentPage->save(); + } + + /** + * @Then the properties are updated + */ + public function thePropertiesAreUpdated() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new MetaServiceDependencyConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->updatedProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->updatedProperties as $key => $value) { + if ($value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I duplicate a meta service dependency + */ + public function iDuplicateAMetaServiceDependency() + { + $this->currentPage = new MetaServiceDependencyConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Duplicate'); + } + + /** + * @Then the new object has the same properties + */ + public function theNewObjectHasTheSameProperties() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new MetaServiceDependencyConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name'] . '_1'); + $object = $this->currentPage->getProperties(); + foreach ($this->initialProperties as $key => $value) { + if ($key != 'name' && $value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I delete a meta service dependency + */ + public function iDeleteAMetaServiceDependency() + { + $this->currentPage = new MetaServiceDependencyConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Delete'); + } + + /** + * @Then the deleted object is not displayed in the list + */ + public function theDeletedObjectIsNotDisplayedInTheList() + { + $this->spin( + function ($context) { + $this->currentPage = new MetaServiceDependencyConfigurationListingPage($this); + $object = $this->currentPage->getEntries(); + $bool = true; + foreach ($object as $value) { + $bool = $bool && $value['name'] != $this->initialProperties['name']; + } + return $bool; + }, + "The service is not being deleted.", + 5 + ); + } +} diff --git a/features/bootstrap/MetaServicesApiContext.php b/features/bootstrap/MetaServicesApiContext.php index 1ba1ddd38f382e2d8725c931eefc88ce5cc71698..01437f3959a566ea4d84f12db802121f5016c17b 100644 --- a/features/bootstrap/MetaServicesApiContext.php +++ b/features/bootstrap/MetaServicesApiContext.php @@ -40,7 +40,6 @@ class MetaServicesApiContext extends CentreonContext { $param = 'all'; $this->jsonreturn = $this->callToApiConfigurationServices($param); - } @@ -51,7 +50,6 @@ class MetaServicesApiContext extends CentreonContext { $param = 's'; $this->jsonreturn = $this->callToApiConfigurationServices($param); - } @@ -62,7 +60,6 @@ class MetaServicesApiContext extends CentreonContext { $param = 'm'; $this->jsonreturn = $this->callToApiConfigurationServices($param); - } diff --git a/features/bootstrap/ServiceConfigurationContext.php b/features/bootstrap/ServiceConfigurationContext.php index 2e399bfdd0ce5980523d86f7cddb208fb14cf24f..12f935f6460a00d8e2045588f71b363ec9e6b8ab 100644 --- a/features/bootstrap/ServiceConfigurationContext.php +++ b/features/bootstrap/ServiceConfigurationContext.php @@ -103,7 +103,7 @@ class ServiceConfigurationContext extends CentreonContext 'severity' => 'serviceCategory2Name (2)', 'geo_coordinates' => 'Paris', 'status' => 1, - 'comments' => 'serviceComments' + 'comments' => 'serviceComments' ); protected $duplicatedProperties = array( @@ -111,7 +111,7 @@ class ServiceConfigurationContext extends CentreonContext 'description' => 'serviceDescription_1', 'templates' => 'generic-service', 'check_command' => 'check_http', - 'macros' => array( + 'macros' => array( 'MACRONAME' => 22 ), 'check_period' => 'workhours', @@ -121,21 +121,21 @@ class ServiceConfigurationContext extends CentreonContext 'active_checks_enabled' => 2, 'passive_checks_enabled' => 1, 'is_volatile' => 0, - 'notifications_enabled' => 2, + 'notifications_enabled' => 2, 'inherits_contacts_groups' => 0, 'contacts' => 'Guest', 'contact_additive_inheritance' => 1, 'contact_groups' => 'Supervisors', 'contact_group_additive_inheritance' => 1, 'notification_interval' => 23, - 'notify_on_none' => 1, + 'notify_on_none' => 1, 'notify_on_warning' => 0, 'notify_on_unknown' => 0, 'notify_on_critical' => 0, 'notify_on_recovery' => 0, 'notify_on_flapping' => 0, 'notify_on_downtime_scheduled' => 0, - 'first_notification_delay' => 4, + 'first_notification_delay' => 4, 'recovery_notification_delay' => 3, 'service_groups' => 'serviceGroup1Name', 'trap_relations' => 'coldStart', @@ -173,7 +173,7 @@ class ServiceConfigurationContext extends CentreonContext 'description' => 'serviceDescriptionChanged', 'templates' => 'Ping-WAN', 'check_command' => 'check_https', - 'macros' => array( + 'macros' => array( 'MACRONAMECHANGED' => 11 ), 'check_period' => 'none', diff --git a/features/bootstrap/ServiceDependencyConfigurationContext.php b/features/bootstrap/ServiceDependencyConfigurationContext.php new file mode 100644 index 0000000000000000000000000000000000000000..cb5d52bbbfcd6bb469c604c2021c1203de299e77 --- /dev/null +++ b/features/bootstrap/ServiceDependencyConfigurationContext.php @@ -0,0 +1,195 @@ +<?php + +use Centreon\Test\Behat\CentreonContext; +use Centreon\Test\Behat\Configuration\ServiceDependencyConfigurationPage; +use Centreon\Test\Behat\Configuration\ServiceDependencyConfigurationListingPage; +use Centreon\Test\Behat\Configuration\HostConfigurationPage; + +class ServiceDependencyConfigurationContext extends CentreonContext +{ + protected $currentPage; + + protected $host = array( + 'name' => 'hostName', + 'alias' => 'hostAlias', + 'address' => 'host@localhost' + ); + + protected $initialProperties = array( + 'name' => 'serviceDependencyName', + 'description' => 'serviceDependencyDescription', + 'parent_relationship' => 0, + 'execution_fails_on_none' => 1, + 'execution_fails_on_ok' => 0, + 'execution_fails_on_warning' => 0, + 'execution_fails_on_unknown' => 0, + 'execution_fails_on_critical' => 0, + 'execution_fails_on_pending' => 0, + 'notification_fails_on_ok' => 1, + 'notification_fails_on_warning' => 1, + 'notification_fails_on_unknown' => 1, + 'notification_fails_on_critical' => 1, + 'notification_fails_on_pending' => 1, + 'notification_fails_on_none' => 0, + 'services' => 'Centreon-Server - Load', + 'dependent_services' => 'Centreon-Server - Memory', + 'dependent_hosts' => 'Centreon-Server', + 'comment' => 'serviceDependingComment' + ); + + protected $updatedProperties = array( + 'name' => 'serviceDependentNameChanged', + 'description' => 'serviceDependentDescriptionChanged', + 'parent_relationship' => 1, + 'execution_fails_on_ok' => 1, + 'execution_fails_on_warning' => 1, + 'execution_fails_on_unknown' => 1, + 'execution_fails_on_critical' => 1, + 'execution_fails_on_pending' => 1, + 'execution_fails_on_none' => 0, + 'notification_fails_on_none' => 1, + 'notification_fails_on_ok' => 0, + 'notification_fails_on_warning' => 0, + 'notification_fails_on_unknown' => 0, + 'notification_fails_on_critical' => 0, + 'notification_fails_on_pending' => 0, + 'services' => 'Centreon-Server - Ping', + 'dependent_services' => 'Centreon-Server - Disk-/home', + 'dependent_hosts' => 'hostName', + 'comment' => 'serviceDependingCommentChanged' + ); + + /** + * @Given a service dependency is configured + */ + public function aServiceDependencyIsConfigured() + { + $this->currentPage = new HostConfigurationPage($this); + $this->currentPage->setProperties($this->host); + $this->currentPage->save(); + $this->currentPage = new ServiceDependencyConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + } + + /** + * @When I change the properties of a service dependency + */ + public function iChangeThePropertiesOfAServiceDependency() + { + $this->currentPage = new ServiceDependencyConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name']); + $this->currentPage->setProperties($this->updatedProperties); + $this->currentPage->save(); + } + + /** + * @Then the properties are updated + */ + public function thePropertiesAreUpdated() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ServiceDependencyConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->updatedProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->updatedProperties as $key => $value) { + if ($value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I duplicate a service dependency + */ + public function iDuplicateAServiceDependency() + { + $this->currentPage = new ServiceDependencyConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Duplicate'); + } + + /** + * @Then the new object has the same properties + */ + public function theNewObjectHasTheSameProperties() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ServiceDependencyConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name'] . '_1'); + $object = $this->currentPage->getProperties(); + foreach ($this->initialProperties as $key => $value) { + if ($key != 'name' && $value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I delete a service dependency + */ + public function iDeleteAServiceDependency() + { + $this->currentPage = new ServiceDependencyConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Delete'); + } + + /** + * @Then the deleted object is not displayed in the list + */ + public function theDeletedObjectIsNotDisplayedInTheList() + { + $this->spin( + function ($context) { + $this->currentPage = new ServiceDependencyConfigurationListingPage($this); + $object = $this->currentPage->getEntries(); + $bool = true; + foreach ($object as $value) { + $bool = $bool && $value['name'] != $this->initialProperties['name']; + } + return $bool; + }, + "The service is not being deleted.", + 5 + ); + } +} diff --git a/features/bootstrap/ServiceSubmitResultContext.php b/features/bootstrap/ServiceSubmitResultContext.php index 006a4929325934292905258f28e1c00f1a2d76d3..feeccee6afbc09ed6f720f99b2780a42472167d0 100644 --- a/features/bootstrap/ServiceSubmitResultContext.php +++ b/features/bootstrap/ServiceSubmitResultContext.php @@ -65,7 +65,11 @@ class ServiceSubmitResultContext extends CentreonContext public function theValuesAreSetAsWantedInMonitoringStatusDetailsPage() { $this->page = new MonitoringServicesPage($this); - $result = $this->page->getPropertyFromAHostAndService($this->hostname, $this->hostservice, 'status_information'); + $result = $this->page->getPropertyFromAHostAndService( + $this->hostname, + $this->hostservice, + 'status_information' + ); if ($result != $this->checkoutput) { throw new Exception('The result submitted is not set as wanted'); } diff --git a/features/bootstrap/VirtualMetricHandleContext.php b/features/bootstrap/VirtualMetricHandleContext.php index 1414b15459b5152dd538076e7c9bd3ee54bb5604..da509c00ced4dc7118dc9956c80c938bd9f16e10 100644 --- a/features/bootstrap/VirtualMetricHandleContext.php +++ b/features/bootstrap/VirtualMetricHandleContext.php @@ -9,7 +9,7 @@ class VirtualMetricHandleContext extends CentreonContext protected $page; protected $vmName = 'vmtestname'; protected $host = 'MetricTestHostname'; - protected $functionRPN ='test10'; + protected $functionRPN = 'test10'; protected $hostService = 'MetricTestService'; protected $duplicatedVmName = 'vmtestname_1'; @@ -27,7 +27,7 @@ class VirtualMetricHandleContext extends CentreonContext 'linked-host_services' => $this->host . ' - ' . $this->hostService )); $this->page->setProperties(array('function' => $this->functionRPN)); - $this->page->save(); + $this->page->save(); } /** @@ -35,11 +35,11 @@ class VirtualMetricHandleContext extends CentreonContext */ public function allPropertiesAreSaved() { - $this->page = new MetricsConfigurationListingPage($this); - $data = $this->page->getEntry($this->vmName); - if ($data['name'] != $this->vmName || $data['function'] != $this->functionRPN) { - throw new \Exception('Some properties have not been saved'); - } + $this->page = new MetricsConfigurationListingPage($this); + $data = $this->page->getEntry($this->vmName); + if ($data['name'] != $this->vmName || $data['function'] != $this->functionRPN) { + throw new \Exception('Some properties have not been saved'); + } } /** @@ -69,8 +69,8 @@ class VirtualMetricHandleContext extends CentreonContext if (key_exists($this->duplicatedVmName, $objects)) { if ($objects[$this->duplicatedVmName]['function'] != $objects[$this->vmName]['function'] || $objects[$this->duplicatedVmName]['def_type'] != $objects[$this->vmName]['def_type']) { - - throw new \Exception( 'Some properties of ' . $this->duplicatedVmName . ' virtual Metric have not ' + + throw new \Exception('Some properties of ' . $this->duplicatedVmName . ' virtual Metric have not ' . 'been duplicated'); } } else { diff --git a/lib/Centreon/Object/Relation/Acl/Group/Action.php b/lib/Centreon/Object/Relation/Acl/Group/Action.php index 47b3580522a6fa1e4b18a4b7550c45a94c20b85d..f5ff37b0b4975dca42ba168a36421b66352dc265 100644 --- a/lib/Centreon/Object/Relation/Acl/Group/Action.php +++ b/lib/Centreon/Object/Relation/Acl/Group/Action.php @@ -40,4 +40,11 @@ class Centreon_Object_Relation_Acl_Group_Action extends Centreon_Object_Relation protected $relationTable = "acl_group_actions_relations"; protected $firstKey = "acl_group_id"; protected $secondKey = "acl_action_id"; + + public function __construct() + { + parent::__construct(); + $this->firstObject = new Centreon_Object_Acl_Group(); + $this->secondObject = new Centreon_Object_Acl_Action(); + } } diff --git a/lib/Centreon/Object/Relation/Acl/Group/Contact/Contact.php b/lib/Centreon/Object/Relation/Acl/Group/Contact/Contact.php index 9fa9a36e1fb4eb284872d2c8ea69cfea61d6204c..958b27737a3f2b5d3c17c28490cd01e43e990e77 100644 --- a/lib/Centreon/Object/Relation/Acl/Group/Contact/Contact.php +++ b/lib/Centreon/Object/Relation/Acl/Group/Contact/Contact.php @@ -40,4 +40,11 @@ class Centreon_Object_Relation_Acl_Group_Contact extends Centreon_Object_Relatio protected $relationTable = "acl_group_contacts_relations"; protected $firstKey = "acl_group_id"; protected $secondKey = "contact_contact_id"; + + public function __construct() + { + parent::__construct(); + $this->firstObject = new Centreon_Object_Acl_Group(); + $this->secondObject = new Centreon_Object_Contact(); + } } diff --git a/lib/Centreon/Object/Relation/Acl/Group/Contact/Group.php b/lib/Centreon/Object/Relation/Acl/Group/Contact/Group.php index 29fcd28ddace83bb42d3c64fb3598ff478bf6332..105d15f4ff9ddff7f10cf5873b774ebe6b3a48d4 100644 --- a/lib/Centreon/Object/Relation/Acl/Group/Contact/Group.php +++ b/lib/Centreon/Object/Relation/Acl/Group/Contact/Group.php @@ -40,4 +40,11 @@ class Centreon_Object_Relation_Acl_Group_Contact_Group extends Centreon_Object_R protected $relationTable = "acl_group_contactgroups_relations"; protected $firstKey = "acl_group_id"; protected $secondKey = "cg_cg_id"; + + public function __construct() + { + parent::__construct(); + $this->firstObject = new Centreon_Object_Acl_Group(); + $this->secondObject = new Centreon_Object_Contact_Group(); + } } diff --git a/lib/Centreon/Object/Relation/Acl/Group/Menu.php b/lib/Centreon/Object/Relation/Acl/Group/Menu.php index 2f43b862d8ba91f0d1064dbc75a3ebbb4568faf7..95b1a6d9772f26d934e7acafa15a105f93713a18 100644 --- a/lib/Centreon/Object/Relation/Acl/Group/Menu.php +++ b/lib/Centreon/Object/Relation/Acl/Group/Menu.php @@ -40,4 +40,11 @@ class Centreon_Object_Relation_Acl_Group_Menu extends Centreon_Object_Relation protected $relationTable = "acl_group_topology_relations"; protected $firstKey = "acl_group_id"; protected $secondKey = "acl_topology_id"; + + public function __construct() + { + parent::__construct(); + $this->firstObject = new Centreon_Object_Acl_Group(); + $this->secondObject = new Centreon_Object_Acl_Menu(); + } } diff --git a/lib/Centreon/Object/Relation/Acl/Group/Resource.php b/lib/Centreon/Object/Relation/Acl/Group/Resource.php index 66968949f5b55ea4a6c0bfed40dc9f20261f1792..dd575f39249a9b3a4223d1fee40db173d8793a98 100644 --- a/lib/Centreon/Object/Relation/Acl/Group/Resource.php +++ b/lib/Centreon/Object/Relation/Acl/Group/Resource.php @@ -40,4 +40,11 @@ class Centreon_Object_Relation_Acl_Group_Resource extends Centreon_Object_Relati protected $relationTable = "acl_res_group_relations"; protected $firstKey = "acl_group_id"; protected $secondKey = "acl_res_id"; + + public function __construct() + { + parent::__construct(); + $this->firstObject = new Centreon_Object_Acl_Group(); + $this->secondObject = new Centreon_Object_Acl_Resource(); + } } diff --git a/tests/rest_api/rest_api.postman_collection.json b/tests/rest_api/rest_api.postman_collection.json index 6d30404eae307afdee8168e275289ceaf4d759ed..bb93c007eb5941a17b57eda3b95785bd87a1f9e4 100644 --- a/tests/rest_api/rest_api.postman_collection.json +++ b/tests/rest_api/rest_api.postman_collection.json @@ -33918,7 +33918,7 @@ ], "body": { "mode": "raw", - "raw": "{\n \"action\": \"addcontact\",\n \"object\": \"stpl\",\n \"values\": \"{{stpl_description}};{{contact_name}}\"\n}" + "raw": "{\n \"action\": \"addcontact\",\n \"object\": \"stpl\",\n \"values\": \"{{stpl_description}};{{contact_alias}}\"\n}" }, "description": "" }, @@ -33980,7 +33980,7 @@ ], "body": { "mode": "raw", - "raw": "{\n \"action\": \"delcontact\",\n \"object\": \"stpl\",\n \"values\": \"{{stpl_description}};{{contact_name}}\"\n}" + "raw": "{\n \"action\": \"delcontact\",\n \"object\": \"stpl\",\n \"values\": \"{{stpl_description}};{{contact_alias}}\"\n}" }, "description": "" }, @@ -34042,7 +34042,7 @@ ], "body": { "mode": "raw", - "raw": "{\n \"action\": \"setcontact\",\n \"object\": \"stpl\",\n \"values\": \"{{stpl_description}};{{contact_name}}|{{contact_name2}}\"\n}" + "raw": "{\n \"action\": \"setcontact\",\n \"object\": \"stpl\",\n \"values\": \"{{stpl_description}};{{contact_alias}}|{{contact_alias2}}\"\n}" }, "description": "" }, @@ -34063,8 +34063,8 @@ " tests[\"Body contains list of contacts\"] = contactData;", " var i = 0;", " while (i < contactData.length) {", - " if (postman.getEnvironmentVariable(\"contact_alias\") == contactData[i].name){", - " tests[\"Body contains added contact_alias\"] = postman.getEnvironmentVariable(\"contact_alias\") == contactData[i].name;", + " if (postman.getEnvironmentVariable(\"contact_alias\") == contactData[i].alias){", + " tests[\"Body contains added contact_alias\"] = postman.getEnvironmentVariable(\"contact_alias\") == contactData[i].alias;", " break;", " }", " i++;", diff --git a/www/api/class/centreon_configuration_objects.class.php b/www/api/class/centreon_configuration_objects.class.php index 6dff7c421d067605a90c8a455320c87b8543e54d..eb70faa46d741e208b502eec70a101e3ecff1108 100644 --- a/www/api/class/centreon_configuration_objects.class.php +++ b/www/api/class/centreon_configuration_objects.class.php @@ -151,6 +151,11 @@ class CentreonConfigurationObjects extends CentreonWebService "FROM $externalObject[table] " . "WHERE $externalObject[comparator] " . "IN ($explodedValues)"; + + if (!empty($externalObject['additionalComparator'])) { + $query .= $this->processAdditionalComparator($externalObject['additionalComparator']); + } + $stmt = $this->pearDB->prepare($query); $resRetrieval = $this->pearDB->execute($stmt, $values); @@ -167,6 +172,24 @@ class CentreonConfigurationObjects extends CentreonWebService return $tmpValues; } + /** + * @param $additonalComparator + * @return string + */ + protected function processAdditionalComparator($additonalComparator) + { + $additonalQueryComparator = ''; + foreach ($additonalComparator as $field => $value) { + if (is_null($value)) { + $additonalQueryComparator .= 'AND ' . $field . ' IS NULL '; + } else { + $additonalQueryComparator .= 'AND ' . $field . ' = ' . $value; + } + } + return $additonalQueryComparator; + } + + /** * @param $currentObject * @param $id diff --git a/www/api/class/centreon_configuration_servicecategory.class.php b/www/api/class/centreon_configuration_servicecategory.class.php index 92e23f2c721e803400e284302c83e72c8ac0a419..7cbeb6f0b299f477f56658c0278ce272123d56e4 100644 --- a/www/api/class/centreon_configuration_servicecategory.class.php +++ b/www/api/class/centreon_configuration_servicecategory.class.php @@ -64,7 +64,7 @@ class CentreonConfigurationServicecategory extends CentreonConfigurationObjects /* * Check for select2 't' argument * 'a' or empty = category and severitiy - * 'c' = catagory only + * 'c' = category only * 's' = severity only */ if (false === isset($this->arguments['t'])) { diff --git a/www/class/centreon-clapi/centreon.Config.Poller.class.php b/www/class/centreon-clapi/centreon.Config.Poller.class.php index 8b32ae392a60e6d6b6c462b07c5803767facddd4..a619c0f3cb118a6812783fd859a971d803ffd4c0 100644 --- a/www/class/centreon-clapi/centreon.Config.Poller.class.php +++ b/www/class/centreon-clapi/centreon.Config.Poller.class.php @@ -691,7 +691,7 @@ class CentreonConfigPoller * @param unknown_type $status * @return string */ - private function display_copying_file($filename = null, $status) + private function display_copying_file($filename = null, $status = null) { if (!isset($filename)) { return; diff --git a/www/class/centreon-clapi/centreonACLAction.class.php b/www/class/centreon-clapi/centreonACLAction.class.php index 320d34a97eedb693541dd8a2ba0880146c294b9b..793e64464ec7787aee608dea685f3919bad56a16 100644 --- a/www/class/centreon-clapi/centreonACLAction.class.php +++ b/www/class/centreon-clapi/centreonACLAction.class.php @@ -67,45 +67,48 @@ class CentreonACLAction extends CentreonObject $this->relObject = new \Centreon_Object_Relation_Acl_Group_Action(); $this->params = array('acl_action_activate' => '1'); $this->nbOfCompulsoryParams = 2; - $this->availableActions = array('global_event_handler', - 'global_flap_detection', - 'global_host_checks', - 'global_host_obsess', - 'global_host_passive_checks', - 'global_notifications', - 'global_perf_data', - 'global_restart', - 'global_service_checks', - 'global_service_obsess', - 'global_service_passive_checks', - 'global_shutdown', - 'host_acknowledgement', - 'host_checks', - 'host_checks_for_services', - 'host_comment', - 'host_event_handler', - 'host_flap_detection', - 'host_notifications', - 'host_notifications_for_services', - 'host_schedule_check', - 'host_schedule_downtime', - 'host_schedule_forced_check', - 'host_submit_result', - 'poller_listing', - 'poller_stats', - 'service_acknowledgement', - 'service_checks', - 'service_comment', - 'service_event_handler', - 'service_flap_detection', - 'service_notifications', - 'service_passive_checks', - 'service_schedule_check', - 'service_schedule_downtime', - 'service_schedule_forced_check', - 'service_submit_result', - 'top_counter'); + $this->availableActions = array( + 'global_event_handler', + 'global_flap_detection', + 'global_host_checks', + 'global_host_obsess', + 'global_host_passive_checks', + 'global_notifications', + 'global_perf_data', + 'global_restart', + 'global_service_checks', + 'global_service_obsess', + 'global_service_passive_checks', + 'global_shutdown', + 'host_acknowledgement', + 'host_checks', + 'host_checks_for_services', + 'host_comment', + 'host_event_handler', + 'host_flap_detection', + 'host_notifications', + 'host_notifications_for_services', + 'host_schedule_check', + 'host_schedule_downtime', + 'host_schedule_forced_check', + 'host_submit_result', + 'poller_listing', + 'poller_stats', + 'service_acknowledgement', + 'service_checks', + 'service_comment', + 'service_event_handler', + 'service_flap_detection', + 'service_notifications', + 'service_passive_checks', + 'service_schedule_check', + 'service_schedule_downtime', + 'service_schedule_forced_check', + 'service_submit_result', + 'top_counter' + ); $this->activateField = "acl_action_activate"; + $this->action = "ACLACTION"; } /** @@ -284,4 +287,52 @@ class CentreonACLAction extends CentreonObject } } } + + public function export($filters = null) + { + $aclActionRuleList = $this->object->getList('*', -1, 0, null, null, $filters); + + $exportLine = ''; + foreach ($aclActionRuleList as $aclActionRule) { + $exportLine .= $this->action . $this->delim . 'ADD' . $this->delim + . $aclActionRule['acl_action_name'] . $this->delim + . $aclActionRule['acl_action_description'] . $this->delim . "\n"; + + $exportLine .= $this->action . $this->delim . 'SETPARAM' . $this->delim + . $aclActionRule['acl_action_name'] . $this->delim; + + $exportLine .= 'activate' . $this->delim . $aclActionRule['acl_action_activate'] . $this->delim . "\n"; + + $exportLine .= $this->exportGrantActions( + $aclActionRule['acl_action_id'], + $aclActionRule['acl_action_name'] + ); + + echo $exportLine; + $exportLine = ''; + } + } + + /** + * @param $aclActionRuleId + * @param $aclActionName + * @return string + */ + private function exportGrantActions($aclActionRuleId, $aclActionName) + { + $grantActions = ''; + + $query = 'SELECT * FROM acl_actions_rules WHERE acl_action_rule_id = ?'; + + $aclActionList = $this->db->fetchAll($query, array($aclActionRuleId)); + + foreach ($aclActionList as $aclAction) { + $grantActions .= $this->action . $this->delim . 'GRANT' . $this->delim . + $aclActionName . $this->delim . + $aclAction['acl_action_name'] . $this->delim . "\n"; + } + + + return $grantActions; + } } diff --git a/www/class/centreon-clapi/centreonACLGroup.class.php b/www/class/centreon-clapi/centreonACLGroup.class.php index 0e65884ae6cb2c637430448323e0c16948442390..215b027a85bca55cd33e40c13722a440d94c03f1 100644 --- a/www/class/centreon-clapi/centreonACLGroup.class.php +++ b/www/class/centreon-clapi/centreonACLGroup.class.php @@ -58,6 +58,14 @@ class CentreonACLGroup extends CentreonObject const ORDER_UNIQUENAME = 0; const ORDER_ALIAS = 1; + public $aDepends = array( + 'CONTACT', + 'CG', + 'ACLMENU', + 'ACLACTION', + 'ACLRESOURCE' + ); + /** * Constructor * @@ -67,11 +75,13 @@ class CentreonACLGroup extends CentreonObject { parent::__construct(); $this->object = new \Centreon_Object_Acl_Group(); - $this->params = array( 'acl_group_changed' => '1', - 'acl_group_activate' => '1' - ); + $this->params = array( + 'acl_group_changed' => '1', + 'acl_group_activate' => '1' + ); $this->nbOfCompulsoryParams = 2; $this->activateField = "acl_group_activate"; + $this->action = "ACLGROUP"; } /** @@ -226,4 +236,121 @@ class CentreonACLGroup extends CentreonObject throw new CentreonClapiException(self::UNKNOWN_METHOD); } } + + /** + * @param null $filters + */ + public function export($filters = null) + { + $aclGroupList = $this->object->getList('*', -1, 0, null, null, $filters); + + $exportLine = ''; + foreach ($aclGroupList as $aclGroup) { + $exportLine .= $this->action . $this->delim . "ADD" . $this->delim + . $aclGroup['acl_group_name'] . $this->delim + . $aclGroup['acl_group_alias'] . $this->delim . "\n"; + + $exportLine .= $this->action . $this->delim . "SETPARAM" . $this->delim + . $aclGroup['acl_group_name'] . $this->delim + . 'activate' . $this->delim + . $aclGroup['acl_group_activate'] . $this->delim . "\n"; + + $exportLine .= $this->exportLinkedObjects($aclGroup['acl_group_id'], $aclGroup['acl_group_name']); + + echo $exportLine; + $exportLine = ''; + } + } + + /** + * @param $aclGroupId + * @param $aclGroupName + * @return string + */ + private function exportLinkedObjects($aclGroupId, $aclGroupName) + { + $objectList = array( + array( + 'object' => 'MENU', + 'relClass' => 'Centreon_Object_Relation_Acl_Group_Menu', + 'objectFieldName' => 'acl_topo_name' + ), + array( + 'object' => 'ACTION', + 'relClass' => 'Centreon_Object_Relation_Acl_Group_Action', + 'objectFieldName' => 'acl_action_name' + ), + array( + 'object' => 'RESOURCE', + 'relClass' => 'Centreon_Object_Relation_Acl_Group_Resource', + 'objectFieldName' => 'acl_res_name' + ), + array( + 'object' => 'CONTACT', + 'relClass' => 'Centreon_Object_Relation_Acl_Group_Contact', + 'objectFieldName' => 'contact_name' + ), + array( + 'object' => 'CONTACTGROUP', + 'relClass' => 'Centreon_Object_Relation_Acl_Group_Contact_Group', + 'objectFieldName' => 'cg_name' + ), + ); + + $linkedObjectsSetter = $this->action . $this->delim . 'SET%s' . $this->delim . + $aclGroupName . $this->delim . + '%s' . $this->delim . "\n"; + + $linkedObjectsStr = ''; + + foreach ($objectList as $currentObject) { + $linkedObjects = $this->getLinkedObject( + $aclGroupId, + $currentObject['relClass'], + $currentObject['objectFieldName'] + ); + if (!empty($linkedObjects)) { + $linkedObjectsStr .= sprintf($linkedObjectsSetter, $currentObject['object'], $linkedObjects); + } + } + + return $linkedObjectsStr; + } + + /** + * @param $aclGroupId + * @param $relClass + * @param $objectFieldName + * @return string + * @throws CentreonClapiException + */ + private function getLinkedObject($aclGroupId, $relClass, $objectFieldName) + { + if (!class_exists($relClass)) { + throw new CentreonClapiException('Unsupported relation object : ' . $relClass); + } + + $relObj = new $relClass(); + + $comparisonKey1 = $this->object->getTableName() . '.' . $this->object->getPrimaryKey(); + + $links = $relObj->getMergedParameters( + array(), + array($objectFieldName), + -1, + 0, + null, + 'ASC', + array($comparisonKey1 => $aclGroupId), + 'AND' + ); + + $linkedObjects = ''; + + foreach ($links as $link) { + $linkedObjects .= $link[$objectFieldName] . '|'; + } + + return trim($linkedObjects, '|'); + } } diff --git a/www/class/centreon-clapi/centreonACLMenu.class.php b/www/class/centreon-clapi/centreonACLMenu.class.php index 438599f1e2039dba46dd3dcf63964a84a65ee63a..101379a41e5086fe38b4fd14bc7d276088665bef 100644 --- a/www/class/centreon-clapi/centreonACLMenu.class.php +++ b/www/class/centreon-clapi/centreonACLMenu.class.php @@ -39,6 +39,8 @@ require_once "centreonObject.class.php"; require_once "Centreon/Object/Acl/Group.php"; require_once "Centreon/Object/Acl/Menu.php"; require_once "Centreon/Object/Relation/Acl/Group/Menu.php"; +require_once _CENTREON_PATH_ . "www/class/centreonDB.class.php"; +require_once _CENTREON_PATH_ . '/www/class/centreonTopology.class.php'; /** * Class for managing ACL Menu rules @@ -56,6 +58,7 @@ class CentreonACLMenu extends CentreonObject const PARENT_MENU_NOT_DEFINED = "Parent menu must be defined"; protected $relObject; protected $aclGroupObj; + protected $topologyObj; /** * Constructor @@ -71,6 +74,8 @@ class CentreonACLMenu extends CentreonObject $this->params = array('acl_topo_activate' => '1'); $this->nbOfCompulsoryParams = 2; $this->activateField = "acl_topo_activate"; + $this->action = "ACLMENU"; + $this->topologyObj = new \CentreonTopology(new \CentreonDB()); } /** @@ -268,7 +273,7 @@ class CentreonACLMenu extends CentreonObject * @param int $parentTopologyId * @return void */ - protected function processChildrenOf($action = "grant", $aclMenuId, $parentTopologyId) + protected function processChildrenOf($action = "grant", $aclMenuId = null, $parentTopologyId = null) { $sql = "SELECT topology_id, topology_page FROM topology WHERE topology_parent = ?"; $res = $this->db->query($sql, array($parentTopologyId)); @@ -374,4 +379,77 @@ class CentreonACLMenu extends CentreonObject } } } + + /** + * @param array $filters + */ + public function export($filters = null) + { + $aclMenuList = $this->object->getList('*', -1, 0, null, null, $filters); + + $exportLine = ''; + foreach ($aclMenuList as $aclMenu) { + $exportLine .= $this->action . $this->delim . "ADD" . $this->delim + . $aclMenu['acl_topo_name'] . $this->delim + . $aclMenu['acl_topo_alias'] . $this->delim . "\n"; + + $exportLine .= $this->action . $this->delim . + "SETPARAM" . $this->delim . + $aclMenu['acl_topo_name'] . $this->delim; + + if (!empty($aclMenu['acl_comments'])) { + $exportLine .= 'comment' . $this->delim . $aclMenu['acl_comments'] . $this->delim . "\n"; + } + + + $exportLine .= 'activate' . $this->delim . $aclMenu['acl_topo_activate'] . $this->delim . "\n"; + $exportLine .= $this->grantMenu($aclMenu['acl_topo_id'], $aclMenu['acl_topo_name']); + + echo $exportLine; + $exportLine = ''; + } + } + + /** + * @param int $aclTopoId + * @param string $aclTopoName + * @return string + */ + private function grantMenu($aclTopoId, $aclTopoName) + { + + $grantedMenu = ''; + + $grantedMenuTpl = $this->action . $this->delim . '%s' . $this->delim . + $aclTopoName . $this->delim . + '%s' . $this->delim . "\n"; + + $grantedPossibilities = array( + '1' => 'GRANTRW', + '2' => 'GRANTRO' + ); + + $queryAclMenuRelations = 'SELECT t.topology_page, t.topology_id, t.topology_name, atr.access_right ' . + 'FROM acl_topology_relations atr, topology t ' . + 'WHERE atr.topology_topology_id = t.topology_id ' . + "AND atr.access_right <> '0'" . + 'AND atr.acl_topo_id = ?'; + + $grantedTopologyList = $this->db->fetchAll($queryAclMenuRelations, array($aclTopoId)); + + foreach ($grantedTopologyList as $grantedTopology) { + $grantedTopologyBreadCrumb = $this->topologyObj->getBreadCrumbFromTopology( + $grantedTopology['topology_page'], + $grantedTopology['topology_name'], + ';' + ); + $grantedMenu .= sprintf( + $grantedMenuTpl, + $grantedPossibilities[$grantedTopology['access_right']], + $grantedTopologyBreadCrumb + ); + } + + return $grantedMenu; + } } diff --git a/www/class/centreon-clapi/centreonACLResource.class.php b/www/class/centreon-clapi/centreonACLResource.class.php index c1eddece52547e873e9978c23c2bb92e53e9494d..a6fdad9a2d40eecfcafdb61df22536cbb94572d1 100644 --- a/www/class/centreon-clapi/centreonACLResource.class.php +++ b/www/class/centreon-clapi/centreonACLResource.class.php @@ -93,6 +93,16 @@ class CentreonACLResource extends CentreonObject */ protected $resourceTypeObjectRelation; + public $aDepends = array( + 'HOST', + 'SERVICE', + 'HG', + 'SG', + 'INSTANCE', + 'HC', + 'SC' + ); + /** * Constructor * @@ -105,14 +115,16 @@ class CentreonACLResource extends CentreonObject $this->aclGroupObj = new \Centreon_Object_Acl_Group(); $this->relObject = new \Centreon_Object_Relation_Acl_Group_Resource(); - $this->params = array( 'all_hosts' => '0', - 'all_hostgroups' => '0', - 'all_servicegroups' => '0', - 'acl_res_activate' => '1', - 'changed' => '1' - ); + $this->params = array( + 'all_hosts' => '0', + 'all_hostgroups' => '0', + 'all_servicegroups' => '0', + 'acl_res_activate' => '1', + 'changed' => '1' + ); $this->nbOfCompulsoryParams = 2; $this->activateField = "acl_res_activate"; + $this->action = "ACLRESOURCE"; } /** @@ -410,4 +422,300 @@ class CentreonACLResource extends CentreonObject throw new CentreonClapiException(self::UNKNOWN_METHOD); } } + + /** + * @param null $filters + */ + public function export($filters = null) + { + $aclResourceList = $this->object->getList('*', -1, 0, null, null, $filters); + + $exportLine = ''; + foreach ($aclResourceList as $aclResource) { + $exportLine .= $this->action . $this->delim . "ADD" . $this->delim + . $aclResource['acl_res_name'] . $this->delim + . $aclResource['acl_res_alias'] . $this->delim . "\n"; + + $exportLine .= $this->action . $this->delim . "SETPARAM" . $this->delim + . $aclResource['acl_res_name'] . $this->delim; + + if (!empty($aclResource['acl_res_comment'])) { + $exportLine .= 'comment' . $this->delim . $aclResource['acl_res_comment'] . $this->delim . "\n"; + } + + $exportLine .= 'activate' . $this->delim . $aclResource['acl_res_activate'] . $this->delim . "\n"; + + $exportLine .= $this->exportGrantResources($aclResource); + + echo $exportLine; + $exportLine = ''; + } + } + + /** + * @param $aclResourceParams + * @return string + */ + private function exportGrantResources($aclResourceParams) + { + $grantResources = ''; + + $grantResources .= $this->exportGrantHostResources( + $aclResourceParams['acl_res_id'], + $aclResourceParams['acl_res_name'], + $aclResourceParams['all_hosts'] + ); + $grantResources .= $this->exportGrantHostgroupResources( + $aclResourceParams['acl_res_id'], + $aclResourceParams['acl_res_name'], + $aclResourceParams['all_hostgroups'] + ); + $grantResources .= $this->exportGrantServicegroupResources( + $aclResourceParams['acl_res_id'], + $aclResourceParams['acl_res_name'], + $aclResourceParams['all_servicegroups'] + ); + $grantResources .= $this->exportGrantMetaserviceResources( + $aclResourceParams['acl_res_id'], + $aclResourceParams['acl_res_name'] + ); + $grantResources .= $this->exportFilterInstance( + $aclResourceParams['acl_res_id'], + $aclResourceParams['acl_res_name'] + ); + $grantResources .= $this->exportFilterHostCategory( + $aclResourceParams['acl_res_id'], + $aclResourceParams['acl_res_name'] + ); + $grantResources .= $this->exportFilterServiceCategory( + $aclResourceParams['acl_res_id'], + $aclResourceParams['acl_res_name'] + ); + + + return $grantResources; + } + + /** + * @param int $aclResId + * @param string $aclResName + * @param int $allHosts + * @param bool $withExclusion + * @return string + */ + private function exportGrantHostResources($aclResId, $aclResName, $allHosts = 1, $withExclusion = true) + { + $grantHostResources = ''; + + if ($allHosts == 1) { + $grantHostResources .= $this->exportGrantObject('*', 'GRANT_HOST', $aclResName); + } else { + $queryHostGranted = 'SELECT h.host_name AS "object_name" ' . + 'FROM host h, acl_resources_host_relations arhr ' . + 'WHERE arhr.host_host_id = h.host_id ' . + 'AND arhr.acl_res_id = ?'; + + $grantedHostList = $this->db->fetchAll($queryHostGranted, array($aclResId)); + $grantHostResources .= $this->exportGrantObject($grantedHostList, 'GRANT_HOST', $aclResName); + } + + if ($withExclusion) { + $queryHostExcluded = 'SELECT h.host_name AS "object_name" ' . + 'FROM host h, acl_resources_hostex_relations arher ' . + 'WHERE arher.host_host_id = h.host_id ' . + 'AND arher.acl_res_id = ?'; + + $excludedHostList = $this->db->fetchAll($queryHostExcluded, array($aclResId)); + $grantHostResources .= $this->exportGrantObject( + $excludedHostList, + 'ADDHOSTEXCLUSION', + $aclResName + ); + } + + return $grantHostResources; + } + + /** + * @param $aclResId + * @param $aclResName + * @param int $allHostgroups + * @return string + */ + private function exportGrantHostgroupResources($aclResId, $aclResName, $allHostgroups = 1) + { + $grantHostgroupResources = ''; + + if ($allHostgroups == 1) { + $grantHostgroupResources .= $this->exportGrantObject('*', 'GRANT_HOSTGROUP', $aclResName); + } else { + $queryHostgroupGranted = 'SELECT hg.hg_name AS "object_name" ' . + 'FROM hostgroup hg, acl_resources_hg_relations arhgr ' . + 'WHERE arhgr.hg_hg_id = hg.hg_id ' . + 'AND arhgr.acl_res_id = ?'; + + $grantedHostgroupList = $this->db->fetchAll($queryHostgroupGranted, array($aclResId)); + $grantHostgroupResources .= $this->exportGrantObject( + $grantedHostgroupList, + 'GRANT_HOSTGROUP', + $aclResName + ); + } + + return $grantHostgroupResources; + } + + /** + * @param $aclResId + * @param $aclResName + * @param int $allServicegroups + * @return string + */ + private function exportGrantServicegroupResources($aclResId, $aclResName, $allServicegroups = 1) + { + $grantServicegroupResources = ''; + + if ($allServicegroups == 1) { + $grantServicegroupResources .= $this->exportGrantObject('*', 'GRANT_SERVICEGROUP', $aclResName); + } else { + $queryServicegroupGranted = 'SELECT sg.sg_name AS "object_name" ' . + 'FROM servicegroup sg, acl_resources_sg_relations arsgr ' . + 'WHERE arsgr.sg_id = sg.sg_id ' . + 'AND arsgr.acl_res_id = ?'; + + $grantedServicegroupList = $this->db->fetchAll($queryServicegroupGranted, array($aclResId)); + $grantServicegroupResources .= $this->exportGrantObject( + $grantedServicegroupList, + 'GRANT_SERVICEGROUP', + $aclResName + ); + } + + return $grantServicegroupResources; + } + + /** + * @param $aclResId + * @param $aclResName + * @return string + */ + private function exportGrantMetaserviceResources($aclResId, $aclResName) + { + $grantMetaserviceResources = ''; + + $queryMetaserviceGranted = 'SELECT m.meta_name AS "object_name" ' . + 'FROM meta_service m, acl_resources_meta_relations armr ' . + 'WHERE armr.meta_id = m.meta_id ' . + 'AND armr.acl_res_id = ?'; + + $grantedMetaserviceList = $this->db->fetchAll($queryMetaserviceGranted, array($aclResId)); + $grantMetaserviceResources .= $this->exportGrantObject( + $grantedMetaserviceList, + 'GRANT_METASERVICE', + $aclResName + ); + + return $grantMetaserviceResources; + } + + /** + * @param $aclResId + * @param $aclResName + * @return string + */ + private function exportFilterInstance($aclResId, $aclResName) + { + $filterInstances = ''; + + $queryFilteredInstances = 'SELECT n.name AS "object_name" ' . + 'FROM nagios_server n, acl_resources_poller_relations arpr ' . + 'WHERE arpr.poller_id = n.id ' . + 'AND arpr.acl_res_id = ?'; + + $filteredInstanceList = $this->db->fetchAll($queryFilteredInstances, array($aclResId)); + $filterInstances .= $this->exportGrantObject($filteredInstanceList, 'ADDFILTER_INSTANCE', $aclResName); + + return $filterInstances; + } + + /** + * @param $aclResId + * @param $aclResName + * @return string + */ + private function exportFilterHostCategory($aclResId, $aclResName) + { + $filterHostCategories = ''; + + $queryFilteredHostCategories = 'SELECT hc.hc_name AS "object_name" ' . + 'FROM hostcategories hc, acl_resources_hc_relations arhcr ' . + 'WHERE arhcr.hc_id = hc.hc_id ' . + 'AND arhcr.acl_res_id = ?'; + + $filteredHostCategoryList = $this->db->fetchAll($queryFilteredHostCategories, array($aclResId)); + $filterHostCategories .= $this->exportGrantObject( + $filteredHostCategoryList, + 'ADDFILTER_HOSTCATEGORY', + $aclResName + ); + + return $filterHostCategories; + } + + /** + * @param $aclResId + * @param $aclResName + * @return string + */ + private function exportFilterServiceCategory($aclResId, $aclResName) + { + $filterServiceCategories = ''; + + $queryFilteredServiceCategories = 'SELECT sc.sc_name AS "object_name" ' . + 'FROM service_categories sc, acl_resources_sc_relations arscr ' . + 'WHERE arscr.sc_id = sc.sc_id ' . + 'AND arscr.acl_res_id = ?'; + + $filteredServiceCategoryList = $this->db->fetchAll($queryFilteredServiceCategories, array($aclResId)); + $filterServiceCategories .= $this->exportGrantObject( + $filteredServiceCategoryList, + 'ADDFILTER_SERVICECATEGORY', + $aclResName + ); + + return $filterServiceCategories; + } + + /** + * @param $grantedResourceItems + * @param $grantCommand + * @param $aclResName + * @return string + */ + private function exportGrantObject($grantedResourceItems, $grantCommand, $aclResName) + { + $grantObject = ''; + + // Template for object export command + $grantedCommandTpl = $this->action . $this->delim . $grantCommand . $this->delim . + $aclResName . $this->delim . + '%s' . $this->delim . "\n"; + + $grantedObjectList = ''; + if (is_array($grantedResourceItems)) { // Non wildcard mode + foreach ($grantedResourceItems as $grantedObject) { + $grantedObjectList .= $grantedObject['object_name'] . '|'; + } + } elseif (is_string($grantedResourceItems)) { // Wildcard mode ('*') + $grantedObjectList .= $grantedResourceItems; + } else { // Unknown mode + throw new \CentreonClapiException('Unsupported resource'); + } + + if (!empty($grantedObjectList)) { // Check if list is useful + $grantObject .= sprintf($grantedCommandTpl, trim($grantedObjectList, '|')); + } + + return $grantObject; + } } diff --git a/www/class/centreon-clapi/centreonAPI.class.php b/www/class/centreon-clapi/centreonAPI.class.php index bbfc1e07100016ada8fa4784f3c77099848f6cc3..afdf88b2baf9e668ef92ef853baa4bc43bedf0ec 100644 --- a/www/class/centreon-clapi/centreonAPI.class.php +++ b/www/class/centreon-clapi/centreonAPI.class.php @@ -187,11 +187,6 @@ class CentreonAPI 'class' => 'ServiceCategory', 'export' => true ); - $this->relationObject["LDAP"] = array( - 'module' => 'core', - 'class' => 'LDAP', - 'export' => true - ); $this->relationObject["CONTACT"] = array( 'module' => 'core', 'class' => 'Contact', @@ -200,6 +195,11 @@ class CentreonAPI ), 'export' => true ); + $this->relationObject["LDAP"] = array( + 'module' => 'core', + 'class' => 'LDAP', + 'export' => true + ); $this->relationObject["CONTACTTPL"] = array( 'module' => 'core', 'class' => 'ContactTemplate', @@ -266,22 +266,22 @@ class CentreonAPI $this->relationObject["ACLGROUP"] = array( 'module' => 'core', 'class' => 'ACLGroup', - 'export' => false + 'export' => true ); $this->relationObject["ACLACTION"] = array( 'module' => 'core', 'class' => 'ACLAction', - 'export' => false + 'export' => true ); $this->relationObject["ACLMENU"] = array( 'module' => 'core', 'class' => 'ACLMenu', - 'export' => false + 'export' => true ); $this->relationObject["ACLRESOURCE"] = array( 'module' => 'core', 'class' => 'ACLResource', - 'export' => false + 'export' => true ); $this->relationObject["SETTINGS"] = array( 'module' => 'core', @@ -307,8 +307,8 @@ class CentreonAPI $finalNamespace = implode( '', array_map( - function($n) { - return ucfirst($n); + function ($n) { + return ucfirst($n); }, explode('-', $finalNamespace) ) @@ -329,9 +329,6 @@ class CentreonAPI $this->optGen = $this->getOptGen(); $version = $this->optGen["version"]; $this->delim = ";"; - - - } /** @@ -339,8 +336,14 @@ class CentreonAPI * @param void * @return CentreonApi */ - public static function getInstance($user=null, $password=null, $action=null, $centreon_path=null, $options=null) { - if(is_null(self::$_instance)) { + public static function getInstance( + $user = null, + $password = null, + $action = null, + $centreon_path = null, + $options = null + ) { + if (is_null(self::$_instance)) { self::$_instance = new CentreonAPI($user, $password, $action, $centreon_path, $options); } @@ -363,12 +366,10 @@ class CentreonAPI */ protected function requireLibs($object) { - - if ($object != "") { if (isset($this->relationObject[$object]['class']) && isset($this->relationObject[$object]['module']) - && !class_exists("Centreon" . $this->relationObject[$object])) { + && !class_exists("Centreon" . $this->relationObject[$object]['class'])) { if ($this->relationObject[$object]['module'] == 'core') { require_once "centreon" . $this->relationObject[$object]['class'] . ".class.php"; } else { @@ -386,7 +387,6 @@ class CentreonAPI } } else { foreach ($this->relationObject as $sSynonyme => $oObjet) { - if (isset($oObjet['class']) && isset($oObjet['module']) && !class_exists("\CentreonClapi\Centreon" . $oObjet['class'])) { @@ -632,11 +632,11 @@ class CentreonAPI * Check class declaration */ if (isset($this->relationObject[$this->object]['class'])) { - if ($this->relationObject[$this->object]['module'] === 'core') { $objName = "\CentreonClapi\centreon" . $this->relationObject[$this->object]['class']; } else { - $objName = $this->relationObject[$this->object]['namespace'] . "\CentreonClapi\Centreon" . $this->relationObject[$this->object]['class']; + $objName = $this->relationObject[$this->object]['namespace'] . + "\CentreonClapi\Centreon" . $this->relationObject[$this->object]['class']; } } else { $objName = ""; @@ -811,9 +811,9 @@ class CentreonAPI print "Unknown object : $splits[0]\n"; $this->setReturnCode(1); $this->close(); - } + } $this->export_filter($splits[0], $this->objectTable[$splits[0]]->getObjectId($splits[1]), $splits[1]); - } + } # Don't want return \n exit($this->return_code); } else { @@ -1026,7 +1026,6 @@ class CentreonAPI if (isset($this->relationObject) && is_array(($this->relationObject))) { $aObject = $this->relationObject; while ($oObjet = array_slice($aObject, -1, 1, true)) { - $key = key($oObjet); if (isset($oObjet[$key]['class']) && $oObjet[$key]['export'] === true @@ -1038,6 +1037,7 @@ class CentreonAPI $objName .= '\CentreonClapi\Centreon' . $oObjet[$key]['class']; $objVars = get_class_vars($objName); + if (isset($objVars['aDepends'])) { $bInsert = true; foreach ($objVars['aDepends'] as $item => $oDependence) { @@ -1061,7 +1061,6 @@ class CentreonAPI array_pop($aObject); } } - } } } diff --git a/www/class/centreon-clapi/centreonCommand.class.php b/www/class/centreon-clapi/centreonCommand.class.php index a076f1f4fda9d213dc25477038f371bbdd36c732..0201ce873602174f7d6bef20fd172a7dab85f46c 100644 --- a/www/class/centreon-clapi/centreonCommand.class.php +++ b/www/class/centreon-clapi/centreonCommand.class.php @@ -214,7 +214,7 @@ class CentreonCommand extends CentreonObject * @return void */ - public function export($filters=null) + public function export($filters = null) { $elements = $this->object->getList("*", -1, 0, null, null, $filters); foreach ($elements as $element) { diff --git a/www/class/centreon-clapi/centreonContact.class.php b/www/class/centreon-clapi/centreonContact.class.php index d7eff03bf016339ba55ee3a246ad555530f0cc5e..6d16a82329ce17efb079d0c893ba0fd48509d733 100644 --- a/www/class/centreon-clapi/centreonContact.class.php +++ b/www/class/centreon-clapi/centreonContact.class.php @@ -141,8 +141,8 @@ class CentreonContact extends CentreonObject 'contact_auth_type' ); $this->exportExcludedParams = array_merge( - $this->insertParams, - array( + $this->insertParams, + array( $this->object->getPrimaryKey(), "contact_register" ) @@ -448,7 +448,7 @@ class CentreonContact extends CentreonObject * @param string $parameters * @return void */ - public function export($filters=null) + public function export($filters = null) { $filters["contact_register"] = $this->register; $elements = $this->object->getList( diff --git a/www/class/centreon-clapi/centreonEngineCfg.class.php b/www/class/centreon-clapi/centreonEngineCfg.class.php index e7ed83994e0ecb42ce42679f921d2124360ac765..19d73515cd935e15e8fb7c65004854379c337684 100644 --- a/www/class/centreon-clapi/centreonEngineCfg.class.php +++ b/www/class/centreon-clapi/centreonEngineCfg.class.php @@ -304,13 +304,13 @@ class CentreonEngineCfg extends CentreonObject /* SETPARAM action */ foreach ($element as $parameter => $value) { if (!in_array($parameter, $this->exportExcludedParams) && !is_null($value) && $value != "") { - if ($parameter == 'global_host_event_handler' + if ($parameter == 'global_host_event_handler' || $parameter == 'global_service_event_handler' - || $parameter == 'host_perfdata_command' + || $parameter == 'host_perfdata_command' || $parameter == 'service_perfdata_command' || $parameter == 'host_perfdata_file_processing_command' || $parameter == 'service_perfdata_file_processing_command' - || $parameter == 'ochp_command' + || $parameter == 'ochp_command' || $parameter == 'ocsp_command') { $tmp = $this->commandObj->getParameters($value, $this->commandObj->getUniqueLabelField()); $value = $tmp[$this->commandObj->getUniqueLabelField()]; diff --git a/www/class/centreon-clapi/centreonExported.class.php b/www/class/centreon-clapi/centreonExported.class.php index 63332f9d2c0719416a56051625a2a63add824f48..8f610aba738c78a4d394ad296ed35b73404ff67d 100644 --- a/www/class/centreon-clapi/centreonExported.class.php +++ b/www/class/centreon-clapi/centreonExported.class.php @@ -35,39 +35,45 @@ namespace CentreonClapi; -class CentreonExported { +class CentreonExported +{ - private $exported = array(); - private $ariane = array(); - private $filter = 0; - private $filter_type = null; - private $filter_ariane = null; + private $exported = array(); + private $ariane = array(); + private $filter = 0; + private $filter_type = null; + private $filter_ariane = null; /** * @var Singleton * @access private * @static */ - private static $_instance = null; + private static $_instance = null; /** * * @param void * @return void */ - private function __construct() { + private function __construct() + { } - public function ariane_push($object, $id, $name) { + public function ariane_push($object, $id, $name) + { array_push($this->ariane, $object . ':' . $name . ':' . $id); } - public function ariane_pop() { + public function ariane_pop() + { array_pop($this->ariane); } - public function set_filter($value=1) { + public function set_filter($value = 1) + { $this->filter = $value; } - public function set_options($options) { + public function set_options($options) + { if (isset($options['filter-type'])) { $this->filter_type = $options['filter-type']; if (!is_array($options['filter-type'])) { @@ -83,7 +89,8 @@ class CentreonExported { } } - private function check_ariane($object, $id, $name) { + private function check_ariane($object, $id, $name) + { if (!is_null($this->filter_ariane)) { $ariane = join('#', $this->ariane); foreach ($this->filter_ariane as $filter) { @@ -97,7 +104,8 @@ class CentreonExported { return 0; } - private function check_filter($object, $id, $name) { + private function check_filter($object, $id, $name) + { if (!is_null($this->filter_type)) { foreach ($this->filter_type as $filter) { if (preg_match('/' . $filter . '/', $object)) { @@ -110,7 +118,8 @@ class CentreonExported { return 0; } - public function is_exported($object, $id, $name) { + public function is_exported($object, $id, $name) + { if ($this->filter == 0) { return 1; } @@ -139,8 +148,9 @@ class CentreonExported { * @param void * @return CentreonExported */ - public static function getInstance() { - if(is_null(self::$_instance)) { + public static function getInstance() + { + if (is_null(self::$_instance)) { self::$_instance = new CentreonExported(); } diff --git a/www/class/centreon-clapi/centreonHost.class.php b/www/class/centreon-clapi/centreonHost.class.php index aeb4c73b02eccfa1dbb0e1801b74781582665cfc..bdfd3563e990106b2821f46d1a9e75263a4c6cbc 100644 --- a/www/class/centreon-clapi/centreonHost.class.php +++ b/www/class/centreon-clapi/centreonHost.class.php @@ -1077,12 +1077,12 @@ class CentreonHost extends CentreonObject # service templates linked $hostRel = new \Centreon_Object_Relation_Host_Service(); $helements = $hostRel->getMergedParameters( - array("host_name"), - array('service_description', 'service_id'), - -1, - 0, - null, - null, + array("host_name"), + array('service_description', 'service_id'), + -1, + 0, + null, + null, array("service_register" => 0, "host_id" => $filters['host_id']), "AND" ); @@ -1093,12 +1093,12 @@ class CentreonHost extends CentreonObject # service linked $hostRel = new \Centreon_Object_Relation_Host_Service(); $helements = $hostRel->getMergedParameters( - array("host_name"), - array('service_description', 'service_id'), - -1, - 0, - null, - null, + array("host_name"), + array('service_description', 'service_id'), + -1, + 0, + null, + null, array("service_register" => 1, "host_id" => $filters['host_id']), "AND" ); @@ -1109,15 +1109,15 @@ class CentreonHost extends CentreonObject # service hg linked and hostgroups $hostRel = new \Centreon_Object_Relation_Host_Group_Host(); $helements = $hostRel->getMergedParameters( - array("hg_name", "hg_id"), - array('*'), - -1, - 0, - null, - null, + array("hg_name", "hg_id"), + array('*'), + -1, + 0, + null, + null, array("host_id" => $filters['host_id']), "AND" - ); + ); foreach ($helements as $helement) { $this->api->export_filter('HG', $helement['hg_id'], $helement['hg_name']); $this->api->export_filter('HGSERVICE', $helement['hg_id'], $helement['hg_name']); @@ -1148,8 +1148,13 @@ class CentreonHost extends CentreonObject * @param int $depth The depth to search * @return array */ - public function getTemplateChain($hostId, $alreadyProcessed = array(), $depth = -1, $allFields = false, $fields = array()) - { + public function getTemplateChain( + $hostId, + $alreadyProcessed = array(), + $depth = -1, + $allFields = false, + $fields = array() + ) { $templates = array(); if (($depth == -1) || ($depth > 0)) { diff --git a/www/class/centreon-clapi/centreonHostGroupService.class.php b/www/class/centreon-clapi/centreonHostGroupService.class.php index 9fb2474673712d3034a1583764ae761dd246b735..94074e4f21d0f83022da0b7b679bc0ce155693a4 100644 --- a/www/class/centreon-clapi/centreonHostGroupService.class.php +++ b/www/class/centreon-clapi/centreonHostGroupService.class.php @@ -914,7 +914,7 @@ class CentreonHostGroupService extends CentreonObject * * @return void */ - public function export($filters=null) + public function export($filters = null) { $filters["service_register"] = $this->register; diff --git a/www/class/centreon-clapi/centreonLDAP.class.php b/www/class/centreon-clapi/centreonLDAP.class.php index 9efbf7d4d8afb745b31f7fbdd9fc60a8bed54e1b..bd553ae8b5074181e047a910bf01e864cc4afd18 100644 --- a/www/class/centreon-clapi/centreonLDAP.class.php +++ b/www/class/centreon-clapi/centreonLDAP.class.php @@ -53,7 +53,7 @@ class CentreonLDAP extends CentreonObject const AR_NOT_EXIST = "LDAP configuration ID not found"; public $aDepends = array( - 'CONTACT' + 'CONTACTTPL' ); diff --git a/www/class/centreon-clapi/centreonService.class.php b/www/class/centreon-clapi/centreonService.class.php index bd722a2982a1de5319f62f891bf28a2f0a51270a..fcf17e8a4b2a932f87694427475aab5e25ea7bfc 100644 --- a/www/class/centreon-clapi/centreonService.class.php +++ b/www/class/centreon-clapi/centreonService.class.php @@ -1102,13 +1102,13 @@ class CentreonService extends CentreonObject $value = CentreonUtils::convertLineBreak($value); # Host Filter $this->api->export_filter('HOST', $element['host_id'], $element['host_name']); - if($this->getClapiActionName($parameter) != "host_id") { + if ($this->getClapiActionName($parameter) != "host_id") { echo $this->action . $this->delim . "setparam" . $this->delim . $element['host_name'] . $this->delim . $element['service_description'] . $this->delim . $this->getClapiActionName($parameter) . $this->delim . $value . "\n"; - } + } } } $params = $extendedObj->getParameters( diff --git a/www/class/centreon-clapi/centreonServiceCategory.class.php b/www/class/centreon-clapi/centreonServiceCategory.class.php index c9e5faf87c1173fb2ab37e8f0a080ab54afa9ec4..ccbd5f99a1c44c46fc8eaee5e4f6a73adf652e95 100644 --- a/www/class/centreon-clapi/centreonServiceCategory.class.php +++ b/www/class/centreon-clapi/centreonServiceCategory.class.php @@ -401,7 +401,14 @@ class CentreonServiceCategory extends CentreonSeverityAbstract */ public function export($filters = null) { - $scs = $this->object->getList(array($this->object->getPrimaryKey(), $this->object->getUniqueLabelField()), -1, 0, null, null, $filters); + $scs = $this->object->getList( + array($this->object->getPrimaryKey(), $this->object->getUniqueLabelField()), + -1, + 0, + null, + null, + $filters + ); $relobj = new \Centreon_Object_Relation_Service_Category_Service(); $hostServiceRel = new \Centreon_Object_Relation_Host_Service(); $svcObj = new \Centreon_Object_Service(); diff --git a/www/class/centreon-clapi/centreonServiceGroup.class.php b/www/class/centreon-clapi/centreonServiceGroup.class.php index a9737969f1761c00b016eae73cc8e79df8d79aa9..0fc42567e8208d9f1d8c9c65a94ed52a66f3a106 100644 --- a/www/class/centreon-clapi/centreonServiceGroup.class.php +++ b/www/class/centreon-clapi/centreonServiceGroup.class.php @@ -323,7 +323,14 @@ class CentreonServiceGroup extends CentreonObject public function export($filters = null) { - $sgs = $this->object->getList(array($this->object->getPrimaryKey(), $this->object->getUniqueLabelField()), -1, 0, null, null, $filters); + $sgs = $this->object->getList( + array($this->object->getPrimaryKey(), $this->object->getUniqueLabelField()), + -1, + 0, + null, + null, + $filters + ); $relobjSvc = new \Centreon_Object_Relation_Service_Group_Service(); $objSvc = new \Centreon_Object_Relation_Host_Service(); $relobjHgSvc = new \Centreon_Object_Relation_Service_Group_Host_Group_Service(); diff --git a/www/class/centreon-clapi/centreonServiceTemplate.class.php b/www/class/centreon-clapi/centreonServiceTemplate.class.php index 925fe63f806da0c779c655ef8bb175ab73bd4308..925fa8ffd5c537e21b12619e3cf82d6a7f5e90a7 100644 --- a/www/class/centreon-clapi/centreonServiceTemplate.class.php +++ b/www/class/centreon-clapi/centreonServiceTemplate.class.php @@ -738,7 +738,7 @@ class CentreonServiceTemplate extends CentreonObject $relationTable = array(); foreach ($relations as $rel) { if ($matches[2] == "contact") { - $tab = $obj->getIdByParameter("contact_name", array($rel)); + $tab = $obj->getIdByParameter("contact_alias", array($rel)); } else { $tab = $obj->getIdByParameter($obj->getUniqueLabelField(), array($rel)); } @@ -802,7 +802,7 @@ class CentreonServiceTemplate extends CentreonObject * @param array $tree * @param Centreon_Object_Service_Extended $extendedObj */ - protected function parseTemplateTree($tree, $filter_id=null) + protected function parseTemplateTree($tree, $filter_id = null) { $commandObj = new \Centreon_Object_Command(); $tpObj = new \Centreon_Object_Timeperiod(); @@ -903,7 +903,7 @@ class CentreonServiceTemplate extends CentreonObject * * @return void */ - public function export($filters=null) + public function export($filters = null) { $filters["service_register"] = $this->register; $elements = $this->object->getList( @@ -956,7 +956,7 @@ class CentreonServiceTemplate extends CentreonObject $filters_contactRel['service_id'] = $filters['service_id']; } $elements = $contactRel->getMergedParameters( - array("contact_name", "contact_id"), + array("contact_alias", "contact_id"), array('service_description'), -1, 0, @@ -970,7 +970,7 @@ class CentreonServiceTemplate extends CentreonObject echo $this->action . $this->delim . "addcontact" . $this->delim . $element['service_description'] . $this->delim - . $element['contact_name'] . "\n"; + . $element['contact_alias'] . "\n"; } // macros diff --git a/www/class/centreon-knowledge/wikiApi.class.php b/www/class/centreon-knowledge/wikiApi.class.php index 10ad514b609cf6a37436f3529c9cc57f8e18958b..81ab654f730eda1e3d9c1b3cc2f6824f350b2f9e 100644 --- a/www/class/centreon-knowledge/wikiApi.class.php +++ b/www/class/centreon-knowledge/wikiApi.class.php @@ -244,16 +244,20 @@ class WikiApi $token = $this->getMethodToken('delete', $title); - $postfields = array( - 'action' => 'delete', - 'title' => $title, - 'token' => $token - ); + if($token){ + $postfields = array( + 'action' => 'delete', + 'title' => $title, + 'token' => $token + ); - curl_setopt($this->curl, CURLOPT_POSTFIELDS, $postfields); - curl_exec($this->curl); + curl_setopt($this->curl, CURLOPT_POSTFIELDS, $postfields); + curl_exec($this->curl); - return true; + return true; + } else { + return false; + } } public function getAllPages() diff --git a/www/class/centreonHost.class.php b/www/class/centreonHost.class.php index 441a54748d9e3a4125f8eadcff16e83d0da83423..f99629595fe684a69118466148a7bb9368b341fd 100755 --- a/www/class/centreonHost.class.php +++ b/www/class/centreonHost.class.php @@ -1656,11 +1656,11 @@ class CentreonHost break; case 'host_hcs': $parameters['type'] = 'relation'; - $parameters['externalObject']['object'] = 'centreonHostcategories'; $parameters['externalObject']['table'] = 'hostcategories'; $parameters['externalObject']['id'] = 'hc_id'; $parameters['externalObject']['name'] = 'hc_name'; $parameters['externalObject']['comparator'] = 'hc_id'; + $parameters['externalObject']['additionalComparator'] = array('level' => null); $parameters['relationObject']['table'] = 'hostcategories_relation'; $parameters['relationObject']['field'] = 'hostcategories_hc_id'; $parameters['relationObject']['comparator'] = 'host_host_id'; diff --git a/www/class/centreonMenu.class.php b/www/class/centreonMenu.class.php index d31a01176aae6fc145ee7a3d6556cc1f1dd13031..e58a2948867e472eb8ccc13a7ae216a9d842cad3 100644 --- a/www/class/centreonMenu.class.php +++ b/www/class/centreonMenu.class.php @@ -35,8 +35,16 @@ class CentreonMenu { + /** + * @var CentreonLang + */ protected $centreonLang; + /** + * @var + */ + protected $db; + /** * Constructor * @@ -74,4 +82,5 @@ class CentreonMenu } return $name; } + } diff --git a/www/class/centreonService.class.php b/www/class/centreonService.class.php index b3691e9b97c17f0035893cc0f9b82c02139fda4d..029634e899521ff368582b1128d8d1c31365743b 100644 --- a/www/class/centreonService.class.php +++ b/www/class/centreonService.class.php @@ -1021,6 +1021,7 @@ class CentreonService $parameters['externalObject']['id'] = 'sc_id'; $parameters['externalObject']['name'] = 'sc_name'; $parameters['externalObject']['comparator'] = 'sc_id'; + $parameters['externalObject']['additionalComparator'] = array('level' => null); $parameters['relationObject']['table'] = 'service_categories_relation'; $parameters['relationObject']['field'] = 'sc_id'; $parameters['relationObject']['comparator'] = 'service_service_id'; diff --git a/www/class/centreonTopology.class.php b/www/class/centreonTopology.class.php new file mode 100644 index 0000000000000000000000000000000000000000..ac86755d5ee9a90dd541f567dffc18b0fe3bc4d4 --- /dev/null +++ b/www/class/centreonTopology.class.php @@ -0,0 +1,92 @@ +<?php +/** + * Copyright 2005-2017 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 + * + */ + +class CentreonTopology +{ + /** + * @var + */ + protected $db; + + /** + * CentreonTopology constructor. + * @param $db + */ + public function __construct($db) + { + $this->db = $db; + } + + /** + * @param $key + * @param $value + * @return mixed + * @throws Exception + */ + public function getTopology($key, $value) + { + $queryTopologyPage = 'SELECT * FROM topology WHERE topology_' . $key . ' = ?'; + $stmt = $this->db->prepare($queryTopologyPage); + $dbresult = $this->db->execute($stmt, array($value)); + if (PEAR::isError($dbresult)) { + throw new \Exception("Error during request"); + } + + $row = $dbresult->fetchRow(); + + return $row; + + } + + /** + * @param $topologyPage + * @param $topologyName + * @param string $breadCrumbDelimiter + * @return string + */ + public function getBreadCrumbFromTopology($topologyPage, $topologyName, $breadCrumbDelimiter = ' > ') + { + $breadCrumb = $topologyName; + $currentTopology = $this->getTopology('page', $topologyPage); + + while (!empty($currentTopology['topology_parent'])) { + $parentTopology = $this->getTopology('page', $currentTopology['topology_parent']); + $breadCrumb = $parentTopology['topology_name'] . $breadCrumbDelimiter . $breadCrumb; + $currentTopology = $parentTopology; + } + + return $breadCrumb; + } +} \ No newline at end of file diff --git a/www/class/config-generate/service.class.php b/www/class/config-generate/service.class.php index 9570f4a068bfcd5da3963c1a527e885ebe32c115..7ca655a445996701d6fd1520c45c59332be42cae 100644 --- a/www/class/config-generate/service.class.php +++ b/www/class/config-generate/service.class.php @@ -134,13 +134,15 @@ class Service extends AbstractService { break; } - if (!is_null($services_tpl[$service_tpl_id]['contacts']) && - $services_tpl[$service_tpl_id]['contacts'] != '') { + if (isset($services_tpl[$service_tpl_id]['contacts']) && + $services_tpl[$service_tpl_id]['contacts'] != '' + ) { $services_tpl[$service_tpl_top_id]['has_tpl_contacts'] = 1; } - if (!is_null($services_tpl[$service_tpl_id]['contact_groups']) && - $services_tpl[$service_tpl_id]['contact_groups'] != '') { + if (isset($services_tpl[$service_tpl_id]['contact_groups']) && + $services_tpl[$service_tpl_id]['contact_groups'] != '' + ) { $services_tpl[$service_tpl_top_id]['has_tpl_contact_groups'] = 1; } diff --git a/www/include/configuration/configKnowledge/templates/display.ihtml b/www/include/configuration/configKnowledge/templates/display.ihtml index 8b2e4cfc88df181fd3d3d87776404c3f5a817a3f..b4001a8f6d1b87d12d291ff5a12013b37587ddec 100644 --- a/www/include/configuration/configKnowledge/templates/display.ihtml +++ b/www/include/configuration/configKnowledge/templates/display.ihtml @@ -1,4 +1,5 @@ <script type="text/javascript" src="./include/common/javascript/tool.js"></script> +<div id="errorMsg" class="inactive"></div> <form name='form' method="POST"> <table class="ajaxOption table"> <tr> @@ -241,7 +242,15 @@ title: title }), success: function (data) { - location.reload() + if(data.result){ + location.reload() + } else { + var msg = "Deletion failed, please check your wiki configuration and your wiki user rights."; + var $popin = jQuery("#errorMsg"); + $popin.html(msg); + jQuery($popin).css('display', 'block'); + $popin.centreonPopin("open"); + } } }); } diff --git a/www/include/configuration/configServers/DB-Func.php b/www/include/configuration/configServers/DB-Func.php index 63c563fc5042992e716ced498d4ff9872d577403..5eb60f6a75dc157261a7264f51de58c4383f6d93 100644 --- a/www/include/configuration/configServers/DB-Func.php +++ b/www/include/configuration/configServers/DB-Func.php @@ -376,9 +376,9 @@ function checkChangeState($poller_id, $last_restart) WHERE action_log_date > $last_restart AND ( - (object_type = 'host' AND (action_type = 'd' OR object_id IN (SELECT host_host_id FROM ".$conf_centreon['db'].".ns_host_relation WHERE nagios_server_id = '$poller_id'))) + (object_type = 'host' AND (object_id IN (SELECT host_id FROM hosts WHERE instance_id = '$poller_id') OR object_id IN (SELECT host_host_id FROM ".$conf_centreon['db'].".ns_host_relation WHERE nagios_server_id = '$poller_id'))) OR - (object_type = 'service' AND (action_type = 'd' OR object_id IN (SELECT service_service_id FROM ".$conf_centreon['db'].".ns_host_relation nhr, ".$conf_centreon['db'].".host_service_relation hsr WHERE nagios_server_id = '$poller_id' AND hsr.host_host_id = nhr.host_host_id))) + (object_type = 'service' AND (object_id IN (SELECT service_id FROM services s, hosts h WHERE h.instance_id = '$poller_id' AND s.host_id = h.host_id) OR object_id IN (SELECT service_service_id FROM ".$conf_centreon['db'].".ns_host_relation nhr, ".$conf_centreon['db'].".host_service_relation hsr WHERE nagios_server_id = '$poller_id' AND hsr.host_host_id = nhr.host_host_id))) )"; $DBRESULT = $pearDBO->query($request); if ($DBRESULT->numRows()) { diff --git a/www/include/eventLogs/xml/data.php b/www/include/eventLogs/xml/data.php index e37184b477ceb634164cd60a61edb60286ee87f4..89e98c33da0afcbc64f448d672e797532cf77eca 100644 --- a/www/include/eventLogs/xml/data.php +++ b/www/include/eventLogs/xml/data.php @@ -510,8 +510,8 @@ $req = "SELECT SQL_CALC_FOUND_ROWS ".(!$is_admin ? "DISTINCT" : "")." logs.instance_name FROM logs ".$innerJoinEngineLog. ((!$is_admin) ? - " inner join centreon_acl acl on ((logs.host_id = acl.host_id AND logs.service_id IS NULL) OR " - . " (logs.host_id = acl.host_id AND acl.service_id = logs.service_id)) " + " inner join centreon_acl acl on (logs.host_id = acl.host_id AND (acl.service_id IS NULL OR " + . " acl.service_id = logs.service_id)) " . " WHERE acl.group_id IN (".$access->getAccessGroupsString().") AND " : "WHERE ") . " logs.ctime > '$start' AND logs.ctime <= '$end' $whereOutput $msg_req"; diff --git a/www/include/monitoring/status/Services/service.php b/www/include/monitoring/status/Services/service.php index 96d28ad9c44d2378bd1a51f102cf803bbd228143..1edee84e4b9dbfb1a6f34ea6f4b413288c6480bb 100644 --- a/www/include/monitoring/status/Services/service.php +++ b/www/include/monitoring/status/Services/service.php @@ -168,11 +168,6 @@ if (!empty($centreon->optGen["global_sort_order"])) { $global_sort_order = $centreon->optGen["global_sort_order"]; } -include_once("./include/monitoring/status/Common/default_poller.php"); -include_once("./include/monitoring/status/Common/default_hostgroups.php"); -include_once("./include/monitoring/status/Common/default_servicegroups.php"); -include_once($svc_path . "/serviceJS.php"); - if ($o == "svcpb" || $o == "svc_unhandled" || empty($o)) { if (!empty($filters["sort_type"])) { $sort_type = $filters["sort_type"]; @@ -203,6 +198,10 @@ if ($o == "svcpb" || $o == "svc_unhandled" || empty($o)) { } } +include_once("./include/monitoring/status/Common/default_poller.php"); +include_once("./include/monitoring/status/Common/default_hostgroups.php"); +include_once("./include/monitoring/status/Common/default_servicegroups.php"); +include_once($svc_path . "/serviceJS.php"); /* * Smarty template Init diff --git a/www/include/monitoring/status/ServicesHostGroups/xml/serviceGridByHGXML.php b/www/include/monitoring/status/ServicesHostGroups/xml/serviceGridByHGXML.php index f50069e1c04fc21933c47f3c8f632076889d0a65..f602ba2264419cfc49e91d55dacec7ba99925676 100644 --- a/www/include/monitoring/status/ServicesHostGroups/xml/serviceGridByHGXML.php +++ b/www/include/monitoring/status/ServicesHostGroups/xml/serviceGridByHGXML.php @@ -178,7 +178,7 @@ if ($instance != -1) { $rq1 .= " AND h.instance_id = ".$instance; } //$rq1 .= " ORDER BY s.description"; - $rq1 .= " order by tri asc"; + $rq1 .= " order by tri asc, s.description asc"; $tabService = array(); $tabHost = array(); diff --git a/www/include/options/accessLists/groupsACL/DB-Func.php b/www/include/options/accessLists/groupsACL/DB-Func.php index a1af9119a961241cce45d35a7918e01ad2a8f7fa..d16798c60c4560e9f6f5f39413833191308cb0c9 100644 --- a/www/include/options/accessLists/groupsACL/DB-Func.php +++ b/www/include/options/accessLists/groupsACL/DB-Func.php @@ -383,10 +383,10 @@ function updateGroupResources($acl_group_id, $ret = array()) return; } - $query = 'DELETE ' - . 'FROM acl_res_group_relations ' - . 'JOIN acl_resources ar ON acl_res_group_relations.acl_res_id = ar.acl_res_id ' - . 'AND acl_res_group_relations.acl_group_id = ' . $acl_group_id . ' ' + $query = 'DELETE argr ' + . 'FROM acl_res_group_relations argr ' + . 'JOIN acl_resources ar ON argr.acl_res_id = ar.acl_res_id ' + . 'WHERE argr.acl_group_id = ' . $acl_group_id . ' ' . 'AND ar.locked = 0 '; $pearDB->query($query); if (isset($_POST["resourceAccess"])) { diff --git a/www/include/views/componentTemplates/formComponentTemplate.ihtml b/www/include/views/componentTemplates/formComponentTemplate.ihtml index e93676f8ff899c8c7fe6fae0fd21777b4f801976..99e306b16d5a11e9b284c784a96ade74e6acb72e 100644 --- a/www/include/views/componentTemplates/formComponentTemplate.ihtml +++ b/www/include/views/componentTemplates/formComponentTemplate.ihtml @@ -30,7 +30,7 @@ <tr class="list_one"> <td class="FormRowField"><img class="helpTooltip" name="tip_data_source_name">{$form.ds_name.label}</td> <td id="td_ds"><table id="table_ds" border="0"><tr> - <td id="td_ds_html" class="FormRowValue" style="padding: 0px; border-width: 0px;">{$form.ds_name.html}</td> + <td id="td_ds_html" class="FormRowValue">{$form.ds_name.html}</td> {if $o == "a" || $o == "c"} <td id="td_list_metrics" style="padding: 0px; border-width: 0px;"> <img src="./img/icons/arrow-left.png" class="ico-14" onclick="insertValueQuery()" /> diff --git a/www/install/sql/centreon/Update-DB-2.8.11_to_2.8.12.sql b/www/install/sql/centreon/Update-DB-2.8.11_to_2.8.12.sql new file mode 100644 index 0000000000000000000000000000000000000000..fd464ba9bb422d4fc2d064607e971ee608059ceb --- /dev/null +++ b/www/install/sql/centreon/Update-DB-2.8.11_to_2.8.12.sql @@ -0,0 +1,2 @@ +-- Change version of Centreon +UPDATE `informations` SET `value` = '2.8.12' WHERE CONVERT( `informations`.`key` USING utf8 ) = 'version' AND CONVERT ( `informations`.`value` USING utf8 ) = '2.8.11' LIMIT 1;