Search in sources :

Example 81 with MailPackage

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

the class EnrollmentManager method doEnroll.

public EnrollStatus doEnroll(Identity identity, Roles roles, BusinessGroup group, ENCourseNode enNode, CoursePropertyManager coursePropertyManager, WindowControl wControl, Translator trans, List<Long> groupKeys, List<Long> areaKeys, CourseGroupManager cgm) {
    final EnrollStatus enrollStatus = new EnrollStatus();
    if (isLogDebugEnabled())
        logDebug("doEnroll");
    // check if the user is able to be enrolled
    int groupsEnrolledCount = getBusinessGroupsWhereEnrolled(identity, groupKeys, areaKeys, cgm.getCourseEntry()).size();
    int waitingListCount = getBusinessGroupsWhereInWaitingList(identity, groupKeys, areaKeys).size();
    int enrollCountConfig = enNode.getModuleConfiguration().getIntegerSafe(ENCourseNode.CONFIG_ALLOW_MULTIPLE_ENROLL_COUNT, 1);
    if ((groupsEnrolledCount + waitingListCount) < enrollCountConfig) {
        if (isLogDebugEnabled())
            logDebug("Identity is not enrolled identity=" + identity.getName() + "  group=" + group.getName());
        // 1. Check if group has max size defined. If so check if group is full
        // o_clusterREVIEW cg please review it - also where does the group.getMaxParticipants().equals("") come from??
        // and: why can't we just have a group here and a max participants count and an identity to enrol?
        // the group was chosen, so why do we need the groupNames and areaNames here???
        MailPackage doNotSendmailPackage = new MailPackage(false);
        EnrollState state = businessGroupService.enroll(identity, roles, identity, group, doNotSendmailPackage);
        if (state.isFailed()) {
            enrollStatus.setErrorMessage(trans.translate(state.getI18nErrorMessage()));
        } else {
            if (state.getEnrolled() == BGMembership.participant) {
                addUserToParticipantList(identity, group, enNode, coursePropertyManager, wControl, trans);
                enrollStatus.setIsEnrolled(true);
            } else if (state.getEnrolled() == BGMembership.waiting) {
                addUserToWaitingList(identity, group, enNode, coursePropertyManager, wControl, trans);
                enrollStatus.setIsInWaitingList(true);
            }
        }
    } else {
        enrollStatus.setErrorMessage(trans.translate("error.group.already.enrolled"));
    }
    if (isLogDebugEnabled())
        logDebug("doEnroll finished");
    return enrollStatus;
}
Also used : MailPackage(org.olat.core.util.mail.MailPackage) EnrollState(org.olat.group.model.EnrollState)

Example 82 with MailPackage

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

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

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

the class AbstractMemberListController method doChangePermission.

protected void doChangePermission(UserRequest ureq, MemberPermissionChangeEvent changes, List<Identity> members, boolean sendMail) {
    MailPackage mailing = new MailPackage(sendMail);
    if (repoEntry != null) {
        List<RepositoryEntryPermissionChangeEvent> repoChanges = changes.generateRepositoryChanges(members);
        repositoryManager.updateRepositoryEntryMemberships(getIdentity(), ureq.getUserSession().getRoles(), repoEntry, repoChanges, mailing);
    }
    // commit all changes to the group memberships
    List<BusinessGroupMembershipChange> allModifications = changes.generateBusinessGroupMembershipChange(members);
    businessGroupService.updateMemberships(getIdentity(), allModifications, mailing);
    reloadModel();
}
Also used : BusinessGroupMembershipChange(org.olat.group.model.BusinessGroupMembershipChange) MailPackage(org.olat.core.util.mail.MailPackage) RepositoryEntryPermissionChangeEvent(org.olat.repository.model.RepositoryEntryPermissionChangeEvent)

Example 84 with MailPackage

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

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)

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