Skip to content

Commit

Permalink
SAK-31805 If It's selected 'Official Foto', the photo that appears in…
Browse files Browse the repository at this point in the history
… the pop up window is not the official (sakaiproject#3440)
  • Loading branch information
manuelal authored and juanjmerono committed Oct 5, 2016
1 parent 696cac2 commit 8da3bdb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,18 +274,20 @@ public Object getUnreadMessagesCount(EntityReference ref) {
}

@EntityCustomAction(action="formatted",viewKey=EntityView.VIEW_SHOW)
public Object getFormattedProfile(EntityReference ref) {
public Object getFormattedProfile(EntityReference ref, EntityView view) {

//this allows a normal full profile to be returned formatted in HTML

final boolean wantsOfficial = StringUtils.equals("official", view.getPathSegment(3)) ? true : false;

//get the full profile
UserProfile userProfile = (UserProfile) getEntity(ref);

//Check for siteId in the request
String siteId = requestGetter.getRequest().getParameter("siteId");

//convert UserProfile to HTML object
String formattedProfile = getUserProfileAsHTML(userProfile, siteId);
String formattedProfile = getUserProfileAsHTML(userProfile, siteId, wantsOfficial);

//ActionReturn actionReturn = new ActionReturn("UTF-8", "text/html", entity);
ActionReturn actionReturn = new ActionReturn(Formats.UTF_8, Formats.HTML_MIME_TYPE, formattedProfile);
Expand Down Expand Up @@ -416,7 +418,7 @@ public String redirectUserAccount(Map<String,String> vars) {
/**
* {@inheritDoc}
*/
private String getUserProfileAsHTML(UserProfile userProfile, String siteId) {
private String getUserProfileAsHTML(UserProfile userProfile, String siteId, boolean official) {

//note there is no birthday in this field. we need a good way to get the birthday without the year.
//maybe it needs to be stored in a separate field and treated differently. Or returned as a localised string.
Expand All @@ -429,7 +431,11 @@ private String getUserProfileAsHTML(UserProfile userProfile, String siteId) {

sb.append("<div class=\"profile2-profile-image\">");
sb.append("<img src=\"");
sb.append(userProfile.getImageUrl());
if (official) {
sb.append(imageLogic.getOfficialProfileImage(userProfile.getUserUuid(), siteId).getUrl());
} else {
sb.append(userProfile.getImageUrl());
}
sb.append("\" />");
sb.append("</div>");

Expand Down
Empty file added profile2/velocity.log
Empty file.
1 change: 1 addition & 0 deletions roster2/src/webapp/js/roster.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@
m.profileImageUrl = "/direct/profile/" + m.userId + "/image";
if (options.forceOfficialPicture || options.showOfficialPictures) {
m.profileImageUrl += "/official";
m.formattedProfileUrl = "/direct/profile/" + m.userId + "/formatted/official?siteId=" + encodeURIComponent(roster.siteId);
}
m.profileImageUrl += "?siteId=" + encodeURIComponent(roster.siteId);
var groupIds = Object.keys(m.groups);
Expand Down

0 comments on commit 8da3bdb

Please sign in to comment.