Search in sources :

Example 56 with MailTemplate

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

the class GroupController method doImportUsers.

private void doImportUsers(UserRequest ureq) {
    removeAsListenerAndDispose(userToGroupWizard);
    Step start = new UsersToGroupWizardStep00(ureq, addUserMailDefaultTempl, mandatoryEmail);
    StepRunnerCallback finish = new StepRunnerCallback() {

        @Override
        public Step execute(UserRequest uureq, WindowControl wControl, StepsRunContext runContext) {
            @SuppressWarnings("unchecked") List<Identity> choosenIdentities = (List<Identity>) runContext.get("members");
            MailTemplate customTemplate = (MailTemplate) runContext.get("mailTemplate");
            if (choosenIdentities == null || choosenIdentities.size() == 0) {
                showError("msg.selectionempty");
            } else {
                doAddIdentitiesToGroup(uureq, choosenIdentities, customTemplate);
            }
            return StepsMainRunController.DONE_MODIFIED;
        }
    };
    userToGroupWizard = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("overview.addusers"), "o_sel_secgroup_import_logins_wizard");
    listenTo(userToGroupWizard);
    getWindowControl().pushAsModalDialog(userToGroupWizard.getInitialComponent());
}
Also used : UsersToGroupWizardStep00(org.olat.admin.securitygroup.gui.multi.UsersToGroupWizardStep00) MailTemplate(org.olat.core.util.mail.MailTemplate) List(java.util.List) ArrayList(java.util.ArrayList) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) Step(org.olat.core.gui.control.generic.wizard.Step) WindowControl(org.olat.core.gui.control.WindowControl) StepsRunContext(org.olat.core.gui.control.generic.wizard.StepsRunContext) Identity(org.olat.core.id.Identity) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback) UserRequest(org.olat.core.gui.UserRequest)

Example 57 with MailTemplate

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

the class UserImportController method sendMailToNewIdentities.

private void sendMailToNewIdentities(Map<TransientIdentity, Identity> newIdentities) {
    MailerResult result = new MailerResult();
    for (Map.Entry<TransientIdentity, Identity> newEntry : newIdentities.entrySet()) {
        if (newEntry.getKey() != null && newEntry.getValue() != null) {
            Identity newIdentity = newEntry.getValue();
            MailTemplate template = createMailTemplateForNewIdentity(newIdentity, newEntry.getKey());
            MailBundle bundle = mailService.makeMailBundle(null, newIdentity, template, getIdentity(), null, result);
            if (bundle != null) {
                mailService.sendExternMessage(bundle, result, true);
            }
        }
    }
}
Also used : MailerResult(org.olat.core.util.mail.MailerResult) MailTemplate(org.olat.core.util.mail.MailTemplate) Identity(org.olat.core.id.Identity) MailBundle(org.olat.core.util.mail.MailBundle) Map(java.util.Map) HashMap(java.util.HashMap)

Example 58 with MailTemplate

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

the class GTAParticipantController method doSubmissionEmail.

private void doSubmissionEmail() {
    String body = config.getStringValue(GTACourseNode.GTASK_SUBMISSION_TEXT);
    if (StringHelper.containsNonWhitespace(body)) {
        MailContext context = new MailContextImpl(getWindowControl().getBusinessControl().getAsString());
        List<Identity> recipientsTO;
        File submitDirectory;
        if (GTAType.group.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
            recipientsTO = businessGroupService.getMembers(assessedGroup, GroupRoles.participant.name());
            submitDirectory = gtaManager.getSubmitDirectory(courseEnv, gtaNode, assessedGroup);
        } else {
            recipientsTO = Collections.singletonList(assessedIdentity);
            submitDirectory = gtaManager.getSubmitDirectory(courseEnv, gtaNode, assessedIdentity);
        }
        String subject = translate("submission.mail.subject");
        File[] files = TaskHelper.getDocuments(submitDirectory);
        MailTemplate template = new GTAMailTemplate(subject, body, files, getIdentity(), getTranslator());
        MailerResult result = new MailerResult();
        MailBundle[] bundles = mailManager.makeMailBundles(context, recipientsTO, template, null, UUID.randomUUID().toString(), result);
        mailManager.sendMessage(bundles);
    }
}
Also used : MailContextImpl(org.olat.core.util.mail.MailContextImpl) MailContext(org.olat.core.util.mail.MailContext) MailerResult(org.olat.core.util.mail.MailerResult) MailTemplate(org.olat.core.util.mail.MailTemplate) Identity(org.olat.core.id.Identity) MailBundle(org.olat.core.util.mail.MailBundle) File(java.io.File)

Example 59 with MailTemplate

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

the class IQEditReplaceWizard method doStep3.

private void doStep3(UserRequest ureq) {
    StringBuilder extLink = new StringBuilder();
    extLink.append(Settings.getServerContextPathURI());
    RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(course, true);
    extLink.append("/url/RepositoryEntry/").append(re.getKey());
    extLink.append("/CourseNode/").append(courseNode.getIdent());
    String[] bodyArgs = new String[] { course.getCourseTitle(), extLink.toString() };
    String subject = translate("inform.users.subject", bodyArgs);
    String body = translate("inform.users.body", bodyArgs);
    MailTemplate mailTempl = new MailTemplate(subject, body, null) {

        @Override
        public void putVariablesInMailContext(VelocityContext context, Identity identity) {
        // nothing to do
        }
    };
    removeAsListenerAndDispose(mailCtr);
    mailCtr = new MailNotificationEditController(getWindowControl(), ureq, mailTempl, false, false, true);
    listenTo(mailCtr);
    vcStep3 = createVelocityContainer("replacewizard_step3");
    vcStep3.put("mailform", mailCtr.getInitialComponent());
    setNextWizardStep(translate("replace.wizard.title.step3"), vcStep3);
}
Also used : VelocityContext(org.apache.velocity.VelocityContext) MailTemplate(org.olat.core.util.mail.MailTemplate) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) MailNotificationEditController(org.olat.core.util.mail.MailNotificationEditController)

Example 60 with MailTemplate

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

the class IQEditReplaceWizard method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == mailCtr && event == Event.DONE_EVENT) {
        MailTemplate mailTemplate = mailCtr.getMailTemplate();
        if (mailTemplate != null) {
            MailContext context = new MailContextImpl(getWindowControl().getBusinessControl().getAsString());
            String metaId = UUID.randomUUID().toString().replace("-", "");
            MailerResult result = new MailerResult();
            MailBundle[] bundles = mailManager.makeMailBundles(context, learners, mailTemplate, getIdentity(), metaId, result);
            result.append(mailManager.sendMessage(bundles));
            if (mailTemplate.getCpfrom()) {
                MailBundle ccBundle = mailManager.makeMailBundle(context, getIdentity(), mailTemplate, getIdentity(), metaId, result);
                result.append(mailManager.sendMessage(ccBundle));
            }
        }
        fireEvent(ureq, Event.DONE_EVENT);
    } else if (source == searchCtr && event == ReferencableEntriesSearchController.EVENT_REPOSITORY_ENTRY_SELECTED) {
        selectedRepositoryEntry = searchCtr.getSelectedEntry();
        doStep2(ureq);
    }
}
Also used : MailContextImpl(org.olat.core.util.mail.MailContextImpl) MailContext(org.olat.core.util.mail.MailContext) MailerResult(org.olat.core.util.mail.MailerResult) MailTemplate(org.olat.core.util.mail.MailTemplate) MailBundle(org.olat.core.util.mail.MailBundle)

Aggregations

MailTemplate (org.olat.core.util.mail.MailTemplate)86 Identity (org.olat.core.id.Identity)62 MailerResult (org.olat.core.util.mail.MailerResult)46 MailBundle (org.olat.core.util.mail.MailBundle)32 MailContext (org.olat.core.util.mail.MailContext)30 MailContextImpl (org.olat.core.util.mail.MailContextImpl)30 VelocityContext (org.apache.velocity.VelocityContext)28 ArrayList (java.util.ArrayList)20 List (java.util.List)16 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)14 MailNotificationEditController (org.olat.core.util.mail.MailNotificationEditController)14 User (org.olat.core.id.User)12 Test (org.junit.Test)10 UserRequest (org.olat.core.gui.UserRequest)10 WindowControl (org.olat.core.gui.control.WindowControl)10 MailPackage (org.olat.core.util.mail.MailPackage)8 Property (org.olat.properties.Property)7 File (java.io.File)6 Locale (java.util.Locale)6 TableMultiSelectEvent (org.olat.core.gui.components.table.TableMultiSelectEvent)6