]> granicus.if.org Git - icinga2/commitdiff
User: register enable_notifications, add GetEnableNotifications()
authorMichael Friedrich <michael.friedrich@netways.de>
Tue, 16 Jul 2013 11:17:10 +0000 (13:17 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Tue, 16 Jul 2013 11:17:53 +0000 (13:17 +0200)
lib/icinga/icinga-type.conf
lib/icinga/user.cpp
lib/icinga/user.h

index 08ae85a54bc85e649dab34b75577a4db7ffc1835..e6ffb89ffa2b2d2b8e86b96ba008ee67050ca726 100644 (file)
@@ -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"
 
index c4ce9291f42cddfb64700256fdc5eb93e9d5e5a8..0790e2397f9a2e723000e2c788756740006d848f 100644 (file)
@@ -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);
index 6cf3bf19ee6a48ef698f5085567694396ffbdb37..7a5f3dbecad01f087c8e1be083f9997aef174272 100644 (file)
@@ -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<String> m_DisplayName;
        Attribute<Dictionary::Ptr> m_Macros;
-       Attribute<String> m_NotificationPeriod;
        Attribute<Array::Ptr> m_Groups;
+       Attribute<bool> m_EnableNotifications;
+       Attribute<String> m_NotificationPeriod;
        Attribute<long> m_NotificationTypeFilter;
        Attribute<long> m_NotificationStateFilter;
 };