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);
}
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);
}
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;
}
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);
}
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;
}
Aggregations