]> granicus.if.org Git - icinga2/commitdiff
Make "enable_notifications" a config attribute
authorGunnar Beutner <gunnar.beutner@netways.de>
Thu, 10 Jul 2014 08:57:44 +0000 (10:57 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Thu, 10 Jul 2014 08:59:22 +0000 (10:59 +0200)
fixes #6671

lib/icinga/user.cpp
lib/icinga/user.hpp
lib/icinga/user.ti

index c7f5020d0e8138796ca5bd91b0d89f6366341c05..6a2afdc87773ea53975f48bc0be99c68f27b465b 100644 (file)
@@ -30,6 +30,8 @@ using namespace icinga;
 REGISTER_TYPE(User);
 REGISTER_SCRIPTFUNCTION(ValidateUserFilters, &User::ValidateFilters);
 
+boost::signals2::signal<void (const User::Ptr&, bool, const MessageOrigin&)> User::OnEnableNotificationsChanged;
+
 void User::OnConfigLoaded(void)
 {
        SetTypeFilter(FilterArrayToInt(GetTypes(), ~0));
@@ -49,7 +51,6 @@ void User::OnConfigLoaded(void)
        }
 }
 
-
 void User::Stop(void)
 {
        DynamicObject::Stop();
@@ -124,3 +125,19 @@ void User::SetModifiedAttributes(int flags, const MessageOrigin& origin)
                OnVarsChanged(GetSelf(), origin);
        }
 }
+
+bool User::GetEnableNotifications(void) const
+{
+       if (!GetOverrideEnableNotifications().IsEmpty())
+               return GetOverrideEnableNotifications();
+       else
+               return GetEnableNotificationsRaw();
+}
+
+void User::SetEnableNotifications(bool enabled, const MessageOrigin& origin)
+{
+       SetOverrideEnableNotifications(enabled);
+
+       OnEnableNotificationsChanged(GetSelf(), enabled, origin);
+}
+
index af64c4bac05342ebfc1e33dbc0c4f592a8ecfc17..e001ad38efc677d203fb4c3899ffbc37d2867ccd 100644 (file)
@@ -46,9 +46,14 @@ public:
 
        static void ValidateFilters(const String& location, const Dictionary::Ptr& attrs);
 
+       bool GetEnableNotifications(void) const;
+       void SetEnableNotifications(bool enabled, const MessageOrigin& origin = MessageOrigin());
+
        int GetModifiedAttributes(void) const;
        void SetModifiedAttributes(int flags, const MessageOrigin& origin = MessageOrigin());
 
+       static boost::signals2::signal<void (const User::Ptr&, bool, const MessageOrigin&)> OnEnableNotificationsChanged;
+
 protected:
        virtual void Stop(void);
 
index f18546ef8e9168a4c328c74d9deefc93b44619c7..1a4e106419fc4170ff282e466edfeaeb334af959 100644 (file)
@@ -26,9 +26,11 @@ class User : CustomVarObject
        [config] String email;
        [config] String pager;
 
-       [state] bool enable_notifications {
+       [config] bool enable_notifications (EnableNotificationsRaw) {
                default {{{ return true; }}}
        };
+
+       [state] Value override_enable_notifications;
        [state] double last_notification;
 };