Mailman-Interface
Bernd Wurst

Bernd Wurst commited on 2018-06-08 11:40:57
Zeige 4 geänderte Dateien mit 113 Einfügungen und 17 Löschungen.

... ...
@@ -19,10 +19,16 @@ require_once('inc/debug.php');
19 19
 require_once('inc/security.php');
20 20
 
21 21
 
22
-function get_lists()
22
+function get_lists($filter)
23 23
 {
24 24
   $uid = (int) $_SESSION['userinfo']['uid'];
25
-  $result = db_query("SELECT id, status, listname, fqdn, admin, archivesize FROM mail.v_mailman_lists WHERE owner=? ORDER BY listname", array($uid));
25
+  $result = NULL;
26
+  if ($filter) {
27
+      $filter = '%'.$filter.'%';
28
+      $result = db_query("SELECT id, created, status, listname, fqdn, admin, archivesize FROM mail.v_mailman_lists WHERE owner=:uid AND (listname LIKE :filter OR fqdn LIKE :filter OR admin LIKE :filter) ORDER BY listname", array('uid' => $uid, 'filter' => $filter));
29
+  } else {
30
+      $result = db_query("SELECT id, created, status, listname, fqdn, admin, archivesize FROM mail.v_mailman_lists WHERE owner=:uid ORDER BY listname", array('uid' => $uid));
31
+  }
26 32
   $ret = array();
27 33
   while ($list = $result->fetch())
28 34
     $ret[] = $list;
... ...
@@ -35,7 +41,7 @@ function get_list($id)
35 41
 {
36 42
   $args = array(":id" => $id,
37 43
                 ":uid" => $_SESSION['userinfo']['uid']);
38
-  $result = db_query("SELECT id, status, listname, fqdn, admin, archivesize FROM mail.v_mailman_lists WHERE owner=:uid AND id=:id", $args);
44
+  $result = db_query("SELECT id, created, status, listname, fqdn, admin, archivesize FROM mail.v_mailman_lists WHERE owner=:uid AND id=:id", $args);
39 45
   if ($result->rowCount() < 1)
40 46
     system_failure('Die gewünschte Mailingliste konnte nicht gefunden werden');
41 47
   $list = $result->fetch();
... ...
@@ -61,13 +67,14 @@ function request_new_password($id)
61 67
 
62 68
 function create_list($listname, $maildomain, $admin)
63 69
 {
70
+    $listname = strtolower($listname);
64 71
   verify_input_username($listname);
65 72
   verify_input_general($admin);
66 73
   if (in_array($listname, array("admin", "administrator", "webmaster", "hostmaster", "postmaster")))
67 74
     system_failure('Der Mailinglistenname '.$listname.' ist unzulässig.');
68 75
   if (! check_emailaddr($admin))
69 76
     system_failure('Der Verwalter muss eine gültige E-Mail-Adresse sein ('.$admin.').');
70
-  $result = db_query("SELECT id FROM mail.mailman_lists WHERE listname=?", array($listname));
77
+  $result = db_query("SELECT id FROM mail.mailman_lists WHERE listname LIKE ?", array($listname));
71 78
   if ($result->rowCount() > 0)
72 79
     system_failure('Eine Liste mit diesem Namen existiert bereits auf unserem Mailinglisten-Server (unter einer Ihrer Domains oder unter einer Domain eines anderen Kunden). Jeder Listenname kann auf dem gesamten Server nur einmal verwendet werden.');
73 80
 
... ...
@@ -0,0 +1,7 @@
1
+
2
+$(function() {
3
+    $('#clear').click( function() { 
4
+        $('#filter').val('');
5
+        $('#mailman_filter').submit();
6
+    });
7
+});
... ...
@@ -14,7 +14,7 @@ http://creativecommons.org/publicdomain/zero/1.0/
14 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 15
 */
16 16
 
17
-require_once('inc/base.php');
17
+require_once('inc/jquery.php');
18 18
 require_once('inc/icons.php');
19 19
 require_once('mailman.php');
20 20
 
... ...
@@ -26,11 +26,25 @@ output('<p>Mit <a href="https://www.gnu.org/software/mailman/index.html">Mailman
26 26
 <p>Auf dieser Seite können Sie Ihre Mailinglisten verwalten.</p>
27 27
 ');
28 28
 
29
-$lists = get_lists();
29
+$filter = "";
30
+if (isset($_REQUEST['filter']) && $_REQUEST['filter'] != '') {
31
+  $filter = filter_input_general($_REQUEST['filter']);
32
+}
33
+$lists = get_lists($filter);
34
+
35
+
36
+// Filter-Funktion
37
+if (count($lists) > 10 || $filter) {
38
+    javascript();
39
+    $form = '<p><label for="filter">Filter für die Anzeige:</label> <input type="text" name="filter" id="filter" value="'.$filter.'"><button type="button" id="clear" title="Filter leeren">&times;</button><input type="submit" value="Filtern!"></p>';
40
+    output(html_form('mailman_filter', 'lists', '', $form));
41
+}
42
+
30 43
 
31 44
 if (! empty($lists))
32 45
 {
33
-  output("<table>\n<tr><th>Listenname</th><th>Verwalter<sup>1</sup></th><th>Status</th><th>Archivgröße<sup>2</sup></th><th>&nbsp;</th></tr>\n");
46
+  addnew('newlist', 'Neue Mailingliste anlegen');
47
+  output('<div id="mailman_lists_container">');
34 48
   foreach ($lists AS $list)
35 49
   {
36 50
     $size = $list['archivesize'];
... ...
@@ -43,39 +57,40 @@ if (! empty($lists))
43 57
     }
44 58
 
45 59
 
46
-    $style = '';
47
-    $status = 'In Betrieb';
60
+    $class = 'regular';
61
+    $status = 'In Betrieb (erstellt am '.strftime('%d.%m.%Y', strtotime($list['created'])).')';
48 62
     if ($list['status'] == 'delete')
49 63
     {
50
-      $style = ' style="text-decoration: line-through;" ';
64
+      $class = 'deleted';
51 65
       $status = 'Wird gelöscht';
52 66
     }
53 67
     elseif ($list['status'] == 'pending')
54 68
     {
55
-      $style = ' style="text-decoration: underline;" ';
69
+      $class = 'new';
56 70
       $status = 'Wird angelegt';
57 71
     }
58 72
     elseif ($list['status'] == 'newpw')
59 73
     {
60
-      $style = ' style="font-style: italic;" ';
74
+      $class = 'edited';
61 75
       $status = 'Neues Passwort angefordert';
62 76
     }
63 77
     elseif ($list['status'] == 'failure')
64 78
     {
65
-      $style = ' style="font-style: italic;" ';
79
+      $class = 'error';
66 80
       $status = 'Fehler bei der Erstellung';
67 81
     }
68 82
     
69 83
     $admin = str_replace(',', ', ', $list['admin']);
70 84
 
71 85
 
72
-    output("<tr><td{$style}><strong>{$list['listname']}</strong>@{$list['fqdn']}</td><td{$style}>{$admin}</td><td>{$status}</td><td style=\"text-align: right;\">{$sizestr}</td>");
86
+    output("<div class=\"mailman_list $class\"><p class=\"listname\"><span class=\"listname\">{$list['listname']}</span>@{$list['fqdn']}</p>
87
+        <p class=\"listadmin\">Verwalter: {$admin}</p><p class=\"status\">Status: {$status}</p><p class=\"archivesize\">Archivgröße: {$sizestr}</p>");
73 88
     if ($list['status'] == 'running')
74
-      output("<td>".internal_link('save', other_icon("lock.png", "Neues Passwort anfordern"), "action=newpw&id={$list['id']}")." ".internal_link('save', icon_delete("Mailingliste löschen"), "action=delete&id={$list['id']}")." <a href=\"https://".config('mailman_host')."/mailman/admin.cgi/{$list['listname']}\">".other_icon("database_go.png", "Listen-Verwaltung aufrufen")."</a></td></tr>\n");
89
+      output("<p class=\"operations\">".internal_link('save', other_icon("lock.png", "Neues Passwort anfordern").' Neues Passwort anfordern', "action=newpw&id={$list['id']}")."<br>".internal_link('save', icon_delete("Mailingliste löschen").' Liste löschen', "action=delete&id={$list['id']}")."<br><a href=\"https://".config('mailman_host')."/mailman/admin.cgi/{$list['listname']}\">".other_icon("database_go.png", "Listen-Verwaltung aufrufen")." Verwaltung aufrufen</a></p></div>\n");
75 90
     else
76
-      output("<td>&#160;</td></tr>\n");
91
+      output("</div>\n");
77 92
   }
78
-  output("</table>");
93
+  output("</div>");
79 94
 }
80 95
 else
81 96
 {
... ...
@@ -0,0 +1,67 @@
1
+#mailman_lists_container {
2
+    display: flex;
3
+    flex-direction: row;
4
+    flex-wrap: wrap;
5
+}
6
+
7
+.mailman_list {
8
+    width: 350px;
9
+    border: none;
10
+    border-left: 5px solid black;
11
+    background-color: #f5f5f5;
12
+    margin: 10px;
13
+    padding: 4px;
14
+}
15
+
16
+.mailman_list.regular {
17
+    border-color: #0a0;
18
+    background-color: #dfd;
19
+}
20
+.mailman_list.deleted {
21
+    border-color: red;
22
+    background-color: #fdd;
23
+}
24
+.mailman_list.new {
25
+    border-color: #ff0;
26
+    background-color: #ffd;
27
+}
28
+.mailman_list.edited {
29
+    border-color: #00a;
30
+    background-color: #ddf;
31
+}
32
+.mailman_list.error {
33
+    /* nutzt den default */
34
+}
35
+
36
+p.listname {
37
+    margin: 0;
38
+    padding: 0;
39
+    font-size: 100%;
40
+    font-weight: normal;
41
+    word-wrap: break-word;
42
+}
43
+p.listname span.listname {
44
+    font-weight: bold;
45
+    font-size: 130%;
46
+}
47
+
48
+p.listadmin {
49
+    font-size: 90%;
50
+    margin-bottom: 0;
51
+}
52
+p.status, p.archivesize {
53
+    margin-top: 0;
54
+    margin-bottom: 0;
55
+    font-size: 90%;
56
+}
57
+input#filter {
58
+    padding-right: 25px;
59
+}
60
+button#clear {
61
+    width: 20px;
62
+    margin-left: -22px;
63
+    margin-right: 1em;
64
+    padding: 0 5px;
65
+    background-color: #fff;
66
+    border: 0;
67
+}
0 68