Search in sources :

Example 31 with ContactMessage

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

the class CertificateAndEfficiencyStatementController method contact.

private void contact(UserRequest ureq) {
    removeAsListenerAndDispose(cmc);
    ContactMessage cmsg = new ContactMessage(getIdentity());
    ContactList contactList = new ContactList("to");
    contactList.add(statementOwner);
    cmsg.addEmailTo(contactList);
    contactCtrl = new ContactFormController(ureq, getWindowControl(), true, false, false, cmsg);
    listenTo(contactCtrl);
    cmc = new CloseableModalController(getWindowControl(), translate("close"), contactCtrl.getInitialComponent());
    cmc.activate();
    listenTo(cmc);
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) ContactFormController(org.olat.modules.co.ContactFormController) ContactList(org.olat.core.util.mail.ContactList) ContactMessage(org.olat.core.util.mail.ContactMessage)

Example 32 with ContactMessage

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

the class GTACoachController method doOpenMailForm.

private void doOpenMailForm(UserRequest ureq) {
    // build recipient list
    ContactList contactList = null;
    if (assessedGroup != null) {
        String toName = assessedGroup.getName();
        contactList = new ContactList(toName);
        List<Identity> memberList = businessGroupService.getMembers(assessedGroup, GroupRoles.participant.name());
        contactList.addAllIdentites(memberList);
    } else if (assessedIdentity != null) {
        String toName = userManager.getUserDisplayName(assessedIdentity);
        contactList = new ContactList(toName);
        contactList.add(assessedIdentity);
    }
    // open dialog with mail form
    if (contactList != null && contactList.getEmailsAsStrings().size() > 0) {
        removeAsListenerAndDispose(emailController);
        ContactMessage cmsg = new ContactMessage(ureq.getIdentity());
        cmsg.addEmailTo(contactList);
        emailController = new ContactFormController(ureq, getWindowControl(), true, false, false, cmsg);
        listenTo(emailController);
        removeAsListenerAndDispose(cmc);
        // same title as link button
        String title = translate(emailLink.getI18n());
        cmc = new CloseableModalController(getWindowControl(), translate("close"), emailController.getInitialComponent(), true, title);
        listenTo(cmc);
        cmc.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) Identity(org.olat.core.id.Identity) ContactMessage(org.olat.core.util.mail.ContactMessage)

Example 33 with ContactMessage

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

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 34 with ContactMessage

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

the class AbstractMemberListController method doSendMail.

protected void doSendMail(UserRequest ureq, List<MemberView> members) {
    List<Long> identityKeys = getMemberKeys(members);
    List<Identity> identities = securityManager.loadIdentityByKeys(identityKeys);
    if (identities.isEmpty()) {
        showWarning("error.msg.send.no.rcps");
        return;
    }
    ContactMessage contactMessage = new ContactMessage(getIdentity());
    String name = repoEntry != null ? repoEntry.getDisplayname() : businessGroup.getName();
    ContactList contactList = new ContactList(name);
    contactList.addAllIdentites(identities);
    contactMessage.addEmailTo(contactList);
    contactCtrl = new ContactFormController(ureq, getWindowControl(), true, false, false, contactMessage);
    listenTo(contactCtrl);
    cmc = new CloseableModalController(getWindowControl(), translate("close"), contactCtrl.getInitialComponent(), true, translate("mail.member"));
    cmc.activate();
    listenTo(cmc);
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) ContactFormController(org.olat.modules.co.ContactFormController) ContactList(org.olat.core.util.mail.ContactList) Identity(org.olat.core.id.Identity) ContactMessage(org.olat.core.util.mail.ContactMessage)

Aggregations

ContactMessage (org.olat.core.util.mail.ContactMessage)34 ContactList (org.olat.core.util.mail.ContactList)28 ContactFormController (org.olat.modules.co.ContactFormController)28 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)20 Identity (org.olat.core.id.Identity)18 ArrayList (java.util.ArrayList)6 WindowControl (org.olat.core.gui.control.WindowControl)6 VelocityContainer (org.olat.core.gui.components.velocity.VelocityContainer)4 OLATResourceable (org.olat.core.id.OLATResourceable)4 HashMap (java.util.HashMap)2 List (java.util.List)2 UserBulkChangeStep00 (org.olat.admin.user.bulkChange.UserBulkChangeStep00)2 SecurityGroup (org.olat.basesecurity.SecurityGroup)2 SingleIdentityChosenEvent (org.olat.basesecurity.events.SingleIdentityChosenEvent)2 CollaborationTools (org.olat.collaboration.CollaborationTools)2 UserRequest (org.olat.core.gui.UserRequest)2 TableEvent (org.olat.core.gui.components.table.TableEvent)2 TableMultiSelectEvent (org.olat.core.gui.components.table.TableMultiSelectEvent)2 ControllerCreator (org.olat.core.gui.control.creator.ControllerCreator)2 PopupBrowserWindow (org.olat.core.gui.control.generic.popup.PopupBrowserWindow)2