Skip to content
Snippets Groups Projects
Commit f21d52ab authored by Dirk Furrer's avatar Dirk Furrer
Browse files

OO-1535: changed ContactFrom/Controller to accept email addresses by the user

parent c56f017e
No related branches found
No related tags found
No related merge requests found
......@@ -89,7 +89,7 @@ public class ImpressumAdminController extends FormBasicController {
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormTitle("menu.impressum");
setFormDescription("config.hint");
boolean enabled = impressumModule.isEnabled();
String[] enableKeys = new String[]{ "on" };
......
......@@ -18,3 +18,4 @@ impressum.file=Impressum auf
termofuse.file=Term of use
enable=ein
enable.impressum=Impressum einschalten
config.hint=Hier k\u00F6nnen Sie das Impressum ein- und ausschalten, positionieren und den Impressumstext \u00E4ndern.
......@@ -10,11 +10,12 @@ contactform.intro=Contact form for general requests.
contactform.title=Contact
enable=on
enable.impressum=Enable imprint
impressum.file=Impressum in
impressum.file=Imprint in
main.menu.title=$\:menu.impressum
main.menu.title.alt=$\:menu.impressum
menu.impressum=Imprint
menu.impressum.alt=$\:menu.impressum
config.hint=Here you can enable or disable the imprint page, choose the position and change the Impress text.
position=Position
position.footer=Footer
position.top=Top
......
......@@ -126,7 +126,7 @@ public class BGEmailCompositionStepController extends StepFormBasicController
MailBundle ccBundle = new MailBundle();
ccBundle.setContext(context);
ccBundle.setFromId(getIdentity());
ccBundle.setCc(contactForm.getEmailFrom());
ccBundle.setCc(getIdentity());
ccBundle.setContent(contactForm.getSubject(), contactForm.getBody(), attachments);
MailerResult ccResult = mailService.sendMessage(ccBundle);
......
......@@ -57,6 +57,7 @@ import org.olat.core.util.StringHelper;
import org.olat.core.util.Util;
import org.olat.core.util.filter.FilterFactory;
import org.olat.core.util.mail.ContactList;
import org.olat.core.util.mail.EmailAddressValidator;
import org.olat.core.util.mail.MailModule;
import org.olat.user.UserManager;
......@@ -196,6 +197,14 @@ public class ContactForm extends FormBasicController {
if(readOnly){
return true;
}
boolean fromMailAddOk = true;
if(tfrom.isEnabled()) {
String mailInputValue = tfrom.getValue().trim();
fromMailAddOk = EmailAddressValidator.isValidEmailAddress(mailInputValue);
if(!fromMailAddOk){
tfrom.setErrorKey("error.field.not.valid.email",null);
}
}
boolean subjectOk = !tsubject.isEmpty("error.field.not.empty");
boolean bodyOk = !tbody.isEmpty("error.field.not.empty");
// the body message may not be longer than about 4 pages or 10000
......@@ -211,14 +220,14 @@ public class ContactForm extends FormBasicController {
//toOk = toOk && ttoBig.notLongerThan(30000, "input.toolong");
}
boolean fromOk = !tfrom.isEmpty("error.field.not.empty");
return subjectOk && bodyOk && toOk && fromOk;
return subjectOk && bodyOk && toOk && fromOk && fromMailAddOk;
}
/**
* @return
*/
public Identity getEmailFrom() {
return emailFrom;
public String getEmailFrom() {
return tfrom.getValue().trim();
}
/**
......@@ -374,7 +383,8 @@ public class ContactForm extends FormBasicController {
}
tfrom = uifactory.addTextElement("ttfrom", NLS_CONTACT_FROM, 255, fullName, formLayout);
tfrom.setElementCssClass("o_sel_contact_to");
tfrom.setEnabled(false);
// When no identity is set, let user enter a valid email address
tfrom.setEnabled((this.emailFrom == null));
tto = uifactory.addTextElement("tto", NLS_CONTACT_TO, 255, "", formLayout);
tto.setEnabled(false);
......
......@@ -203,12 +203,16 @@ public class ContactFormController extends BasicController {
boolean success = false;
try {
File[] attachments = cntctForm.getAttachments();
//fxdiff VCRP-16: intern mail system
MailContext context = new MailContextImpl(getWindowControl().getBusinessControl().getAsString());
MailBundle bundle = new MailBundle();
bundle.setContext(context);
bundle.setFromId(emailFrom);
if (emailFrom == null) {
// in case the user provides his own email in form
bundle.setFrom(cntctForm.getEmailFrom());
} else {
bundle.setFromId(emailFrom);
}
bundle.setContactLists(cntctForm.getEmailToContactLists());
bundle.setContent(cntctForm.getSubject(), cntctForm.getBody(), attachments);
......@@ -218,8 +222,14 @@ public class ContactFormController extends BasicController {
MailBundle ccBundle = new MailBundle();
ccBundle.setContext(context);
ccBundle.setFromId(emailFrom);
ccBundle.setCc(cntctForm.getEmailFrom());
if (emailFrom == null) {
// in case the user provides his own email in form
ccBundle.setFrom(cntctForm.getEmailFrom());
ccBundle.setTo(cntctForm.getEmailFrom());
} else {
ccBundle.setFromId(emailFrom);
ccBundle.setCc(emailFrom);
}
ccBundle.setContent(cntctForm.getSubject(), cntctForm.getBody(), attachments);
MailerResult ccResult = mailService.sendMessage(ccBundle);
......
......@@ -8,7 +8,8 @@ contact.to=An
contact.to.groupname.undisclosedrecipients=Vordefinierte Empf\u00E4nger
contact.attachment=Anhang
contact.attachment.maxsize={0} MB ist die maximal Gr\u00F6sse f\u00FCr Anhänge
error.field.not.empty=Dieses Feld darf nicht leer sein.
error.field.not.empty=Dieses Feld darf nicht leer sein
error.field.not.valid.email=Es muss eine valide E-Mailadresse sein.
error.msg.content.nok=Die Betreffzeile oder die Nachricht sind ung\u00FCltig.
error.msg.notconnectto.smtp=Die Verbindung zum SMTP-Server <i>{0}</i> konnte nicht hergestellt werden.
error.msg.nousers=Die gew\u00E4hlte Empf\u00E4ngergruppe enth\u00E4lt keine Teilnehmer. Die E-Mail kann nicht abgeschickt werden.
......
......@@ -9,6 +9,7 @@ contact.subject=Subject
contact.to=To
contact.to.groupname.undisclosedrecipients=Predefined recipients
error.field.not.empty=This field is mandatory.
error.field.not.valid.email=Must be a valid E-Mail address
error.msg.content.nok=Your message or its subject is invalid.
error.msg.notconnectto.smtp=A connection to the SMTP server <i>{0}</i> could not be established.
error.msg.nousers=The selected recipient group has no participants. Your e-mail cannot be sent.
......
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