Rudimentäre Adressauswahl/Domainupdate-UI
Bernd Wurst

Bernd Wurst commited on 2018-01-24 10:34:58
Zeige 6 geänderte Dateien mit 227 Einfügungen und 1 Löschungen.

... ...
@@ -280,6 +280,22 @@ function have_module($modname)
280 280
 }
281 281
 
282 282
 
283
+function use_module($modname) 
284
+{
285
+    global $prefix;
286
+    if (! have_module($modname)) {
287
+        system_failure("Soll nicht verfügbares Modul laden!");
288
+    }
289
+    /* setup module include path */
290
+    ini_set('include_path',ini_get('include_path').':./modules/'.$modname.'/include:');
291
+    $style = 'modules/'.$modname.'/style.css';
292
+    if (file_exists($style)) {
293
+        html_header('<link rel="stylesheet" href="'.$prefix.$style.'" type="text/css" />'."\n");
294
+    }
295
+
296
+}
297
+
298
+
283 299
 function encode_querystring($querystring)
284 300
 {
285 301
   global $debugmode;
... ...
@@ -57,6 +57,17 @@ div.contact.mainaddress {
57 57
     padding: 2px 9px;
58 58
 }
59 59
 
60
+div.contact.modified::after {
61
+    content: "(noch nicht gespeichert)";
62
+    font-style: italic;
63
+    font-weight: bold;
64
+    color: red;
65
+}
66
+div.contact.modified {
67
+    border: 2px solid red;
68
+    padding: 2px 9px;
69
+}
70
+
60 71
 p.contact-id {
61 72
     text-align: right;
62 73
     float: right;
... ...
@@ -0,0 +1,40 @@
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
+if (isset($_GET['type'])) {
18
+    $function = 'owner';
19
+    if ($_GET['type'] == 'admin_c') {
20
+        if (isset($_GET['detach'])) {
21
+            $_SESSION['domains_update_detach'] = $_GET['detach'];
22
+        }
23
+        $function = 'admin_c';
24
+    }
25
+    $t = 'Inhaber';
26
+    if ($function == 'admin_c') {
27
+        $t = 'Verwalter';
28
+    }
29
+    $_SESSION['contacts_choose_header'] = 'Wählen Sie einen neuen '.$t.' für die Domain '.$_SESSION['domains_update_domainname'];
30
+    $_SESSION['contacts_choose_key'] = 'domains_update_'.$function;
31
+    $_SESSION['contacts_choose_redirect'] = '../domains/update';
32
+    redirect('../contacts/choose');
33
+} else {
34
+    unset($_SESSION['contacts_choose_key']);
35
+    unset($_SESSION['contacts_choose_header']);
36
+    unset($_SESSION['contacts_choose_redirect']);
37
+    redirect("update.php");
38
+}
39
+
40
+
... ...
@@ -0,0 +1,101 @@
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('inc/debug.php');
18
+require_once('inc/icons.php');
19
+
20
+require_once('class/domain.php');
21
+require_once('domains.php');
22
+
23
+require_role(ROLE_CUSTOMER);
24
+use_module('contacts');
25
+require_once('contacts.php');
26
+
27
+$dom = NULL;
28
+if (isset($_REQUEST['id'])) {
29
+    $dom = new Domain( (int) $_REQUEST['id']);
30
+    if ($dom->provider == 'external' || $dom->provider != 'terions') {
31
+        system_failure("<p>Diese Domain ist extern registriert!</p>");
32
+    }
33
+    $_SESSION['domains_update_domainname'] = $dom->fqdn;
34
+    $_SESSION['domains_update_owner'] = $dom->owner;
35
+    $_SESSION['domains_update_admin_c'] = $dom->admin_c;
36
+} else {
37
+    $dom = new Domain($_SESSION['domains_update_domainname']);
38
+}
39
+if (!$dom) {
40
+    system_failure("Keine Domain gewählt!");
41
+}
42
+
43
+if ($_SESSION['domains_update_admin_c'] == $dom->admin_c && 
44
+    $_SESSION['domains_update_owner'] != $dom->owner && 
45
+    (!isset($_SESSION['domains_update_detach']) || $_SESSION['domains_update_detach'] == 0)) {
46
+    // Wenn der Owner geändert wurde, der Admin aber nicht und das detach-Flag 
47
+    // nicht gesetzt ist, dann wird der Admin gleich dem Owner gesetzt
48
+    $_SESSION['domains_update_admin_c'] = $_SESSION['domains_update_owner'];
49
+}
50
+
51
+if (isset($_GET['admin_c']) && $_GET['admin_c'] == 'none') {
52
+    $_SESSION['domains_update_admin_c'] = $_SESSION['domains_update_owner'];
53
+    unset($_SESSION['domains_update_detach']);
54
+}
55
+
56
+
57
+
58
+title("Änderung der Domain {$dom->fqdn}");
59
+$section = 'domains_domains';
60
+output('<p>Legen Sie hier einen neuen Inhaber für diese Domain fest.</p>');
61
+
62
+$changed = false;
63
+
64
+$owner = get_contact($_SESSION['domains_update_owner']);
65
+$admin_c = get_contact($_SESSION['domains_update_admin_c']);
66
+$function = 'Inhaber';
67
+if ($owner['id'] == $admin_c['id']) {
68
+    $function .= ' und Verwalter';
69
+}
70
+$cssclass = '';
71
+if ($owner['id'] != $dom->owner) {
72
+    $cssclass = 'modified';
73
+    $changed = true;
74
+}
75
+output('<p><strong>'.$function.':</strong></p>'.display_contact($owner, '', $cssclass));
76
+addnew('choose', 'Neuen Inhaber wählen', "type=owner");
77
+if ($owner['id'] != $admin_c['id']) {
78
+    $cssclass = '';
79
+    if ($admin_c['id'] != $dom->admin_c) {
80
+        $cssclass = 'modified';
81
+        $changed = true;
82
+    }
83
+    output('<p><strong>Verwalter:</strong></p>'.display_contact($admin_c, '', $cssclass));
84
+    addnew('choose', 'Neuen Inhaber wählen', "type=admin_c");
85
+    output('<p class="delete">'.internal_link('update', 'Keinen separaten Verwalter festlegen', 'admin_c=none').'</p>');
86
+} else {
87
+    addnew('choose', 'Einen separaten Verwalter wählen', "type=admin_c&detach=1");
88
+}
89
+
90
+
91
+if ($changed) {
92
+    if (isset($_GET['error']) && $_GET['error'] == '1') {
93
+        input_error('Sie müssen der Übertragung explizit zustimmen!');
94
+    }
95
+    $form = '<p>Es sind Änderungen vorgenommen worden, die noch nicht gespeichert wurden</p>';
96
+    $form .= '<p><input type="checkbox" name="accept" value="1" id="accept"><label for="accept"> Ich bestätige, dass ich einen Inhaberwechsel bei der Domain '.$dom->fqdn.' vornehmen möchte. Ich bin darüber informiert, dass die Adresse des Domaininhabers öffentlich abrufbar ist. Der bisherige Domaininhaber hat der Übertragung explizit zugestimmt.</p>';
97
+    $form .= '<p><input type="submit" name="sumbit" value="Änderungen speichern und Domaininhaber ändern"></p>';
98
+    output(html_form('domains_update', 'update_save', "id=".$dom->id, $form));
99
+} 
100
+
101
+output('<p>'.internal_link('domains', 'Ohne Änderungen zurück').'</p>');
... ...
@@ -0,0 +1,39 @@
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('inc/debug.php');
18
+require_once('inc/icons.php');
19
+
20
+require_once('class/domain.php');
21
+require_once('domains.php');
22
+
23
+require_role(ROLE_CUSTOMER);
24
+
25
+if (!(isset($_POST['accept']) && $_POST['accept'] == '1')) {
26
+    redirect('update?error=1');
27
+}
28
+$dom = new Domain($_SESSION['domains_update_domainname']);
29
+if (!$dom) {
30
+    system_failure("Keine Domain gewählt!");
31
+}
32
+
33
+DEBUG($dom);
34
+/* DAS TUT NICHT! */
35
+$dom->owner = $_SESSION['domains_update_owner'];
36
+$dom->admin_c = $_SESSION['domains_update_admin_c'];
37
+$dom->save();
38
+
39
+print_r($_SESSION);
... ...
@@ -79,7 +79,7 @@ p.admininfo {
79 79
   background-color: #fdd;
80 80
 }
81 81
 
82
-p.addnew {
82
+p.addnew,p.delete {
83 83
   margin-top: 1.5em;
84 84
   margin-bottom: 2em;
85 85
 }
... ...
@@ -103,6 +103,25 @@ p.addnew a:hover {
103 103
 }
104 104
 
105 105
 
106
+p.delete a {
107
+  color: #b22;
108
+  font-size: 110%;
109
+  font-weight: bold;
110
+  padding: 5px;
111
+  min-height: 18px;
112
+  padding-left: 25px;
113
+  background-image: url('../../images/delete.png');
114
+  background-position: 0 5px;
115
+  background-repeat: no-repeat;
116
+}
117
+
118
+p.delete a:hover {
119
+  text-decoration: none;
120
+  padding-bottom: 0;
121
+  border-bottom: 2px solid #b22;
122
+}
123
+
124
+
106 125
 p.userinfo {
107 126
   margin: 3px;
108 127
   margin-top: 1.5em;
109 128