@@ -173,6 +173,44 @@ public static function logModification(IcingaObject $object, Db $db)
173173 return static ::create ($ data )->store ($ db );
174174 }
175175
176+ public static function logServiceBlacklist (IcingaHost $ host , Db $ db , bool $ blacklist = true )
177+ {
178+ $ name = $ host ->getObjectName ();
179+ $ type = $ host ->getTableName ();
180+
181+ if ($ blacklist ) {
182+ $ oldProps = json_encode ($ host ->getPlainUnmodifiedObject ());
183+ $ newProps = $ host ->toJson (null , true );
184+ } else {
185+ $ oldProps = $ host ->toJson (null , true );
186+ $ newProps = json_encode ($ host ->getPlainUnmodifiedObject ());
187+ }
188+
189+ $ data = [
190+ 'object_name ' => $ name ,
191+ 'action_name ' => self ::ACTION_MODIFY ,
192+ 'author ' => static ::username (),
193+ 'object_type ' => $ type ,
194+ 'old_properties ' => $ oldProps ,
195+ 'new_properties ' => $ newProps ,
196+ 'change_time ' => date ('Y-m-d H:i:s ' ),
197+ 'parent_checksum ' => $ db ->getLastActivityChecksum ()
198+ ];
199+
200+ $ data ['checksum ' ] = sha1 (json_encode ($ data ), true );
201+ $ data ['parent_checksum ' ] = hex2bin ($ data ['parent_checksum ' ]);
202+
203+ static ::audit ($ db , [
204+ 'action ' => self ::ACTION_MODIFY ,
205+ 'object_type ' => $ type ,
206+ 'object_name ' => $ name ,
207+ 'old_props ' => $ oldProps ,
208+ 'new_props ' => $ newProps
209+ ]);
210+
211+ return static ::create ($ data )->store ($ db );
212+ }
213+
176214 public static function logRemoval (IcingaObject $ object , Db $ db )
177215 {
178216 $ name = $ object ->getObjectName ();
0 commit comments