Search in sources :

Example 56 with ContactList

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

the class CORunController method retrieveParticipantsFromCourse.

private ContactList retrieveParticipantsFromCourse() {
    List<Identity> participiants = cgm.getParticipants();
    ContactList cl = new ContactList(translate("form.message.chckbx.partips"));
    cl.addAllIdentites(participiants);
    return cl;
}
Also used : ContactList(org.olat.core.util.mail.ContactList) Identity(org.olat.core.id.Identity)

Example 57 with ContactList

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

the class BusinessGroupMainRunController method createContactFormController.

/**
 * generates the email adress list.
 *
 * @param ureq
 * @return a contact form controller for this group
 */
private ContactFormController createContactFormController(UserRequest ureq) {
    ContactMessage cmsg = new ContactMessage(ureq.getIdentity());
    // two named ContactLists, the new way using the contact form
    // the same name as in the checkboxes are taken as contactlist names
    // = new ContactList(translate("sendtochooser.form.chckbx.owners"));
    ContactList ownerCntctLst;
    // = new ContactList(translate("sendtochooser.form.chckbx.partip"));
    ContactList partipCntctLst;
    // = new ContactList(translate("sendtochooser.form.chckbx.waitingList"));
    ContactList waitingListContactList;
    if (sendToChooserForm.ownerChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_ALL)) {
        ownerCntctLst = new ContactList(translate("sendtochooser.form.radio.owners.all"));
        List<Identity> ownerList = businessGroupService.getMembers(businessGroup, GroupRoles.coach.name());
        ownerCntctLst.addAllIdentites(ownerList);
        cmsg.addEmailTo(ownerCntctLst);
    } else {
        if (sendToChooserForm.ownerChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_CHOOSE)) {
            ownerCntctLst = new ContactList(translate("sendtochooser.form.radio.owners.choose"));
            List<Identity> ownerList = businessGroupService.getMembers(businessGroup, GroupRoles.coach.name());
            List<Identity> changeableOwnerList = new ArrayList<>(ownerList);
            for (Identity identity : ownerList) {
                boolean keyIsSelected = false;
                for (Long key : sendToChooserForm.getSelectedOwnerKeys()) {
                    if (key.equals(identity.getKey())) {
                        keyIsSelected = true;
                        break;
                    }
                }
                if (!keyIsSelected) {
                    changeableOwnerList.remove(changeableOwnerList.indexOf(identity));
                }
            }
            ownerCntctLst.addAllIdentites(changeableOwnerList);
            cmsg.addEmailTo(ownerCntctLst);
        }
    }
    if (sendToChooserForm != null) {
        if (sendToChooserForm.participantChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_ALL)) {
            partipCntctLst = new ContactList(translate("sendtochooser.form.radio.partip.all"));
            List<Identity> participantsList = businessGroupService.getMembers(businessGroup, GroupRoles.participant.name());
            partipCntctLst.addAllIdentites(participantsList);
            cmsg.addEmailTo(partipCntctLst);
        } else {
            if (sendToChooserForm.participantChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_CHOOSE)) {
                partipCntctLst = new ContactList(translate("sendtochooser.form.radio.partip.choose"));
                List<Identity> participantsList = businessGroupService.getMembers(businessGroup, GroupRoles.participant.name());
                List<Identity> changeableParticipantsList = new ArrayList<>(participantsList);
                for (Identity identity : participantsList) {
                    boolean keyIsSelected = false;
                    for (Long key : sendToChooserForm.getSelectedPartipKeys()) {
                        if (key.equals(identity.getKey())) {
                            keyIsSelected = true;
                            break;
                        }
                    }
                    if (!keyIsSelected) {
                        changeableParticipantsList.remove(changeableParticipantsList.indexOf(identity));
                    }
                }
                partipCntctLst.addAllIdentites(changeableParticipantsList);
                cmsg.addEmailTo(partipCntctLst);
            }
        }
    }
    if (sendToChooserForm != null && isAdmin && businessGroup.getWaitingListEnabled().booleanValue()) {
        if (sendToChooserForm.waitingListChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_ALL)) {
            waitingListContactList = new ContactList(translate("sendtochooser.form.radio.waitings.all"));
            List<Identity> waitingListIdentities = businessGroupService.getMembers(businessGroup, GroupRoles.waiting.name());
            waitingListContactList.addAllIdentites(waitingListIdentities);
            cmsg.addEmailTo(waitingListContactList);
        } else {
            if (sendToChooserForm.waitingListChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_CHOOSE)) {
                waitingListContactList = new ContactList(translate("sendtochooser.form.radio.waitings.choose"));
                List<Identity> waitingListIdentities = businessGroupService.getMembers(businessGroup, GroupRoles.waiting.name());
                List<Identity> changeableWaitingListIdentities = new ArrayList<>(waitingListIdentities);
                for (Identity indentity : waitingListIdentities) {
                    boolean keyIsSelected = false;
                    for (Long key : sendToChooserForm.getSelectedWaitingKeys()) {
                        if (key.equals(indentity.getKey())) {
                            keyIsSelected = true;
                            break;
                        }
                    }
                    if (!keyIsSelected) {
                        changeableWaitingListIdentities.remove(changeableWaitingListIdentities.indexOf(indentity));
                    }
                }
                waitingListContactList.addAllIdentites(changeableWaitingListIdentities);
                cmsg.addEmailTo(waitingListContactList);
            }
        }
    }
    cmsg.setSubject(translate("businessgroup.contact.subject", businessGroup.getName()));
    if (sendToChooserForm.waitingListChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_NOTHING)) {
        String restUrl = BusinessControlFactory.getInstance().getAsURIString(getWindowControl().getBusinessControl(), true);
        cmsg.setBodyText(getTranslator().translate("businessgroup.contact.bodytext", new String[] { businessGroup.getName(), "<a href='" + restUrl + "'>" + restUrl + "</a>" }));
    } else {
        cmsg.setBodyText("");
    }
    CollaborationTools collabTools = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(businessGroup);
    return collabTools.createContactFormController(ureq, getWindowControl(), cmsg);
}
Also used : ArrayList(java.util.ArrayList) CollaborationTools(org.olat.collaboration.CollaborationTools) ContactList(org.olat.core.util.mail.ContactList) Identity(org.olat.core.id.Identity) ContactMessage(org.olat.core.util.mail.ContactMessage)

Example 58 with ContactList

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

the class MembersAvatarDisplayRunController method doSendEmailToMember.

private void doSendEmailToMember(Member member, UserRequest ureq) {
    if (!editable)
        return;
    ContactList memberList;
    if (courseEnv == null) {
        memberList = new ContactList(translate("members.to", new String[] { member.getFullName(), businessGroup.getName() }));
    } else {
        memberList = new ContactList(translate("members.to", new String[] { member.getFullName(), courseEnv.getCourseTitle() }));
    }
    Identity identity = securityManager.loadIdentityByKey(member.getKey());
    memberList.add(identity);
    doSendEmailToMember(memberList, ureq);
}
Also used : ContactList(org.olat.core.util.mail.ContactList) Identity(org.olat.core.id.Identity)

Example 59 with ContactList

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

the class DENManager method sendParticipantsMessage.

/**
 * Generates the mail window
 * @param ureq
 * @param wControl
 * @param listener
 * @param velocity_root
 * @param trans
 * @param participants
 * @return VelocityContainer
 */
protected VelocityContainer sendParticipantsMessage(UserRequest ureq, WindowControl wControl, DefaultController listener, String velocity_root, Translator trans, List<Identity> participants) {
    VelocityContainer sendMessageVC = new VelocityContainer("sendmessage", velocity_root + "/sendmessage.html", trans, listener);
    ContactMessage cmsg = new ContactMessage(ureq.getIdentity());
    ContactList contactList = null;
    if (participants.size() == 1) {
        contactList = new ContactList(participants.get(0).getUser().getProperty(UserConstants.EMAIL, ureq.getLocale()));
    } else {
        contactList = new ContactList(trans.translate("participants.message.to"));
    }
    contactList.addAllIdentites(participants);
    cmsg.addEmailTo(contactList);
    ContactFormController contactCtr = new ContactFormController(ureq, wControl, false, false, false, cmsg);
    contactCtr.addControllerListener(listener);
    sendMessageVC.contextPut("title", trans.translate("participants.message"));
    sendMessageVC.put("contactForm", contactCtr.getInitialComponent());
    return sendMessageVC;
}
Also used : ContactFormController(org.olat.modules.co.ContactFormController) ContactList(org.olat.core.util.mail.ContactList) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer) ContactMessage(org.olat.core.util.mail.ContactMessage)

Example 60 with ContactList

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

the class DENManageParticipantsController method createParticipantsMail.

private void createParticipantsMail(UserRequest ureq, List<Identity> participants) {
    VelocityContainer sendMessageVC = createVelocityContainer("sendmessage");
    ContactMessage cmsg = new ContactMessage(ureq.getIdentity());
    ContactList contactList = new ContactList(translate("participants.message.to"));
    contactList.addAllIdentites(participants);
    cmsg.addEmailTo(contactList);
    removeAsListenerAndDispose(contactCtr);
    contactCtr = new ContactFormController(ureq, getWindowControl(), false, false, false, cmsg);
    listenTo(contactCtr);
    sendMessageVC.contextPut("title", translate("participants.message"));
    sendMessageVC.put("contactForm", contactCtr.getInitialComponent());
    removeAsListenerAndDispose(notificationCmc);
    notificationCmc = new CloseableModalController(getWindowControl(), "close", sendMessageVC);
    listenTo(notificationCmc);
    notificationCmc.activate();
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) ContactFormController(org.olat.modules.co.ContactFormController) ContactList(org.olat.core.util.mail.ContactList) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer) ContactMessage(org.olat.core.util.mail.ContactMessage)

Aggregations

ContactList (org.olat.core.util.mail.ContactList)92 Identity (org.olat.core.id.Identity)66 ContactMessage (org.olat.core.util.mail.ContactMessage)28 MailBundle (org.olat.core.util.mail.MailBundle)26 ContactFormController (org.olat.modules.co.ContactFormController)22 MailContextImpl (org.olat.core.util.mail.MailContextImpl)18 MailerResult (org.olat.core.util.mail.MailerResult)18 MailContext (org.olat.core.util.mail.MailContext)16 ArrayList (java.util.ArrayList)14 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)14 RepositoryEntry (org.olat.repository.RepositoryEntry)10 HashSet (java.util.HashSet)8 Test (org.junit.Test)8 BusinessGroup (org.olat.group.BusinessGroup)7 Locale (java.util.Locale)6 WindowControl (org.olat.core.gui.control.WindowControl)6 Translator (org.olat.core.gui.translator.Translator)6 File (java.io.File)4 Date (java.util.Date)4 Address (javax.mail.Address)4