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