Search in sources :

Example 1 with EMailIdentity

use of org.olat.core.util.mail.ui.EMailIdentity in project OpenOLAT by OpenOLAT.

the class MembersMailController method doSend.

private void doSend(UserRequest ureq) {
    ContactList contactList = new ContactList("");
    if (courseEnv == null) {
        if (coachEl != null && coachEl.isAtLeastSelected(1)) {
            List<Long> identityKeys = new ArrayList<>(coachList.size());
            for (Member coach : coachList) {
                identityKeys.add(coach.getKey());
            }
            List<Identity> coaches = securityManager.loadIdentityByKeys(identityKeys);
            contactList.addAllIdentites(coaches);
        }
        if (participantEl != null && participantEl.isAtLeastSelected(1)) {
            List<Long> identityKeys = new ArrayList<>(participantList.size());
            for (Member participant : participantList) {
                identityKeys.add(participant.getKey());
            }
            List<Identity> participants = securityManager.loadIdentityByKeys(identityKeys);
            contactList.addAllIdentites(participants);
        }
        if (waitingEl != null && waitingEl.isAtLeastSelected(1)) {
            List<Long> identityKeys = new ArrayList<>(waitingList.size());
            for (Member waiter : waitingList) {
                identityKeys.add(waiter.getKey());
            }
            List<Identity> waiters = securityManager.loadIdentityByKeys(identityKeys);
            contactList.addAllIdentites(waiters);
        }
    } else {
        if (ownerEl != null && ownerEl.isAtLeastSelected(1)) {
            RepositoryEntry courseRepositoryEntry = courseEnv.getCourseGroupManager().getCourseEntry();
            List<Identity> owners = repositoryService.getMembers(courseRepositoryEntry, GroupRoles.owner.name());
            contactList.addAllIdentites(owners);
        }
        if (coachEl != null && coachEl.isAtLeastSelected(1)) {
            Set<Long> sendToWhatYouSee = new HashSet<>();
            for (Member coach : coachList) {
                sendToWhatYouSee.add(coach.getKey());
            }
            CourseGroupManager cgm = courseEnv.getCourseGroupManager();
            avoidInvisibleMember(cgm.getCoachesFromBusinessGroups(), contactList, sendToWhatYouSee);
            avoidInvisibleMember(cgm.getCoaches(), contactList, sendToWhatYouSee);
        }
        if (participantEl != null && participantEl.isAtLeastSelected(1)) {
            Set<Long> sendToWhatYouSee = new HashSet<>();
            for (Member participant : participantList) {
                sendToWhatYouSee.add(participant.getKey());
            }
            CourseGroupManager cgm = courseEnv.getCourseGroupManager();
            avoidInvisibleMember(cgm.getParticipantsFromBusinessGroups(), contactList, sendToWhatYouSee);
            avoidInvisibleMember(cgm.getParticipants(), contactList, sendToWhatYouSee);
        }
    }
    if (individualEl != null && individualEl.isAtLeastSelected(1) && selectedMembers != null && selectedMembers.size() > 0) {
        List<Long> identityKeys = new ArrayList<>(selectedMembers.size());
        for (Member member : selectedMembers) {
            identityKeys.add(member.getKey());
        }
        List<Identity> selectedIdentities = securityManager.loadIdentityByKeys(identityKeys);
        contactList.addAllIdentites(selectedIdentities);
    }
    if (externalEl != null && externalEl.isAtLeastSelected(1)) {
        String value = externalAddressesEl.getValue();
        if (StringHelper.containsNonWhitespace(value)) {
            for (StringTokenizer tokenizer = new StringTokenizer(value, ",\r\n", false); tokenizer.hasMoreTokens(); ) {
                String email = tokenizer.nextToken().trim();
                contactList.add(new EMailIdentity(email, getLocale()));
            }
        }
    }
    doSendEmailToMember(ureq, contactList);
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) ArrayList(java.util.ArrayList) ContactList(org.olat.core.util.mail.ContactList) RepositoryEntry(org.olat.repository.RepositoryEntry) StringTokenizer(java.util.StringTokenizer) EMailIdentity(org.olat.core.util.mail.ui.EMailIdentity) EMailIdentity(org.olat.core.util.mail.ui.EMailIdentity) Identity(org.olat.core.id.Identity) Member(org.olat.course.nodes.members.Member) HashSet(java.util.HashSet)

Example 2 with EMailIdentity

use of org.olat.core.util.mail.ui.EMailIdentity in project openolat by klemens.

the class MembersMailController method doSend.

private void doSend(UserRequest ureq) {
    ContactList contactList = new ContactList("");
    if (courseEnv == null) {
        if (coachEl != null && coachEl.isAtLeastSelected(1)) {
            List<Long> identityKeys = new ArrayList<>(coachList.size());
            for (Member coach : coachList) {
                identityKeys.add(coach.getKey());
            }
            List<Identity> coaches = securityManager.loadIdentityByKeys(identityKeys);
            contactList.addAllIdentites(coaches);
        }
        if (participantEl != null && participantEl.isAtLeastSelected(1)) {
            List<Long> identityKeys = new ArrayList<>(participantList.size());
            for (Member participant : participantList) {
                identityKeys.add(participant.getKey());
            }
            List<Identity> participants = securityManager.loadIdentityByKeys(identityKeys);
            contactList.addAllIdentites(participants);
        }
        if (waitingEl != null && waitingEl.isAtLeastSelected(1)) {
            List<Long> identityKeys = new ArrayList<>(waitingList.size());
            for (Member waiter : waitingList) {
                identityKeys.add(waiter.getKey());
            }
            List<Identity> waiters = securityManager.loadIdentityByKeys(identityKeys);
            contactList.addAllIdentites(waiters);
        }
    } else {
        if (ownerEl != null && ownerEl.isAtLeastSelected(1)) {
            RepositoryEntry courseRepositoryEntry = courseEnv.getCourseGroupManager().getCourseEntry();
            List<Identity> owners = repositoryService.getMembers(courseRepositoryEntry, GroupRoles.owner.name());
            contactList.addAllIdentites(owners);
        }
        if (coachEl != null && coachEl.isAtLeastSelected(1)) {
            Set<Long> sendToWhatYouSee = new HashSet<>();
            for (Member coach : coachList) {
                sendToWhatYouSee.add(coach.getKey());
            }
            CourseGroupManager cgm = courseEnv.getCourseGroupManager();
            avoidInvisibleMember(cgm.getCoachesFromBusinessGroups(), contactList, sendToWhatYouSee);
            avoidInvisibleMember(cgm.getCoaches(), contactList, sendToWhatYouSee);
        }
        if (participantEl != null && participantEl.isAtLeastSelected(1)) {
            Set<Long> sendToWhatYouSee = new HashSet<>();
            for (Member participant : participantList) {
                sendToWhatYouSee.add(participant.getKey());
            }
            CourseGroupManager cgm = courseEnv.getCourseGroupManager();
            avoidInvisibleMember(cgm.getParticipantsFromBusinessGroups(), contactList, sendToWhatYouSee);
            avoidInvisibleMember(cgm.getParticipants(), contactList, sendToWhatYouSee);
        }
    }
    if (individualEl != null && individualEl.isAtLeastSelected(1) && selectedMembers != null && selectedMembers.size() > 0) {
        List<Long> identityKeys = new ArrayList<>(selectedMembers.size());
        for (Member member : selectedMembers) {
            identityKeys.add(member.getKey());
        }
        List<Identity> selectedIdentities = securityManager.loadIdentityByKeys(identityKeys);
        contactList.addAllIdentites(selectedIdentities);
    }
    if (externalEl != null && externalEl.isAtLeastSelected(1)) {
        String value = externalAddressesEl.getValue();
        if (StringHelper.containsNonWhitespace(value)) {
            for (StringTokenizer tokenizer = new StringTokenizer(value, ",\r\n", false); tokenizer.hasMoreTokens(); ) {
                String email = tokenizer.nextToken().trim();
                contactList.add(new EMailIdentity(email, getLocale()));
            }
        }
    }
    doSendEmailToMember(ureq, contactList);
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) ArrayList(java.util.ArrayList) ContactList(org.olat.core.util.mail.ContactList) RepositoryEntry(org.olat.repository.RepositoryEntry) StringTokenizer(java.util.StringTokenizer) EMailIdentity(org.olat.core.util.mail.ui.EMailIdentity) EMailIdentity(org.olat.core.util.mail.ui.EMailIdentity) Identity(org.olat.core.id.Identity) Member(org.olat.course.nodes.members.Member) HashSet(java.util.HashSet)

Aggregations

ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 StringTokenizer (java.util.StringTokenizer)2 Identity (org.olat.core.id.Identity)2 ContactList (org.olat.core.util.mail.ContactList)2 EMailIdentity (org.olat.core.util.mail.ui.EMailIdentity)2 CourseGroupManager (org.olat.course.groupsandrights.CourseGroupManager)2 Member (org.olat.course.nodes.members.Member)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2