use of org.olat.user.DisplayPortraitController in project OpenOLAT by OpenOLAT.
the class UserAdminController method exposeUserDataToVC.
/**
* Add some user data to velocity container including the users portrait
* @param ureq
* @param identity
*/
private void exposeUserDataToVC(UserRequest ureq, Identity identity) {
removeAsListenerAndDispose(portraitCtr);
portraitCtr = new DisplayPortraitController(ureq, getWindowControl(), identity, true, true);
myContent.put("portrait", portraitCtr.getInitialComponent());
removeAsListenerAndDispose(userShortDescrCtr);
userShortDescrCtr = new UserShortDescription(ureq, getWindowControl(), identity);
myContent.put("userShortDescription", userShortDescrCtr.getInitialComponent());
}
use of org.olat.user.DisplayPortraitController in project OpenOLAT by OpenOLAT.
the class GTACoachController method initContainer.
@Override
protected void initContainer(UserRequest ureq) {
mainVC = createVelocityContainer("coach");
reviewedButton = LinkFactory.createCustomLink("coach.reviewed.button", "reviewed", "coach.reviewed.button", Link.BUTTON, mainVC, this);
reviewedButton.setElementCssClass("o_sel_course_gta_reviewed");
reviewedButton.setIconLeftCSS("o_icon o_icon_accepted");
reviewedButton.setPrimary(true);
reviewedButton.setVisible(!coachCourseEnv.isCourseReadOnly());
if (config.getBooleanSafe(GTACourseNode.GTASK_REVISION_PERIOD)) {
needRevisionsButton = LinkFactory.createCustomLink("coach.need.revision.button", "need-revision", "coach.need.revision.button", Link.BUTTON, mainVC, this);
needRevisionsButton.setElementCssClass("o_sel_course_gta_need_revision");
needRevisionsButton.setPrimary(true);
needRevisionsButton.setVisible(!coachCourseEnv.isCourseReadOnly());
needRevisionsButton.setIconLeftCSS("o_icon o_icon_rejected");
}
if (withTitle) {
if (assessedGroup != null) {
mainVC.contextPut("groupName", assessedGroup.getName());
emailLink = LinkFactory.createButtonXSmall("mailto.group", mainVC, this);
emailLink.setIconLeftCSS("o_icon o_icon_mail");
} else if (assessedIdentity != null) {
mainVC.contextPut("identityFullName", userManager.getUserDisplayName(assessedIdentity));
Controller dpc = new DisplayPortraitController(ureq, getWindowControl(), assessedIdentity, false, true, true, true);
// auto dispose, no need to keep local reference
listenTo(dpc);
mainVC.put("image", dpc.getInitialComponent());
emailLink = LinkFactory.createButtonXSmall("mailto.user", mainVC, this);
emailLink.setIconLeftCSS("o_icon o_icon_mail");
}
}
if (withReset) {
resetTaskButton = LinkFactory.createCustomLink("coach.reset.button", "reset", "coach.reset.button", Link.BUTTON, mainVC, this);
resetTaskButton.setElementCssClass("o_sel_course_gta_reset");
resetTaskButton.setVisible(false);
}
putInitialPanel(mainVC);
}
use of org.olat.user.DisplayPortraitController in project OpenOLAT by OpenOLAT.
the class HighScoreRunController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
VelocityContainer mainVC = this.flc.getFormItemComponent();
mainVC.put("loadd3js", new StatisticsComponent("d3loader"));
if (viewHistogram) {
VelocityContainer scoreHistogramVC = createVelocityContainer("histogram_score");
// transfer all scores to velocity container as base data for histogram
HighScoreRankingResults modifiedData = highScoreManager.processHistogramData(allScores, lowerBorder, upperBorder);
allScores = modifiedData.getModifiedScores();
scoreHistogramVC.contextPut("datas", BarSeries.datasToString(allScores));
// histogram marker for own position
scoreHistogramVC.contextPut("cutValue", ownIdIndices.size() > 0 ? highScoreManager.calculateHistogramCutvalue(allMembers.get(ownIdIndices.get(0)).getScore(), modifiedData.getClasswidth(), modifiedData.getMin()) : -1000);
// classwidth to correctly display the histogram
long classwidth = modifiedData.getClasswidth();
scoreHistogramVC.contextPut("step", classwidth);
// find path for ownID image to display in histogram
UserAvatarMapper mapper = new UserAvatarMapper(false);
String mapperPath = registerMapper(ureq, mapper);
String identityMapperPath = mapper.createPathFor(mapperPath, ownIdentity);
scoreHistogramVC.contextPut("mapperUrl", identityMapperPath);
mainVC.put("scoreHistogram", scoreHistogramVC);
}
if (viewPodium) {
String[] localizer = { "first", "second", "third" };
// for clarity and space reasons do not show any portraits if one position has more than 6 persons
int maxPerson = 6;
boolean showPortraits = !anonymous && allPodium.get(0).size() <= maxPerson && allPodium.get(1).size() <= maxPerson && allPodium.get(2).size() <= maxPerson;
for (int i = 0; i < localizer.length; i++) {
int sizePerPos = allPodium.get(i).size();
StringBuilder sb = new StringBuilder();
if (sizePerPos > 2) {
int reduce = 0;
// create link if podium has more than 2 entries per rank, entries can be displayed as anonymous
if (allPodium.get(i).get(0).getIdentity().equals(ownIdentity)) {
sb.append(userManager.getUserDisplayName(ownIdentity));
++reduce;
}
if (sizePerPos > 6 || anonymous) {
mainVC.contextPut("further" + (i + 1), (sizePerPos - reduce) + " " + (reduce == 1 ? translate("highscore.further") : translate("highscore.total")));
} else {
links[i] = LinkFactory.createLink(null, "link" + (i + 1), "cmd", (sizePerPos - reduce) + " " + (reduce == 1 ? translate("highscore.further") : translate("highscore.total")), getTranslator(), mainVC, this, 16);
}
} else {
for (HighScoreTableEntry te : allPodium.get(i)) {
if (!anonymous || te.getIdentity().equals(ownIdentity)) {
sb.append(userManager.getUserDisplayName(te.getIdentity()));
sb.append("<br/>");
}
}
}
mainVC.contextPut(localizer[i], sizePerPos > 0 ? sb.toString() : translate("highscore.unavail"));
mainVC.contextPut("score" + (i + 1), sizePerPos > 0 ? allPodium.get(i).get(0).getScore() : null);
if (sizePerPos > 0 && showPortraits) {
// decide whether or not to display id portrait
mainVC.contextPut("number" + (i + 1), sizePerPos);
for (int j = 0; j < sizePerPos; j++) {
Identity currentID = allPodium.get(i).get(j).getIdentity();
boolean choosePortrait = !anonymous || ownIdentity.equals(currentID);
DisplayPortraitController portrait = new DisplayPortraitController(ureq, getWindowControl(), currentID, false, choosePortrait, !choosePortrait);
listenTo(portrait);
Component portraitComponent = portrait.getInitialComponent();
mainVC.put("portrait" + (i + 1) + "-" + (j + 1), portraitComponent);
}
} else {
// if amount of people per rank is too large, own id portrait can still be displayed
for (int j = 0; j < sizePerPos; j++) {
Identity currentID = allPodium.get(i).get(j).getIdentity();
if (ownIdentity.equals(currentID)) {
DisplayPortraitController portrait = new DisplayPortraitController(ureq, getWindowControl(), currentID, true, true, false);
listenTo(portrait);
mainVC.put("portrait" + (i + 1), portrait.getInitialComponent());
}
}
}
}
}
if (viewTable) {
FlexiTableColumnModel tableColumnModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("highscore.table.header1", HighScoreTableEntry.RANK));
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("highscore.table.header2", HighScoreTableEntry.SCORE));
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("highscore.table.header3", HighScoreTableEntry.NAME));
// trim to tableSize
if (tableSize < allMembers.size()) {
allMembers.subList(tableSize, allMembers.size()).clear();
}
tableDataModel = new FlexiTableDataModelImpl<HighScoreTableEntry>(new HighScoreFlexiTableModel(allMembers, anonymous, translate("highscore.anonymous"), ownIdentity), tableColumnModel);
FlexiTableElement topTenTable = uifactory.addTableElement(getWindowControl(), "table", tableDataModel, getTranslator(), formLayout);
topTenTable.setNumOfRowsEnabled(false);
topTenTable.setCustomizeColumns(false);
topTenTable.setCssDelegate(new MarkedMemberCssDelegate(false));
// establish a 2nd table if ownID position is greater than first table's size setting
if (!ownIdMembers.isEmpty()) {
tableDataModel2 = new FlexiTableDataModelImpl<HighScoreTableEntry>(new HighScoreFlexiTableModel(ownIdMembers, anonymous, translate("highscore.anonymous"), ownIdentity), tableColumnModel);
FlexiTableElement tableElement = uifactory.addTableElement(getWindowControl(), "table2", tableDataModel2, getTranslator(), formLayout);
tableElement.setNumOfRowsEnabled(false);
tableElement.setCustomizeColumns(false);
tableElement.setCssDelegate(new MarkedMemberCssDelegate(true));
}
}
if (viewPosition && ownIdIndices.size() > 0) {
int amountWorse = allScores.length - ownIdIndices.get(0) - 1;
if (amountWorse > 0) {
mainVC.contextPut("relposition", translate("highscore.position.inrelation", new String[] { String.valueOf(amountWorse) }));
}
int ownRank = highscoreDataModel.getOwnTableEntry().getRank();
mainVC.contextPut("position", translate("highscore.position.yourposition", new String[] { String.valueOf(ownRank) }));
}
}
use of org.olat.user.DisplayPortraitController in project OpenOLAT by OpenOLAT.
the class SingleParticipantCallController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
int numOfChecks = lectureBlock.getPlannedLecturesNumber();
List<Integer> absences = rollCall.getLecturesAbsentList();
for (int i = 0; i < numOfChecks; i++) {
String checkId = "check_" + i;
MultipleSelectionElement check = uifactory.addCheckboxesHorizontal(checkId, null, layoutCont, onKeys, onValues);
check.setDomReplacementWrapperRequired(false);
check.addActionListener(FormEvent.ONCHANGE);
if (absences.contains(i)) {
check.select(onKeys[0], true);
}
checks.add(check);
}
layoutCont.contextPut("checks", checks);
DisplayPortraitController portraitCtr = new DisplayPortraitController(ureq, getWindowControl(), calledIdentity, true, false);
listenTo(portraitCtr);
layoutCont.getFormItemComponent().put("portrait", portraitCtr.getInitialComponent());
UserShortDescription userDescr = new UserShortDescription(ureq, getWindowControl(), calledIdentity);
listenTo(userDescr);
layoutCont.getFormItemComponent().put("userDescr", userDescr.getInitialComponent());
}
if (autorizedAbsenceEnabled) {
authorizedAbsencedEl = uifactory.addCheckboxesHorizontal("authorized.absence", "authorized.absence", formLayout, onKeys, onValues);
authorizedAbsencedEl.setDomReplacementWrapperRequired(false);
authorizedAbsencedEl.addActionListener(FormEvent.ONCHANGE);
if (rollCall.getAbsenceAuthorized() != null && rollCall.getAbsenceAuthorized().booleanValue()) {
authorizedAbsencedEl.select(onKeys[0], true);
}
String reason = rollCall.getAbsenceReason();
absenceReasonEl = uifactory.addTextAreaElement("absence.reason", "authorized.absence.reason", 2000, 4, 36, false, reason, formLayout);
absenceReasonEl.setDomReplacementWrapperRequired(false);
absenceReasonEl.setPlaceholderKey("authorized.absence.reason", null);
absenceReasonEl.setVisible(authorizedAbsencedEl.isAtLeastSelected(1));
absenceReasonEl.setMandatory(!absenceDefaultAuthorized);
}
String comment = rollCall.getComment();
commentEl = uifactory.addTextAreaElement("comment", "rollcall.comment", 2000, 4, 36, false, comment, formLayout);
commentEl.setPlaceholderKey("rollcall.comment", null);
selectAllLink = uifactory.addFormLink("all", formLayout);
uifactory.addFormSubmitButton("save", "save.next", formLayout);
uifactory.addFormCancelButton("cancel", formLayout, ureq, getWindowControl());
}
use of org.olat.user.DisplayPortraitController in project OpenOLAT by OpenOLAT.
the class MessageListController method addMessageToCurrentMessagesAndVC.
private void addMessageToCurrentMessagesAndVC(UserRequest ureq, MessageLight m, MessageView messageView, Map<String, Mark> marks, Map<String, MarkResourceStat> stats, Map<String, Long> artefactStats, Set<Long> readSet) {
// all values belonging to a message are stored in this map
// these values can be accessed in velocity. make sure you clean up
// everything
// you create here in disposeCurrentMessages()!
String keyString = m.getKey().toString();
if (readSet == null || readSet.contains(m.getKey())) {
messageView.setNewMessage(false);
} else {
// mark now as read
markRead(m);
messageView.setNewMessage(true);
}
// add some data now
messageView.setFormattedCreationDate(formatter.formatDateAndTime(m.getCreationDate()));
messageView.setFormattedLastModified(formatter.formatDateAndTime(m.getLastModified()));
Identity creator = m.getCreator();
Identity modifier = m.getModifier();
if (modifier != null) {
messageView.setModified(true);
if (modifier.equals(creator) && StringHelper.containsNonWhitespace(m.getPseudonym())) {
messageView.setModifierPseudonym(m.getPseudonym());
} else {
messageView.setModifierFirstName(modifier.getUser().getProperty(UserConstants.FIRSTNAME, getLocale()));
messageView.setModifierLastName(modifier.getUser().getProperty(UserConstants.LASTNAME, getLocale()));
}
} else {
messageView.setModified(false);
}
boolean userIsMsgCreator = false;
// keeps the first 15 chars
if (creator != null) {
userIsMsgCreator = getIdentity().equals(creator);
if (!StringHelper.containsNonWhitespace(m.getPseudonym())) {
messageView.setCreatorFirstname(Formatter.truncate(creator.getUser().getProperty(UserConstants.FIRSTNAME, getLocale()), 18));
messageView.setCreatorLastname(Formatter.truncate(creator.getUser().getProperty(UserConstants.LASTNAME, getLocale()), 18));
}
}
// message attachments
VFSContainer msgContainer = forumManager.getMessageContainer(forum.getKey(), m.getKey());
messageView.setMessageContainer(msgContainer);
List<VFSItem> attachments = new ArrayList<VFSItem>(msgContainer.getItems(new VFSItemMetaFilter()));
messageView.setAttachments(attachments);
// number of children and modify/delete permissions
int numOfChildren = messageView.getNumOfChildren();
messageView.setAuthor(userIsMsgCreator);
boolean threadTop = m.getThreadtop() == null;
messageView.setThreadTop(threadTop);
boolean isThreadClosed;
if (threadTop) {
isThreadClosed = Status.getStatus(m.getStatusCode()).isClosed();
} else {
if (thread == null) {
isThreadClosed = Status.getStatus(m.getThreadtop().getStatusCode()).isClosed();
} else {
isThreadClosed = Status.getStatus(thread.getStatusCode()).isClosed();
}
}
messageView.setClosed(isThreadClosed);
if (!guestOnly && !m.isGuest() && creator != null && !StringHelper.containsNonWhitespace(m.getPseudonym())) {
// add portrait to map for later disposal and key for rendering in velocity
DisplayPortraitController portrait = new DisplayPortraitController(ureq, getWindowControl(), creator, true, true, false, true);
messageView.setPortrait(portrait);
mainVC.put("portrait_".concat(keyString), portrait.getInitialComponent());
// Add link with username that is clickable
String creatorFullName = StringHelper.escapeHtml(UserManager.getInstance().getUserDisplayName(creator));
Link visitingCardLink = LinkFactory.createCustomLink("vc_".concat(keyString), "vc", creatorFullName, Link.LINK_CUSTOM_CSS + Link.NONTRANSLATED, mainVC, this);
visitingCardLink.setUserObject(creator);
LinkPopupSettings settings = new LinkPopupSettings(800, 600, "_blank");
visitingCardLink.setPopup(settings);
}
if (!isThreadClosed) {
if ((numOfChildren == 0 && userIsMsgCreator && foCallback.mayDeleteOwnMessage()) || foCallback.mayDeleteMessageAsModerator()) {
Link deleteLink = LinkFactory.createCustomLink("dl_".concat(keyString), "dl", "msg.delete", Link.BUTTON_SMALL, mainVC, this);
deleteLink.setIconLeftCSS("o_icon o_icon-fw o_icon_delete_item");
deleteLink.setUserObject(messageView);
}
if ((numOfChildren == 0 && userIsMsgCreator && foCallback.mayEditOwnMessage()) || foCallback.mayEditMessageAsModerator()) {
Link editLink = LinkFactory.createCustomLink("ed_".concat(keyString), "ed", "msg.update", Link.BUTTON_SMALL, mainVC, this);
editLink.setIconLeftCSS("o_icon o_icon-fw o_icon_edit");
editLink.setUserObject(messageView);
}
if (foCallback.mayReplyMessage()) {
Link quoteLink = LinkFactory.createCustomLink("qt_".concat(keyString), "qt", "msg.quote", Link.BUTTON_SMALL, mainVC, this);
quoteLink.setElementCssClass("o_sel_forum_reply_quoted");
quoteLink.setIconLeftCSS("o_icon o_icon-fw o_icon_reply_with_quote");
quoteLink.setUserObject(messageView);
Link replyLink = LinkFactory.createCustomLink("rp_".concat(keyString), "rp", "msg.reply", Link.BUTTON_SMALL, mainVC, this);
replyLink.setElementCssClass("o_sel_forum_reply");
replyLink.setIconLeftCSS("o_icon o_icon-fw o_icon_reply");
replyLink.setUserObject(messageView);
}
if (foCallback.mayEditMessageAsModerator()) {
if (!threadTop) {
Link splitLink = LinkFactory.createCustomLink("split_".concat(keyString), "split", "msg.split", Link.LINK, mainVC, this);
splitLink.setIconLeftCSS("o_icon o_icon-fw o_icon_split");
splitLink.setUserObject(messageView);
Link moveLink = LinkFactory.createCustomLink("move_".concat(keyString), "move", "msg.move", Link.LINK, mainVC, this);
moveLink.setIconLeftCSS("o_icon o_icon-fw o_icon_move");
moveLink.setUserObject(messageView);
}
Link exileLink = LinkFactory.createCustomLink("exile_".concat(keyString), "exile", "msg.exile", Link.LINK, mainVC, this);
exileLink.setIconLeftCSS("o_icon o_icon-fw o_forum_status_thread_icon");
exileLink.setUserObject(messageView);
}
}
Mark currentMark = marks.get(keyString);
MarkResourceStat stat = stats.get(keyString);
if (!guestOnly) {
String businessPath = currentMark == null ? getWindowControl().getBusinessControl().getAsString() + "[Message:" + m.getKey() + "]" : currentMark.getBusinessPath();
Controller markCtrl = markingService.getMarkController(ureq, getWindowControl(), currentMark, stat, forumOres, keyString, businessPath);
mainVC.put("mark_".concat(keyString), markCtrl.getInitialComponent());
}
if (userIsMsgCreator && !StringHelper.containsNonWhitespace(m.getPseudonym())) {
OLATResourceable messageOres = OresHelper.createOLATResourceableInstance("Forum", m.getKey());
String businessPath = BusinessControlFactory.getInstance().getAsString(getWindowControl().getBusinessControl()) + "[Message:" + m.getKey() + "]";
Long artefact = artefactStats.get(businessPath);
int numOfArtefact = artefact == null ? 0 : artefact.intValue();
if (portfolioModule.isEnabled()) {
String collectorId = "eportfolio_" + keyString;
Component collectorCmp = new MediaCollectorComponent(collectorId, getWindowControl(), m, forumMediaHandler, businessPath);
mainVC.put(collectorId, collectorCmp);
} else {
Controller ePFCollCtrl = EPUIFactory.createArtefactCollectWizzardController(ureq, getWindowControl(), numOfArtefact, messageOres, businessPath);
if (ePFCollCtrl != null) {
messageView.setArtefact(ePFCollCtrl);
mainVC.put("eportfolio_" + keyString, ePFCollCtrl.getInitialComponent());
}
}
}
}
Aggregations