diff --git a/lib/icinga/icinga-type.conf b/lib/icinga/icinga-type.conf index 08ae85a54..e6ffb89ff 100644 --- a/lib/icinga/icinga-type.conf +++ b/lib/icinga/icinga-type.conf @@ -56,6 +56,7 @@ type Host { %attribute number "check_interval", %attribute number "retry_interval", + %attribute number "enable_notifications", %attribute number "notification_interval", %attribute name(TimePeriod) "notification_period", @@ -142,6 +143,7 @@ type Host { %attribute number "check_interval", %attribute number "retry_interval", + %attribute number "enable_notifications", %attribute number "notification_interval", %attribute name(TimePeriod) "notification_period", @@ -279,6 +281,8 @@ type Notification { %attribute number "end", }, + %attribute number "enable_notifications", + %attribute name(NotificationCommand) "notification_command", %attribute number "notification_interval", @@ -299,6 +303,7 @@ type User { %attribute name(UserGroup) "*" }, + %attribute number "enable_notifications", %attribute number "notification_type_filter", %attribute number "notification_state_filter" diff --git a/lib/icinga/user.cpp b/lib/icinga/user.cpp index c4ce9291f..0790e2397 100644 --- a/lib/icinga/user.cpp +++ b/lib/icinga/user.cpp @@ -33,6 +33,7 @@ User::User(const Dictionary::Ptr& serializedUpdate) RegisterAttribute("display_name", Attribute_Config, &m_DisplayName); RegisterAttribute("macros", Attribute_Config, &m_Macros); RegisterAttribute("groups", Attribute_Config, &m_Groups); + RegisterAttribute("enable_notifications", Attribute_Config, &m_EnableNotifications); RegisterAttribute("notification_period", Attribute_Config, &m_NotificationPeriod); RegisterAttribute("notification_type_filter", Attribute_Config, &m_NotificationTypeFilter); RegisterAttribute("notification_state_filter", Attribute_Config, &m_NotificationStateFilter); @@ -76,6 +77,20 @@ Dictionary::Ptr User::GetMacros(void) const return m_Macros; } +bool User::GetEnableNotifications(void) const +{ + if (m_EnableNotifications.IsEmpty()) + return true; + else + return m_EnableNotifications; +} + +void User::SetEnableNotifications(bool enabled) +{ + m_EnableNotifications = enabled; + Touch("enable_notifications"); +} + TimePeriod::Ptr User::GetNotificationPeriod(void) const { return TimePeriod::GetByName(m_NotificationPeriod); diff --git a/lib/icinga/user.h b/lib/icinga/user.h index 6cf3bf19e..7a5f3dbec 100644 --- a/lib/icinga/user.h +++ b/lib/icinga/user.h @@ -46,6 +46,10 @@ public: String GetDisplayName(void) const; Array::Ptr GetGroups(void) const; + + /* Notifications */ + bool GetEnableNotifications(void) const; + void SetEnableNotifications(bool enabled); TimePeriod::Ptr GetNotificationPeriod(void) const; unsigned long GetNotificationTypeFilter(void) const; unsigned long GetNotificationStateFilter(void) const; @@ -60,8 +64,9 @@ protected: private: Attribute m_DisplayName; Attribute m_Macros; - Attribute m_NotificationPeriod; Attribute m_Groups; + Attribute m_EnableNotifications; + Attribute m_NotificationPeriod; Attribute m_NotificationTypeFilter; Attribute m_NotificationStateFilter; };