Browse code

Transfer-Freigabe und Kündigung implementiert

Bernd Wurst authored on05/02/2018 16:34:38
Showing4 changed files
... ...
@@ -135,13 +135,40 @@ if ($dom->status == 'prereg') {
135 135
     output('<h4>Domain-Registrierung abschließen</h4>
136 136
             <p>'.internal_link('domainreg', 'Domain registrieren', "domain={$dom->fqdn}").'</p>');
137 137
 } elseif ($dom->status == 'pretransfer') {
138
-    output('<h4>Domain-Umzug ausführen</h4>
138
+    output('<h4>Domain zu '.config('company_name').' umziehen</h4>
139 139
             <p>'.internal_link('domainreg', 'Umzugsautrag (ggf. nochmals) erteilen', "domain={$dom->fqdn}").'</p>');
140 140
 } elseif ($dom->provider != 'terions') {
141
-    output('<h4>Domain-Transfer ausführen</h4>
142
-            <p>'.internal_link('domainreg', 'Domain-Transfer ausführen', "domain={$dom->fqdn}").'</p>');
141
+    output('<h4>Domain zu '.config('company_name').' umziehen</h4>
142
+            <p>'.internal_link('domainreg', 'Domain-Transfer starten', "domain={$dom->fqdn}").'</p>');
143 143
 }
144 144
 
145
+
146
+// Block Domain löschen/kündigen
147
+
148
+$domain_in_use = mailman_subdomains($dom->id) || mail_in_use($dom->id) || web_in_use($dom->id) || $dom->jabber == 1;
149
+if (!$domain_in_use && ($dom->status == 'prereg' || $dom->status == 'pretransfer' || $dom->status == 'transferfailed' || $dom->status == 'external')) {
150
+    output('<h4>Domain wieder entfernen</h4>');
151
+    output('<p class="delete">'.internal_link('save', 'Die Domain '.$dom->fqdn.' entfernen', 'action=delete&domain='.$dom->id).'</p>');
152
+} elseif ($dom->provider == 'terions') {
153
+    output('<h4>Domain kündigen</h4>');
154
+    $info = api_download_domain($dom->id);
155
+    if ($info['authInfo']) {
156
+        output('<p>Das Auth-Info für diese Domain lautet: <strong>'.$info['authInfo'].'</strong></p>');
157
+        output('<p>Wenden Sie sich an den Support, wenn Sie den Domainumzug wieder sperren möchten.</p>');
158
+    } else {
159
+        output('<p>Hier können Sie die Domain zum Umzug freigeben.</p>');
160
+        $form = '<p><input type="hidden" name="domain" value="'.$dom->id.'"><input type="submit" name="submit" value="Die Domain '.$dom->fqdn.' zum Umzug freigeben"></p>';
161
+        output(html_form('domains_transfer', 'save', 'action=transfer', $form));
162
+    }
163
+    output('<p>Die aktuelle Laufzeit der Domain dauert noch bis '.$info['currentContractPeriodEnd'].'</p>');
164
+    if ($info['deletionDate']) {
165
+        output('<p>Es liegt aktuell eine Kündigung vor auf <strong>'.$info['deletionDate'].'</strong></p><p>Um die Kündigung aufzuheben, wenden Sie sich bitte an den Support.</p>');
166
+    } else {
167
+        output('<p class="delete">'.internal_link('save', 'Die Domain '.$dom->fqdn.' kündigen', 'action=cancel&domain='.$dom->id).'</p>');
168
+    }
169
+}
170
+
171
+
145 172
 // Block Domain bestätigen
146 173
 
147 174
 if ($dom->mailserver_lock == 1 && $dom->status != 'prereg') {
... ...
@@ -162,3 +162,36 @@ function api_domain_available($domainname)
162 162
 }
163 163
 
164 164
 
165
+function api_cancel_domain($domainname)
166
+{
167
+    $data = array("domainName" => $domainname);
168
+    $result = api_request('domainInfo', $data);
169
+    if ($result['status'] != 'success') {
170
+        system_failure("Abfrage nicht erfolgreich!");
171
+    }
172
+    $apidomain = $result['response'];
173
+    if (! $apidomain['latestDeletionDateWithoutRenew']) {
174
+        system_failure("Konnte Vertragsende nicht herausfinden.");
175
+    }
176
+    $args = array("domainName" => $domainname, "execDate" => $apidomain['latestDeletionDateWithoutRenew']);
177
+    $result = api_request('domainDelete', $args);
178
+    if ($result['status'] == 'error') {
179
+        //system_failure(print_r($result['errors'], true));
180
+    }
181
+ }
182
+
183
+
184
+function api_unlock_domain($domainname) 
185
+{
186
+    $data = array("domainName" => $domainname);
187
+    $result = api_request('domainInfo', $data);
188
+    if ($result['status'] != 'success') {
189
+        system_failure("Abfrage nicht erfolgreich!");
190
+    }
191
+    $apidomain = $result['response'];
192
+    $apidomain['transferLockEnabled'] = false;
193
+    $args = array("domain" => $apidomain);
194
+    api_request('domainUpdate', $args);
195
+}
196
+
197
+
... ...
@@ -301,4 +301,10 @@ function insert_domain_external($domain, $dns = false, $mail = true)
301 301
     return $id;
302 302
 }
303 303
 
304
+function delete_domain($id)
305
+{
306
+    $cid = (int) $_SESSION['customerinfo']['customerno'];
307
+    db_query("DELETE FROM kundendaten.domains WHERE id=? AND kunde=?", array($id, $cid)); 
308
+}
309
+
304 310
 
305 311
new file mode 100644
... ...
@@ -0,0 +1,57 @@
1
+<?php
2
+/*
3
+This file belongs to the Webinterface of schokokeks.org Hosting
4
+
5
+Written 2008-2018 by schokokeks.org Hosting, namely
6
+  Bernd Wurst <bernd@schokokeks.org>
7
+  Hanno Böck <hanno@schokokeks.org>
8
+
9
+To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
10
+
11
+You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see 
12
+http://creativecommons.org/publicdomain/zero/1.0/
13
+
14
+Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
15
+*/
16
+
17
+require_once("class/domain.php");
18
+require_once("domains.php");
19
+require_once("domainapi.php");
20
+require_role(ROLE_CUSTOMER);
21
+
22
+$dom = new Domain( (int) $_REQUEST['domain']);
23
+$dom->ensure_customerdomain();
24
+
25
+$domain_in_use = mailman_subdomains($dom->id) || mail_in_use($dom->id) || web_in_use($dom->id) || $dom->jabber == 1;
26
+if ($_REQUEST['action'] == 'delete') {
27
+    if ($domain_in_use || !($dom->status == 'prereg' || $dom->status == 'pretransfer' || $dom->status == 'transferfailed' || $dom->status == 'external')) {
28
+        system_failure("Diese Domain ist noch in Benutzung. Bitte Postfächer und Websites löschen sowie Eintragungen in Mailinglisten oder Jabber-Server löschen lassen.");
29
+    }
30
+    $sure = user_is_sure();
31
+    if ($sure === NULL) {
32
+        are_you_sure("action=delete&domain={$dom->id}", "Möchten Sie die Domain »{$dom->fqdn}« wirklich löschen?");
33
+    } elseif ($sure === true) {
34
+        delete_domain($dom->id);
35
+        redirect('domains');
36
+    } elseif ($sure === false) {
37
+        redirect('detail?id='.$dom->id);
38
+    }
39
+} elseif ($_REQUEST['action'] == 'cancel') {
40
+    $info = api_download_domain($dom->id);
41
+    $sure = user_is_sure();
42
+    if ($sure === NULL) {
43
+        are_you_sure("action=cancel&domain={$dom->id}", "Möchten Sie die Domain »{$dom->fqdn}« wirklich kündigen?<br>Das Kündigungsdatum wäre dann {$info['currentContractPeriodEnd']}");
44
+    } elseif ($sure === true) {
45
+        api_cancel_domain($dom->fqdn);
46
+        redirect('detail?id='.$dom->id);
47
+    } elseif ($sure === false) {
48
+        redirect('detail?id='.$dom->id);
49
+    }
50
+} elseif ($_REQUEST['action'] == 'transfer') {
51
+    check_form_token('domains_transfer');
52
+    api_unlock_domain($dom->fqdn);
53
+    redirect('detail?id='.$dom->id);
54
+}
55
+
56
+
57
+