Search in sources :

Example 1 with AddToGroupsEvent

use of org.olat.group.model.AddToGroupsEvent in project OpenOLAT by OpenOLAT.

the class GroupSearchController method doSave.

private void doSave(UserRequest ureq) {
    List<Long> ownerGroups = getCheckedTutorKeys();
    List<Long> partGroups = getCheckedParticipantKeys();
    if (isUsedInStepWizzard()) {
        // might be used in wizzard during user import or user bulk change. allow next/finish according to previous steps.
        addToRunContext("ownerGroups", ownerGroups);
        addToRunContext("partGroups", partGroups);
        boolean groupsChoosen = (ownerGroups.size() != 0 || partGroups.size() != 0);
        boolean validImport = getFromRunContext("validImport") != null && ((Boolean) getFromRunContext("validImport"));
        boolean validBulkChange = getFromRunContext("validChange") != null && ((Boolean) getFromRunContext("validChange"));
        boolean isValid = groupsChoosen || (validImport || validBulkChange);
        addToRunContext("validGroupAdd", isValid);
        // fxdiff: FXOLAT-245 notify userbulkchange-wizard about valid change
        addToRunContext("validChange", isValid);
        fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
    } else {
        fireEvent(ureq, new AddToGroupsEvent(ownerGroups, partGroups));
    }
}
Also used : AddToGroupsEvent(org.olat.group.model.AddToGroupsEvent)

Example 2 with AddToGroupsEvent

use of org.olat.group.model.AddToGroupsEvent in project openolat by klemens.

the class GroupOverviewController 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
protected void event(UserRequest ureq, Controller source, Event event) {
    super.event(ureq, source, event);
    if (source == groupListCtr) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent te = (TableEvent) event;
            GroupOverviewRow item = tableDataModel.getObject(te.getRowId());
            BusinessGroup currBusinessGroup = businessGroupService.loadBusinessGroup(item.getKey());
            if (currBusinessGroup == null) {
                // group seems to be removed meanwhile, reload table and show error
                showError("group.removed");
                updateModel();
            } else if (TABLE_ACTION_LAUNCH.equals(te.getActionId())) {
                NewControllerFactory.getInstance().launch("[BusinessGroup:" + currBusinessGroup.getKey() + "]", ureq, getWindowControl());
            } else if (TABLE_ACTION_UNSUBSCRIBE.equals(te.getActionId())) {
                doLeave(ureq, Collections.singletonList(currBusinessGroup));
            }
        } else if (event instanceof TableMultiSelectEvent) {
            TableMultiSelectEvent mse = (TableMultiSelectEvent) event;
            List<GroupOverviewRow> items = tableDataModel.getObjects(mse.getSelection());
            if (TABLE_ACTION_UNSUBSCRIBE.equals(mse.getAction())) {
                List<BusinessGroup> groups = toBusinessGroups(items);
                doLeave(ureq, groups);
            }
        }
    } else if (source == groupsCtrl && event instanceof AddToGroupsEvent) {
        AddToGroupsEvent groupsEv = (AddToGroupsEvent) event;
        if (groupsEv.isEmpty()) {
            // no groups selected
            showWarning("group.add.result.none");
        } else {
            if (cmc != null) {
                cmc.deactivate();
            }
            boolean mailMandatory = groupModule.isMandatoryEnrolmentEmail(ureq.getUserSession().getRoles());
            if (mailMandatory) {
                doAddToGroups(groupsEv, true);
                updateModel();
            } else {
                confirmSendMailBox = activateYesNoDialog(ureq, null, translate("dialog.modal.bg.send.mail"), confirmSendMailBox);
                confirmSendMailBox.setUserObject(groupsEv);
            }
        }
        cleanUpPopups();
    } else if (source == confirmSendMailBox) {
        boolean sendMail = DialogBoxUIFactory.isYesEvent(event) || DialogBoxUIFactory.isOkEvent(event);
        AddToGroupsEvent groupsEv = (AddToGroupsEvent) confirmSendMailBox.getUserObject();
        doAddToGroups(groupsEv, sendMail);
        updateModel();
    } else if (source == removeFromGrpDlg) {
        if (event == Event.DONE_EVENT) {
            boolean sendMail = removeFromGrpDlg.isSendMail();
            List<BusinessGroup> groupsToDelete = removeFromGrpDlg.getGroupsToDelete();
            List<BusinessGroup> groupsToLeave = removeFromGrpDlg.getGroupsToLeave();
            removeUserFromGroup(ureq, groupsToLeave, groupsToDelete, sendMail);
        }
        cmc.deactivate();
        cleanUpPopups();
    } else if (source == cmc) {
        cleanUpPopups();
    }
}
Also used : AddToGroupsEvent(org.olat.group.model.AddToGroupsEvent) TableEvent(org.olat.core.gui.components.table.TableEvent) BusinessGroup(org.olat.group.BusinessGroup) TableMultiSelectEvent(org.olat.core.gui.components.table.TableMultiSelectEvent) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with AddToGroupsEvent

use of org.olat.group.model.AddToGroupsEvent in project openolat by klemens.

the class GroupSearchController method doSave.

private void doSave(UserRequest ureq) {
    List<Long> ownerGroups = getCheckedTutorKeys();
    List<Long> partGroups = getCheckedParticipantKeys();
    if (isUsedInStepWizzard()) {
        // might be used in wizzard during user import or user bulk change. allow next/finish according to previous steps.
        addToRunContext("ownerGroups", ownerGroups);
        addToRunContext("partGroups", partGroups);
        boolean groupsChoosen = (ownerGroups.size() != 0 || partGroups.size() != 0);
        boolean validImport = getFromRunContext("validImport") != null && ((Boolean) getFromRunContext("validImport"));
        boolean validBulkChange = getFromRunContext("validChange") != null && ((Boolean) getFromRunContext("validChange"));
        boolean isValid = groupsChoosen || (validImport || validBulkChange);
        addToRunContext("validGroupAdd", isValid);
        // fxdiff: FXOLAT-245 notify userbulkchange-wizard about valid change
        addToRunContext("validChange", isValid);
        fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
    } else {
        fireEvent(ureq, new AddToGroupsEvent(ownerGroups, partGroups));
    }
}
Also used : AddToGroupsEvent(org.olat.group.model.AddToGroupsEvent)

Example 4 with AddToGroupsEvent

use of org.olat.group.model.AddToGroupsEvent in project OpenOLAT by OpenOLAT.

the class GroupOverviewController 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
protected void event(UserRequest ureq, Controller source, Event event) {
    super.event(ureq, source, event);
    if (source == groupListCtr) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent te = (TableEvent) event;
            GroupOverviewRow item = tableDataModel.getObject(te.getRowId());
            BusinessGroup currBusinessGroup = businessGroupService.loadBusinessGroup(item.getKey());
            if (currBusinessGroup == null) {
                // group seems to be removed meanwhile, reload table and show error
                showError("group.removed");
                updateModel();
            } else if (TABLE_ACTION_LAUNCH.equals(te.getActionId())) {
                NewControllerFactory.getInstance().launch("[BusinessGroup:" + currBusinessGroup.getKey() + "]", ureq, getWindowControl());
            } else if (TABLE_ACTION_UNSUBSCRIBE.equals(te.getActionId())) {
                doLeave(ureq, Collections.singletonList(currBusinessGroup));
            }
        } else if (event instanceof TableMultiSelectEvent) {
            TableMultiSelectEvent mse = (TableMultiSelectEvent) event;
            List<GroupOverviewRow> items = tableDataModel.getObjects(mse.getSelection());
            if (TABLE_ACTION_UNSUBSCRIBE.equals(mse.getAction())) {
                List<BusinessGroup> groups = toBusinessGroups(items);
                doLeave(ureq, groups);
            }
        }
    } else if (source == groupsCtrl && event instanceof AddToGroupsEvent) {
        AddToGroupsEvent groupsEv = (AddToGroupsEvent) event;
        if (groupsEv.isEmpty()) {
            // no groups selected
            showWarning("group.add.result.none");
        } else {
            if (cmc != null) {
                cmc.deactivate();
            }
            boolean mailMandatory = groupModule.isMandatoryEnrolmentEmail(ureq.getUserSession().getRoles());
            if (mailMandatory) {
                doAddToGroups(groupsEv, true);
                updateModel();
            } else {
                confirmSendMailBox = activateYesNoDialog(ureq, null, translate("dialog.modal.bg.send.mail"), confirmSendMailBox);
                confirmSendMailBox.setUserObject(groupsEv);
            }
        }
        cleanUpPopups();
    } else if (source == confirmSendMailBox) {
        boolean sendMail = DialogBoxUIFactory.isYesEvent(event) || DialogBoxUIFactory.isOkEvent(event);
        AddToGroupsEvent groupsEv = (AddToGroupsEvent) confirmSendMailBox.getUserObject();
        doAddToGroups(groupsEv, sendMail);
        updateModel();
    } else if (source == removeFromGrpDlg) {
        if (event == Event.DONE_EVENT) {
            boolean sendMail = removeFromGrpDlg.isSendMail();
            List<BusinessGroup> groupsToDelete = removeFromGrpDlg.getGroupsToDelete();
            List<BusinessGroup> groupsToLeave = removeFromGrpDlg.getGroupsToLeave();
            removeUserFromGroup(ureq, groupsToLeave, groupsToDelete, sendMail);
        }
        cmc.deactivate();
        cleanUpPopups();
    } else if (source == cmc) {
        cleanUpPopups();
    }
}
Also used : AddToGroupsEvent(org.olat.group.model.AddToGroupsEvent) TableEvent(org.olat.core.gui.components.table.TableEvent) BusinessGroup(org.olat.group.BusinessGroup) TableMultiSelectEvent(org.olat.core.gui.components.table.TableMultiSelectEvent) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

AddToGroupsEvent (org.olat.group.model.AddToGroupsEvent)4 ArrayList (java.util.ArrayList)2 List (java.util.List)2 TableEvent (org.olat.core.gui.components.table.TableEvent)2 TableMultiSelectEvent (org.olat.core.gui.components.table.TableMultiSelectEvent)2 BusinessGroup (org.olat.group.BusinessGroup)2