Search in sources :

Example 11 with MailNotificationEditController

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

the class WaitingGroupController method event.

/**
 * @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) {
        if (event.getCommand().equals(Table.COMMAND_MULTISELECT)) {
            // Multiselect events
            TableMultiSelectEvent tmse = (TableMultiSelectEvent) event;
            if (tmse.getAction().equals(COMMAND_MOVE_USER_WAITINGLIST)) {
                if (tmse.getSelection().isEmpty()) {
                    getWindowControl().setWarning(translate("msg.selectionempty"));
                } else {
                    List<Identity> objects = identitiesTableModel.getIdentities(tmse.getSelection());
                    toTransfer = objects;
                    removeAsListenerAndDispose(transferMailCtr);
                    transferMailCtr = new MailNotificationEditController(getWindowControl(), ureq, transferUserMailTempl, true, mandatoryEmail, true);
                    listenTo(transferMailCtr);
                    removeAsListenerAndDispose(cmc);
                    cmc = new CloseableModalController(getWindowControl(), translate("close"), transferMailCtr.getInitialComponent());
                    listenTo(cmc);
                    cmc.activate();
                    // don't execute super method
                    return;
                }
            }
        }
    } else if (sourceController == transferMailCtr) {
        if (event == Event.DONE_EVENT) {
            // fetch configured mail template and finish this controller workflow
            MailTemplate customTransferTemplate = transferMailCtr.getMailTemplate();
            cmc.deactivate();
            IdentitiesMoveEvent identitiesMoveEvent = new IdentitiesMoveEvent(toTransfer);
            identitiesMoveEvent.setMailTemplate(customTransferTemplate);
            fireEvent(ureq, identitiesMoveEvent);
            StringBuilder infoMessage = new StringBuilder();
            for (Identity identity : identitiesMoveEvent.getNotMovedIdentities()) {
                String fullName = userManager.getUserDisplayName(identity);
                infoMessage.append(translate("msg.alreadyinwaiitinggroup", fullName)).append("<br />");
            }
            // report any errors on screen
            if (infoMessage.length() > 0)
                getWindowControl().setInfo(infoMessage.toString());
            // don't execute super method
            return;
        } else if (event == Event.CANCELLED_EVENT) {
            cmc.deactivate();
            // don't execute super method
            return;
        } else {
            throw new RuntimeException("unknown event ::" + event.getCommand());
        }
    }
    // it is no WaitingGroupController event, forward it to super class GroupController
    super.event(ureq, sourceController, event);
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) TableMultiSelectEvent(org.olat.core.gui.components.table.TableMultiSelectEvent) MailTemplate(org.olat.core.util.mail.MailTemplate) Identity(org.olat.core.id.Identity) MailNotificationEditController(org.olat.core.util.mail.MailNotificationEditController)

Example 12 with MailNotificationEditController

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

the class SelectionForm method handleEmailButtonEvent.

private void handleEmailButtonEvent(UserRequest ureq, TableMultiSelectEvent tmse) {
    List<Identity> identities = tdm.getObjects(tmse.getSelection());
    if (identities.size() > 0) {
        selectedIdentities = identities;
        MailTemplate deleteMailTemplate = createMailTemplate(translate(KEY_EMAIL_SUBJECT), translate(KEY_EMAIL_BODY));
        deleteMailTemplate.setCpfrom(Boolean.FALSE);
        deleteMailTemplate.addToContext("lastloginduration", Integer.toString(UserDeletionManager.getInstance().getLastLoginDuration()));
        deleteMailTemplate.addToContext("durationdeleteemail", Integer.toString(UserDeletionManager.getInstance().getDeleteEmailDuration()));
        removeAsListenerAndDispose(deleteUserMailCtr);
        deleteUserMailCtr = new MailNotificationEditController(getWindowControl(), ureq, deleteMailTemplate, true, false, false);
        listenTo(deleteUserMailCtr);
        removeAsListenerAndDispose(cmc);
        cmc = new CloseableModalController(getWindowControl(), translate("close"), deleteUserMailCtr.getInitialComponent());
        listenTo(cmc);
        cmc.activate();
    } else {
        showWarning("nothing.selected.msg");
    }
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) MailTemplate(org.olat.core.util.mail.MailTemplate) Identity(org.olat.core.id.Identity) MailNotificationEditController(org.olat.core.util.mail.MailNotificationEditController)

Example 13 with MailNotificationEditController

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

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 14 with MailNotificationEditController

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

the class TaskFolderCallback method event.

/**
 * @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 urequest, Controller source, Event event) {
    if (source == modulesForm) {
        boolean onoff = event.getCommand().endsWith("true");
        if (event.getCommand().startsWith("task")) {
            config.set(TACourseNode.CONF_TASK_ENABLED, new Boolean(onoff));
            myTabbedPane.setEnabled(taskTabPosition, onoff);
            if (onoff) {
                accessabilityVC.put("taskCondition", taskConditionC.getInitialComponent());
            } else {
                accessabilityVC.remove(taskConditionC.getInitialComponent());
            }
        } else if (event.getCommand().startsWith("dropbox")) {
            config.set(TACourseNode.CONF_DROPBOX_ENABLED, new Boolean(onoff));
            myTabbedPane.setEnabled(dropboxTabPosition, onoff);
            if (onoff) {
                accessabilityVC.put("dropCondition", dropConditionC.getInitialComponent());
            } else {
                accessabilityVC.remove(dropConditionC.getInitialComponent());
            }
        } else if (event.getCommand().startsWith("returnbox")) {
            config.set(TACourseNode.CONF_RETURNBOX_ENABLED, new Boolean(onoff));
            if (onoff) {
                accessabilityVC.put("returnboxCondition", returnboxConditionC.getInitialComponent());
            } else {
                accessabilityVC.remove(returnboxConditionC.getInitialComponent());
            }
        } else if (event.getCommand().startsWith("scoring")) {
            config.set(TACourseNode.CONF_SCORING_ENABLED, new Boolean(onoff));
            myTabbedPane.setEnabled(scoringTabPosition, onoff);
            if (onoff) {
                accessabilityVC.put("scoringCondition", scoringConditionC.getInitialComponent());
            } else {
                accessabilityVC.remove(scoringConditionC.getInitialComponent());
            }
        } else if (event.getCommand().startsWith("solution")) {
            config.set(TACourseNode.CONF_SOLUTION_ENABLED, new Boolean(onoff));
            myTabbedPane.setEnabled(solutionTabPosition, onoff);
            if (onoff) {
                accessabilityVC.put("solutionCondition", solutionConditionC.getInitialComponent());
            } else {
                accessabilityVC.remove(solutionConditionC.getInitialComponent());
            }
        }
        fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        return;
    } else if (source == taskConditionC) {
        if (event == Event.CHANGED_EVENT) {
            node.setConditionTask(taskConditionC.getCondition());
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == dropConditionC) {
        if (event == Event.CHANGED_EVENT) {
            node.setConditionDrop(dropConditionC.getCondition());
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == returnboxConditionC) {
        if (event == Event.CHANGED_EVENT) {
            node.setConditionReturnbox(returnboxConditionC.getCondition());
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == scoringConditionC) {
        if (event == Event.CHANGED_EVENT) {
            node.setConditionScoring(scoringConditionC.getCondition());
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == solutionConditionC) {
        if (event == Event.CHANGED_EVENT) {
            node.setConditionSolution(solutionConditionC.getCondition());
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == dialogBoxController) {
        if (DialogBoxUIFactory.isOkEvent(event)) {
            // ok: open task folder
            String relPath = TACourseNode.getTaskFolderPathRelToFolderRoot(course, node);
            OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(relPath, null);
            OlatNamedContainerImpl namedFolder = new OlatNamedContainerImpl(translate("taskfolder"), rootFolder);
            namedFolder.setLocalSecurityCallback(getTaskFolderSecCallback(relPath));
            frc = new FolderRunController(namedFolder, false, urequest, getWindowControl());
            listenTo(frc);
            CloseableModalController cmc = new CloseableModalController(getWindowControl(), translate("folder.close"), frc.getInitialComponent());
            cmc.activate();
            fireEvent(urequest, Event.CHANGED_EVENT);
        }
    } else if (source == taskController) {
        if (event == Event.CANCELLED_EVENT) {
            return;
        } else if (event == Event.DONE_EVENT) {
            config.set(TACourseNode.CONF_TASK_TYPE, taskController.getTaskType());
            config.set(TACourseNode.CONF_TASK_TEXT, taskController.getOptionalText());
            config.set(TACourseNode.CONF_TASK_SAMPLING_WITH_REPLACEMENT, new Boolean(taskController.getIsSamplingWithReplacement()));
            config.setBooleanEntry(TACourseNode.CONF_TASK_PREVIEW, taskController.isTaskPreviewMode());
            config.setBooleanEntry(TACourseNode.CONF_TASK_DESELECT, taskController.isTaskDeselectMode());
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
            return;
        }
    } else if (source == scoringController) {
        if (event == Event.CANCELLED_EVENT) {
            if (hasLogEntries) {
                scoringController.setDisplayOnly(true);
            }
            editScoring.contextPut("isOverwriting", new Boolean(false));
            return;
        } else if (event == Event.DONE_EVENT) {
            scoringController.updateModuleConfiguration(config);
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == dropboxForm) {
        if (event == Event.CANCELLED_EVENT) {
            return;
        } else if (event == Event.DONE_EVENT) {
            config.set(TACourseNode.CONF_DROPBOX_ENABLEMAIL, new Boolean(dropboxForm.mailEnabled()));
            config.set(TACourseNode.CONF_DROPBOX_CONFIRMATION, dropboxForm.getConfirmation());
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
            return;
        }
    } else if (source == frc && (event instanceof FolderEvent) && event.getCommand().equals(FolderEvent.DELETE_EVENT)) {
        String deletedTaskFile = getFileListAsComaSeparated(((FolderEvent) event).getFilename());
        // cancel task assignment
        identitiesToBeNotified = removeAssignedTask(course, deletedTaskFile);
        if (identitiesToBeNotified.size() > 0) {
            // prepare mailTemplate if they are any identities to be notified
            removeAsListenerAndDispose(mailCtr);
            RepositoryEntry repositoryEntry = RepositoryManager.getInstance().lookupRepositoryEntry(course, true);
            String courseURL = Settings.getServerContextPathURI() + "/url/RepositoryEntry/" + repositoryEntry.getKey();
            MailTemplate mailTemplate = this.createTaskDeletedMailTemplate(urequest, course.getCourseTitle(), courseURL, deletedTaskFile);
            mailCtr = new MailNotificationEditController(getWindowControl(), urequest, mailTemplate, true, false, true);
            listenTo(mailCtr);
            cmc = new CloseableModalController(getWindowControl(), translate("close"), mailCtr.getInitialComponent());
            listenTo(cmc);
            cmc.activate();
        }
    } else if (source == mailCtr) {
        if (event == Event.DONE_EVENT) {
            cmc.deactivate();
            if (identitiesToBeNotified != null && identitiesToBeNotified.size() > 0) {
                // sent email to all identities that used to have the deleted task assigned
                sendNotificationEmail(urequest, mailCtr.getMailTemplate(), identitiesToBeNotified);
            }
        } else if (event == Event.CANCELLED_EVENT) {
            cmc.deactivate();
        }
    } else {
        log.warn("Can not handle event in TACourseNodeEditController source=" + source + " " + event.toString());
    }
}
Also used : OlatNamedContainerImpl(org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) FolderRunController(org.olat.core.commons.modules.bc.FolderRunController) MailTemplate(org.olat.core.util.mail.MailTemplate) FolderEvent(org.olat.core.commons.modules.bc.FolderEvent) RepositoryEntry(org.olat.repository.RepositoryEntry) MailNotificationEditController(org.olat.core.util.mail.MailNotificationEditController)

Aggregations

MailNotificationEditController (org.olat.core.util.mail.MailNotificationEditController)14 MailTemplate (org.olat.core.util.mail.MailTemplate)14 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)12 Identity (org.olat.core.id.Identity)10 TableMultiSelectEvent (org.olat.core.gui.components.table.TableMultiSelectEvent)6 ArrayList (java.util.ArrayList)4 List (java.util.List)4 MultiIdentityChosenEvent (org.olat.basesecurity.events.MultiIdentityChosenEvent)4 SingleIdentityChosenEvent (org.olat.basesecurity.events.SingleIdentityChosenEvent)4 UserRequest (org.olat.core.gui.UserRequest)4 TableEvent (org.olat.core.gui.components.table.TableEvent)4 WindowControl (org.olat.core.gui.control.WindowControl)4 ControllerCreator (org.olat.core.gui.control.creator.ControllerCreator)4 PopupBrowserWindow (org.olat.core.gui.control.generic.popup.PopupBrowserWindow)4 AssertException (org.olat.core.logging.AssertException)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4 UserInfoMainController (org.olat.user.UserInfoMainController)4 VelocityContext (org.apache.velocity.VelocityContext)2 FolderEvent (org.olat.core.commons.modules.bc.FolderEvent)2 FolderRunController (org.olat.core.commons.modules.bc.FolderRunController)2