diff --git a/src/main/java/org/olat/course/member/wizard/ImportMemberMailController.java b/src/main/java/org/olat/course/member/wizard/ImportMemberMailController.java index aa910de22d0e0b4a1b34dad075762bf7b172457a..fc1aeceec568458d947a7697692986285f4879f2 100644 --- a/src/main/java/org/olat/course/member/wizard/ImportMemberMailController.java +++ b/src/main/java/org/olat/course/member/wizard/ImportMemberMailController.java @@ -21,7 +21,6 @@ package org.olat.course.member.wizard; import java.util.List; -import org.olat.core.CoreSpringFactory; import org.olat.core.gui.UserRequest; import org.olat.core.gui.components.form.flexible.FormItemContainer; import org.olat.core.gui.components.form.flexible.impl.Form; @@ -43,6 +42,7 @@ import org.olat.modules.curriculum.CurriculumElement; import org.olat.modules.curriculum.ui.CurriculumMailing; import org.olat.repository.RepositoryEntry; import org.olat.repository.RepositoryMailing; +import org.springframework.beans.factory.annotation.Autowired; /** * @@ -52,14 +52,17 @@ public class ImportMemberMailController extends StepFormBasicController { private MailTemplate mailTemplate; private final BGMailTemplateController mailTemplateForm; + + @Autowired + private BusinessGroupModule businessGroupModule; public ImportMemberMailController(UserRequest ureq, WindowControl wControl, RepositoryEntry repoEntry, Form rootForm, StepsRunContext runContext) { super(ureq, wControl, rootForm, runContext, LAYOUT_CUSTOM, "mail_template"); MemberPermissionChangeEvent e = (MemberPermissionChangeEvent)runContext.get("permissions"); - boolean mandatoryEmail = CoreSpringFactory.getImpl(BusinessGroupModule.class).isMandatoryEnrolmentEmail(ureq.getUserSession().getRoles()); - if(mandatoryEmail) { + boolean mandatoryEmail = businessGroupModule.isMandatoryEnrolmentEmail(ureq.getUserSession().getRoles()); + if(mandatoryEmail && e != null) { boolean includeParticipantsOrTutorsRights = hasParticipantOrTutorsRightsChanges(e); if(!includeParticipantsOrTutorsRights) { mandatoryEmail = false;//only mandatory for participants and tutors diff --git a/src/main/java/org/olat/course/nodes/projectbroker/GroupController.java b/src/main/java/org/olat/course/nodes/projectbroker/GroupController.java index 4f647c9ef0e6f5475adc5c13627ca2b9117f087b..242851c8b6c5e6ec58534f19f7eb4205515fe130 100644 --- a/src/main/java/org/olat/course/nodes/projectbroker/GroupController.java +++ b/src/main/java/org/olat/course/nodes/projectbroker/GroupController.java @@ -74,7 +74,6 @@ import org.olat.core.gui.control.generic.popup.PopupBrowserWindow; import org.olat.core.gui.control.generic.wizard.Step; import org.olat.core.gui.control.generic.wizard.StepRunnerCallback; import org.olat.core.gui.control.generic.wizard.StepsMainRunController; -import org.olat.core.gui.control.generic.wizard.StepsRunContext; import org.olat.core.gui.translator.Translator; import org.olat.core.id.Identity; import org.olat.core.id.Roles; @@ -266,12 +265,8 @@ public class GroupController extends BasicController { this.removeUserMailDefaultTempl = removeUserMailTempl; this.showSenderInRemovMailFooter = showSenderInRemoveFooter; } - - /** - * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, - * org.olat.core.gui.components.Component, - * org.olat.core.gui.control.Event) - */ + + @Override public void event(UserRequest ureq, Component source, Event event) { if (source == addUserButton) { if (!mayModifyMembers) throw new AssertException("not allowed to add a member!"); @@ -282,10 +277,6 @@ public class GroupController extends BasicController { } } - /** - * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, - * org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event) - */ @Override public void event(UserRequest ureq, Controller sourceController, Event event) { if (sourceController == tableCtr) { @@ -480,23 +471,20 @@ public class GroupController extends BasicController { cmc.activate(); } - private void doImportUsers(UserRequest ureq) { + private void doImportUsers(final UserRequest ureq) { removeAsListenerAndDispose(userToGroupWizard); Step start = new UsersToGroupWizardStep00(ureq, addUserMailDefaultTempl, mandatoryEmail); - StepRunnerCallback finish = new StepRunnerCallback() { - @Override - public Step execute(UserRequest ureq, 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(ureq, choosenIdentities, customTemplate); - } - return StepsMainRunController.DONE_MODIFIED; + StepRunnerCallback finish = (uureq, wControl, runContext) -> { + @SuppressWarnings("unchecked") + List<Identity> choosenIdentities = (List<Identity>)runContext.get("members"); + MailTemplate customTemplate = (MailTemplate)runContext.get("mailTemplate"); + if (choosenIdentities == null || choosenIdentities.isEmpty()) { + showError("msg.selectionempty"); + } else { + doAddIdentitiesToGroup(uureq, choosenIdentities, customTemplate); } + return StepsMainRunController.DONE_MODIFIED; }; userToGroupWizard = new StepsMainRunController(ureq, getWindowControl(), start, finish, null,