1010use Icinga \Module \Notifications \Forms \EventRuleForm ;
1111use Icinga \Module \Notifications \Forms \SaveEventRuleForm ;
1212use Icinga \Module \Notifications \Model \Incident ;
13- use Icinga \Module \Notifications \Model \ObjectExtraTag ;
1413use Icinga \Module \Notifications \Model \Rule ;
1514use Icinga \Module \Notifications \Web \Control \SearchBar \ExtraTagSuggestions ;
1615use Icinga \Module \Notifications \Widget \EventRuleConfig ;
@@ -62,21 +61,9 @@ public function indexAction(): void
6261 );
6362 }
6463
65- $ disableRemoveButton = false ;
66- if (ctype_digit ($ ruleId )) {
67- $ incidents = Incident::on (Database::get ())
68- ->with ('rule ' )
69- ->filter (Filter::equal ('rule.id ' , $ ruleId ));
70-
71- if ($ incidents ->count () > 0 ) {
72- $ disableRemoveButton = true ;
73- }
74- }
75-
7664 $ saveForm = (new SaveEventRuleForm ())
7765 ->setShowRemoveButton ()
7866 ->setShowDismissChangesButton ($ cache !== null )
79- ->setRemoveButtonDisabled ($ disableRemoveButton )
8067 ->setSubmitButtonDisabled ($ cache === null )
8168 ->setSubmitLabel ($ this ->translate ('Save Changes ' ))
8269 ->on (SaveEventRuleForm::ON_SUCCESS , function ($ form ) use ($ ruleId , $ eventRuleConfig ) {
@@ -151,7 +138,7 @@ public function indexAction(): void
151138 public function fromDb (int $ ruleId ): array
152139 {
153140 $ query = Rule::on (Database::get ())
154- ->withoutColumns ( ' timeperiod_id ' )
141+ ->columns ([ ' id ' , ' name ' , ' object_filter ' ] )
155142 ->filter (Filter::equal ('id ' , $ ruleId ));
156143
157144 $ rule = $ query ->first ();
@@ -161,12 +148,20 @@ public function fromDb(int $ruleId): array
161148
162149 $ config = iterator_to_array ($ rule );
163150
164- foreach ($ rule ->rule_escalation as $ re ) {
151+ $ ruleEscalations = $ rule
152+ ->rule_escalation
153+ ->withoutColumns (['changed_at ' , 'deleted ' ]);
154+
155+ foreach ($ ruleEscalations as $ re ) {
165156 foreach ($ re as $ k => $ v ) {
166157 $ config [$ re ->getTableName ()][$ re ->position ][$ k ] = $ v ;
167158 }
168159
169- foreach ($ re ->rule_escalation_recipient as $ recipient ) {
160+ $ escalationRecipients = $ re
161+ ->rule_escalation_recipient
162+ ->withoutColumns (['changed_at ' , 'deleted ' ]);
163+
164+ foreach ($ escalationRecipients as $ recipient ) {
170165 $ config [$ re ->getTableName ()][$ re ->position ]['recipient ' ][] = iterator_to_array ($ recipient );
171166 }
172167 }
@@ -248,7 +243,6 @@ public function editAction(): void
248243 ->setAction (Url::fromRequest ()->getAbsoluteUrl ())
249244 ->on (Form::ON_SUCCESS , function ($ form ) use ($ ruleId , $ cache , $ config ) {
250245 $ config ['name ' ] = $ form ->getValue ('name ' );
251- $ config ['is_active ' ] = $ form ->getValue ('is_active ' );
252246
253247 if ($ cache || $ ruleId === '-1 ' ) {
254248 $ this ->sessionNamespace ->set ($ ruleId , $ config );
0 commit comments