Search in sources :

Example 81 with Identity

use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.

the class MembersAvatarDisplayRunController method createMemberLinks.

protected List<Member> createMemberLinks(List<Identity> identities, Set<Long> duplicateCatcher, FormLayoutContainer formLayout, boolean withEmail) {
    if (duplicateCatcher == null) {
        duplicateCatcher = new HashSet<>();
    }
    List<Member> members = new ArrayList<>(identities.size());
    for (Identity identity : identities) {
        if (duplicateCatcher.contains(identity.getKey())) {
            continue;
        }
        duplicateCatcher.add(identity.getKey());
        Member member = createMember(identity);
        members.add(member);
        String guiId = Integer.toString(++count);
        String fullname = StringHelper.escapeHtml(member.getFullName());
        FormLink idLink = uifactory.addFormLink("id_".concat(guiId), "id", fullname, null, formLayout, Link.NONTRANSLATED);
        idLink.setUserObject(member);
        formLayout.add(idLink.getComponent().getComponentName(), idLink);
        member.setIdLink(idLink);
        if (withEmail) {
            FormLink emailLink = uifactory.addFormLink("mail_".concat(guiId), "mail", "", null, formLayout, Link.NONTRANSLATED);
            emailLink.setUserObject(member);
            emailLink.setIconLeftCSS("o_icon o_icon_mail o_icon-lg");
            emailLink.setElementCssClass("o_mail");
            formLayout.add(emailLink.getComponent().getComponentName(), emailLink);
            member.setEmailLink(emailLink);
        }
        if (chatEnabled && editable) {
            FormLink chatLink = uifactory.addFormLink("chat_".concat(guiId), "chat", "", null, formLayout, Link.NONTRANSLATED);
            chatLink.setUserObject(member);
            chatLink.setElementCssClass("o_chat");
            formLayout.add(chatLink.getComponent().getComponentName(), chatLink);
            member.setChatLink(chatLink);
        }
    }
    if (chatEnabled && editable) {
        Long me = getIdentity().getKey();
        if (imModule.isOnlineStatusEnabled()) {
            Map<Long, Member> loadStatus = new HashMap<>();
            for (Member member : members) {
                if (member.getKey().equals(me)) {
                    member.getChatLink().setVisible(false);
                } else if (sessionManager.isOnline(member.getKey())) {
                    loadStatus.put(member.getKey(), member);
                } else {
                    member.getChatLink().setIconLeftCSS("o_icon o_icon_status_unavailable");
                }
            }
            if (loadStatus.size() > 0) {
                List<Long> statusToLoadList = new ArrayList<>(loadStatus.keySet());
                Map<Long, String> statusMap = imService.getBuddyStatus(statusToLoadList);
                for (Long toLoad : statusToLoadList) {
                    String status = statusMap.get(toLoad);
                    Member member = loadStatus.get(toLoad);
                    if (status == null || Presence.available.name().equals(status)) {
                        member.getChatLink().setIconLeftCSS("o_icon o_icon_status_available");
                    } else if (Presence.dnd.name().equals(status)) {
                        member.getChatLink().setIconLeftCSS("o_icon o_icon_status_dnd");
                    } else {
                        member.getChatLink().setIconLeftCSS("o_icon o_icon_status_unavailable");
                    }
                }
            }
        } else {
            for (Member member : members) {
                if (member.getKey().equals(me)) {
                    member.getChatLink().setVisible(false);
                } else {
                    member.getChatLink().setIconLeftCSS("o_icon o_icon_status_chat");
                }
            }
        }
    }
    return members;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) Member(org.olat.course.nodes.members.Member)

Example 82 with Identity

use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.

the class GTAAvailableTaskController method doSendConfirmationEmail.

private void doSendConfirmationEmail(Task assignedTask) {
    MailContext context = new MailContextImpl(getWindowControl().getBusinessControl().getAsString());
    MailBundle bundle = new MailBundle();
    bundle.setContext(context);
    ContactList contacts = new ContactList("participants");
    if (GTAType.group.name().equals(gtaNode.getModuleConfiguration().getStringValue(GTACourseNode.GTASK_TYPE))) {
        List<Identity> participants = businessGroupService.getMembers(assessedGroup, GroupRoles.participant.name());
        contacts.addAllIdentites(participants);
        bundle.setMetaId(UUID.randomUUID().toString());
    } else {
        contacts.add(assessedIdentity);
    }
    bundle.setContactList(contacts);
    String[] args = new String[] { // 0 first name
    getIdentity().getUser().getFirstName(), // 1 last name
    getIdentity().getUser().getLastName(), // 2 course name
    courseEnv.getCourseTitle(), // 3 task
    assignedTask.getTaskName() };
    String subject = translate("mail.confirm.assignment.subject", args);
    String body = translate("mail.confirm.assignment.body", args);
    bundle.setContent(subject, body);
    mailManager.sendMessage(bundle);
}
Also used : MailContextImpl(org.olat.core.util.mail.MailContextImpl) MailContext(org.olat.core.util.mail.MailContext) ContactList(org.olat.core.util.mail.ContactList) MailBundle(org.olat.core.util.mail.MailBundle) Identity(org.olat.core.id.Identity)

Example 83 with Identity

use of org.olat.core.id.Identity 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();
    }
}
Also used : 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 84 with Identity

use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.

the class GTACoachedParticipantListController method collectIdentities.

private void collectIdentities(Consumer<Identity> participantCollector) {
    Set<Identity> duplicateKiller = new HashSet<>();
    CourseGroupManager cgm = coachCourseEnv.getCourseEnvironment().getCourseGroupManager();
    boolean admin = coachCourseEnv.isAdmin();
    List<BusinessGroup> coachedGroups = admin ? cgm.getAllBusinessGroups() : coachCourseEnv.getCoachedGroups();
    List<Identity> participants = businessGroupService.getMembers(coachedGroups, GroupRoles.participant.name());
    for (Identity participant : participants) {
        if (!duplicateKiller.contains(participant)) {
            participantCollector.accept(participant);
            duplicateKiller.add(participant);
        }
    }
    RepositoryEntry re = coachCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
    boolean repoTutor = admin || (coachedGroups.isEmpty() && repositoryService.hasRole(getIdentity(), re, GroupRoles.coach.name()));
    if (repoTutor) {
        List<Identity> courseParticipants = repositoryService.getMembers(re, GroupRoles.participant.name());
        for (Identity participant : courseParticipants) {
            if (!duplicateKiller.contains(participant)) {
                participantCollector.accept(participant);
                duplicateKiller.add(participant);
            }
        }
    }
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) HashSet(java.util.HashSet)

Example 85 with Identity

use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.

the class GTACoachedParticipantListController method doToogleMark.

private boolean doToogleMark(UserRequest ureq, Long particiantKey) {
    RepositoryEntry entry = courseEnv.getCourseGroupManager().getCourseEntry();
    Identity participant = securityManager.loadIdentityByKey(particiantKey);
    return gtaManager.toggleMark(entry, gtaNode, ureq.getIdentity(), participant);
}
Also used : RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity)

Aggregations

Identity (org.olat.core.id.Identity)3749 Test (org.junit.Test)1956 RepositoryEntry (org.olat.repository.RepositoryEntry)898 BusinessGroup (org.olat.group.BusinessGroup)560 ArrayList (java.util.ArrayList)550 Date (java.util.Date)312 URI (java.net.URI)272 ICourse (org.olat.course.ICourse)266 HttpResponse (org.apache.http.HttpResponse)260 File (java.io.File)211 AssessmentManager (org.olat.course.assessment.AssessmentManager)210 Path (javax.ws.rs.Path)182 OLATResource (org.olat.resource.OLATResource)172 OLATResourceable (org.olat.core.id.OLATResourceable)156 Roles (org.olat.core.id.Roles)154 HashMap (java.util.HashMap)151 RestSecurityHelper.getIdentity (org.olat.restapi.security.RestSecurityHelper.getIdentity)142 HashSet (java.util.HashSet)136 List (java.util.List)132 Produces (javax.ws.rs.Produces)130