Bugfix für nomail-Option und DKIM
Bernd Wurst

Bernd Wurst commited on 2023-12-09 13:28:47
Zeige 3 geänderte Dateien mit 30 Einfügungen und 13 Löschungen.

... ...
@@ -21,32 +21,46 @@ require_role(ROLE_SYSTEMUSER);
21 21
 
22 22
 check_form_token('vmail_domainchange');
23 23
 
24
+$newsetting = [];
25
+$newdkimsetting = [];
24 26
 foreach ($_POST as $key => $value) {
25 27
     if (strpos($key, "option-") === 0) {
26 28
         $id = substr($key, 7);
27
-        $type = 'virtual';
29
+        $newsetting[$id] = 'virtual';
28 30
         if ($value == 'manual') {
29
-            $type = 'auto';
31
+            $newsetting[$id] = 'auto';
30 32
         } elseif ($value == 'off') {
31
-            $type = 'none';
32
-        } elseif ($value == 'nomail') {
33
-            $type = 'nomail';
33
+            $newsetting[$id] = 'none';
34
+        }
35
+    }
36
+    if (strpos($key, "nomail-") === 0) {
37
+        $id = substr($key, 7);
38
+        if ($value == 'nomail' && (!isset($newsetting[$id]) || $newsetting[$id] == 'none')) {
39
+            $newsetting[$id] = 'nomail';
34 40
         }
35
-        DEBUG('MAILCONFIG change request for id #' . $id . ' to ' . $value);
36
-        change_domain($id, $type);
37 41
     }
38 42
     if (strpos($key, "dkim-") === 0) {
39 43
         $id = substr($key, 5);
40
-        $type = 'none';
44
+        $newdkimsetting[$id] = 'none';
41 45
         if ($value == 'dkim') {
42
-            $type = 'dkim';
46
+            $newdkimsetting[$id] = 'dkim';
43 47
         } elseif ($value == 'dmarc') {
44
-            $type = 'dmarc';
48
+            $newdkimsetting[$id] = 'dmarc';
45 49
         }
46
-        DEBUG('DKIM change request for id #' . $id . ' to ' . $value);
47
-        change_domain_dkim($id, $type);
48 50
     }
49 51
 }
52
+foreach ($newsetting as $id => $type) {
53
+        DEBUG('MAILCONFIG change request for id #' . $id . ' to ' . $type);
54
+        change_domain($id, $type);
55
+        if ($type == "nomail" || $type == "none") {
56
+            // DKIM muss abgeschaltet sein, wenn das DKIM-UI nicht mehr angezeigt wird
57
+            $newdkimsetting[$id] = 'none';
58
+        }
59
+}
60
+foreach ($newdkimsetting as $id => $type) {
61
+        DEBUG('DKIM change request for id #' . $id . ' to ' . $type);
62
+        change_domain_dkim($id, $type);
63
+}
50 64
 
51 65
 if (!$debugmode) {
52 66
     header('Location: domains');
... ...
@@ -79,7 +79,7 @@ foreach ($domains as $id => $dom) {
79 79
     $buttons .= '<input type="submit" value="Speichern" />
80 80
       </span>';
81 81
     if ($dom['type'] == 'nomail' || $dom['type'] == 'none') {
82
-        $buttons .= '<span class="nomail"><input type="checkbox" class="nomail autosubmit" name="option-' . $id . '" id="option-' . $id . '-nomail" value="nomail"' . $check_nomail . ' ' . ($edit_disabled ? ' disabled="disabled"' : '') . '/>
82
+        $buttons .= '<span class="nomail"><input type="checkbox" class="nomail autosubmit" name="nomail-' . $id . '" id="option-' . $id . '-nomail" value="nomail"' . $check_nomail . ' ' . ($edit_disabled ? ' disabled="disabled"' : '') . '/>
83 83
                      <label class="nomail" for="option-' . $id . '-nomail">Mail-Nutzung verhindern</label>
84 84
          <input class="hidden" type="submit" value="Speichern" /></span>';
85 85
     }
... ...
@@ -1,3 +1,6 @@
1
+table th {
2
+    text-align: left;
3
+}
1 4
 
2 5
 input#filter {
3 6
     padding-right: 25px;
4 7