From bfe58ba4ec8419ebc40d8dd8d972d71bd5019ab1 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 11 Nov 2021 16:13:41 +0100 Subject: [PATCH] Introduce new hook `IcingadbSupportHook` --- library/Icingadb/Hook/IcingadbSupportHook.php | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 library/Icingadb/Hook/IcingadbSupportHook.php diff --git a/library/Icingadb/Hook/IcingadbSupportHook.php b/library/Icingadb/Hook/IcingadbSupportHook.php new file mode 100644 index 00000000..8de77a72 --- /dev/null +++ b/library/Icingadb/Hook/IcingadbSupportHook.php @@ -0,0 +1,52 @@ +getUser()->getPreferences()->get('icingaweb'); + if (! empty($webPreferences) && array_key_exists(static::PREFERENCE_NAME, $webPreferences)) { + return (bool) $webPreferences[static::PREFERENCE_NAME]; + } + + return false; + } + + /** + * Whether to use icingadb as the backend + * + * @return bool Returns true if monitoring module is disabled or icingadb is selected as backend, false otherwise. + */ + final public static function useIcingaDbAsBackend(): bool + { + return ! Icinga::app()->getModuleManager()->hasEnabled('monitoring') || self::isSetAsBackend(); + } +}