Neues Modul für Mailman-Verwaltung
bernd

bernd commited on 2009-04-28 17:45:54
Zeige 5 geänderte Dateien mit 214 Einfügungen und 0 Löschungen.


git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@1348 87cf0b9e-d624-0410-a070-f6ee81989793
... ...
@@ -0,0 +1,69 @@
1
+<?php
2
+
3
+require_once('inc/base.php');
4
+require_once('inc/debug.php');
5
+require_once('inc/security.php');
6
+
7
+
8
+function get_lists()
9
+{
10
+  $uid = (int) $_SESSION['userinfo']['uid'];
11
+  $result = db_query("SELECT id, status, listname, fqdn, admin FROM mail.v_mailman_lists WHERE owner={$uid};");
12
+  $ret = array();
13
+  while ($list = mysql_fetch_assoc($result))
14
+    $ret[] = $list;
15
+  DEBUG($ret);
16
+  return $ret;
17
+}
18
+
19
+
20
+function get_list($id)
21
+{
22
+  $id = (int) $id;
23
+  $uid = (int) $_SESSION['userinfo']['uid'];
24
+  $result = db_query("SELECT id, status, listname, fqdn, admin FROM mail.v_mailman_lists WHERE owner={$uid} AND id={$id};");
25
+  if (mysql_num_rows($result) < 1)
26
+    system_failure('Die gewünschte Mailingliste konnte nicht gefunden werden');
27
+  $list = mysql_fetch_assoc($result);
28
+  DEBUG($list);
29
+
30
+  return $list;
31
+}
32
+
33
+
34
+function delete_list($id)
35
+{
36
+  $uid = (int) $_SESSION['userinfo']['uid'];
37
+  $id = (int) $id;
38
+  db_query("UPDATE mail.mailman_lists SET status='delete' WHERE owner={$uid} AND id={$id};");
39
+}
40
+
41
+
42
+function create_list($listname, $maildomain, $admin)
43
+{
44
+  $listname = filter_input_username($listname);
45
+  $maildomain = maybe_null( (int) $maildomain );
46
+  $owner = (int) $_SESSION['userinfo']['uid'];
47
+  $admin = filter_input_general($admin);
48
+  if (! check_emailaddr($admin))
49
+    system_failure('Der Verwalter muss eine gültige E-Mail-Adresse sein ('.$admin.').');
50
+  $result = db_query("SELECT id FROM mail.mailman_lists WHERE listname='{$listname}'");
51
+  if (mysql_num_rows($result) > 0)
52
+    system_failure('Eine Liste mit diesem Namen existiert bereits (unter dieser oder einer anderen Domain). Jeder Listenname kann nur einmal verwendet werden.');
53
+
54
+  db_query("INSERT INTO mail.mailman_lists (status, listname, maildomain, owner, admin) VALUES ('pending', '{$listname}', {$maildomain}, {$owner}, '{$admin}');");
55
+  DEBUG('Neue ID: '.mysql_insert_id());
56
+}
57
+
58
+
59
+function get_mailman_domains()
60
+{
61
+  $uid = (int) $_SESSION['userinfo']['uid'];
62
+  $result = db_query("SELECT md.id, md.fqdn FROM mail.v_mailman_domains AS md left join mail.v_domains AS d on (d.id=md.domain) where d.user={$uid}");
63
+  $ret = array();
64
+  while ($dom = mysql_fetch_assoc($result))
65
+    $ret[] = $dom;
66
+  DEBUG($ret);
67
+  return $ret;
68
+}
69
+
... ...
@@ -0,0 +1,54 @@
1
+<?php
2
+
3
+require_once('inc/base.php');
4
+require_once('mailman.php');
5
+
6
+require_role(ROLE_SYSTEMUSER);
7
+
8
+$title = 'Mailinglisten';
9
+
10
+$output = '<h3>Mailinglisten</h3>
11
+<p>Mit <a href="http://www.mailman.org">Mailman</a> bieten wir Ihnen eine umfangreiche Lösung für E-Mail-Verteilerlisten an. <a href="https://wiki.schokokeks.org/E-Mail/Mailinglisten">In unserem Wiki</a> sind die Möglichkeiten einer Mailingliste detaillierter beschrieben.</p>
12
+<p>Auf dieser Seite können Sie Ihre Mailinglisten verwalten.</p>
13
+';
14
+
15
+$lists = get_lists();
16
+
17
+if (! empty($lists))
18
+{
19
+  $output .= "<table>\n<tr><th>Listenname</th><th>Verwalter</th><th>Status</th><th>&nbsp;</th></tr>\n";
20
+  foreach ($lists AS $list)
21
+  {
22
+    $style = '';
23
+    if ($list['status'] == 'delete')
24
+      $style = ' style="text-decoration: line-through;" ';
25
+    elseif ($list['status'] == 'pending')
26
+      $style = ' style="text-decoration: underline;" ';
27
+
28
+    $status = 'In Betrieb';
29
+    if ($list['status'] == 'delete')
30
+      $status = 'Wird gelöscht';
31
+    elseif ($list['status'] == 'pending')
32
+      $status = 'Wird angelegt';
33
+    
34
+
35
+    $output .= "<tr><td{$style}><strong>{$list['listname']}</strong>@{$list['fqdn']}</td><td{$style}>{$list['admin']}</td><td>{$status}</td>";
36
+    if ($list['status'] == 'running')
37
+      $output .= "<td>".internal_link('save', "<img src=\"{$prefix}images/delete.png\" />", "action=delete&id={$list['id']}")."</tr>\n";
38
+    else
39
+      $output .= "<td>&#160;</td></tr>\n";
40
+  }
41
+  $output .= "</table>";
42
+}
43
+else
44
+{
45
+  // keine Listen
46
+  $output .= '<p><em>Sie betreiben bisher keine Mailinglisten.</em></p>';
47
+}
48
+
49
+
50
+$output .= "<p><strong>".internal_link('newlist', 'Neue Mailingliste anlegen')."</strong></p>\n";
51
+
52
+
53
+$output .= "<p><strong>Hinweis:</strong> Sie können im Webinterface von Mailman einen abweichenden oder auch mehrere Verwalter eintragen. Die Information auf dieser Seite wird dann nicht automatisch geändert sondern bezeichnet den Verwalter, den Sie beim Anlegen der Liste benannt haben.</p>\n";
54
+
... ...
@@ -0,0 +1,10 @@
1
+<?php
2
+
3
+$role = $_SESSION['role'];
4
+
5
+if ($role & ROLE_SYSTEMUSER)
6
+{
7
+  $menu['mailman_lists'] = array("label" => "Mailinglisten", "file" => "lists", "weight" => 5, 'submenu' => 'email_vmail');
8
+}
9
+
10
+?>
... ...
@@ -0,0 +1,29 @@
1
+<?php
2
+require_once('mailman.php');
3
+require_role(ROLE_SYSTEMUSER);
4
+
5
+$title = "Neue Mailingliste erstellen";
6
+$section = 'mailman_lists';
7
+$domains = get_mailman_domains();
8
+
9
+$maildomains = array('0' => 'lists.schokokeks.org');
10
+foreach ($domains AS $domain)
11
+{
12
+  $maildomains[$domain['id']] = $domain['fqdn'];
13
+}
14
+
15
+output("<h3>Neue Mailingliste erstellen</h3>");
16
+
17
+output('<p>Tragen Sie hier die benötigten Daten zur Erstellung einer neuen Mailingliste ein. Die Liste wird <strong>mit etwas Zeitverzögerung</strong> angelegt, Sie erhalten dann eine E-Mail an die unten angegebene Adresse des Listen-Verwalters</p>
18
+
19
+'.html_form('mailman_newlist', 'save', 'action=new', '
20
+<table>
21
+<tr><td>Listenname:</td><td><input type="text" name="listname" value="" />&#160;@&#160;'.html_select('maildomain', $maildomains).'</td></tr>
22
+<tr><td>E-Mail-Adresse des Listen-Verwalters:</td><td><input type="text" name="admin" value="'.$_SESSION['userinfo']['username'].'@'.$config['masterdomain'].'" /></td></tr>
23
+</table>
24
+<br />
25
+<input type="submit" name="submit" value="Anlegen" />
26
+'));
27
+
28
+
29
+?>
... ...
@@ -0,0 +1,52 @@
1
+<?php
2
+
3
+require_once('mailman.php');
4
+require_role(ROLE_SYSTEMUSER);
5
+
6
+$title = "Neue Mailingliste erstellen";
7
+$domains = get_mailman_domains();
8
+
9
+$maildomains = array('0' => 'lists.schokokeks.org');
10
+foreach ($domains AS $domain)
11
+{
12
+  $maildomains[$domain['id']] = $domain['fqdn'];
13
+}
14
+
15
+
16
+if ($_GET['action'] == 'new')
17
+{
18
+  $maildomain = $_POST['maildomain'];
19
+  if ($maildomain == 0)
20
+    $maildomain = NULL;
21
+  else
22
+    if (! isset($maildomains[$maildomain]))
23
+      system_failure('Ihre Domain-Auswahl scheint ungültig zu sein');
24
+
25
+  create_list($_POST['listname'], $maildomain, $_POST['admin']);
26
+}
27
+
28
+elseif ($_GET['action'] == 'delete')
29
+  $list = get_list($_GET['id']);
30
+  $sure = user_is_sure();
31
+  if ($sure === NULL)
32
+  {
33
+    are_you_sure('action=delete&id='.$list['id'], 'Möchten Sie die Mailingliste »<strong>'.$list['listname'].'</strong>@'.$list['fqdn'].'« wirklich löschen?');
34
+  }
35
+  elseif ($sure === true)
36
+  {
37
+    delete_list($list['id']);
38
+    if (! $debugmode)
39
+      header('Location: lists');
40
+  }
41
+  elseif ($sure === false)
42
+  {
43
+    if (! $debugmode)
44
+      header('Location: lists');
45
+  }
46
+
47
+else
48
+{
49
+  system_failure('Function not implemented');
50
+}
51
+
52
+
0 53