Search in sources :

Example 1 with BGUserMailTemplate

use of org.olat.group.ui.wizard.BGUserMailTemplate in project OpenOLAT by OpenOLAT.

the class AbstractBusinessGroupListController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == deleteDialogBox) {
        if (event == Event.DONE_EVENT) {
            boolean withEmail = deleteDialogBox.isSendMail();
            List<BusinessGroup> groupsToDelete = deleteDialogBox.getGroupsToDelete();
            doDelete(ureq, withEmail, groupsToDelete);
            tableEl.deselectAll();
            reloadModel();
        }
        cmc.deactivate();
        cleanUpPopups();
    } else if (source == leaveDialogBox) {
        if (event != Event.CANCELLED_EVENT && DialogBoxUIFactory.isYesEvent(event)) {
            doLeave((BusinessGroup) leaveDialogBox.getUserObject());
            tableEl.deselectAll();
            reloadModel();
        }
    } else if (source == groupCreateController) {
        BusinessGroup group = null;
        if (event == Event.DONE_EVENT) {
            Set<BusinessGroup> groups = groupCreateController.getCreatedGroups();
            if (groups.size() == 1) {
                group = groups.iterator().next();
            }
            if (groups.size() > 0) {
                tableEl.deselectAll();
                reloadModel();
            }
        }
        cmc.deactivate();
        cleanUpPopups();
        // if new group -> go to the tab
        if (group != null) {
            String businessPath = "[BusinessGroup:" + group.getKey() + "]";
            NewControllerFactory.getInstance().launch(businessPath, ureq, getWindowControl());
        }
        fireEvent(ureq, Event.CHANGED_EVENT);
    } else if (source == businessGroupWizard) {
        if (event == Event.CANCELLED_EVENT || event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            getWindowControl().pop();
            removeAsListenerAndDispose(businessGroupWizard);
            businessGroupWizard = null;
            if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
                reloadModel();
            }
        }
    } else if (source == emailWizard) {
        if (event == Event.CANCELLED_EVENT || event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            getWindowControl().pop();
            removeAsListenerAndDispose(emailWizard);
            emailWizard = null;
            if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
                tableEl.deselectAll();
            }
        }
    } else if (source == userManagementController) {
        cmc.deactivate();
        if (event == Event.DONE_EVENT) {
            // confirm sending emails
            MembershipModification mod = userManagementController.getModifications();
            List<BusinessGroup> groups = userManagementController.getGroups();
            confirmUserManagementEmail(ureq, mod, groups);
        } else {
            cleanUpPopups();
        }
    } else if (source == userManagementSendMailController) {
        if (event == Event.DONE_EVENT) {
            BGUserMailTemplate sendMail = (BGUserMailTemplate) userManagementSendMailController.getTemplate();
            MembershipModification mod = sendMail.getModifications();
            List<BusinessGroup> groups = sendMail.getGroups();
            finishUserManagement(mod, groups, sendMail, userManagementSendMailController.isSendMail());
            reloadModel();
        }
        cmc.deactivate();
        cleanUpPopups();
    } else if (source == searchCtrl) {
        if (event instanceof SearchEvent) {
            doSearch(ureq, (SearchEvent) event);
        }
    } else if (source == contactCtrl) {
        cmc.deactivate();
        cleanUpPopups();
    } else if (source == cmc) {
        cleanUpPopups();
    }
    super.event(ureq, source, event);
}
Also used : BGCopyBusinessGroup(org.olat.group.ui.wizard.BGCopyBusinessGroup) BGConfigBusinessGroup(org.olat.group.ui.wizard.BGConfigBusinessGroup) BusinessGroup(org.olat.group.BusinessGroup) MembershipModification(org.olat.group.model.MembershipModification) ContactList(org.olat.core.util.mail.ContactList) List(java.util.List) ArrayList(java.util.ArrayList) BGUserMailTemplate(org.olat.group.ui.wizard.BGUserMailTemplate) FlexiTableSearchEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableSearchEvent)

Example 2 with BGUserMailTemplate

use of org.olat.group.ui.wizard.BGUserMailTemplate in project OpenOLAT by OpenOLAT.

the class AbstractBusinessGroupListController method confirmUserManagementEmail.

private void confirmUserManagementEmail(UserRequest ureq, MembershipModification mod, List<BusinessGroup> groups) {
    removeAsListenerAndDispose(cmc);
    removeAsListenerAndDispose(userManagementSendMailController);
    MailTemplate defaultTemplate = null;
    int totalModification = (mod.size() * groups.size());
    if (totalModification == 1) {
        MailType type = BusinessGroupMailing.getDefaultTemplateType(mod);
        if (type != null) {
            defaultTemplate = BusinessGroupMailing.getDefaultTemplate(type, groups.get(0), ureq.getIdentity());
        }
    }
    MailTemplate template = new BGUserMailTemplate(groups, mod, defaultTemplate);
    boolean mandatoryEmail = !mod.getAddParticipants().isEmpty() && groupModule.isMandatoryEnrolmentEmail(ureq.getUserSession().getRoles());
    userManagementSendMailController = new BGMailNotificationEditController(getWindowControl(), ureq, template, totalModification == 1, totalModification == 1, false, mandatoryEmail);
    Component cmp = userManagementSendMailController.getInitialComponent();
    listenTo(userManagementSendMailController);
    cmc = new CloseableModalController(getWindowControl(), translate("close"), cmp, true, translate("users.group"));
    cmc.activate();
    listenTo(cmc);
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) MailTemplate(org.olat.core.util.mail.MailTemplate) BGUserMailTemplate(org.olat.group.ui.wizard.BGUserMailTemplate) BGMailNotificationEditController(org.olat.group.ui.wizard.BGMailNotificationEditController) BGUserMailTemplate(org.olat.group.ui.wizard.BGUserMailTemplate) MailType(org.olat.group.manager.BusinessGroupMailing.MailType) Component(org.olat.core.gui.components.Component)

Example 3 with BGUserMailTemplate

use of org.olat.group.ui.wizard.BGUserMailTemplate in project openolat by klemens.

the class AbstractBusinessGroupListController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == deleteDialogBox) {
        if (event == Event.DONE_EVENT) {
            boolean withEmail = deleteDialogBox.isSendMail();
            List<BusinessGroup> groupsToDelete = deleteDialogBox.getGroupsToDelete();
            doDelete(ureq, withEmail, groupsToDelete);
            tableEl.deselectAll();
            reloadModel();
        }
        cmc.deactivate();
        cleanUpPopups();
    } else if (source == leaveDialogBox) {
        if (event != Event.CANCELLED_EVENT && DialogBoxUIFactory.isYesEvent(event)) {
            doLeave((BusinessGroup) leaveDialogBox.getUserObject());
            tableEl.deselectAll();
            reloadModel();
        }
    } else if (source == groupCreateController) {
        BusinessGroup group = null;
        if (event == Event.DONE_EVENT) {
            Set<BusinessGroup> groups = groupCreateController.getCreatedGroups();
            if (groups.size() == 1) {
                group = groups.iterator().next();
            }
            if (groups.size() > 0) {
                tableEl.deselectAll();
                reloadModel();
            }
        }
        cmc.deactivate();
        cleanUpPopups();
        // if new group -> go to the tab
        if (group != null) {
            String businessPath = "[BusinessGroup:" + group.getKey() + "]";
            NewControllerFactory.getInstance().launch(businessPath, ureq, getWindowControl());
        }
        fireEvent(ureq, Event.CHANGED_EVENT);
    } else if (source == businessGroupWizard) {
        if (event == Event.CANCELLED_EVENT || event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            getWindowControl().pop();
            removeAsListenerAndDispose(businessGroupWizard);
            businessGroupWizard = null;
            if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
                reloadModel();
            }
        }
    } else if (source == emailWizard) {
        if (event == Event.CANCELLED_EVENT || event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            getWindowControl().pop();
            removeAsListenerAndDispose(emailWizard);
            emailWizard = null;
            if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
                tableEl.deselectAll();
            }
        }
    } else if (source == userManagementController) {
        cmc.deactivate();
        if (event == Event.DONE_EVENT) {
            // confirm sending emails
            MembershipModification mod = userManagementController.getModifications();
            List<BusinessGroup> groups = userManagementController.getGroups();
            confirmUserManagementEmail(ureq, mod, groups);
        } else {
            cleanUpPopups();
        }
    } else if (source == userManagementSendMailController) {
        if (event == Event.DONE_EVENT) {
            BGUserMailTemplate sendMail = (BGUserMailTemplate) userManagementSendMailController.getTemplate();
            MembershipModification mod = sendMail.getModifications();
            List<BusinessGroup> groups = sendMail.getGroups();
            finishUserManagement(mod, groups, sendMail, userManagementSendMailController.isSendMail());
            reloadModel();
        }
        cmc.deactivate();
        cleanUpPopups();
    } else if (source == searchCtrl) {
        if (event instanceof SearchEvent) {
            doSearch(ureq, (SearchEvent) event);
        }
    } else if (source == contactCtrl) {
        cmc.deactivate();
        cleanUpPopups();
    } else if (source == cmc) {
        cleanUpPopups();
    }
    super.event(ureq, source, event);
}
Also used : BGCopyBusinessGroup(org.olat.group.ui.wizard.BGCopyBusinessGroup) BGConfigBusinessGroup(org.olat.group.ui.wizard.BGConfigBusinessGroup) BusinessGroup(org.olat.group.BusinessGroup) MembershipModification(org.olat.group.model.MembershipModification) ContactList(org.olat.core.util.mail.ContactList) List(java.util.List) ArrayList(java.util.ArrayList) BGUserMailTemplate(org.olat.group.ui.wizard.BGUserMailTemplate) FlexiTableSearchEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableSearchEvent)

Example 4 with BGUserMailTemplate

use of org.olat.group.ui.wizard.BGUserMailTemplate in project openolat by klemens.

the class AbstractBusinessGroupListController method confirmUserManagementEmail.

private void confirmUserManagementEmail(UserRequest ureq, MembershipModification mod, List<BusinessGroup> groups) {
    removeAsListenerAndDispose(cmc);
    removeAsListenerAndDispose(userManagementSendMailController);
    MailTemplate defaultTemplate = null;
    int totalModification = (mod.size() * groups.size());
    if (totalModification == 1) {
        MailType type = BusinessGroupMailing.getDefaultTemplateType(mod);
        if (type != null) {
            defaultTemplate = BusinessGroupMailing.getDefaultTemplate(type, groups.get(0), ureq.getIdentity());
        }
    }
    MailTemplate template = new BGUserMailTemplate(groups, mod, defaultTemplate);
    boolean mandatoryEmail = !mod.getAddParticipants().isEmpty() && groupModule.isMandatoryEnrolmentEmail(ureq.getUserSession().getRoles());
    userManagementSendMailController = new BGMailNotificationEditController(getWindowControl(), ureq, template, totalModification == 1, totalModification == 1, false, mandatoryEmail);
    Component cmp = userManagementSendMailController.getInitialComponent();
    listenTo(userManagementSendMailController);
    cmc = new CloseableModalController(getWindowControl(), translate("close"), cmp, true, translate("users.group"));
    cmc.activate();
    listenTo(cmc);
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) MailTemplate(org.olat.core.util.mail.MailTemplate) BGUserMailTemplate(org.olat.group.ui.wizard.BGUserMailTemplate) BGMailNotificationEditController(org.olat.group.ui.wizard.BGMailNotificationEditController) BGUserMailTemplate(org.olat.group.ui.wizard.BGUserMailTemplate) MailType(org.olat.group.manager.BusinessGroupMailing.MailType) Component(org.olat.core.gui.components.Component)

Aggregations

BGUserMailTemplate (org.olat.group.ui.wizard.BGUserMailTemplate)4 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Component (org.olat.core.gui.components.Component)2 FlexiTableSearchEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableSearchEvent)2 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)2 ContactList (org.olat.core.util.mail.ContactList)2 MailTemplate (org.olat.core.util.mail.MailTemplate)2 BusinessGroup (org.olat.group.BusinessGroup)2 MailType (org.olat.group.manager.BusinessGroupMailing.MailType)2 MembershipModification (org.olat.group.model.MembershipModification)2 BGConfigBusinessGroup (org.olat.group.ui.wizard.BGConfigBusinessGroup)2 BGCopyBusinessGroup (org.olat.group.ui.wizard.BGCopyBusinessGroup)2 BGMailNotificationEditController (org.olat.group.ui.wizard.BGMailNotificationEditController)2