use of org.olat.core.util.mail.ContactList in project openolat by klemens.
the class BusinessGroupServiceImpl method getAdminContactList.
public ContactList getAdminContactList(BusinessGroup group) {
ContactList list = new ContactList("Contact");
List<Identity> coaches = getMembers(group, GroupRoles.coach.name());
if (coaches.isEmpty()) {
Collection<BusinessGroup> groups = Collections.singletonList(group);
List<RepositoryEntry> entries = businessGroupRelationDAO.findRepositoryEntries(groups, 0, -1);
for (RepositoryEntry re : entries) {
coaches.addAll(repositoryService.getMembers(re, GroupRoles.coach.name()));
}
if (coaches.isEmpty()) {
// get system administrators
SecurityGroup adminSecGroup = securityManager.findSecurityGroupByName(Constants.GROUP_ADMIN);
List<Identity> admins = securityManager.getIdentitiesByPowerSearch(null, null, false, new SecurityGroup[] { adminSecGroup }, null, null, null, null, null, null, Identity.STATUS_VISIBLE_LIMIT);
coaches.addAll(admins);
}
}
list.addAllIdentites(coaches);
return list;
}
use of org.olat.core.util.mail.ContactList in project openolat by klemens.
the class BusinessGroupMainRunController method createContactFormController.
/**
* generates the email adress list.
*
* @param ureq
* @return a contact form controller for this group
*/
private ContactFormController createContactFormController(UserRequest ureq) {
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
// = new ContactList(translate("sendtochooser.form.chckbx.owners"));
ContactList ownerCntctLst;
// = new ContactList(translate("sendtochooser.form.chckbx.partip"));
ContactList partipCntctLst;
// = new ContactList(translate("sendtochooser.form.chckbx.waitingList"));
ContactList waitingListContactList;
if (sendToChooserForm.ownerChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_ALL)) {
ownerCntctLst = new ContactList(translate("sendtochooser.form.radio.owners.all"));
List<Identity> ownerList = businessGroupService.getMembers(businessGroup, GroupRoles.coach.name());
ownerCntctLst.addAllIdentites(ownerList);
cmsg.addEmailTo(ownerCntctLst);
} else {
if (sendToChooserForm.ownerChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_CHOOSE)) {
ownerCntctLst = new ContactList(translate("sendtochooser.form.radio.owners.choose"));
List<Identity> ownerList = businessGroupService.getMembers(businessGroup, GroupRoles.coach.name());
List<Identity> changeableOwnerList = new ArrayList<>(ownerList);
for (Identity identity : ownerList) {
boolean keyIsSelected = false;
for (Long key : sendToChooserForm.getSelectedOwnerKeys()) {
if (key.equals(identity.getKey())) {
keyIsSelected = true;
break;
}
}
if (!keyIsSelected) {
changeableOwnerList.remove(changeableOwnerList.indexOf(identity));
}
}
ownerCntctLst.addAllIdentites(changeableOwnerList);
cmsg.addEmailTo(ownerCntctLst);
}
}
if (sendToChooserForm != null) {
if (sendToChooserForm.participantChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_ALL)) {
partipCntctLst = new ContactList(translate("sendtochooser.form.radio.partip.all"));
List<Identity> participantsList = businessGroupService.getMembers(businessGroup, GroupRoles.participant.name());
partipCntctLst.addAllIdentites(participantsList);
cmsg.addEmailTo(partipCntctLst);
} else {
if (sendToChooserForm.participantChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_CHOOSE)) {
partipCntctLst = new ContactList(translate("sendtochooser.form.radio.partip.choose"));
List<Identity> participantsList = businessGroupService.getMembers(businessGroup, GroupRoles.participant.name());
List<Identity> changeableParticipantsList = new ArrayList<>(participantsList);
for (Identity identity : participantsList) {
boolean keyIsSelected = false;
for (Long key : sendToChooserForm.getSelectedPartipKeys()) {
if (key.equals(identity.getKey())) {
keyIsSelected = true;
break;
}
}
if (!keyIsSelected) {
changeableParticipantsList.remove(changeableParticipantsList.indexOf(identity));
}
}
partipCntctLst.addAllIdentites(changeableParticipantsList);
cmsg.addEmailTo(partipCntctLst);
}
}
}
if (sendToChooserForm != null && isAdmin && businessGroup.getWaitingListEnabled().booleanValue()) {
if (sendToChooserForm.waitingListChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_ALL)) {
waitingListContactList = new ContactList(translate("sendtochooser.form.radio.waitings.all"));
List<Identity> waitingListIdentities = businessGroupService.getMembers(businessGroup, GroupRoles.waiting.name());
waitingListContactList.addAllIdentites(waitingListIdentities);
cmsg.addEmailTo(waitingListContactList);
} else {
if (sendToChooserForm.waitingListChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_CHOOSE)) {
waitingListContactList = new ContactList(translate("sendtochooser.form.radio.waitings.choose"));
List<Identity> waitingListIdentities = businessGroupService.getMembers(businessGroup, GroupRoles.waiting.name());
List<Identity> changeableWaitingListIdentities = new ArrayList<>(waitingListIdentities);
for (Identity indentity : waitingListIdentities) {
boolean keyIsSelected = false;
for (Long key : sendToChooserForm.getSelectedWaitingKeys()) {
if (key.equals(indentity.getKey())) {
keyIsSelected = true;
break;
}
}
if (!keyIsSelected) {
changeableWaitingListIdentities.remove(changeableWaitingListIdentities.indexOf(indentity));
}
}
waitingListContactList.addAllIdentites(changeableWaitingListIdentities);
cmsg.addEmailTo(waitingListContactList);
}
}
}
cmsg.setSubject(translate("businessgroup.contact.subject", businessGroup.getName()));
if (sendToChooserForm.waitingListChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_NOTHING)) {
String restUrl = BusinessControlFactory.getInstance().getAsURIString(getWindowControl().getBusinessControl(), true);
cmsg.setBodyText(getTranslator().translate("businessgroup.contact.bodytext", new String[] { businessGroup.getName(), "<a href='" + restUrl + "'>" + restUrl + "</a>" }));
} else {
cmsg.setBodyText("");
}
CollaborationTools collabTools = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(businessGroup);
return collabTools.createContactFormController(ureq, getWindowControl(), cmsg);
}
use of org.olat.core.util.mail.ContactList in project openolat by klemens.
the class AbstractMemberListController method doSendMail.
protected void doSendMail(UserRequest ureq, List<MemberView> members) {
List<Long> identityKeys = getMemberKeys(members);
List<Identity> identities = securityManager.loadIdentityByKeys(identityKeys);
if (identities.isEmpty()) {
showWarning("error.msg.send.no.rcps");
return;
}
ContactMessage contactMessage = new ContactMessage(getIdentity());
String name = repoEntry != null ? repoEntry.getDisplayname() : businessGroup.getName();
ContactList contactList = new ContactList(name);
contactList.addAllIdentites(identities);
contactMessage.addEmailTo(contactList);
contactCtrl = new ContactFormController(ureq, getWindowControl(), true, false, false, contactMessage);
listenTo(contactCtrl);
cmc = new CloseableModalController(getWindowControl(), translate("close"), contactCtrl.getInitialComponent(), true, translate("mail.member"));
cmc.activate();
listenTo(cmc);
}
use of org.olat.core.util.mail.ContactList in project openolat by klemens.
the class BGEmailCompositionStepController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
StringBuilder groupNames = new StringBuilder();
for (int i = 0; i < 5 && i < groups.size(); i++) {
if (groupNames.length() > 0)
groupNames.append(" - ");
groupNames.append(groups.get(i).getName());
}
String contactsName;
if (groups.size() > 5) {
String otherGroups = Integer.toString(groups.size() - 5);
contactsName = translate("email.other.groups", new String[] { groupNames.toString(), otherGroups });
} else {
contactsName = groupNames.toString();
}
ContactList contacts = new ContactList(contactsName);
Boolean sendToTutorObj = (Boolean) getFromRunContext("tutors");
boolean sendToTutors = sendToTutorObj == null ? false : sendToTutorObj.booleanValue();
if (sendToTutors) {
List<Identity> coaches = businessGroupService.getMembers(groups, GroupRoles.coach.name());
contacts.addAllIdentites(coaches);
}
Boolean sendToParticipantObj = (Boolean) getFromRunContext("participants");
boolean sendToParticipants = sendToParticipantObj == null ? false : sendToParticipantObj.booleanValue();
if (sendToParticipants) {
List<Identity> participants = businessGroupService.getMembers(groups, GroupRoles.participant.name());
contacts.addAllIdentites(participants);
}
contactForm = new ContactForm(ureq, getWindowControl(), mainForm, getIdentity(), false, false, false, false);
contactForm.addEmailTo(contacts);
formLayout.add("wrapped", contactForm.getInitialFormItem());
}
use of org.olat.core.util.mail.ContactList in project openolat by klemens.
the class ContactForm method addEmailTo.
/**
* add a ContactList as EmailTo:
*
* @param emailList
*/
public void addEmailTo(ContactList emailList) {
if (contactLists.containsKey(emailList.getName())) {
// there is already a ContactList with this name...
ContactList existing = contactLists.get(emailList.getName());
// , merge their values.
existing.add(emailList);
// the form itself must not be updated, because it already displays
// the name.
} else {
// a new ContactList, put it into contactLists
contactLists.put(emailList.getName(), emailList);
// and add its name in the form
addContactFormEmailTo("[" + emailList.getName() + "]");
}
}
Aggregations