Search in sources :

Example 41 with MailPackage

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

the class AbstractBusinessGroupListController method finishUserManagement.

private void finishUserManagement(MembershipModification mod, List<BusinessGroup> groups, MailTemplate template, boolean sendMail) {
    MailPackage mailing = new MailPackage(template, getWindowControl().getBusinessControl().getAsString(), sendMail);
    businessGroupService.updateMembership(getIdentity(), mod, groups, mailing);
    MailHelper.printErrorsAndWarnings(mailing.getResult(), getWindowControl(), false, getLocale());
}
Also used : MailPackage(org.olat.core.util.mail.MailPackage)

Example 42 with MailPackage

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

the class CourseRuntimeController method doLeave.

private void doLeave(UserRequest ureq) {
    if (roles.isGuestOnly())
        return;
    MailerResult result = new MailerResult();
    MailPackage reMailing = new MailPackage(result, getWindowControl().getBusinessControl().getAsString(), true);
    // leave course
    LeavingStatusList status = new LeavingStatusList();
    repositoryManager.leave(getIdentity(), getRepositoryEntry(), status, reMailing);
    // leave groups
    businessGroupService.leave(getIdentity(), getRepositoryEntry(), status, reMailing);
    if (status.isWarningManagedGroup() || status.isWarningManagedCourse()) {
        showWarning("sign.out.warning.managed");
    } else if (status.isWarningGroupWithMultipleResources()) {
        showWarning("sign.out.warning.mutiple.resources");
    } else {
        showInfo("sign.out.success", new String[] { getRepositoryEntry().getDisplayname() });
    }
    doClose(ureq);
}
Also used : LeavingStatusList(org.olat.repository.LeavingStatusList) MailPackage(org.olat.core.util.mail.MailPackage) MailerResult(org.olat.core.util.mail.MailerResult)

Example 43 with MailPackage

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

the class CourseOverviewController method doChangePermission.

private void doChangePermission(UserRequest ureq, MemberPermissionChangeEvent e, RepositoryEntry re, boolean sendMail) {
    MailPackage mailing = new MailPackage(sendMail);
    if (re != null) {
        List<RepositoryEntryPermissionChangeEvent> changes = Collections.singletonList((RepositoryEntryPermissionChangeEvent) e);
        repositoryManager.updateRepositoryEntryMemberships(getIdentity(), ureq.getUserSession().getRoles(), re, 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();
    updateModel();
}
Also used : MailPackage(org.olat.core.util.mail.MailPackage) RepositoryEntryPermissionChangeEvent(org.olat.repository.model.RepositoryEntryPermissionChangeEvent)

Example 44 with MailPackage

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

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 45 with MailPackage

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

the class CourseOverviewController method removeUserFromCourse.

private void removeUserFromCourse(UserRequest ureq, List<RepositoryEntry> repoEntriesToLeave, List<BusinessGroup> groupsToLeave, List<BusinessGroup> groupsToDelete, boolean doSendMail) {
    List<Identity> membersToRemove = Collections.singletonList(editedIdentity);
    for (BusinessGroup group : groupsToLeave) {
        if (groupsToDelete.contains(group)) {
            // really delete the group as it has no more owners/participants
            if (doSendMail) {
                String businessPath = getWindowControl().getBusinessControl().getAsString();
                businessGroupService.deleteBusinessGroupWithMail(group, businessPath, getIdentity(), getLocale());
            } else {
                businessGroupService.deleteBusinessGroup(group);
            }
        } else {
            // 1) remove as owner
            if (businessGroupService.hasRoles(editedIdentity, group, GroupRoles.coach.name())) {
                businessGroupService.removeOwners(ureq.getIdentity(), membersToRemove, group);
            }
            MailPackage mailing = new MailPackage(doSendMail);
            // 2) remove as participant
            businessGroupService.removeParticipants(getIdentity(), membersToRemove, group, mailing);
            MailHelper.printErrorsAndWarnings(mailing.getResult(), getWindowControl(), ureq.getUserSession().getRoles().isOLATAdmin(), getLocale());
        }
    }
    for (RepositoryEntry repoEntry : repoEntriesToLeave) {
        if (isRepoMember(repoEntry)) {
            MailPackage mailing = new MailPackage(doSendMail);
            repositoryManager.removeMembers(getIdentity(), membersToRemove, repoEntry, mailing);
        }
    }
    updateModel();
    StringBuilder groupNames = new StringBuilder();
    for (BusinessGroup group : groupsToLeave) {
        if (groupNames.length() > 0)
            groupNames.append(", ");
        groupNames.append(group.getName());
    }
    showInfo("unsubscribe.successful");
}
Also used : MailPackage(org.olat.core.util.mail.MailPackage) BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity)

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