Skip to content
Snippets Groups Projects
Commit e6153ad1 authored by gnaegi's avatar gnaegi
Browse files

OO-2802 implement mail subject for reminder mail

parent f3d895f8
No related branches found
No related tags found
No related merge requests found
Showing
with 72 additions and 10 deletions
...@@ -66,6 +66,7 @@ public class CourseReminderEditController extends FormBasicController { ...@@ -66,6 +66,7 @@ public class CourseReminderEditController extends FormBasicController {
private final String[] typeKeys; private final String[] typeKeys;
private final String[] typeValues; private final String[] typeValues;
private TextElement subjectEl;
private RichTextElement emailEl; private RichTextElement emailEl;
private TextElement descriptionEl; private TextElement descriptionEl;
private FormLayoutContainer rulesCont; private FormLayoutContainer rulesCont;
...@@ -113,6 +114,7 @@ public class CourseReminderEditController extends FormBasicController { ...@@ -113,6 +114,7 @@ public class CourseReminderEditController extends FormBasicController {
String desc = reminder.getDescription(); String desc = reminder.getDescription();
descriptionEl = uifactory.addTextElement("reminder.description", "reminder.description", 128, desc, generalCont); descriptionEl = uifactory.addTextElement("reminder.description", "reminder.description", 128, desc, generalCont);
descriptionEl.setMandatory(true);
descriptionEl.setElementCssClass("o_sel_course_reminder_desc"); descriptionEl.setElementCssClass("o_sel_course_reminder_desc");
String sendTime = getSendTimeDescription(); String sendTime = getSendTimeDescription();
...@@ -147,12 +149,19 @@ public class CourseReminderEditController extends FormBasicController { ...@@ -147,12 +149,19 @@ public class CourseReminderEditController extends FormBasicController {
FormLayoutContainer contentCont = FormLayoutContainer.createVerticalFormLayout("contents", getTranslator()); FormLayoutContainer contentCont = FormLayoutContainer.createVerticalFormLayout("contents", getTranslator());
contentCont.setRootForm(mainForm); contentCont.setRootForm(mainForm);
formLayout.add(contentCont); formLayout.add(contentCont);
//email subject
String subject = reminder.getEmailSubject();
subjectEl = uifactory.addTextElement("reminder.subject", "reminder.subject", 128, subject, contentCont);
subjectEl.setMandatory(true);
subjectEl.setElementCssClass("o_sel_course_reminder_subject");
String emailContent = reminder == null ? null : reminder.getEmailBody(); String emailContent = reminder == null ? null : reminder.getEmailBody();
if(!StringHelper.containsNonWhitespace(emailContent)) { if(!StringHelper.containsNonWhitespace(emailContent)) {
emailContent = translate("reminder.def.body"); emailContent = translate("reminder.def.body");
} }
emailEl = uifactory.addRichTextElementForStringDataMinimalistic("email.content", "email.content", emailContent, 10, 60, contentCont, getWindowControl()); emailEl = uifactory.addRichTextElementForStringDataMinimalistic("email.content", "email.content", emailContent, 10, 60, contentCont, getWindowControl());
emailEl.setMandatory(true);
String buttonPage = velocity_root + "/edit_rules_buttons.html"; String buttonPage = velocity_root + "/edit_rules_buttons.html";
FormLayoutContainer buttonLayout = FormLayoutContainer.createCustomFormLayout("buttons", getTranslator(), buttonPage); FormLayoutContainer buttonLayout = FormLayoutContainer.createCustomFormLayout("buttons", getTranslator(), buttonPage);
...@@ -230,6 +239,12 @@ public class CourseReminderEditController extends FormBasicController { ...@@ -230,6 +239,12 @@ public class CourseReminderEditController extends FormBasicController {
descriptionEl.setErrorKey("form.mandatory.hover", null); descriptionEl.setErrorKey("form.mandatory.hover", null);
allOk &= false; allOk &= false;
} }
subjectEl.clearError();
if(!StringHelper.containsNonWhitespace(subjectEl.getValue())) {
subjectEl.setErrorKey("form.mandatory.hover", null);
allOk &= false;
}
emailEl.clearError(); emailEl.clearError();
if(!StringHelper.containsNonWhitespace(emailEl.getValue())) { if(!StringHelper.containsNonWhitespace(emailEl.getValue())) {
...@@ -328,7 +343,10 @@ public class CourseReminderEditController extends FormBasicController { ...@@ -328,7 +343,10 @@ public class CourseReminderEditController extends FormBasicController {
String configuration = reminderManager.toXML(rules); String configuration = reminderManager.toXML(rules);
reminder.setConfiguration(configuration); reminder.setConfiguration(configuration);
String emailSubject = subjectEl.getValue();
reminder.setEmailSubject(emailSubject);
String emailBody = emailEl.getValue(); String emailBody = emailEl.getValue();
reminder.setEmailBody(emailBody); reminder.setEmailBody(emailBody);
......
...@@ -23,7 +23,8 @@ new.reminder=Neue Erinnerung ...@@ -23,7 +23,8 @@ new.reminder=Neue Erinnerung
passed=Bestanden passed=Bestanden
points=Punkte points=Punkte
reminder.def.body=<p>Liebe(r) $firstname $lastname</p><p>Sie haben sich in den Kurs "$coursename" eingetragen. Jetzt w\u00E4re ein guter Zeitpunkt diesen zu besuchen\!</p><p>$courseurl</p><p>Viele Gr\u00FCsse</p> reminder.def.body=<p>Liebe(r) $firstname $lastname</p><p>Sie haben sich in den Kurs "$coursename" eingetragen. Jetzt w\u00E4re ein guter Zeitpunkt diesen zu besuchen\!</p><p>$courseurl</p><p>Viele Gr\u00FCsse</p>
reminder.description=Beschreibung reminder.description=Beschreibung (nur für Autor)
reminder.subject=E-Mail-Betreff
reminder.id=ID reminder.id=ID
reminder.resend=Erinnerung wurde erfolgreich geschickt. reminder.resend=Erinnerung wurde erfolgreich geschickt.
reminders=Erinnerungen reminders=Erinnerungen
......
...@@ -23,7 +23,8 @@ new.reminder=New reminder ...@@ -23,7 +23,8 @@ new.reminder=New reminder
passed=Passed passed=Passed
points=Points points=Points
reminder.def.body=<p>Dear $firstname $lastname</p><p>You are registered in the course "$coursename". Now would be a good time to view it!</p><p>$courseurl</p><p>Best regards</p> reminder.def.body=<p>Dear $firstname $lastname</p><p>You are registered in the course "$coursename". Now would be a good time to view it!</p><p>$courseurl</p><p>Best regards</p>
reminder.description=Description reminder.description=Description (only for author)
reminder.subject=E-mail subject
reminder.id=ID reminder.id=ID
reminder.resend=Reminder was successfully sent. reminder.resend=Reminder was successfully sent.
reminders=Reminders reminders=Reminders
......
...@@ -42,7 +42,11 @@ public interface Reminder extends CreateInfo, ModifiedInfo { ...@@ -42,7 +42,11 @@ public interface Reminder extends CreateInfo, ModifiedInfo {
public String getConfiguration(); public String getConfiguration();
public void setConfiguration(String configuration); public void setConfiguration(String configuration);
public String getEmailSubject();
public void setEmailSubject(String emailSubject);
public String getEmailBody(); public String getEmailBody();
public void setEmailBody(String emailBody); public void setEmailBody(String emailBody);
......
...@@ -100,6 +100,7 @@ public class ReminderDAO { ...@@ -100,6 +100,7 @@ public class ReminderDAO {
reminder.setCreator(creator); reminder.setCreator(creator);
reminder.setDescription(toCopy.getDescription() + " (Copy)"); reminder.setDescription(toCopy.getDescription() + " (Copy)");
reminder.setConfiguration(toCopy.getConfiguration()); reminder.setConfiguration(toCopy.getConfiguration());
reminder.setEmailSubject(toCopy.getEmailSubject());
reminder.setEmailBody(toCopy.getEmailBody()); reminder.setEmailBody(toCopy.getEmailBody());
dbInstance.getCurrentEntityManager().persist(reminder); dbInstance.getCurrentEntityManager().persist(reminder);
return reminder; return reminder;
......
...@@ -210,6 +210,7 @@ public class ReminderServiceImpl implements ReminderService { ...@@ -210,6 +210,7 @@ public class ReminderServiceImpl implements ReminderService {
Reminder reminder = reminderDao.createReminder(newEntry, creator); Reminder reminder = reminderDao.createReminder(newEntry, creator);
reminder.setDescription(importReminder.getDescription()); reminder.setDescription(importReminder.getDescription());
reminder.setEmailBody(importReminder.getEmailBody()); reminder.setEmailBody(importReminder.getEmailBody());
reminder.setEmailSubject(importReminder.getEmailSubject() == null ? importReminder.getDescription() : importReminder.getEmailSubject());
reminder.setConfiguration(importReminder.getConfiguration()); reminder.setConfiguration(importReminder.getConfiguration());
reminders.add(reminder); reminders.add(reminder);
} }
...@@ -243,8 +244,13 @@ public class ReminderServiceImpl implements ReminderService { ...@@ -243,8 +244,13 @@ public class ReminderServiceImpl implements ReminderService {
MailContext context = new MailContextImpl("[RepositoryEntry:" + entry.getKey() + "]"); MailContext context = new MailContextImpl("[RepositoryEntry:" + entry.getKey() + "]");
Translator trans = Util.createPackageTranslator(ReminderAdminController.class, I18nModule.getDefaultLocale()); Translator trans = Util.createPackageTranslator(ReminderAdminController.class, I18nModule.getDefaultLocale());
String subject = trans.translate("reminder.subject"); String subject = reminder.getEmailSubject();
String body = reminder.getEmailBody(); String body = reminder.getEmailBody();
if (body.contains("$courseurl")) {
body = body.replace("$courseurl", "<a href=\"$courseurl\">$courseurl</a>");
} else {
body = body + "<p>---<br />" + trans.translate("reminder.from.course", new String[] {"<a href=\"$courseurl\">$coursename</a>"}) + "</p>";
}
String metaId = UUID.randomUUID().toString(); String metaId = UUID.randomUUID().toString();
String url = Settings.getServerContextPathURI() + "/url/RepositoryEntry/" + entry.getKey(); String url = Settings.getServerContextPathURI() + "/url/RepositoryEntry/" + entry.getKey();
......
...@@ -35,6 +35,7 @@ public class ImportExportReminder implements Serializable { ...@@ -35,6 +35,7 @@ public class ImportExportReminder implements Serializable {
private String description; private String description;
private String configuration; private String configuration;
private String emailSubject; // added in OO 12.0
private String emailBody; private String emailBody;
public ImportExportReminder() { public ImportExportReminder() {
...@@ -44,6 +45,7 @@ public class ImportExportReminder implements Serializable { ...@@ -44,6 +45,7 @@ public class ImportExportReminder implements Serializable {
public ImportExportReminder(Reminder reminder) { public ImportExportReminder(Reminder reminder) {
description = reminder.getDescription(); description = reminder.getDescription();
configuration = reminder.getConfiguration(); configuration = reminder.getConfiguration();
emailSubject = reminder.getEmailSubject();
emailBody = reminder.getEmailBody(); emailBody = reminder.getEmailBody();
} }
...@@ -63,6 +65,14 @@ public class ImportExportReminder implements Serializable { ...@@ -63,6 +65,14 @@ public class ImportExportReminder implements Serializable {
this.configuration = configuration; this.configuration = configuration;
} }
public String getEmailSubject() {
return emailSubject;
}
public void setEmailSubject(String emailSubject) {
this.emailSubject = emailSubject;
}
public String getEmailBody() { public String getEmailBody() {
return emailBody; return emailBody;
} }
......
...@@ -93,6 +93,8 @@ public class ReminderImpl implements Reminder, Persistable { ...@@ -93,6 +93,8 @@ public class ReminderImpl implements Reminder, Persistable {
private Date startDate; private Date startDate;
@Column(name="r_configuration", nullable=true, insertable=true, updatable=true) @Column(name="r_configuration", nullable=true, insertable=true, updatable=true)
private String configuration; private String configuration;
@Column(name="r_email_Subject", nullable=true, insertable=true, updatable=true)
private String emailSubject;
@Column(name="r_email_body", nullable=true, insertable=true, updatable=true) @Column(name="r_email_body", nullable=true, insertable=true, updatable=true)
private String emailBody; private String emailBody;
...@@ -172,6 +174,16 @@ public class ReminderImpl implements Reminder, Persistable { ...@@ -172,6 +174,16 @@ public class ReminderImpl implements Reminder, Persistable {
this.configuration = configuration; this.configuration = configuration;
} }
@Override
public String getEmailSubject() {
return emailSubject;
}
@Override
public void setEmailSubject(String emailSubject) {
this.emailSubject = emailSubject;
}
@Override @Override
public String getEmailBody() { public String getEmailBody() {
return emailBody; return emailBody;
......
...@@ -17,7 +17,7 @@ interval.4=Alle vier Stunden ...@@ -17,7 +17,7 @@ interval.4=Alle vier Stunden
interval.2=Alle zwei Stunden interval.2=Alle zwei Stunden
interval.1=Jede Stunde interval.1=Jede Stunde
reminder.admin.title=Kurserinnerungen reminder.admin.title=Kurserinnerungen
reminder.subject=Kurserinnerung reminder.from.course=Erinnerung aus Kurs {0}
rule.after.date=Nach Datum rule.after.date=Nach Datum
rule.course.enrollment.date=Einschreibedatum rule.course.enrollment.date=Einschreibedatum
rule.course.role=Kursrolle rule.course.role=Kursrolle
......
...@@ -17,7 +17,7 @@ interval.4=Every 4 hours ...@@ -17,7 +17,7 @@ interval.4=Every 4 hours
interval.2=Every 2 hours interval.2=Every 2 hours
interval.1=Every hour interval.1=Every hour
reminder.admin.title=Course reminders reminder.admin.title=Course reminders
reminder.subject=Course reminder reminder.from.course=Reminder from course {0}
rule.after.date=After date rule.after.date=After date
rule.course.enrollment.date=Enrollment date rule.course.enrollment.date=Enrollment date
rule.course.role=Course role rule.course.role=Course role
......
...@@ -17,7 +17,6 @@ interval.4=Toutes les quatre heures ...@@ -17,7 +17,6 @@ interval.4=Toutes les quatre heures
interval.6=Quatre fois par jour interval.6=Quatre fois par jour
interval.8=Trois fois par jour interval.8=Trois fois par jour
reminder.admin.title=Rappels des cours reminder.admin.title=Rappels des cours
reminder.subject=Rappel
rule.after.date=Fonction de la date rule.after.date=Fonction de la date
rule.course.enrollment.date=Date d'inscription rule.course.enrollment.date=Date d'inscription
rule.course.role=R\u00F4le au sein du cours rule.course.role=R\u00F4le au sein du cours
......
...@@ -17,7 +17,6 @@ interval.4=Ogni 4 ore ...@@ -17,7 +17,6 @@ interval.4=Ogni 4 ore
interval.6=Quattro volte al giorno interval.6=Quattro volte al giorno
interval.8=Tre volte al giorno interval.8=Tre volte al giorno
reminder.admin.title=Promemoria dei corsi reminder.admin.title=Promemoria dei corsi
reminder.subject=Promemoria di corso
rule.after.date=Dopo la data rule.after.date=Dopo la data
rule.course.enrollment.date=Data di iscrizione rule.course.enrollment.date=Data di iscrizione
rule.course.role=Ruolo nel corso rule.course.role=Ruolo nel corso
......
...@@ -17,7 +17,6 @@ interval.4=A cada 4 horas ...@@ -17,7 +17,6 @@ interval.4=A cada 4 horas
interval.6=4 vezes ao dia interval.6=4 vezes ao dia
interval.8=3 vezes ao dia interval.8=3 vezes ao dia
reminder.admin.title=Lembretes de Curso reminder.admin.title=Lembretes de Curso
reminder.subject=Lembrete
rule.after.date=Ap\u00F3s data rule.after.date=Ap\u00F3s data
rule.course.enrollment.date=Data de inscri\u00E7\u00E3o rule.course.enrollment.date=Data de inscri\u00E7\u00E3o
rule.course.role=Fun\u00E7\u00E3o curso rule.course.role=Fun\u00E7\u00E3o curso
......
...@@ -458,6 +458,7 @@ public class CourseHandler implements RepositoryHandler { ...@@ -458,6 +458,7 @@ public class CourseHandler implements RepositoryHandler {
Reminder clonedReminder = reminderService.createReminder(target, author); Reminder clonedReminder = reminderService.createReminder(target, author);
clonedReminder.setDescription(reminder.getDescription()); clonedReminder.setDescription(reminder.getDescription());
clonedReminder.setEmailSubject(reminder.getEmailSubject());
clonedReminder.setEmailBody(reminder.getEmailBody()); clonedReminder.setEmailBody(reminder.getEmailBody());
clonedReminder.setConfiguration(reminderService.toXML(clonedRules)); clonedReminder.setConfiguration(reminderService.toXML(clonedRules));
reminderService.save(clonedReminder); reminderService.save(clonedReminder);
......
...@@ -208,3 +208,6 @@ alter table o_lecture_block_audit_log ENGINE = InnoDB; ...@@ -208,3 +208,6 @@ alter table o_lecture_block_audit_log ENGINE = InnoDB;
create index idx_lec_audit_entry_idx on o_lecture_block_audit_log(fk_entry); create index idx_lec_audit_entry_idx on o_lecture_block_audit_log(fk_entry);
create index idx_lec_audit_ident_idx on o_lecture_block_audit_log(fk_identity); create index idx_lec_audit_ident_idx on o_lecture_block_audit_log(fk_identity);
alter table o_rem_reminder add column r_email_subject varchar(255);
update o_rem_reminder set r_email_subject=r_description;
...@@ -1869,6 +1869,7 @@ create table o_rem_reminder ( ...@@ -1869,6 +1869,7 @@ create table o_rem_reminder (
r_start datetime, r_start datetime,
r_sendtime varchar(16), r_sendtime varchar(16),
r_configuration mediumtext, r_configuration mediumtext,
r_email_subject varchar(255),
r_email_body mediumtext, r_email_body mediumtext,
fk_creator bigint not null, fk_creator bigint not null,
fk_entry bigint not null, fk_entry bigint not null,
......
...@@ -210,4 +210,7 @@ create index idx_lec_audit_entry_idx on o_lecture_block_audit_log(fk_entry); ...@@ -210,4 +210,7 @@ create index idx_lec_audit_entry_idx on o_lecture_block_audit_log(fk_entry);
create index idx_lec_audit_ident_idx on o_lecture_block_audit_log(fk_identity); create index idx_lec_audit_ident_idx on o_lecture_block_audit_log(fk_identity);
alter table o_rem_reminder add column r_email_subject varchar(255);
update o_rem_reminder set r_email_subject=r_description;
...@@ -1892,6 +1892,7 @@ create table o_rem_reminder ( ...@@ -1892,6 +1892,7 @@ create table o_rem_reminder (
r_start date, r_start date,
r_sendtime varchar(16), r_sendtime varchar(16),
r_configuration clob, r_configuration clob,
r_email_subject varchar(255),
r_email_body clob, r_email_body clob,
fk_creator number(20) not null, fk_creator number(20) not null,
fk_entry number(20) not null, fk_entry number(20) not null,
......
...@@ -210,5 +210,7 @@ create index idx_lec_audit_entry_idx on o_lecture_block_audit_log(fk_entry); ...@@ -210,5 +210,7 @@ create index idx_lec_audit_entry_idx on o_lecture_block_audit_log(fk_entry);
create index idx_lec_audit_ident_idx on o_lecture_block_audit_log(fk_identity); create index idx_lec_audit_ident_idx on o_lecture_block_audit_log(fk_identity);
alter table o_rem_reminder add column r_email_subject varchar(255);
update o_rem_reminder set r_email_subject=r_description;
...@@ -1866,6 +1866,7 @@ create table o_rem_reminder ( ...@@ -1866,6 +1866,7 @@ create table o_rem_reminder (
r_start timestamp, r_start timestamp,
r_sendtime varchar(16), r_sendtime varchar(16),
r_configuration text, r_configuration text,
r_email_subject varchar(255),
r_email_body text, r_email_body text,
fk_creator int8 not null, fk_creator int8 not null,
fk_entry int8 not null, fk_entry int8 not null,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment