Manager scrtMngr = ManagerFactory.getManager();
ContactMessage cmsg = new ContactMessage(ureq.getIdentity());
// two named ContactLists, the new way using the contact form
// the same name as in the checkboxes are taken as contactlist names
ContactList ownerCntctLst = new ContactList(businessGroupTranslator.translate("sendtochooser.form.chckbx.owners"));
ContactList partipCntctLst = new ContactList(businessGroupTranslator.translate("sendtochooser.form.chckbx.partip"));
ContactList waitingListContactList = new ContactList(businessGroupTranslator.translate("sendtochooser.form.chckbx.waitingList"));
if (flags.isEnabled(BGConfigFlags.GROUP_OWNERS)) {
if (sendToChooserForm.ownerChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_ALL)) {
SecurityGroup owners = this.currentGroup.getOwnerGroup();
List<Identity> ownerList = scrtMngr.getIdentitiesOfSecurityGroup(owners);
ownerCntctLst.addAllIdentites(ownerList);
cmsg.addEmailTo(ownerCntctLst);
} else {
if (sendToChooserForm.ownerChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_CHOOSE)) {
SecurityGroup owners = this.currentGroup.getOwnerGroup();
List<Identity> ownerList = scrtMngr.getIdentitiesOfSecurityGroup(owners);
for (Identity identity : new ArrayList<Identity>(ownerList)) {
boolean keyIsSelected = false;
for (Long key : sendToChooserForm.getSelectedOwnerKeys()) {
if (key.equals(identity.getKey())) {
keyIsSelected = true;
break;
}
}
if (!keyIsSelected) {
ownerList.remove(identity);
}
}
ownerCntctLst.addAllIdentites(ownerList);
cmsg.addEmailTo(ownerCntctLst);
}
}
}
if (sendToChooserForm != null) {
if (sendToChooserForm.participantChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_ALL)) {
SecurityGroup participants = this.currentGroup.getPartipiciantGroup();
List<Identity> participantsList = scrtMngr.getIdentitiesOfSecurityGroup(participants);
partipCntctLst.addAllIdentites(participantsList);
cmsg.addEmailTo(partipCntctLst);
} else {
if (sendToChooserForm.participantChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_CHOOSE)) {
SecurityGroup participants = this.currentGroup.getPartipiciantGroup();
List<Identity> participantsList = scrtMngr.getIdentitiesOfSecurityGroup(participants);
for (Identity identity : new ArrayList<Identity>(participantsList)) {
boolean keyIsSelected = false;
for (Long key : sendToChooserForm.getSelectedPartipKeys()) {
if (key.equals(identity.getKey())) {
keyIsSelected = true;
break;
}
}
if (!keyIsSelected) {
participantsList.remove(identity);
}
}
partipCntctLst.addAllIdentites(participantsList);
cmsg.addEmailTo(partipCntctLst);
}
}
}
if (sendToChooserForm != null && getIsGMAdminOwner(ureq) && this.currentGroup.getWaitingListEnabled().booleanValue()) {
if (sendToChooserForm.waitingListChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_ALL)) {
SecurityGroup waitingList = this.currentGroup.getWaitingGroup();
List<Identity> waitingListIdentities = scrtMngr.getIdentitiesOfSecurityGroup(waitingList);
waitingListContactList.addAllIdentites(waitingListIdentities);
cmsg.addEmailTo(waitingListContactList);
} else {
if (sendToChooserForm.waitingListChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_CHOOSE)) {
SecurityGroup waitingList = this.currentGroup.getWaitingGroup();
List<Identity> waitingListIdentities = scrtMngr.getIdentitiesOfSecurityGroup(waitingList);
for (Identity identity : new ArrayList<Identity>(waitingListIdentities)) {
boolean keyIsSelected = false;
for (Long key : sendToChooserForm.getSelectedWaitingKeys()) {
if (key.equals(identity.getKey())) {
keyIsSelected = true;
break;
}
}
if (!keyIsSelected) {
waitingListIdentities.remove(identity);
}
}
waitingListContactList.addAllIdentites(waitingListIdentities);
cmsg.addEmailTo(waitingListContactList);
}
}
}
String resourceUrl = JumpInManager.getJumpInUri(this.getWindowControl().getBusinessControl());