Search in sources :

Example 1 with Member

use of org.olat.course.nodes.members.Member in project OpenOLAT by OpenOLAT.

the class MembersPrintController method initFormMemberList.

private void initFormMemberList(String name, String label, List<Identity> members) {
    List<Member> memberWrappers = members.stream().map(m -> createMember(m)).collect(Collectors.toList());
    VelocityContainer listVC = createVelocityContainer("printList");
    listVC.contextPut("label", label);
    listVC.contextPut("avatarBaseURL", avatarBaseURL);
    listVC.contextPut("members", memberWrappers);
    listVC.contextPut("typecss", "o_" + name);
    listVC.contextPut("userPropertyPrintHandlers", userPropertyPrintHandlers);
    // add lookup table so the avatar properties can be read out from the member object that contains the full list of attributes
    Map<String, Integer> handlerLookupMap = new HashMap<String, Integer>();
    for (int i = userPropertyPrintHandlers.size(); i-- > 0; ) {
        UserPropertyHandler handler = userPropertyPrintHandlers.get(i);
        handlerLookupMap.put(handler.getName(), i);
    }
    listVC.contextPut("handlerLookupMap", handlerLookupMap);
    mainVC.put(name, listVC);
}
Also used : Util(org.olat.core.util.Util) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) MediaResource(org.olat.core.gui.media.MediaResource) Event(org.olat.core.gui.control.Event) Member(org.olat.course.nodes.members.Member) HttpServletRequest(javax.servlet.http.HttpServletRequest) MainPanel(org.olat.core.gui.components.panel.MainPanel) UserConstants(org.olat.core.id.UserConstants) Locale(java.util.Locale) Map(java.util.Map) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer) MetaInfo(org.olat.core.commons.modules.bc.meta.MetaInfo) BaseSecurityModule(org.olat.basesecurity.BaseSecurityModule) MetaTagged(org.olat.core.commons.modules.bc.meta.tagged.MetaTagged) VFSLeaf(org.olat.core.util.vfs.VFSLeaf) Translator(org.olat.core.gui.translator.Translator) WindowControl(org.olat.core.gui.control.WindowControl) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler) DisplayPortraitManager(org.olat.user.DisplayPortraitManager) Component(org.olat.core.gui.components.Component) Collectors(java.util.stream.Collectors) Mapper(org.olat.core.dispatcher.mapper.Mapper) NotFoundMediaResource(org.olat.core.gui.media.NotFoundMediaResource) UserManager(org.olat.user.UserManager) BasicController(org.olat.core.gui.control.controller.BasicController) List(java.util.List) Identity(org.olat.core.id.Identity) VFSMediaResource(org.olat.core.util.vfs.VFSMediaResource) UserRequest(org.olat.core.gui.UserRequest) Roles(org.olat.core.id.Roles) HashMap(java.util.HashMap) Member(org.olat.course.nodes.members.Member) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer)

Example 2 with Member

use of org.olat.course.nodes.members.Member in project OpenOLAT by OpenOLAT.

the class MembersMailController method doSend.

private void doSend(UserRequest ureq) {
    ContactList contactList = new ContactList("");
    if (courseEnv == null) {
        if (coachEl != null && coachEl.isAtLeastSelected(1)) {
            List<Long> identityKeys = new ArrayList<>(coachList.size());
            for (Member coach : coachList) {
                identityKeys.add(coach.getKey());
            }
            List<Identity> coaches = securityManager.loadIdentityByKeys(identityKeys);
            contactList.addAllIdentites(coaches);
        }
        if (participantEl != null && participantEl.isAtLeastSelected(1)) {
            List<Long> identityKeys = new ArrayList<>(participantList.size());
            for (Member participant : participantList) {
                identityKeys.add(participant.getKey());
            }
            List<Identity> participants = securityManager.loadIdentityByKeys(identityKeys);
            contactList.addAllIdentites(participants);
        }
        if (waitingEl != null && waitingEl.isAtLeastSelected(1)) {
            List<Long> identityKeys = new ArrayList<>(waitingList.size());
            for (Member waiter : waitingList) {
                identityKeys.add(waiter.getKey());
            }
            List<Identity> waiters = securityManager.loadIdentityByKeys(identityKeys);
            contactList.addAllIdentites(waiters);
        }
    } else {
        if (ownerEl != null && ownerEl.isAtLeastSelected(1)) {
            RepositoryEntry courseRepositoryEntry = courseEnv.getCourseGroupManager().getCourseEntry();
            List<Identity> owners = repositoryService.getMembers(courseRepositoryEntry, GroupRoles.owner.name());
            contactList.addAllIdentites(owners);
        }
        if (coachEl != null && coachEl.isAtLeastSelected(1)) {
            Set<Long> sendToWhatYouSee = new HashSet<>();
            for (Member coach : coachList) {
                sendToWhatYouSee.add(coach.getKey());
            }
            CourseGroupManager cgm = courseEnv.getCourseGroupManager();
            avoidInvisibleMember(cgm.getCoachesFromBusinessGroups(), contactList, sendToWhatYouSee);
            avoidInvisibleMember(cgm.getCoaches(), contactList, sendToWhatYouSee);
        }
        if (participantEl != null && participantEl.isAtLeastSelected(1)) {
            Set<Long> sendToWhatYouSee = new HashSet<>();
            for (Member participant : participantList) {
                sendToWhatYouSee.add(participant.getKey());
            }
            CourseGroupManager cgm = courseEnv.getCourseGroupManager();
            avoidInvisibleMember(cgm.getParticipantsFromBusinessGroups(), contactList, sendToWhatYouSee);
            avoidInvisibleMember(cgm.getParticipants(), contactList, sendToWhatYouSee);
        }
    }
    if (individualEl != null && individualEl.isAtLeastSelected(1) && selectedMembers != null && selectedMembers.size() > 0) {
        List<Long> identityKeys = new ArrayList<>(selectedMembers.size());
        for (Member member : selectedMembers) {
            identityKeys.add(member.getKey());
        }
        List<Identity> selectedIdentities = securityManager.loadIdentityByKeys(identityKeys);
        contactList.addAllIdentites(selectedIdentities);
    }
    if (externalEl != null && externalEl.isAtLeastSelected(1)) {
        String value = externalAddressesEl.getValue();
        if (StringHelper.containsNonWhitespace(value)) {
            for (StringTokenizer tokenizer = new StringTokenizer(value, ",\r\n", false); tokenizer.hasMoreTokens(); ) {
                String email = tokenizer.nextToken().trim();
                contactList.add(new EMailIdentity(email, getLocale()));
            }
        }
    }
    doSendEmailToMember(ureq, contactList);
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) ArrayList(java.util.ArrayList) ContactList(org.olat.core.util.mail.ContactList) RepositoryEntry(org.olat.repository.RepositoryEntry) StringTokenizer(java.util.StringTokenizer) EMailIdentity(org.olat.core.util.mail.ui.EMailIdentity) EMailIdentity(org.olat.core.util.mail.ui.EMailIdentity) Identity(org.olat.core.id.Identity) Member(org.olat.course.nodes.members.Member) HashSet(java.util.HashSet)

Example 3 with Member

use of org.olat.course.nodes.members.Member 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 4 with Member

use of org.olat.course.nodes.members.Member in project openolat by klemens.

the class MembersAvatarDisplayRunController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (source == allEmailLink) {
        doEmail(ureq);
    } else if (source == downloadLink) {
        doExport(ureq);
    } else if (source instanceof FormLink) {
        FormLink link = (FormLink) source;
        Object uobject = link.getUserObject();
        if (uobject instanceof Member) {
            Member member = (Member) uobject;
            String cmd = link.getCmd();
            if ("id".equals(cmd)) {
                doOpenHomePage(member, ureq);
            } else if ("mail".equals(cmd)) {
                doSendEmailToMember(member, ureq);
            } else if ("chat".equals(cmd)) {
                doOpenChat(member, ureq);
            }
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) Member(org.olat.course.nodes.members.Member)

Example 5 with Member

use of org.olat.course.nodes.members.Member in project openolat by klemens.

the class MembersListDisplayRunController method convertIdentitiesToMembers.

private List<Member> convertIdentitiesToMembers(List<Identity> identities) {
    List<Member> memberList = new ArrayList<>();
    for (Identity identity : identities) {
        Member member = createMember(identity);
        memberList.add(member);
    }
    return memberList;
}
Also used : ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity) Member(org.olat.course.nodes.members.Member)

Aggregations

Member (org.olat.course.nodes.members.Member)20 ArrayList (java.util.ArrayList)8 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)8 Identity (org.olat.core.id.Identity)8 HashMap (java.util.HashMap)6 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)4 HashSet (java.util.HashSet)2 List (java.util.List)2 Locale (java.util.Locale)2 Map (java.util.Map)2 StringTokenizer (java.util.StringTokenizer)2 Collectors (java.util.stream.Collectors)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 BaseSecurityModule (org.olat.basesecurity.BaseSecurityModule)2 MetaInfo (org.olat.core.commons.modules.bc.meta.MetaInfo)2 MetaTagged (org.olat.core.commons.modules.bc.meta.tagged.MetaTagged)2 Mapper (org.olat.core.dispatcher.mapper.Mapper)2 UserRequest (org.olat.core.gui.UserRequest)2 Component (org.olat.core.gui.components.Component)2 MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)2