Browse Source

Merge branch 'main' into lang_de

lang_de
Stephan Richter 3 years ago
parent
commit
49845a076a
  1. 2
      pom.xml
  2. 15
      src/main/java/de/srsoftware/widerhall/data/Database.java
  3. 4
      src/main/java/de/srsoftware/widerhall/data/ListMember.java
  4. 77
      src/main/java/de/srsoftware/widerhall/data/MailingList.java
  5. 5
      src/main/java/de/srsoftware/widerhall/mail/ImapClient.java
  6. 7
      src/main/java/de/srsoftware/widerhall/mail/ProblemListener.java
  7. 107
      src/main/java/de/srsoftware/widerhall/web/Web.java
  8. 62
      static/templates/add_list.st
  9. 4
      static/templates/css.st
  10. 17
      static/templates/edit_list.st
  11. 1
      static/templates/inspect.st
  12. 6
      static/templates/js.st
  13. 59
      static/templates/list_data_form.st
  14. 3
      static/templates/listadminlist.st
  15. 6
      static/templates/navigation.st

2
pom.xml

@ -6,7 +6,7 @@
<groupId>org.example</groupId> <groupId>org.example</groupId>
<artifactId>Widerhall</artifactId> <artifactId>Widerhall</artifactId>
<version>0.2.21</version> <version>0.2.23</version>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>

15
src/main/java/de/srsoftware/widerhall/data/Database.java

@ -183,6 +183,11 @@ public class Database {
} }
} }
public void run() throws SQLException {
compile().run();
}
/** /**
* set single value for a certain key * set single value for a certain key
* @param key * @param key
@ -194,6 +199,11 @@ public class Database {
return this; return this;
} }
public Request sort(String field) {
sortFields.add(field);
return this;
}
/** /**
* get the current (i.e. non-final) sql * get the current (i.e. non-final) sql
* @return * @return
@ -251,11 +261,6 @@ public class Database {
list.add(value); list.add(value);
return this; return this;
} }
public Request sort(String field) {
sortFields.add(field);
return this;
}
} }
public Database(Connection connection) { public Database(Connection connection) {

4
src/main/java/de/srsoftware/widerhall/data/ListMember.java

@ -407,6 +407,10 @@ public class ListMember {
} }
} }
public static void updateListEmail(String oldEmail, String newEmail) throws SQLException {
Database.open().update(TABLE_NAME).set(LIST_EMAIL,newEmail).where(LIST_EMAIL,oldEmail).compile().run();
}
public User user(){ public User user(){
return user; return user;
} }

77
src/main/java/de/srsoftware/widerhall/data/MailingList.java

@ -3,14 +3,12 @@ package de.srsoftware.widerhall.data;
import de.srsoftware.widerhall.Configuration; import de.srsoftware.widerhall.Configuration;
import de.srsoftware.widerhall.mail.ImapClient; import de.srsoftware.widerhall.mail.ImapClient;
import de.srsoftware.widerhall.mail.MessageHandler; import de.srsoftware.widerhall.mail.MessageHandler;
import de.srsoftware.widerhall.mail.ProblemListener;
import de.srsoftware.widerhall.mail.SmtpClient; import de.srsoftware.widerhall.mail.SmtpClient;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.mail.Address; import javax.mail.*;
import javax.mail.Flags;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.internet.AddressException; import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress; import javax.mail.internet.InternetAddress;
import javax.ws.rs.HEAD; import javax.ws.rs.HEAD;
@ -28,7 +26,7 @@ import static de.srsoftware.widerhall.data.User.PERMISSION_ADMIN;
/** /**
* this class encapsulates a MailingList db object * this class encapsulates a MailingList db object
*/ */
public class MailingList implements MessageHandler { public class MailingList implements MessageHandler, ProblemListener {
public static final String KEY_FORWARD_FROM = "forward_from"; public static final String KEY_FORWARD_FROM = "forward_from";
public static final String KEY_FORWARD_ATTACHED = "forward_attached"; public static final String KEY_FORWARD_ATTACHED = "forward_attached";
public static final String KEY_HIDE_RECEIVERS = "hide_receivers"; public static final String KEY_HIDE_RECEIVERS = "hide_receivers";
@ -62,11 +60,11 @@ public class MailingList implements MessageHandler {
private static final int HIDDEN = 0; private static final int HIDDEN = 0;
private static final int DEFAULT_STATE = STATE_PENDING|STATE_HIDE_RECEIVERS|STATE_PUBLIC_ARCHIVE; private static final int DEFAULT_STATE = STATE_PENDING|STATE_HIDE_RECEIVERS|STATE_PUBLIC_ARCHIVE;
private static final String RETAINED_FOLDER = "retained"; private static final String RETAINED_FOLDER = "retained";
private final String name; private static final String LAST_ERROR = "last_error";
private final String email; private String email, name, lastError;
private int state; private int state;
private final SmtpClient smtp; private SmtpClient smtp;
private final ImapClient imap; private ImapClient imap;
private static final HashMap<String,MailingList> cache = new HashMap<>(); private static final HashMap<String,MailingList> cache = new HashMap<>();
@ -89,7 +87,7 @@ public class MailingList implements MessageHandler {
this.name = name; this.name = name;
this.state = state; this.state = state;
this.smtp = new SmtpClient(smtpHost,smtpPort,smtpUser,smtpPass); this.smtp = new SmtpClient(smtpHost,smtpPort,smtpUser,smtpPass);
this.imap = new ImapClient(imapHost,imapPort,imapUser,imapPass,inbox); this.imap = new ImapClient(imapHost,imapPort,imapUser,imapPass,inbox,this);
} }
public MailingList archive(boolean enabled) throws SQLException { public MailingList archive(boolean enabled) throws SQLException {
@ -134,7 +132,8 @@ public class MailingList implements MessageHandler {
.append(SMTP_PORT).append(" ").append(INT).append(", ") .append(SMTP_PORT).append(" ").append(INT).append(", ")
.append(SMTP_USER).append(" ").append(VARCHAR).append(", ") .append(SMTP_USER).append(" ").append(VARCHAR).append(", ")
.append(SMTP_PASS).append(" ").append(VARCHAR).append(", ") .append(SMTP_PASS).append(" ").append(VARCHAR).append(", ")
.append(STATE).append(" ").append(INT) .append(STATE).append(" ").append(INT).append(", ")
.append(LAST_ERROR).append(" ").append(TEXT)
.append(");"); .append(");");
Database.open().query(sql).compile().run(); Database.open().query(sql).compile().run();
} }
@ -147,7 +146,10 @@ public class MailingList implements MessageHandler {
public MailingList enable(boolean enable) throws SQLException { public MailingList enable(boolean enable) throws SQLException {
if (!enable) imap.stop(); if (!enable) imap.stop();
setFlag(STATE_ENABLED,enable); setFlag(STATE_ENABLED,enable);
if (enable) imap.start().addListener(this); if (enable) {
setLastError(null);
imap.start().addListener(this);
}
return this; return this;
} }
@ -274,12 +276,15 @@ public class MailingList implements MessageHandler {
public static MailingList load(String listEmail) { public static MailingList load(String listEmail) {
if (listEmail == null) return null; if (listEmail == null) return null;
var ml = cache.get(listEmail); var ml = cache.get(listEmail);
if (ml == null) try { try {
var rs = Database.open() var rs = Database.open()
.select(TABLE_NAME) .select(TABLE_NAME)
.where(EMAIL,listEmail) .where(EMAIL,listEmail)
.compile().exec(); .compile().exec();
if (rs.next()) ml = MailingList.from(rs); if (rs.next()) {
if (ml == null ) ml = MailingList.from(rs);
ml.lastError = rs.getString(LAST_ERROR);
}
} catch (SQLException e) { } catch (SQLException e) {
LOG.debug("Konnte Mailing-Liste nicht laden: ",e); LOG.debug("Konnte Mailing-Liste nicht laden: ",e);
} }
@ -353,6 +358,7 @@ public class MailingList implements MessageHandler {
map.put(EMAIL,Map.of(PREFIX,parts[0],DOMAIN,parts[1])); map.put(EMAIL,Map.of(PREFIX,parts[0],DOMAIN,parts[1]));
map.put(NAME, name); map.put(NAME, name);
map.put(STATE, stateMap()); map.put(STATE, stateMap());
map.put(LAST_ERROR, lastError);
return map; return map;
} }
@ -382,6 +388,16 @@ public class MailingList implements MessageHandler {
return name; return name;
} }
@Override
public void onImapException(MessagingException e) {
try {
if (e instanceof AuthenticationFailedException afe) this.enable(false);
setLastError(e.getMessage());
} catch (SQLException sqle) {
LOG.warn("Database error during onImapException ({})",e.getMessage(),sqle);
}
}
@Override @Override
public void onMessageReceived(Message message) throws MessagingException { public void onMessageReceived(Message message) throws MessagingException {
LOG.info("Nachricht empfangen: {}",message.getFrom()); LOG.info("Nachricht empfangen: {}",message.getFrom());
@ -478,6 +494,7 @@ public class MailingList implements MessageHandler {
if (smtp.port() != 0) map.put(SMTP_PORT, smtp.port()); if (smtp.port() != 0) map.put(SMTP_PORT, smtp.port());
if (smtp.username() != null) map.put(SMTP_USER, smtp.username()); if (smtp.username() != null) map.put(SMTP_USER, smtp.username());
map.put(STATE,stateMap()); map.put(STATE,stateMap());
if (lastError != null) map.put(LAST_ERROR, lastError);
return map; return map;
} }
@ -551,6 +568,10 @@ public class MailingList implements MessageHandler {
return this; return this;
} }
private void setLastError(String message) throws SQLException {
Database.open().update(TABLE_NAME).set(LAST_ERROR,message).where(EMAIL,email()).run();
}
public Map<String,Integer> stateMap(){ public Map<String,Integer> stateMap(){
var map = new HashMap<String,Integer>(); var map = new HashMap<String,Integer>();
if (hasState(STATE_ENABLED)) map.put("enabled",VISIBLE); if (hasState(STATE_ENABLED)) map.put("enabled",VISIBLE);
@ -665,4 +686,32 @@ public class MailingList implements MessageHandler {
return new ArrayList<InternetAddress>().stream(); return new ArrayList<InternetAddress>().stream();
} }
} }
public void update(String name, String email, String imapHost, Integer imapPort, String imapUser, String imapPass, String inbox, String smtpHost, Integer smtpPort, String smtpUser, String smtpPass) throws SQLException {
imap.stop();
Database.open()
.update(TABLE_NAME)
.set(EMAIL, email)
.set(NAME, name)
.set(IMAP_HOST, imapHost)
.set(IMAP_PORT, imapPort)
.set(IMAP_USER, imapUser)
.set(IMAP_PASS, imapPass)
.set(INBOX,inbox)
.set(SMTP_HOST, smtpHost)
.set(SMTP_PORT, smtpPort)
.set(SMTP_USER, smtpUser)
.set(SMTP_PASS, smtpPass)
.where(EMAIL,email())
.compile()
.run();
if (!this.email.equals(email)){
ListMember.updateListEmail(this.email,email);
this.email = email;
}
this.name = name;
smtp = new SmtpClient(smtpHost,smtpPort,smtpUser,smtpPass);
imap = new ImapClient(imapHost,imapPort,imapUser,imapPass,inbox,this);
if (this.hasState(STATE_ENABLED)) imap.start().addListener(this);
}
} }

5
src/main/java/de/srsoftware/widerhall/mail/ImapClient.java

@ -14,6 +14,7 @@ public class ImapClient {
private static final Logger LOG = LoggerFactory.getLogger(ImapClient.class); private static final Logger LOG = LoggerFactory.getLogger(ImapClient.class);
private final int port; private final int port;
private final String host, username, password, folderName; private final String host, username, password, folderName;
private final ProblemListener problemListener;
private IMAPFolder inbox; private IMAPFolder inbox;
private ListeningThread listeningThread; private ListeningThread listeningThread;
private Heartbeat heartbeat; private Heartbeat heartbeat;
@ -47,6 +48,7 @@ public class ImapClient {
openInbox(); openInbox();
} catch (MessagingException e){ } catch (MessagingException e){
LOG.warn("Verbindung-Problem:",e); LOG.warn("Verbindung-Problem:",e);
problemListener.onImapException(e);
} }
} }
} }
@ -127,12 +129,13 @@ public class ImapClient {
} }
} }
public ImapClient(String host, int port, String username, String password, String folderName) { public ImapClient(String host, int port, String username, String password, String folderName,ProblemListener listener) {
this.host = host; this.host = host;
this.port = port; this.port = port;
this.username = username; this.username = username;
this.password = password; this.password = password;
this.folderName = folderName; this.folderName = folderName;
this.problemListener = listener;
} }
public ImapClient addListener(MessageHandler messageHandler) { public ImapClient addListener(MessageHandler messageHandler) {

7
src/main/java/de/srsoftware/widerhall/mail/ProblemListener.java

@ -0,0 +1,7 @@
package de.srsoftware.widerhall.mail;
import javax.mail.MessagingException;
public interface ProblemListener {
public void onImapException(MessagingException e);
}

107
src/main/java/de/srsoftware/widerhall/web/Web.java

@ -21,6 +21,7 @@ import java.util.Map;
import static de.srsoftware.widerhall.Constants.*; import static de.srsoftware.widerhall.Constants.*;
import static de.srsoftware.widerhall.Util.t; import static de.srsoftware.widerhall.Util.t;
import static de.srsoftware.widerhall.data.MailingList.*; import static de.srsoftware.widerhall.data.MailingList.*;
import static de.srsoftware.widerhall.data.User.PERMISSION_ADMIN;
public class Web extends TemplateServlet { public class Web extends TemplateServlet {
public static final String WEB_ROOT = "/web"; public static final String WEB_ROOT = "/web";
@ -29,6 +30,7 @@ public class Web extends TemplateServlet {
private static final String CSS = "css"; private static final String CSS = "css";
private static final Logger LOG = LoggerFactory.getLogger(Web.class); private static final Logger LOG = LoggerFactory.getLogger(Web.class);
private static final String ADMIN = "admin"; private static final String ADMIN = "admin";
private static final String EDIT_LIST = "edit_list";
private static final String INSPECT = "inspect"; private static final String INSPECT = "inspect";
private static final String LOGIN = "login"; private static final String LOGIN = "login";
private static final String LOGOUT = "logout"; private static final String LOGOUT = "logout";
@ -48,13 +50,10 @@ public class Web extends TemplateServlet {
private static final int PRIMARY_KEY_CONSTRAINT = 19; private static final int PRIMARY_KEY_CONSTRAINT = 19;
private String addList(HttpServletRequest req, HttpServletResponse resp) { private String addList(HttpServletRequest req, HttpServletResponse resp) {
var user = Util.getUser(req);
var o = req.getSession().getAttribute(USER); if (user == null) return redirectTo(LOGIN,resp);
if (!(o instanceof User user)) {
return redirectTo(LOGIN,resp);
}
var data = new HashMap<String, Object>(); var data = new HashMap<String, Object>();
data.put(USER, user); data.put(USER, user.safeMap());
if (!user.hashPermission(User.PERMISSION_CREATE_LISTS)){ if (!user.hashPermission(User.PERMISSION_CREATE_LISTS)){
data.put(ERROR,t("Ihnen ist es nicht gestattet, neue Mailinglisten anzulegen!")); data.put(ERROR,t("Ihnen ist es nicht gestattet, neue Mailinglisten anzulegen!"));
@ -128,7 +127,7 @@ public class Web extends TemplateServlet {
try { try {
var list = MailingList.create(email, name, imapHost, imapPort, imapUser, imapPass, inbox, smtpHost, smtpPort, smtpUser, smtpPass); var list = MailingList.create(email, name, imapHost, imapPort, imapUser, imapPass, inbox, smtpHost, smtpPort, smtpUser, smtpPass);
ListMember.create(list, user, ListMember.STATE_OWNER); ListMember.create(list, user, ListMember.STATE_OWNER);
return redirectTo(INDEX, resp); return redirectTo(ADMIN, resp);
} catch (SQLException e) { } catch (SQLException e) {
return t("Erzeugen der Liste '{}' fehlgeschlagen: {}", name, e.getMessage()); return t("Erzeugen der Liste '{}' fehlgeschlagen: {}", name, e.getMessage());
} }
@ -164,6 +163,91 @@ public class Web extends TemplateServlet {
if (error != null) resp.sendError(400,error); if (error != null) resp.sendError(400,error);
} }
public String editList(HttpServletRequest req, HttpServletResponse resp) {
var user = Util.getUser(req);
if (user == null) return redirectTo(LOGIN,resp);
var data = new HashMap<String, Object>();
data.put(USER,user.safeMap());
var list = Util.getMailingList(req);
data.put(LIST,list.safeMap());
try {
var allowed = user.hashPermission(PERMISSION_ADMIN) || ListMember.load(list,user).isOwner();
if (!allowed) return loadTemplate(ADMIN,data,resp);
var name = req.getParameter(NAME);
data.put(NAME, name);
var email = req.getParameter(EMAIL);
data.put(EMAIL, email);
var imapHost = req.getParameter(IMAP_HOST);
data.put(IMAP_HOST, imapHost);
var imapUser = req.getParameter(IMAP_USER);
data.put(IMAP_USER, imapUser);
var imapPass = req.getParameter(IMAP_PASS);
var inbox = req.getParameter(INBOX);
if (inbox == null || inbox.isBlank()) inbox = DEFAULT_INBOX;
data.put(INBOX, inbox);
var smtpHost = req.getParameter(SMTP_HOST);
data.put(SMTP_HOST, smtpHost);
var smtpUser = req.getParameter(SMTP_USER);
data.put(SMTP_USER, smtpUser);
var smtpPass = req.getParameter(SMTP_PASS);
Integer imapPort = 993;
data.put(IMAP_PORT, imapPort);
Integer smtpPort = 465;
data.put(SMTP_PORT, smtpPort);
if (name == null || name.isBlank() || email == null || email.isBlank()) {
data.put(ERROR, "Listen-Name und -adresse sind erforderlich!");
return loadTemplate(EDIT_LIST, data, resp);
}
if (!Util.isEmail(email)) {
data.put(ERROR, t("Listen-E-Mail ({}) ist keine gültige Mailadresse!", email));
return loadTemplate(EDIT_LIST, data, resp);
}
if (imapHost == null || imapHost.isBlank() || imapUser == null || imapUser.isBlank() || imapPass == null || imapPass.isBlank()) {
data.put(ERROR, "IMAP-Zugangsdaten sind erforderlich!");
return loadTemplate(EDIT_LIST, data, resp);
}
try {
imapPort = Integer.parseInt(req.getParameter(IMAP_PORT));
data.put(IMAP_PORT, imapPort);
} catch (NumberFormatException nfe) {
data.put(ERROR, t("'{}' ist keine gültige Port-Nummer!", req.getParameter(IMAP_PORT)));
return loadTemplate(EDIT_LIST, data, resp);
}
if (smtpHost == null || smtpHost.isBlank() || smtpUser == null || smtpUser.isBlank() || smtpPass == null || smtpPass.isBlank()) {
data.put(ERROR, "SMTP-Zugangsdaten sind erforderlich!");
return loadTemplate(EDIT_LIST, data, resp);
}
try {
smtpPort = Integer.parseInt(req.getParameter(SMTP_PORT));
data.put(SMTP_PORT, smtpPort);
} catch (NumberFormatException nfe) {
data.put(ERROR, t("'{}' ist keine gültige Port-Nummer!", req.getParameter(SMTP_PORT)));
return loadTemplate(EDIT_LIST, data, resp);
}
list.update(name,email,imapHost,imapPort,imapUser,imapPass,inbox,smtpHost,smtpPort,smtpUser,smtpPass);
return loadTemplate(ADMIN,data,resp);
} catch (SQLException e) {
LOG.warn("Editing list {} by {} failed",list.email(),user.email(),e);
return t("Bearbeiten der Liste {} durch {} fehlgeschlagen",list.email(),user.email());
}
}
private SQLException getCausingException(SQLException sqle) { private SQLException getCausingException(SQLException sqle) {
Throwable cause = sqle.getCause(); Throwable cause = sqle.getCause();
while (cause instanceof SQLException){ while (cause instanceof SQLException){
@ -230,7 +314,10 @@ public class Web extends TemplateServlet {
if (user != null){ if (user != null){
if (list != null) data.put(LIST,req.getParameter(LIST)); if (list != null) data.put(LIST,req.getParameter(LIST));
//data.put(NOTES,notes); switch (path){
case EDIT_LIST:
return editList(req,resp);
}
return loadTemplate(path,data,resp); return loadTemplate(path,data,resp);
} }
return redirectTo(LOGIN,resp); return redirectTo(LOGIN,resp);
@ -263,6 +350,8 @@ public class Web extends TemplateServlet {
switch (path){ switch (path){
case ADD_LIST: case ADD_LIST:
return addList(req,resp); return addList(req,resp);
case EDIT_LIST:
return editList(req,resp);
case INSPECT: case INSPECT:
return inspect(req,resp); return inspect(req,resp);
case LOGIN: case LOGIN:
@ -367,7 +456,7 @@ public class Web extends TemplateServlet {
try { try {
var user = User.create(email, name, pass); var user = User.create(email, name, pass);
if (firstUser) user.addPermission(User.PERMISSION_ADMIN|User.PERMISSION_CREATE_LISTS); if (firstUser) user.addPermission(PERMISSION_ADMIN|User.PERMISSION_CREATE_LISTS);
req.getSession().setAttribute("user",user); req.getSession().setAttribute("user",user);
return redirectTo(INDEX,resp); return redirectTo(INDEX,resp);
} catch (SQLException e) { } catch (SQLException e) {

62
static/templates/add_list.st

@ -9,66 +9,8 @@
<body id="add_list"> <body id="add_list">
«navigation()» «navigation()»
«userinfo()» «userinfo()»
<h1>Widerhall Listen-Erzeugung</h1>
«messages()» «messages()»
<form method="POST" action="add_list"> <h1>Widerhall List Creation</h1>
<fieldset> «list_data_form()»
<legend>Listen-Konfiguration</legend>
<fieldset>
<legend>Basis-Daten</legend>
<label>
<input type="text" name="name" value="«data.name»" id="name" />
Name der ML
</label>
<label>
<input type="text" name="email" value="«data.email»" id="email" />
Email-Adresse
</label>
</fieldset>
<fieldset>
<legend>IMAP-Protokoll</legend>
<label>
<input type="text" name="imap_host" value="«data.imap_host»" id="imap_host" />
Hostname
</label>
<label>
<input type="number" name="imap_port" value="«data.imap_port»" id="imap_port" />
Port
</label>
<label>
<input type="text" name="imap_user" value="«data.imap_user»" id="imap_user" />
Benutzername
</label>
<label>
<input type="password" name="imap_pass" value="«data.imap_pass»" id="imap_pass" />
Passwort
</label>
<label>
<input type="text" name="inbox" value="«if(data.inbox)»«data.inbox»«else»INBOX«endif»" id="imap_inbox" />
Name des Posteingangs-Ordners
</label>
</fieldset>
<fieldset>
<legend>SMTP-Protokoll</legend>
<label>
<input type="text" name="smtp_host" value="«data.smtp_host»" id="smtp_host" />
Hostname
</label>
<label>
<input type="number" name="smtp_port" value="«data.smtp_port»" id="smtp_port" />
Port
</label>
<label>
<input type="text" name="smtp_user" value="«data.smtp_user»" id="smtp_user" />
Benutzername
</label>
<label>
<input type="password" name="smtp_pass" value="«data.smtp_pass»" id="smtp_pass" />
Passwort
</label>
</fieldset>
<button type="submit">neue ML speichern</button>
</fieldset>
</form>
</body> </body>
</html> </html>

4
static/templates/css.st

@ -3,11 +3,11 @@ label {
margin: 5px 0; margin: 5px 0;
} }
#add_list form, form#list_data,
#login form, #login form,
#register form, #register form,
#subscribe form{ #subscribe form{
width: 450px; width: 500px;
margin: 0 auto; margin: 0 auto;
} }

17
static/templates/edit_list.st

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script src="jquery"></script>
<script src="js"></script>
<link rel="stylesheet" href="css" />
</head>
<body>
«navigation()»
«userinfo()»
«messages()»
<h1>Widerhall List Setup</h1>
«list_data_form()»
«footer()»
</body>
</html>

1
static/templates/inspect.st

@ -14,6 +14,7 @@
<form method="POST"> <form method="POST">
<fieldset> <fieldset>
<legend>Einstellungen</legend> <legend>Einstellungen</legend>
Diese Seite zeigt Konfigurations-Optionen für die Mailingliste. Um Login-Daten zu ändern, gehe zu <a href="edit_list?list=«data.list»">Listenbarebeitung</a>.
<fieldset> <fieldset>
<legend>Weiterleitungs-Rechte</legend> <legend>Weiterleitungs-Rechte</legend>
<p> <p>

6
static/templates/js.st

@ -110,7 +110,9 @@ function showListOfModeratedLists(data){
if (list.state[state] > 0) states.push(state); if (list.state[state] > 0) states.push(state);
} }
$('<td/>').text(states.toString()).appendTo(row); $('<td/>').text(states.toString()).appendTo(row);
if (list.last_error){
$('<td/>').html('<span class="error">'+list.last_error+'</span>').appendTo(row);
} else $('<td/>').text('-').appendTo(row);
let select = $('<select/>',{name:addr}).change(function () { let select = $('<select/>',{name:addr}).change(function () {
let action = $(this).children("option:selected").val(); let action = $(this).children("option:selected").val();
let list = $(this).attr('name'); let list = $(this).attr('name');
@ -123,11 +125,9 @@ function showListOfModeratedLists(data){
$('<td/>').text(list.imap_host).appendTo(row); $('<td/>').text(list.imap_host).appendTo(row);
$('<td/>').text(list.imap_port).appendTo(row); $('<td/>').text(list.imap_port).appendTo(row);
$('<td/>').text(list.imap_user).appendTo(row);
$('<td/>').text(list.inbox).appendTo(row); $('<td/>').text(list.inbox).appendTo(row);
$('<td/>').text(list.smtp_host).appendTo(row); $('<td/>').text(list.smtp_host).appendTo(row);
$('<td/>').text(list.smtp_port).appendTo(row); $('<td/>').text(list.smtp_port).appendTo(row);
$('<td/>').text(list.smtp_user).appendTo(row);
row.appendTo('#listlist'); row.appendTo('#listlist');
} }
if (data.user.permissions.includes('create lists')){ if (data.user.permissions.includes('create lists')){

59
static/templates/list_data_form.st

@ -0,0 +1,59 @@
<form id="list_data" method="POST">
<fieldset>
<legend>Listen-Konfiguration</legend>
<fieldset>
<legend>Basisdaten</legend>
<label>
<input type="text" name="name" value="«if(data.name)»«data.name»«else»«data.list.name»«endif»" id="name" />
Name der Mailing-Liste
</label>
<label>
<input type="text" name="email" value="«if(data.email)»«data.email»«else»«data.list.email.prefix»@«data.list.email.domain»«endif»" id="email" />
Email-Adresse der ML
</label>
</fieldset>
<fieldset>
<legend>IMAP-Protocoll</legend>
<label>
<input type="text" name="imap_host" value="«if(data.imap_host)»«data.imap_host»«else»«data.list.imap_host»«endif»" id="imap_host" />
Hostname
</label>
<label>
<input type="number" name="imap_port" value="«if(data.imap_port)»«data.imap_port»«else»«data.list.imap_port»«endif»" id="imap_port" />
Port
</label>
<label>
<input type="text" name="imap_user" value="«if(data.imap_user)»«data.imap_user»«else»«data.list.imap_user»«endif»" id="imap_user" />
Benutzername
</label>
<label>
<input type="password" name="imap_pass" value="«data.imap_pass»" id="imap_pass" />
Passwort
</label>
<label>
<input type="text" name="inbox" value="«if(data.inbox)»«data.inbox»«else»INBOX«endif»" id="imap_inbox" />
Name des Posteingangs-Ordners
</label>
</fieldset>
<fieldset>
<legend>SMTP-Protocoll</legend>
<label>
<input type="text" name="smtp_host" value="«if(data.smtp_host)»«data.smtp_host»«else»«data.list.smtp_host»«endif»" id="smtp_host" />
Hostname
</label>
<label>
<input type="number" name="smtp_port" value="«if(data.smtp_port)»«data.smtp_port»«else»«data.list.smtp_port»«endif»" id="smtp_port" />
Port
</label>
<label>
<input type="text" name="smtp_user" value="«if(data.smtp_user)»«data.smtp_user»«else»«data.list.smtp_user»«endif»" id="smtp_user" />
Benutzername
</label>
<label>
<input type="password" name="smtp_pass" value="«data.smtp_pass»" id="smtp_pass" />
Passwort
</label>
</fieldset>
<button type="submit">Mailing-Liste speichern</button>
</fieldset>
</form>

3
static/templates/listadminlist.st

@ -10,14 +10,13 @@
<th>Name</th> <th>Name</th>
<th>Adresse</th> <th>Adresse</th>
<th>Status</th> <th>Status</th>
<th>Letzter Fehler</th>
<th>Aktionen</th> <th>Aktionen</th>
<th>Host</th> <th>Host</th>
<th>Port</th> <th>Port</th>
<th>Benutzername</th>
<th>Posteingang</th> <th>Posteingang</th>
<th>Host</th> <th>Host</th>
<th>Port</th> <th>Port</th>
<th>Benutzername</th>
</tr> </tr>
</table> </table>
<a href="add_list">Neue Mailing-Liste anlegen</a> <a href="add_list">Neue Mailing-Liste anlegen</a>

6
static/templates/navigation.st

@ -1,5 +1,9 @@
<nav> <nav>
<a href="index">Home</a> <a href="index">Home</a>
<a href="admin">Administration</a> <a href="admin">Administration</a>
<!-- a class="button" href="reload" />Templates neu laden</a --> <script type="text/javascript">
if ('«data.user.permissions»'.includes('admin')){
$('<a/>',{class:'button',href:'reload'}).text('Templates neu laden').appendTo($('nav'));
}
</script>
</nav> </nav>
Loading…
Cancel
Save