Search in sources :

Example 41 with ContactList

use of org.olat.core.util.mail.ContactList in project openolat by klemens.

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();
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) ContactFormController(org.olat.modules.co.ContactFormController) ContactList(org.olat.core.util.mail.ContactList) Identity(org.olat.core.id.Identity) ContactMessage(org.olat.core.util.mail.ContactMessage)

Example 42 with ContactList

use of org.olat.core.util.mail.ContactList in project openolat by klemens.

the class BusinessGroupServiceTest method allowToLeavingBusinessGroup_withCourse.

@Test
public void allowToLeavingBusinessGroup_withCourse() {
    // authors group
    RepositoryEntry resource = JunitTestHelper.createAndPersistRepositoryEntry();
    Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("leave-bg-5-");
    BusinessGroup group = businessGroupService.createBusinessGroup(null, "Leaving group", "But you cannot leave :-(", new Integer(0), new Integer(2), false, false, resource);
    businessGroupRelationDao.addRole(participant, group, GroupRoles.participant.name());
    dbInstance.commitAndCloseSession();
    // set to not allowed to leave
    group = businessGroupService.updateAllowToLeaveBusinessGroup(group, false);
    dbInstance.commitAndCloseSession();
    // check the authors group leaving option
    LeaveOption optionToLeave = businessGroupService.isAllowToLeaveBusinessGroup(participant, group);
    Assert.assertNotNull(optionToLeave);
    Assert.assertFalse(optionToLeave.isAllowToLeave());
    ContactList contacts = optionToLeave.getContacts();
    Collection<Identity> contactList = contacts.getIdentiEmails().values();
    Assert.assertNotNull(contactList);
    Assert.assertFalse(contactList.isEmpty());
    for (Identity contact : contactList) {
        Roles roles = securityManager.getRoles(contact);
        Assert.assertNotNull(roles);
        Assert.assertTrue(roles.isOLATAdmin());
    }
}
Also used : LeaveOption(org.olat.group.model.LeaveOption) BusinessGroup(org.olat.group.BusinessGroup) Roles(org.olat.core.id.Roles) GroupRoles(org.olat.basesecurity.GroupRoles) RepositoryEntry(org.olat.repository.RepositoryEntry) ContactList(org.olat.core.util.mail.ContactList) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 43 with ContactList

use of org.olat.core.util.mail.ContactList in project openolat by klemens.

the class AbstractMemberListController method doOpenContact.

protected void doOpenContact(UserRequest ureq, MemberView member) {
    removeAsListenerAndDispose(contactCtrl);
    Identity choosenIdentity = securityManager.loadIdentityByKey(member.getIdentityKey());
    String fullname = userManager.getUserDisplayName(choosenIdentity);
    ContactMessage cmsg = new ContactMessage(ureq.getIdentity());
    ContactList emailList = new ContactList(fullname);
    emailList.add(choosenIdentity);
    cmsg.addEmailTo(emailList);
    OLATResourceable ores = OresHelper.createOLATResourceableType("Contact");
    WindowControl bwControl = addToHistory(ureq, ores, null);
    contactCtrl = new ContactFormController(ureq, bwControl, true, false, false, cmsg);
    listenTo(contactCtrl);
    toolbarPanel.pushController(fullname, contactCtrl);
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) ContactFormController(org.olat.modules.co.ContactFormController) ContactList(org.olat.core.util.mail.ContactList) Identity(org.olat.core.id.Identity) WindowControl(org.olat.core.gui.control.WindowControl) ContactMessage(org.olat.core.util.mail.ContactMessage)

Example 44 with ContactList

use of org.olat.core.util.mail.ContactList in project openolat by klemens.

the class GroupContactController method createContactMessage.

private ContactMessage createContactMessage(Identity from, String contactListName, BusinessGroup businessGroup) {
    ContactMessage contactMessage = new ContactMessage(from);
    ContactList contactList = new ContactList(translate(contactListName));
    List<Identity> members = businessGroupService.getMembers(businessGroup, GroupRoles.coach.name());
    for (Identity member : members) {
        contactList.add(member);
    }
    contactMessage.addEmailTo(contactList);
    return contactMessage;
}
Also used : ContactList(org.olat.core.util.mail.ContactList) Identity(org.olat.core.id.Identity) ContactMessage(org.olat.core.util.mail.ContactMessage)

Example 45 with ContactList

use of org.olat.core.util.mail.ContactList in project openolat by klemens.

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();
}
Also used : User(org.olat.core.id.User) Reference(org.olat.resource.references.Reference) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) ContactList(org.olat.core.util.mail.ContactList) ContactMessage(org.olat.core.util.mail.ContactMessage) CorruptedCourseException(org.olat.course.CorruptedCourseException) CourseNode(org.olat.course.nodes.CourseNode) Identity(org.olat.core.id.Identity)

Aggregations

ContactList (org.olat.core.util.mail.ContactList)92 Identity (org.olat.core.id.Identity)66 ContactMessage (org.olat.core.util.mail.ContactMessage)28 MailBundle (org.olat.core.util.mail.MailBundle)26 ContactFormController (org.olat.modules.co.ContactFormController)22 MailContextImpl (org.olat.core.util.mail.MailContextImpl)18 MailerResult (org.olat.core.util.mail.MailerResult)18 MailContext (org.olat.core.util.mail.MailContext)16 ArrayList (java.util.ArrayList)14 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)14 RepositoryEntry (org.olat.repository.RepositoryEntry)10 HashSet (java.util.HashSet)8 Test (org.junit.Test)8 BusinessGroup (org.olat.group.BusinessGroup)7 Locale (java.util.Locale)6 WindowControl (org.olat.core.gui.control.WindowControl)6 Translator (org.olat.core.gui.translator.Translator)6 File (java.io.File)4 Date (java.util.Date)4 Address (javax.mail.Address)4