use of org.olat.core.util.mail.ContactMessage in project OpenOLAT by OpenOLAT.
the class GTACoachController method doOpenMailForm.
private void doOpenMailForm(UserRequest ureq) {
// build recipient list
ContactList contactList = null;
if (assessedGroup != null) {
String toName = assessedGroup.getName();
contactList = new ContactList(toName);
List<Identity> memberList = businessGroupService.getMembers(assessedGroup, GroupRoles.participant.name());
contactList.addAllIdentites(memberList);
} else if (assessedIdentity != null) {
String toName = userManager.getUserDisplayName(assessedIdentity);
contactList = new ContactList(toName);
contactList.add(assessedIdentity);
}
// open dialog with mail form
if (contactList != null && contactList.getEmailsAsStrings().size() > 0) {
removeAsListenerAndDispose(emailController);
ContactMessage cmsg = new ContactMessage(ureq.getIdentity());
cmsg.addEmailTo(contactList);
emailController = new ContactFormController(ureq, getWindowControl(), true, false, false, cmsg);
listenTo(emailController);
removeAsListenerAndDispose(cmc);
// same title as link button
String title = translate(emailLink.getI18n());
cmc = new CloseableModalController(getWindowControl(), translate("close"), emailController.getInitialComponent(), true, title);
listenTo(cmc);
cmc.activate();
}
}
use of org.olat.core.util.mail.ContactMessage in project OpenOLAT by OpenOLAT.
the class StudentCoursesController method contact.
private void contact(UserRequest ureq) {
removeAsListenerAndDispose(cmc);
ContactMessage cmsg = new ContactMessage(getIdentity());
ContactList contactList = new ContactList("to");
contactList.add(student);
cmsg.addEmailTo(contactList);
contactCtrl = new ContactFormController(ureq, getWindowControl(), true, false, false, cmsg);
listenTo(contactCtrl);
cmc = new CloseableModalController(getWindowControl(), translate("close"), contactCtrl.getInitialComponent());
cmc.activate();
listenTo(cmc);
}
use of org.olat.core.util.mail.ContactMessage in project OpenOLAT by OpenOLAT.
the class ParticipantLectureBlocksController method doAppeal.
private void doAppeal(UserRequest ureq, LectureBlockAndRollCall row) {
if (appealCtrl != null)
return;
LectureBlock block = lectureService.getLectureBlock(row.getLectureBlockRef());
List<Identity> teachers = lectureService.getTeachers(block);
List<Identity> onwers = repositoryService.getMembers(entry, GroupRoles.owner.name());
ContactList contactList = new ContactList(translate("appeal.contact.list"));
contactList.addAllIdentites(teachers);
contactList.addAllIdentites(onwers);
StringBuilder teacherNames = new StringBuilder();
for (Identity teacher : teachers) {
if (teacherNames.length() > 0)
teacherNames.append(", ");
teacherNames.append(teacher.getUser().getFirstName()).append(" ").append(teacher.getUser().getLastName());
}
String date = Formatter.getInstance(getLocale()).formatDate(block.getStartDate());
String[] args = new String[] { row.getLectureBlockTitle(), teacherNames.toString(), date };
ContactMessage cmsg = new ContactMessage(getIdentity());
cmsg.addEmailTo(contactList);
cmsg.setSubject(translate("appeal.subject", args));
cmsg.setBodyText(translate("appeal.body", args));
appealCtrl = new ContactFormController(ureq, getWindowControl(), true, false, false, cmsg);
appealCtrl.setUserObject(row);
appealCtrl.setContactFormTitle(translate("new.appeal.title"));
listenTo(appealCtrl);
String title = translate("appeal.title", new String[] { row.getLectureBlockTitle() });
cmc = new CloseableModalController(getWindowControl(), "close", appealCtrl.getInitialComponent(), true, title);
listenTo(cmc);
cmc.activate();
}
use of org.olat.core.util.mail.ContactMessage in project OpenOLAT by OpenOLAT.
the class QTIEditorMainController method createReferenceesMsg.
/**
* helper method to create the message about qti resource stakeholders and
* from where the qti resource is referenced.
*
* @return
*/
private String createReferenceesMsg(UserRequest ureq) {
/*
* problems: A tries to reference this test, after test editor has been
* started
*/
changeEmail = new ContactMessage(ureq.getIdentity());
// the owners of this qtiPkg
RepositoryEntry myEntry = repositoryManager.lookupRepositoryEntry(qtiPackage.getRepresentingResourceable(), false);
// add qti resource owners as group
ContactList cl = new ContactList("qtiPkgOwners");
cl.addAllIdentites(repositoryService.getMembers(myEntry, GroupRoles.owner.name()));
changeEmail.addEmailTo(cl);
StringBuilder result = new StringBuilder();
result.append(translate("qti.restricted.leading"));
for (Iterator<Reference> iter = referencees.iterator(); iter.hasNext(); ) {
Reference element = iter.next();
if ("CourseModule".equals(element.getSource().getResourceableTypeName())) {
ICourse course = null;
try {
course = CourseFactory.loadCourse(element.getSource().getResourceableId());
if (course == null) {
continue;
}
} catch (CorruptedCourseException ex) {
logError("", ex);
continue;
}
CourseNode cn = course.getEditorTreeModel().getCourseNode(element.getUserdata());
if (cn == null) {
logError("Cannot find course element " + element.getUserdata() + " in course " + course, null);
continue;
}
String courseTitle = course.getCourseTitle();
StringBuilder stakeHolders = new StringBuilder();
// the course owners
RepositoryEntry entry = repositoryManager.lookupRepositoryEntry(course, false);
if (entry != null) {
// OO-1300
List<Identity> stakeHoldersIds = repositoryService.getMembers(entry, GroupRoles.owner.name());
if (stakeHoldersIds != null && stakeHoldersIds.size() > 0) {
// add stakeholders as group
cl = new ContactList(courseTitle);
cl.addAllIdentites(stakeHoldersIds);
changeEmail.addEmailTo(cl);
for (Identity stakeHoldersId : stakeHoldersIds) {
if (stakeHolders.length() > 0)
stakeHolders.append(", ");
User user = stakeHoldersId.getUser();
stakeHolders.append(user.getProperty(UserConstants.FIRSTNAME, getLocale())).append(" ").append(user.getProperty(UserConstants.LASTNAME, getLocale()));
}
}
}
String courseNodeTitle = cn.getShortTitle();
result.append(translate("qti.restricted.course", StringHelper.escapeHtml(courseTitle)));
result.append(translate("qti.restricted.node", StringHelper.escapeHtml(courseNodeTitle)));
result.append(translate("qti.restricted.owners", stakeHolders.toString()));
}
}
return result.toString();
}
use of org.olat.core.util.mail.ContactMessage in project OpenOLAT by OpenOLAT.
the class UserInfoMainController method doOpenContact.
private ContactFormController doOpenContact(UserRequest ureq) {
removeAsListenerAndDispose(contactFormController);
ContactMessage cmsg = new ContactMessage(ureq.getIdentity());
ContactList emailList = new ContactList(firstLastName);
emailList.add(chosenIdentity);
cmsg.addEmailTo(emailList);
OLATResourceable ores = OresHelper.createOLATResourceableType(CMD_CONTACT);
WindowControl bwControl = addToHistory(ureq, ores, null);
contactFormController = new ContactFormController(ureq, bwControl, true, false, false, cmsg);
listenTo(contactFormController);
return contactFormController;
}
Aggregations