Search in sources :

Example 11 with Member

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

the class MembersMailController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (source == externalEl) {
        externalAddressesEl.setVisible(externalEl.isAtLeastSelected(1));
    } else if (source == individualEl) {
        individualMemberCont.setVisible(individualEl.isAtLeastSelected(1));
        flc.setDirty(true);
    } else if (source == attachmentEl) {
        doUploadAttachement();
    } else if (source == addMemberButton) {
        doChooseMember(ureq);
    } else if (source instanceof FormLink) {
        FormLink link = (FormLink) source;
        String cmd = link.getCmd();
        if ("delete".equals(cmd)) {
            Attachment attachment = (Attachment) link.getUserObject();
            doDeleteAttachment(attachment);
        } else if ("remove".equals(cmd)) {
            Member member = (Member) link.getUserObject();
            doRemoveIndividualMember(member);
        }
    }
    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 12 with Member

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

the class SelectMembersController method makeSelection.

private MultipleSelectionElement makeSelection(String name, List<Member> members, FormItemContainer formLayout) {
    String[] keys = new String[members.size()];
    String[] values = new String[members.size()];
    List<String> preSelectedOptions = new ArrayList<>();
    for (int i = members.size(); i-- > 0; ) {
        Member member = members.get(i);
        String optionKey = member.getKey().toString();
        keys[i] = optionKey;
        values[i] = member.getFullName();
        if (preSelectedMembers.contains(member)) {
            preSelectedOptions.add(optionKey);
        }
    }
    MultipleSelectionElement selectionEl = uifactory.addCheckboxesVertical(name, name, formLayout, keys, values, 2);
    for (String preSelectedOption : preSelectedOptions) {
        selectionEl.select(preSelectedOption, true);
    }
    return selectionEl;
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) ArrayList(java.util.ArrayList) Member(org.olat.course.nodes.members.Member)

Example 13 with Member

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

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 14 with Member

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

the class MembersAvatarDisplayRunController method initFormMemberList.

private List<Member> initFormMemberList(String name, List<Identity> ids, Set<Long> duplicateCatcher, FormItemContainer formLayout, boolean withEmail) {
    String page = velocity_root + "/memberList.html";
    FormLayoutContainer container = FormLayoutContainer.createCustomFormLayout(name, getTranslator(), page);
    container.contextPut("userPropertyHandlers", userPropertyAvatarHandlers);
    // 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<>();
    for (int i = userPropertyHandlers.size(); i-- > 0; ) {
        UserPropertyHandler handler = userPropertyHandlers.get(i);
        handlerLookupMap.put(handler.getName(), i);
    }
    container.contextPut("handlerLookupMap", handlerLookupMap);
    formLayout.add(name, container);
    container.setRootForm(mainForm);
    List<Member> members = createMemberLinks(ids, duplicateCatcher, container, withEmail);
    container.contextPut("members", members);
    container.contextPut("avatarBaseURL", avatarBaseURL);
    return members;
}
Also used : HashMap(java.util.HashMap) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) Member(org.olat.course.nodes.members.Member) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 15 with Member

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

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)

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