10
10
use Icinga \Module \Notifications \Forms \EventRuleForm ;
11
11
use Icinga \Module \Notifications \Forms \SaveEventRuleForm ;
12
12
use Icinga \Module \Notifications \Model \Incident ;
13
- use Icinga \Module \Notifications \Model \ObjectExtraTag ;
14
13
use Icinga \Module \Notifications \Model \Rule ;
15
14
use Icinga \Module \Notifications \Web \Control \SearchBar \ExtraTagSuggestions ;
16
15
use Icinga \Module \Notifications \Widget \EventRuleConfig ;
@@ -62,21 +61,9 @@ public function indexAction(): void
62
61
);
63
62
}
64
63
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
-
76
64
$ saveForm = (new SaveEventRuleForm ())
77
65
->setShowRemoveButton ()
78
66
->setShowDismissChangesButton ($ cache !== null )
79
- ->setRemoveButtonDisabled ($ disableRemoveButton )
80
67
->setSubmitButtonDisabled ($ cache === null )
81
68
->setSubmitLabel ($ this ->translate ('Save Changes ' ))
82
69
->on (SaveEventRuleForm::ON_SUCCESS , function ($ form ) use ($ ruleId , $ eventRuleConfig ) {
@@ -151,7 +138,7 @@ public function indexAction(): void
151
138
public function fromDb (int $ ruleId ): array
152
139
{
153
140
$ query = Rule::on (Database::get ())
154
- ->withoutColumns ( ' timeperiod_id ' )
141
+ ->columns ([ ' id ' , ' name ' , ' object_filter ' ] )
155
142
->filter (Filter::equal ('id ' , $ ruleId ));
156
143
157
144
$ rule = $ query ->first ();
@@ -161,12 +148,20 @@ public function fromDb(int $ruleId): array
161
148
162
149
$ config = iterator_to_array ($ rule );
163
150
164
- foreach ($ rule ->rule_escalation as $ re ) {
151
+ $ ruleEscalations = $ rule
152
+ ->rule_escalation
153
+ ->withoutColumns (['changed_at ' , 'deleted ' ]);
154
+
155
+ foreach ($ ruleEscalations as $ re ) {
165
156
foreach ($ re as $ k => $ v ) {
166
157
$ config [$ re ->getTableName ()][$ re ->position ][$ k ] = $ v ;
167
158
}
168
159
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 ) {
170
165
$ config [$ re ->getTableName ()][$ re ->position ]['recipient ' ][] = iterator_to_array ($ recipient );
171
166
}
172
167
}
@@ -248,7 +243,6 @@ public function editAction(): void
248
243
->setAction (Url::fromRequest ()->getAbsoluteUrl ())
249
244
->on (Form::ON_SUCCESS , function ($ form ) use ($ ruleId , $ cache , $ config ) {
250
245
$ config ['name ' ] = $ form ->getValue ('name ' );
251
- $ config ['is_active ' ] = $ form ->getValue ('is_active ' );
252
246
253
247
if ($ cache || $ ruleId === '-1 ' ) {
254
248
$ this ->sessionNamespace ->set ($ ruleId , $ config );
0 commit comments