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