Search in sources :

Example 21 with DBMailRecipient

use of org.olat.core.util.mail.model.DBMailRecipient in project openolat by klemens.

the class MailController method getRecipients.

private String getRecipients() {
    StringBuilder sb = new StringBuilder();
    Set<String> groups = new HashSet<>();
    int recipientsCounter = 0;
    int groupCounter = 0;
    sb.append("<ul class='list-inline'>");
    for (DBMailRecipient recipient : mail.getRecipients()) {
        if (recipient == null)
            continue;
        if (recipientsCounter >= maxRecipients && !showAllRecipients) {
            sb.append("<li class='o_more'>").append(translate("recipients.more", (mail.getRecipients().size() - recipientsCounter) + "")).append("<span>");
            break;
        }
        recipientsCounter++;
        String group = recipient.getGroup();
        if (StringHelper.containsNonWhitespace(group) && !groups.contains(group)) {
            // recipient is the entire group
            if (sb.length() > 0) {
                sb.append("</ul>");
                sb.append("<ul class='list-inline'>");
            }
            sb.append("<li class='o_group'><i class='o_icon o_icon_group o_icon-fw'> </i><span>");
            sb.append(group);
            sb.append("</span></li>");
            groups.add(group);
            groupCounter = 0;
        }
        if (showRecipientNames()) {
            if (recipient.getRecipient() != null) {
                sb.append("<li class='o_recipient'>");
                if (groupCounter > 0)
                    sb.append(", ");
                sb.append("<span>").append(getFullName(recipient)).append("</span>");
                if (showMailAdresses()) {
                    sb.append(" &lt;");
                    sb.append(UserManager.getInstance().getUserDisplayEmail(recipient.getRecipient(), getLocale()));
                    sb.append("&gt;");
                }
                sb.append("</li>");
                groupCounter++;
            }
        }
        if (showMailAdresses()) {
            if (recipient.getEmailAddress() != null) {
                // recipient is not an OpenOLAT identity but an external email
                sb.append("<li class='o_mail'>");
                if (groupCounter > 0)
                    sb.append(", ");
                sb.append("&lt;");
                sb.append(UserManager.getInstance().getUserDisplayEmail(recipient.getEmailAddress(), getLocale()));
                sb.append("&gt;</li>");
                groupCounter++;
            }
        }
    }
    sb.append("</ul>");
    return sb.toString();
}
Also used : HashSet(java.util.HashSet) DBMailRecipient(org.olat.core.util.mail.model.DBMailRecipient)

Example 22 with DBMailRecipient

use of org.olat.core.util.mail.model.DBMailRecipient in project openolat by klemens.

the class MailController method getFrom.

private String getFrom() {
    StringBuilder sb = new StringBuilder();
    DBMailRecipient from = mail.getFrom();
    sb.append("<ul class='list-inline'><li>");
    if (from != null) {
        sb.append(getFullName(from));
        if (showMailAdresses()) {
            Identity fromIdentity = from.getRecipient();
            if (fromIdentity != null) {
                sb.append(" &lt;");
                sb.append(UserManager.getInstance().getUserDisplayEmail(fromIdentity, getLocale()));
                sb.append("&gt; ");
            }
        }
    }
    sb.append("</li></ul>");
    return sb.toString();
}
Also used : Identity(org.olat.core.id.Identity) DBMailRecipient(org.olat.core.util.mail.model.DBMailRecipient)

Aggregations

DBMailRecipient (org.olat.core.util.mail.model.DBMailRecipient)22 HashSet (java.util.HashSet)6 ArrayList (java.util.ArrayList)4 Address (javax.mail.Address)4 InternetAddress (javax.mail.internet.InternetAddress)4 IdentityImpl (org.olat.basesecurity.IdentityImpl)4 Identity (org.olat.core.id.Identity)4 MailerResult (org.olat.core.util.mail.MailerResult)4 DBMailAttachment (org.olat.core.util.mail.model.DBMailAttachment)4 DBMailLight (org.olat.core.util.mail.model.DBMailLight)4 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 BitSet (java.util.BitSet)2 Date (java.util.Date)2 Set (java.util.Set)2 Adler32 (java.util.zip.Adler32)2 AddressException (javax.mail.internet.AddressException)2 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)2