Search in sources :

Example 61 with MailPackage

use of org.olat.core.util.mail.MailPackage in project OpenOLAT by OpenOLAT.

the class CourseOverviewController method doAddToRepositoryEntry.

private void doAddToRepositoryEntry(UserRequest ureq, Collection<RepositoryEntry> res, SearchType type, boolean sendEmail) {
    // commit changes to the repository entry
    MailerResult result = new MailerResult();
    MailPackage reMailing = new MailPackage(result, getWindowControl().getBusinessControl().getAsString(), sendEmail);
    RepositoryEntryPermissionChangeEvent changeEvent = new RepositoryEntryPermissionChangeEvent(editedIdentity);
    switch(type) {
        case owner:
            changeEvent.setRepoOwner(Boolean.TRUE);
            break;
        case tutor:
            changeEvent.setRepoTutor(Boolean.TRUE);
            break;
        case participant:
            changeEvent.setRepoParticipant(Boolean.TRUE);
            break;
    }
    List<RepositoryEntryPermissionChangeEvent> repoChanges = Collections.singletonList(changeEvent);
    for (RepositoryEntry repoEntry : res) {
        repositoryManager.updateRepositoryEntryMemberships(getIdentity(), ureq.getUserSession().getRoles(), repoEntry, repoChanges, reMailing);
    }
    // make sure all is committed before loading the model again (I see issues without)
    DBFactory.getInstance().commitAndCloseSession();
    MailHelper.printErrorsAndWarnings(result, getWindowControl(), ureq.getUserSession().getRoles().isOLATAdmin(), getLocale());
}
Also used : MailPackage(org.olat.core.util.mail.MailPackage) MailerResult(org.olat.core.util.mail.MailerResult) RepositoryEntryPermissionChangeEvent(org.olat.repository.model.RepositoryEntryPermissionChangeEvent) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 62 with MailPackage

use of org.olat.core.util.mail.MailPackage 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 63 with MailPackage

use of org.olat.core.util.mail.MailPackage in project OpenOLAT by OpenOLAT.

the class AbstractMemberListController method doChangePermission.

protected void doChangePermission(UserRequest ureq, MemberPermissionChangeEvent e, boolean sendMail) {
    MailPackage mailing = new MailPackage(sendMail);
    if (repoEntry != null) {
        List<RepositoryEntryPermissionChangeEvent> changes = Collections.singletonList((RepositoryEntryPermissionChangeEvent) e);
        repositoryManager.updateRepositoryEntryMemberships(getIdentity(), ureq.getUserSession().getRoles(), repoEntry, changes, mailing);
    }
    businessGroupService.updateMemberships(getIdentity(), e.getGroupChanges(), mailing);
    // make sure all is committed before loading the model again (I see issues without)
    DBFactory.getInstance().commitAndCloseSession();
    reloadModel();
}
Also used : MailPackage(org.olat.core.util.mail.MailPackage) RepositoryEntryPermissionChangeEvent(org.olat.repository.model.RepositoryEntryPermissionChangeEvent)

Example 64 with MailPackage

use of org.olat.core.util.mail.MailPackage in project OpenOLAT by OpenOLAT.

the class AbstractMemberListController method doLeave.

protected void doLeave(List<Identity> members, boolean sendMail) {
    MailPackage mailing = new MailPackage(sendMail);
    if (repoEntry != null) {
        businessGroupService.removeMembers(getIdentity(), members, repoEntry.getOlatResource(), mailing);
        repositoryManager.removeMembers(getIdentity(), members, repoEntry, mailing);
    } else {
        businessGroupService.removeMembers(getIdentity(), members, businessGroup.getResource(), mailing);
    }
    reloadModel();
}
Also used : MailPackage(org.olat.core.util.mail.MailPackage)

Example 65 with MailPackage

use of org.olat.core.util.mail.MailPackage in project OpenOLAT by OpenOLAT.

the class BusinessGroupServiceImpl method dedupSingleRepositoryentry.

private int dedupSingleRepositoryentry(Identity ureqIdentity, RepositoryEntry entry, boolean coaches, boolean participants, boolean dryRun) {
    int count = 0;
    // load only if needed
    List<BusinessGroup> groups = null;
    if (coaches) {
        List<Identity> repoTutorList = repositoryEntryRelationDao.getMembers(entry, RepositoryEntryRelationType.defaultGroup, GroupRoles.coach.name());
        if (!repoTutorList.isEmpty()) {
            SearchBusinessGroupParams params = new SearchBusinessGroupParams();
            groups = businessGroupDAO.findBusinessGroups(params, entry, 0, -1);
            List<Identity> ownerList = getMembers(groups, GroupRoles.participant.name());
            repoTutorList.retainAll(ownerList);
            if (!dryRun) {
                repositoryManager.removeTutors(ureqIdentity, repoTutorList, entry, new MailPackage(false));
            }
            count += repoTutorList.size();
        }
    }
    if (participants) {
        List<Identity> repoParticipantList = repositoryEntryRelationDao.getMembers(entry, RepositoryEntryRelationType.defaultGroup, GroupRoles.participant.name());
        if (!repoParticipantList.isEmpty()) {
            if (groups == null) {
                SearchBusinessGroupParams params = new SearchBusinessGroupParams();
                groups = businessGroupDAO.findBusinessGroups(params, entry, 0, -1);
            }
            List<Identity> participantList = getMembers(groups, GroupRoles.participant.name());
            repoParticipantList.retainAll(participantList);
            if (!dryRun) {
                repositoryManager.removeParticipants(ureqIdentity, repoParticipantList, entry, null, false);
            }
            count += repoParticipantList.size();
        }
    }
    return count;
}
Also used : MailPackage(org.olat.core.util.mail.MailPackage) BusinessGroup(org.olat.group.BusinessGroup) Identity(org.olat.core.id.Identity) SearchBusinessGroupParams(org.olat.group.model.SearchBusinessGroupParams)

Aggregations

MailPackage (org.olat.core.util.mail.MailPackage)84 Identity (org.olat.core.id.Identity)58 RepositoryEntry (org.olat.repository.RepositoryEntry)42 Path (javax.ws.rs.Path)26 RestSecurityHelper.getIdentity (org.olat.restapi.security.RestSecurityHelper.getIdentity)26 IdentitiesAddEvent (org.olat.admin.securitygroup.gui.IdentitiesAddEvent)22 PUT (javax.ws.rs.PUT)16 Test (org.junit.Test)16 UserRequest (org.olat.core.gui.UserRequest)16 BusinessGroup (org.olat.group.BusinessGroup)16 BusinessGroupMembershipChange (org.olat.group.model.BusinessGroupMembershipChange)16 RepositoryManager (org.olat.repository.RepositoryManager)16 RestSecurityHelper.getUserRequest (org.olat.restapi.security.RestSecurityHelper.getUserRequest)16 BaseSecurity (org.olat.basesecurity.BaseSecurity)14 ArrayList (java.util.ArrayList)12 MailerResult (org.olat.core.util.mail.MailerResult)12 RepositoryEntryPermissionChangeEvent (org.olat.repository.model.RepositoryEntryPermissionChangeEvent)12 DELETE (javax.ws.rs.DELETE)10 Consumes (javax.ws.rs.Consumes)8 MailTemplate (org.olat.core.util.mail.MailTemplate)8