Search in sources :

Example 6 with RepositoryEntryPermissionChangeEvent

use of org.olat.repository.model.RepositoryEntryPermissionChangeEvent 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 7 with RepositoryEntryPermissionChangeEvent

use of org.olat.repository.model.RepositoryEntryPermissionChangeEvent 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 8 with RepositoryEntryPermissionChangeEvent

use of org.olat.repository.model.RepositoryEntryPermissionChangeEvent in project OpenOLAT by OpenOLAT.

the class RepositoryManager method updateRepositoryEntryMemberships.

public void updateRepositoryEntryMemberships(Identity ureqIdentity, Roles ureqRoles, RepositoryEntry re, List<RepositoryEntryPermissionChangeEvent> changes, MailPackage mailing) {
    int count = 0;
    List<RepositoryEntryMembershipModifiedEvent> deferredEvents = new ArrayList<>();
    for (RepositoryEntryPermissionChangeEvent e : changes) {
        updateRepositoryEntryMembership(ureqIdentity, ureqRoles, re, e, mailing, deferredEvents);
        if (++count % 100 == 0) {
            dbInstance.commitAndCloseSession();
        }
    }
    dbInstance.commitAndCloseSession();
    sendDeferredEvents(deferredEvents, re);
}
Also used : RepositoryEntryMembershipModifiedEvent(org.olat.repository.model.RepositoryEntryMembershipModifiedEvent) ArrayList(java.util.ArrayList) RepositoryEntryPermissionChangeEvent(org.olat.repository.model.RepositoryEntryPermissionChangeEvent)

Example 9 with RepositoryEntryPermissionChangeEvent

use of org.olat.repository.model.RepositoryEntryPermissionChangeEvent 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 10 with RepositoryEntryPermissionChangeEvent

use of org.olat.repository.model.RepositoryEntryPermissionChangeEvent 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)

Aggregations

RepositoryEntryPermissionChangeEvent (org.olat.repository.model.RepositoryEntryPermissionChangeEvent)14 MailPackage (org.olat.core.util.mail.MailPackage)12 MailerResult (org.olat.core.util.mail.MailerResult)6 BusinessGroupMembershipChange (org.olat.group.model.BusinessGroupMembershipChange)6 List (java.util.List)4 Identity (org.olat.core.id.Identity)4 MailTemplate (org.olat.core.util.mail.MailTemplate)4 MemberPermissionChangeEvent (org.olat.group.ui.main.MemberPermissionChangeEvent)4 ArrayList (java.util.ArrayList)2 Roles (org.olat.core.id.Roles)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2 RepositoryEntryMembershipModifiedEvent (org.olat.repository.model.RepositoryEntryMembershipModifiedEvent)2