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());
}
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());
}
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();
}
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();
}
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;
}
Aggregations