Choose-Funktion
Bernd Wurst

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

... ...
@@ -0,0 +1,55 @@
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('contactapi.php');
18
+require_once('inc/base.php');
19
+
20
+require_once('contacts.php');
21
+
22
+if (! isset($_SESSION['contacts_choose_key'])) {
23
+    system_failure("Ungültiger Aufruf dieser Funktion");
24
+}
25
+$sesskey = $_SESSION['contacts_choose_key'];
26
+
27
+if (isset($_REQUEST['id'])) {
28
+    $c = get_contact($_REQUEST['id']);
29
+    $_SESSION[$sesskey] = $c['id'];
30
+    redirect($_SESSION['contacts_choose_redirect']);
31
+}
32
+
33
+
34
+title('Kontakt auswählen');
35
+$section = 'contacts_list';
36
+
37
+if (isset($_SESSION['contacts_choose_header'])) {
38
+    output($_SESSION['contacts_choose_header']);
39
+} else {
40
+    output('Wählen Sie einen Kontakt aus!');
41
+}
42
+
43
+
44
+output('<div class="contact-list">');
45
+$contacts = possible_domainholders();
46
+foreach ($contacts as $c) {
47
+    output(internal_link('', display_contact($c), "id={$c['id']}", 'class="contacts-choose"'));
48
+}
49
+
50
+output('</div>');
51
+
52
+
53
+
54
+
55
+
... ...
@@ -65,7 +65,7 @@ function get_contact($id)
65 65
 
66 66
 function get_contacts() {
67 67
     $cid = (int) $_SESSION['customerinfo']['customerno'];
68
-    $result = db_query("SELECT id, state, lastchange, nic_id, nic_handle, company, name, address, zip, city, country, phone, mobile, fax, email, pgp_id, pgp_key FROM kundendaten.contacts WHERE (state<>'deleted' OR state IS NULL) AND customer=? ORDER BY id", array($cid));
68
+    $result = db_query("SELECT id, state, lastchange, nic_id, nic_handle, company, name, address, zip, city, country, phone, mobile, fax, email, pgp_id, pgp_key FROM kundendaten.contacts WHERE (state<>'deleted' OR state IS NULL) AND customer=? ORDER BY COALESCE(company, name)", array($cid));
69 69
     $ret = array();
70 70
     while ($contact = $result->fetch()) {
71 71
         $ret[$contact['id']] = $contact;
... ...
@@ -264,7 +264,7 @@ function domainlist_by_contact($c) {
264 264
 }
265 265
 
266 266
 
267
-function display_contact($contact, $additional_html='', $cssclass='')
267
+function contact_as_string($contact)
268 268
 {
269 269
     $adresse = nl2br("\n".filter_input_general($contact['address'])."\n".filter_input_general($contact['country']).'-'.filter_input_general($contact['zip']).' '.filter_input_general($contact['city']));
270 270
     if (! $contact['city']) {
... ...
@@ -282,7 +282,14 @@ function display_contact($contact, $additional_html='', $cssclass='')
282 282
     $email = implode("<br>\n", array_filter(array($email, filter_input_general($contact['phone']), filter_input_general($contact['fax']), filter_input_general($contact['mobile']))));
283 283
  
284 284
 
285
-    $contact_string = "<div class=\"contact {$cssclass}\" id=\"contact-{$contact['id']}\"><p class=\"contact-id\">#{$contact['id']}</p><p class=\"contact-address\"><strong>$name</strong>$adresse</p><p class=\"contact-contact\">$email</p>{$additional_html}</div>";
285
+    $contact_string = "<p class=\"contact-id\">#{$contact['id']}</p><p class=\"contact-address\"><strong>$name</strong>$adresse</p><p class=\"contact-contact\">$email</p>";
286
+    return $contact_string;
287
+}
288
+
289
+function display_contact($contact, $additional_html='', $cssclass='')
290
+{
291
+    $html = contact_as_string($contact);
292
+    $contact_string = "<div class=\"contact {$cssclass}\" id=\"contact-{$contact['id']}\">{$html}{$additional_html}</div>";
286 293
     return $contact_string;
287 294
 }
288 295
 
... ...
@@ -34,6 +34,24 @@ div.contact {
34 34
     margin: 1em;
35 35
     padding: 3px 10px;    
36 36
 }
37
+
38
+a.contacts-choose {
39
+    color: initial;
40
+    text-decoration: none;
41
+}
42
+a div.contact {
43
+    min-height: 10em;
44
+}
45
+a div.contact:hover {
46
+    border: 2px solid blue;
47
+    padding: 2px 9px;
48
+}
49
+
50
+a.contacts-choose:hover {
51
+    color: initial;
52
+    text-decoration: none;
53
+}
54
+
37 55
 div.contact.mainaddress {
38 56
     border: 2px solid red;
39 57
     padding: 2px 9px;
... ...
@@ -0,0 +1,30 @@
1
+<?php
2
+
3
+require_once('contactapi.php');
4
+require_once('inc/base.php');
5
+
6
+require_once('contacts.php');
7
+
8
+
9
+title('Kontakt hochladen');
10
+
11
+if (isset($_SESSION['contacts_upload'])) {
12
+    $c = get_contact($_SESSION['contacts_upload']);
13
+    unset($_SESSION['contacts_upload']);
14
+    unset($_SESSION['contacts_choose_key']);
15
+    unset($_SESSION['contacts_choose_header']);
16
+    unset($_SESSION['contacts_choose_redirect']);
17
+
18
+    output('<p>Kontakt gewählt:</p>'.display_contact($c));
19
+} else {
20
+    $_SESSION['contacts_choose_header'] = 'Wählen Sie einen Kontakt zum Hochladen.';
21
+    $_SESSION['contacts_choose_key'] = 'contacts_upload';
22
+    $_SESSION['contacts_choose_redirect'] = 'test';
23
+    redirect('choose');
24
+}
25
+
26
+
27
+
28
+
29
+
30
+
0 31