Bernd Wurst commited on 2019-12-04 16:55:39
Zeige 3 geänderte Dateien mit 51 Einfügungen und 1 Löschungen.
... | ... |
@@ -114,12 +114,19 @@ if ($is_current_user) { |
114 | 114 |
$everused = true; |
115 | 115 |
} |
116 | 116 |
if (have_module('mailman') && mailman_subdomains($dom->id)) { |
117 |
+ use_module('mailman'); |
|
118 |
+ include('mailman.php'); |
|
117 | 119 |
$mailmanhosts = mailman_subdomains($dom->id); |
118 | 120 |
$hostname = $dom->fqdn; |
119 | 121 |
if (count($mailmanhosts) == 1) { |
120 | 122 |
$hostname = $mailmanhosts[0]['hostname'].'.'.$dom->fqdn; |
121 | 123 |
} |
122 |
- output("<div class=\"tile usage used\"><p><strong>".internal_link('../mailman/lists', "Mailinglisten", 'filter='.$hostname)."</strong></p><p>Diese Domain wird für Mailinglisten verwendet</p></div>"); |
|
124 |
+ $lists = lists_on_domain($dom->id); |
|
125 |
+ $delete = ''; |
|
126 |
+ if (count($lists) == 0) { |
|
127 |
+ $delete = '<p class="delete">'.internal_link('save', "Nicht mehr für Mailinglisten verwenden", "action=nomailman&domain=".$dom->id).'</p>'; |
|
128 |
+ } |
|
129 |
+ output("<div class=\"tile usage used\"><p><strong>".internal_link('../mailman/lists', "Mailinglisten", 'filter='.$hostname)."</strong></p><p>Diese Domain wird für Mailinglisten verwendet</p>$delete</div>"); |
|
123 | 130 |
$used = true; |
124 | 131 |
$everused = true; |
125 | 132 |
} |
... | ... |
@@ -51,4 +51,24 @@ if ($_REQUEST['action'] == 'delete') { |
51 | 51 |
check_form_token('domains_transfer'); |
52 | 52 |
api_unlock_domain($dom->fqdn); |
53 | 53 |
redirect('detail?id='.$dom->id); |
54 |
+} elseif ($_REQUEST['action'] == 'nomailman') { |
|
55 |
+ if (have_module('mailman')) { |
|
56 |
+ use_module('mailman'); |
|
57 |
+ include('mailman.php'); |
|
58 |
+ if (count(lists_on_domain($dom->id)) > 0) { |
|
59 |
+ system_failure("Es gibt noch Mailinglisten auf dieser Domain, daher kann sie nicht gelöscht werden"); |
|
60 |
+ } |
|
61 |
+ $sure = user_is_sure(); |
|
62 |
+ if ($sure === null) { |
|
63 |
+ are_you_sure("action=nomailman&domain={$dom->id}", "Möchten Sie die Domain »{$dom->fqdn}« wirklich aus der Mailinglisten-Konfiguration entfernen?"); |
|
64 |
+ } elseif ($sure === true) { |
|
65 |
+ delete_mailman_domain($dom->id); |
|
66 |
+ redirect('detail?id='.$dom->id); |
|
67 |
+ } elseif ($sure === false) { |
|
68 |
+ redirect('detail?id='.$dom->id); |
|
69 |
+ } |
|
70 |
+ |
|
71 |
+ } else { |
|
72 |
+ system_failure('Das Mailman-Modul ist nicht verfügbar'); |
|
73 |
+ } |
|
54 | 74 |
} |
... | ... |
@@ -123,6 +123,29 @@ function insert_mailman_domain($subdomain, $domainid) |
123 | 123 |
} |
124 | 124 |
|
125 | 125 |
|
126 |
+function lists_on_domain($domainid) |
|
127 |
+{ |
|
128 |
+ DEBUG("lists_on_domain()"); |
|
129 |
+ $result = db_query("SELECT id, listname FROM mail.mailman_lists WHERE status != 'delete' AND maildomain=(SELECT id FROM mail.mailman_domains WHERE domain=?)", array($domainid)); |
|
130 |
+ $ret = array(); |
|
131 |
+ while ($l = $result->fetch()) { |
|
132 |
+ $ret[] = $l; |
|
133 |
+ } |
|
134 |
+ return $ret; |
|
135 |
+} |
|
136 |
+ |
|
137 |
+ |
|
138 |
+function delete_mailman_domain($domainid) |
|
139 |
+{ |
|
140 |
+ DEBUG("delete_mailman_domain()"); |
|
141 |
+ $lists = lists_on_domain($domainid); |
|
142 |
+ if (count($lists) > 0) { |
|
143 |
+ system_failure("Es gibt noch Mailinglisten unter diesem Domainnamen, er kann daher nicht gelöscht werden"); |
|
144 |
+ } else { |
|
145 |
+ db_query("DELETE FROM mail.mailman_domains WHERE domain=? AND (SELECT COUNT(*) FROM mail.mailman_lists WHERE maildomain=mail.mailman_domains.id)=0;", array($domainid)); |
|
146 |
+ } |
|
147 |
+} |
|
148 |
+ |
|
126 | 149 |
function get_mailman_domains() |
127 | 150 |
{ |
128 | 151 |
DEBUG('get_mailman_domains()'); |
129 | 152 |