Search in sources :

Example 6 with MemberPermissionChangeEvent

use of org.olat.group.ui.main.MemberPermissionChangeEvent in project OpenOLAT by OpenOLAT.

the class CourseOverviewController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == courseListCtr) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent te = (TableEvent) event;
            CourseMemberView item = tableDataModel.getObject(te.getRowId());
            if (TABLE_ACTION_LAUNCH.equals(te.getActionId())) {
                launch(ureq, item.getRepoKey());
            } else if (TABLE_ACTION_UNSUBSCRIBE.equals(te.getActionId())) {
                doLeave(ureq, Collections.singletonList(item));
            } else if (TABLE_ACTION_EDIT.equals(te.getActionId())) {
                doOpenEdit(ureq, item);
            }
        } else if (event instanceof TableMultiSelectEvent) {
            TableMultiSelectEvent mse = (TableMultiSelectEvent) event;
            List<CourseMemberView> items = tableDataModel.getObjects(mse.getSelection());
            if (TABLE_ACTION_UNSUBSCRIBE.equals(mse.getAction())) {
                doLeave(ureq, items);
            }
        }
    } else if (source == repoSearchCtr) {
        SearchType type = (SearchType) repoSearchCtr.getUserObject();
        if (event == ReferencableEntriesSearchController.EVENT_REPOSITORY_ENTRY_SELECTED) {
            // repository search controller done
            RepositoryEntry re = repoSearchCtr.getSelectedEntry();
            removeAsListenerAndDispose(repoSearchCtr);
            cmc.deactivate();
            doConfirmSendEmail(ureq, Collections.singletonList(re), type);
        } else if (event == ReferencableEntriesSearchController.EVENT_REPOSITORY_ENTRIES_SELECTED) {
            // repository search controller done
            List<RepositoryEntry> res = repoSearchCtr.getSelectedEntries();
            removeAsListenerAndDispose(repoSearchCtr);
            cmc.deactivate();
            if (res != null && !res.isEmpty()) {
                doConfirmSendEmail(ureq, res, type);
            }
        }
    } else if (source == editSingleMemberCtrl) {
        cmc.deactivate();
        if (event instanceof MemberPermissionChangeEvent) {
            MemberPermissionChangeEvent e = (MemberPermissionChangeEvent) event;
            RepositoryEntry re = editSingleMemberCtrl.getRepositoryEntry();
            doConfirmChangePermission(ureq, e, re);
        }
    } else if (source == confirmSendMailBox) {
        boolean sendMail = DialogBoxUIFactory.isYesEvent(event) || DialogBoxUIFactory.isOkEvent(event);
        Object confirmation = confirmSendMailBox.getUserObject();
        if (confirmation instanceof ConfirmAdd) {
            ConfirmAdd addInfos = (ConfirmAdd) confirmation;
            doAddToRepositoryEntry(ureq, addInfos.getEntries(), addInfos.getType(), sendMail);
        } else if (confirmation instanceof ConfirmEdit) {
            ConfirmEdit editInfos = (ConfirmEdit) confirmation;
            doChangePermission(ureq, editInfos.getChangeEvent(), editInfos.getEntry(), sendMail);
        }
        updateModel();
    } else if (source == removeFromCourseDlg) {
        if (event == Event.DONE_EVENT) {
            boolean sendMail = removeFromCourseDlg.isSendMail();
            List<BusinessGroup> groupsToDelete = removeFromCourseDlg.getGroupsToDelete();
            List<BusinessGroup> groupsToLeave = removeFromCourseDlg.getGroupsToLeave();
            List<RepositoryEntry> repoEntriesToLeave = removeFromCourseDlg.getRepoEntriesToLeave();
            removeUserFromCourse(ureq, repoEntriesToLeave, groupsToLeave, groupsToDelete, sendMail);
        }
        cmc.deactivate();
        cleanUp();
    } else if (source == cmc) {
        cleanUp();
    }
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) TableMultiSelectEvent(org.olat.core.gui.components.table.TableMultiSelectEvent) MemberPermissionChangeEvent(org.olat.group.ui.main.MemberPermissionChangeEvent) RepositoryEntry(org.olat.repository.RepositoryEntry) TableEvent(org.olat.core.gui.components.table.TableEvent) List(java.util.List) ArrayList(java.util.ArrayList)

Example 7 with MemberPermissionChangeEvent

use of org.olat.group.ui.main.MemberPermissionChangeEvent in project OpenOLAT by OpenOLAT.

the class BusinessGroupMembersController method addMembers.

private void addMembers(StepsRunContext runContext) {
    @SuppressWarnings("unchecked") List<Identity> members = (List<Identity>) runContext.get("members");
    MemberPermissionChangeEvent changes = (MemberPermissionChangeEvent) runContext.get("permissions");
    // commit all changes to the group memberships
    List<BusinessGroupMembershipChange> allModifications = changes.generateBusinessGroupMembershipChange(members);
    MailTemplate template = (MailTemplate) runContext.get("mailTemplate");
    MailPackage mailing = new MailPackage(template, getWindowControl().getBusinessControl().getAsString(), template != null);
    businessGroupService.updateMemberships(getIdentity(), allModifications, mailing);
    MailHelper.printErrorsAndWarnings(mailing.getResult(), getWindowControl(), false, getLocale());
}
Also used : BusinessGroupMembershipChange(org.olat.group.model.BusinessGroupMembershipChange) MailPackage(org.olat.core.util.mail.MailPackage) MemberPermissionChangeEvent(org.olat.group.ui.main.MemberPermissionChangeEvent) MailTemplate(org.olat.core.util.mail.MailTemplate) List(java.util.List) Identity(org.olat.core.id.Identity)

Example 8 with MemberPermissionChangeEvent

use of org.olat.group.ui.main.MemberPermissionChangeEvent in project OpenOLAT by OpenOLAT.

the class ImportMemberPermissionChoiceController method validateFormLogic.

@Override
protected boolean validateFormLogic(UserRequest ureq) {
    boolean allOk = true;
    MemberPermissionChangeEvent e = new MemberPermissionChangeEvent(null);
    permissionCtrl.collectRepoChanges(e);
    permissionCtrl.collectGroupChanges(e);
    int size = e.size();
    flc.contextRemove("off_warn");
    if (size == 0) {
        String warning = translate("error.select.role");
        flc.contextPut("off_warn", warning);
        allOk &= false;
    }
    return allOk & super.validateFormLogic(ureq);
}
Also used : MemberPermissionChangeEvent(org.olat.group.ui.main.MemberPermissionChangeEvent)

Example 9 with MemberPermissionChangeEvent

use of org.olat.group.ui.main.MemberPermissionChangeEvent in project openolat by klemens.

the class RepositoryMembersController method addMembers.

protected void addMembers(UserRequest ureq, StepsRunContext runContext) {
    @SuppressWarnings("unchecked") List<Identity> members = (List<Identity>) runContext.get("members");
    MailTemplate template = (MailTemplate) runContext.get("mailTemplate");
    MemberPermissionChangeEvent changes = (MemberPermissionChangeEvent) runContext.get("permissions");
    // commit changes to the repository entry
    MailerResult result = new MailerResult();
    MailPackage reMailing = new MailPackage(template, result, getWindowControl().getBusinessControl().getAsString(), template != null);
    List<RepositoryEntryPermissionChangeEvent> repoChanges = changes.generateRepositoryChanges(members);
    repositoryManager.updateRepositoryEntryMemberships(getIdentity(), ureq.getUserSession().getRoles(), repoEntry, repoChanges, reMailing);
    // commit all changes to the group memberships
    List<BusinessGroupMembershipChange> allModifications = changes.generateBusinessGroupMembershipChange(members);
    MailPackage bgMailing = new MailPackage(template, result, getWindowControl().getBusinessControl().getAsString(), template != null);
    businessGroupService.updateMemberships(getIdentity(), allModifications, bgMailing);
    MailHelper.printErrorsAndWarnings(result, getWindowControl(), ureq.getUserSession().getRoles().isOLATAdmin(), getLocale());
}
Also used : BusinessGroupMembershipChange(org.olat.group.model.BusinessGroupMembershipChange) MailPackage(org.olat.core.util.mail.MailPackage) MailerResult(org.olat.core.util.mail.MailerResult) MailTemplate(org.olat.core.util.mail.MailTemplate) MemberPermissionChangeEvent(org.olat.group.ui.main.MemberPermissionChangeEvent) List(java.util.List) RepositoryEntryPermissionChangeEvent(org.olat.repository.model.RepositoryEntryPermissionChangeEvent) Identity(org.olat.core.id.Identity)

Example 10 with MemberPermissionChangeEvent

use of org.olat.group.ui.main.MemberPermissionChangeEvent in project openolat by klemens.

the class CourseOverviewController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == courseListCtr) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent te = (TableEvent) event;
            CourseMemberView item = tableDataModel.getObject(te.getRowId());
            if (TABLE_ACTION_LAUNCH.equals(te.getActionId())) {
                launch(ureq, item.getRepoKey());
            } else if (TABLE_ACTION_UNSUBSCRIBE.equals(te.getActionId())) {
                doLeave(ureq, Collections.singletonList(item));
            } else if (TABLE_ACTION_EDIT.equals(te.getActionId())) {
                doOpenEdit(ureq, item);
            }
        } else if (event instanceof TableMultiSelectEvent) {
            TableMultiSelectEvent mse = (TableMultiSelectEvent) event;
            List<CourseMemberView> items = tableDataModel.getObjects(mse.getSelection());
            if (TABLE_ACTION_UNSUBSCRIBE.equals(mse.getAction())) {
                doLeave(ureq, items);
            }
        }
    } else if (source == repoSearchCtr) {
        SearchType type = (SearchType) repoSearchCtr.getUserObject();
        if (event == ReferencableEntriesSearchController.EVENT_REPOSITORY_ENTRY_SELECTED) {
            // repository search controller done
            RepositoryEntry re = repoSearchCtr.getSelectedEntry();
            removeAsListenerAndDispose(repoSearchCtr);
            cmc.deactivate();
            doConfirmSendEmail(ureq, Collections.singletonList(re), type);
        } else if (event == ReferencableEntriesSearchController.EVENT_REPOSITORY_ENTRIES_SELECTED) {
            // repository search controller done
            List<RepositoryEntry> res = repoSearchCtr.getSelectedEntries();
            removeAsListenerAndDispose(repoSearchCtr);
            cmc.deactivate();
            if (res != null && !res.isEmpty()) {
                doConfirmSendEmail(ureq, res, type);
            }
        }
    } else if (source == editSingleMemberCtrl) {
        cmc.deactivate();
        if (event instanceof MemberPermissionChangeEvent) {
            MemberPermissionChangeEvent e = (MemberPermissionChangeEvent) event;
            RepositoryEntry re = editSingleMemberCtrl.getRepositoryEntry();
            doConfirmChangePermission(ureq, e, re);
        }
    } else if (source == confirmSendMailBox) {
        boolean sendMail = DialogBoxUIFactory.isYesEvent(event) || DialogBoxUIFactory.isOkEvent(event);
        Object confirmation = confirmSendMailBox.getUserObject();
        if (confirmation instanceof ConfirmAdd) {
            ConfirmAdd addInfos = (ConfirmAdd) confirmation;
            doAddToRepositoryEntry(ureq, addInfos.getEntries(), addInfos.getType(), sendMail);
        } else if (confirmation instanceof ConfirmEdit) {
            ConfirmEdit editInfos = (ConfirmEdit) confirmation;
            doChangePermission(ureq, editInfos.getChangeEvent(), editInfos.getEntry(), sendMail);
        }
        updateModel();
    } else if (source == removeFromCourseDlg) {
        if (event == Event.DONE_EVENT) {
            boolean sendMail = removeFromCourseDlg.isSendMail();
            List<BusinessGroup> groupsToDelete = removeFromCourseDlg.getGroupsToDelete();
            List<BusinessGroup> groupsToLeave = removeFromCourseDlg.getGroupsToLeave();
            List<RepositoryEntry> repoEntriesToLeave = removeFromCourseDlg.getRepoEntriesToLeave();
            removeUserFromCourse(ureq, repoEntriesToLeave, groupsToLeave, groupsToDelete, sendMail);
        }
        cmc.deactivate();
        cleanUp();
    } else if (source == cmc) {
        cleanUp();
    }
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) TableMultiSelectEvent(org.olat.core.gui.components.table.TableMultiSelectEvent) MemberPermissionChangeEvent(org.olat.group.ui.main.MemberPermissionChangeEvent) RepositoryEntry(org.olat.repository.RepositoryEntry) TableEvent(org.olat.core.gui.components.table.TableEvent) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

MemberPermissionChangeEvent (org.olat.group.ui.main.MemberPermissionChangeEvent)12 List (java.util.List)8 Identity (org.olat.core.id.Identity)6 MailPackage (org.olat.core.util.mail.MailPackage)6 MailTemplate (org.olat.core.util.mail.MailTemplate)6 BusinessGroupMembershipChange (org.olat.group.model.BusinessGroupMembershipChange)6 MailerResult (org.olat.core.util.mail.MailerResult)4 RepositoryEntryPermissionChangeEvent (org.olat.repository.model.RepositoryEntryPermissionChangeEvent)4 ArrayList (java.util.ArrayList)2 TableEvent (org.olat.core.gui.components.table.TableEvent)2 TableMultiSelectEvent (org.olat.core.gui.components.table.TableMultiSelectEvent)2 Roles (org.olat.core.id.Roles)2 BusinessGroup (org.olat.group.BusinessGroup)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2