Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAK-32712 Roster feature to add the display of a user's properties #4624

Merged
merged 1 commit into from
Jul 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
SAK-32712 Roster feature to add the display of a user's properties
  • Loading branch information
ern committed Jul 19, 2017
commit b107e40f53f9ac3f07980418dce58af14aaed773
Original file line number Diff line number Diff line change
Expand Up @@ -2806,6 +2806,10 @@
# DEFAULT: false
# roster.showVisits=true

# Include user properties in roster
# DEFAULT: true
# roster_view_user_properties=false

## SEARCH
# Elastic search is the default search as of Sakai 10
# For more information please see this confluence page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@
font-weight: bold;
padding-right: 10px;
}

.roster-user-properties {
list-style: none;
}
}
.roster-last-visit-time-cell {
font-size: 0.9em;
Expand Down
11 changes: 11 additions & 0 deletions roster2/src/handlebars/enrollment_status.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
{{#if viewEmail}}
<th width="20%"><a href="#">{{translate 'facet_email'}}</a></th>
{{/if}}
{{#if viewUserProperty}}
<th width="20%"><a href="#">{{translate 'facet_userProperties'}}</a></th>
{{/if}}
<th width="12.5%"><a href="#">{{translate 'facet_status'}}</a></th>
<th width="12.5%"><a href="#">{{translate 'facet_credits'}}</a></th>
</tr>
Expand All @@ -22,6 +25,9 @@
{{#if viewEmail}}
<td></td>
{{/if}}
{{#if viewUserProperty}}
<td></td>
{{/if}}
<td></td>
<td></td>
</tr>
Expand All @@ -48,6 +54,11 @@
{{#if ../../viewEmail}}
<td><a href="mailto:{{email}}">{{email}}</a></td>
{{/if}}
{{#if ../../viewUserProperty}}
{{#each userProperties}}
<li>{{@key}}: {{this}}</li>
{{/each}}
{{/if}}
<td>{{enrollmentStatus}}</td>
<td>{{credits}}</td>
</tr>
Expand Down
12 changes: 12 additions & 0 deletions roster2/src/handlebars/members.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,17 @@
<a href="mailto:{{email}}" title="{{translate 'profile_email'}} {{email}}">{{email}}</a>
</div>
{{/if}}

{{#if ../viewUserProperty}}
<div class="roster-table-cell">
<div class="roster-mobile-label">{{translate 'facet_userProperties'}}</div>
<ul class="roster-user-properties">
{{#each userProperties}}
<li>{{@key}}: {{this}}</li>
{{/each}}
</ul>
</div>
{{/if}}

</div> <!-- /roster-table-row -->
{{/each}}
3 changes: 3 additions & 0 deletions roster2/src/handlebars/members_header.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
{{#if viewEmail}}
<div class="roster-table-cell">{{translate 'facet_email'}}</div>
{{/if}}
{{#if viewUserProperty}}
<div class="roster-table-cell">{{translate 'facet_userProperties'}}</div>
{{/if}}
</div>
</div>
<div id="roster-members" class="roster-table-row-group"></div>
Expand Down
6 changes: 6 additions & 0 deletions roster2/src/handlebars/permissions.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
<td align="center"><input type="checkbox" class="roster_permission_checkbox" {{#if (roleAllowed permission='roster.viewemail')}}checked="checked"{{/if}}" id="{{name}}:roster.viewemail"/></td>
{{/each}}
</tr>
<tr>
<td align="left">{{translate 'permissions_user_properties'}}</td>
{{#each roles}}
<td align="center"><input type="checkbox" class="roster_permission_checkbox" {{#if (roleAllowed permission='roster.viewuserproperties')}}checked="checked"{{/if}}" id="{{name}}:roster.viewuserproperties"/></td>
{{/each}}
</tr>
<tr>
<td align="left">{{translate 'permissions_photo'}}</td>
{{#each roles}}
Expand Down
12 changes: 7 additions & 5 deletions roster2/src/i18n/org/sakaiproject/roster/i18n/ui.properties
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ profile_picture_alt = Photo of
facet_picture = Picture
facet_name = Name
facet_userId = User ID
facet_userProperties = User Properties
facet_email = Email
facet_role = Role
facet_status = Status
Expand Down Expand Up @@ -93,9 +94,10 @@ permissions_header = Permission
permissions_allmembers = View all participants
permissions_hidden = View hidden participants
permissions_groups = View groups
permissions_enrollment = View participants' enrollment status
permissions_profile = View participants' profile
permissions_email = View participants' email
permissions_photo = View participants' official photo
permissions_visits = View participants' site visits
permissions_enrollment = View participant's enrollment status
permissions_profile = View participant's profile
permissions_email = View participant's email
permissions_photo = View participant's official photo
permissions_visits = View participant's site visits
permissions_export = Export roster
permissions_user_properties= View participant's properties
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ public interface RosterFunctions {
public static final String ROSTER_FUNCTION_VIEWEMAIL = ROSTER_FUNCTION_PREFIX + "viewemail";
public static final String ROSTER_FUNCTION_VIEWOFFICIALPHOTO = ROSTER_FUNCTION_PREFIX + "viewofficialphoto";
public static final String ROSTER_FUNCTION_VIEWSITEVISITS = ROSTER_FUNCTION_PREFIX + "viewsitevisits";
public static final String ROSTER_FUNCTION_VIEWUSERPROPERTIES = ROSTER_FUNCTION_PREFIX + "viewuserproperties";

}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public class RosterMember {
@Getter
private Map<String, String> groups = new HashMap<String, String>();
@Getter @Setter
private Map<String, String> userProperties = new HashMap<>();
@Getter @Setter
private int connectionStatus; // connection status to the current user
@Getter @Setter
private int totalSiteVisits;
Expand Down
16 changes: 16 additions & 0 deletions roster2/src/java/org/sakaiproject/roster/api/SakaiProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public interface SakaiProxy {
public final static Boolean DEFAULT_VIEW_EMAIL = true;
public final static Boolean DEFAULT_VIEW_CONNECTIONS = true;
public final static Boolean DEFAULT_VIEW_USER_DISPLAY_ID = true;
public final static Boolean DEFAULT_VIEW_USER_PROPERTIES = true;
public final static Integer DEFAULT_ROSTER_STATE = 0;

/**
Expand Down Expand Up @@ -144,6 +145,21 @@ public interface SakaiProxy {
*/
public Boolean getViewUserDisplayId();

/**
* Returns the value of the <code>roster_view_user_properties</code> Sakai property.
*
* @return the value of the <code>roster_view_user_properties</code> Sakai property.
*/
public Boolean getViewUserProperty();

/**
* Returns the value of the <code>roster_view_user_properties</code> Sakai property.
*
* @param siteId a site
* @return the value of the <code>roster_view_user_properties</code> Sakai property.
*/
public Boolean getViewUserProperty(String siteId);

/**
* Returns the value of the <code>roster.display.officialPicturesByDefault</code> Sakai property.
*
Expand Down
25 changes: 25 additions & 0 deletions roster2/src/java/org/sakaiproject/roster/impl/SakaiProxyImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.*;

import org.apache.commons.lang.ArrayUtils;
import org.sakaiproject.entity.api.serialize.SerializablePropertiesAccess;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sakaiproject.api.privacy.PrivacyManager;
Expand Down Expand Up @@ -133,6 +134,10 @@ public void init() {
functionManager.registerFunction(RosterFunctions.ROSTER_FUNCTION_VIEWSITEVISITS, true);
}

if (!registered.contains(RosterFunctions.ROSTER_FUNCTION_VIEWUSERPROPERTIES)) {
functionManager.registerFunction(RosterFunctions.ROSTER_FUNCTION_VIEWUSERPROPERTIES, true);
}

eventTrackingService.addObserver(this);

memberComparator = new RosterMemberComparator(getFirstNameLastName());
Expand Down Expand Up @@ -285,6 +290,19 @@ public Boolean getViewUserDisplayId() {
"roster.display.userDisplayId", DEFAULT_VIEW_USER_DISPLAY_ID);
}

@Override
public Boolean getViewUserProperty() {
return getViewUserProperty(getCurrentSiteId());
}

@Override
public Boolean getViewUserProperty(String siteId) {
if(serverConfigurationService.getBoolean("roster_view_user_properties", DEFAULT_VIEW_USER_PROPERTIES)) {
return hasUserSitePermission(getCurrentUserId(), RosterFunctions.ROSTER_FUNCTION_VIEWUSERPROPERTIES, siteId);
}
return false;
}

/**
* {@inheritDoc}
*/
Expand Down Expand Up @@ -599,6 +617,13 @@ private RosterMember getRosterMember(Map<String, User> userMap, Collection<Group
rosterMember.setDisplayName(user.getDisplayName());
rosterMember.setSortName(user.getSortName());

Map<String, String> userPropertiesMap = new HashMap<>();
Map<String, Object> props = ((SerializablePropertiesAccess) user.getProperties()).getSerializableProperties();
for (String propKey : props.keySet() ) {
userPropertiesMap.put(propKey, (String) props.get(propKey));
}
rosterMember.setUserProperties(userPropertiesMap);

for (Group group : groups) {
if (group.getMember(userId) != null) {
rosterMember.addGroup(group.getId(), group.getTitle());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ protected void doGet(HttpServletRequest request,
request.setAttribute("firstNameLastName", sakaiProxy.getFirstNameLastName());
request.setAttribute("hideSingleGroupFilter", sakaiProxy.getHideSingleGroupFilter());
request.setAttribute("viewUserDisplayId", sakaiProxy.getViewUserDisplayId());
request.setAttribute("viewUserProperty", sakaiProxy.getViewUserProperty());
request.setAttribute("officialPicturesByDefault", sakaiProxy.getOfficialPicturesByDefault());
request.setAttribute("viewEmail", sakaiProxy.getViewEmail());
request.setAttribute("superUser", sakaiProxy.isSuperUser());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

import javax.servlet.http.HttpServletResponse;
Expand Down Expand Up @@ -389,6 +390,11 @@ private void addOverviewRows(final List<List<String>> dataInRows,
row.add(member.getEmail());
}

if (this.sakaiProxy.getViewUserProperty(siteId)) {
List<String> props = member.getUserProperties().entrySet().stream().map(e -> e.getKey() + ":" + e.getValue()).collect(Collectors.toList());
row.add(String.join(",", props));
}

row.add(member.getRole());

if (this.sakaiProxy.hasUserSitePermission(userId, RosterFunctions.ROSTER_FUNCTION_VIEWGROUP, siteId)) {
Expand Down Expand Up @@ -443,6 +449,11 @@ private void addEnrollmentStatusRows(final List<List<String>> dataInRows,
row.add(member.getEmail());
}

if (this.sakaiProxy.getViewUserProperty(siteId)) {
List<String> props = member.getUserProperties().entrySet().stream().sorted(Map.Entry.comparingByKey()).map(e -> e.getKey() + ":" + e.getValue()).collect(Collectors.toList());
row.add(String.join(",", props));
}

row.add(member.getEnrollmentStatusText());
row.add(member.getCredits());

Expand Down Expand Up @@ -507,10 +518,15 @@ private List<String> createColumnHeader(final String viewType, final String site
if (this.sakaiProxy.getViewUserDisplayId()) {
header.add(rl.getString("facet_userId"));
}

if (this.sakaiProxy.getViewEmail(siteId)) {
header.add(rl.getString("facet_email"));
}

if (this.sakaiProxy.getViewUserProperty(siteId)) {
header.add(rl.getString("facet_userProperties"));
}

if (VIEW_OVERVIEW.equals(viewType)) {
header.add(rl.getString("facet_role"));
} else if (VIEW_ENROLLMENT_STATUS.equals(viewType)) {
Expand Down
1 change: 1 addition & 0 deletions roster2/src/webapp/WEB-INF/bootstrap.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
firstNameLastName: ${firstNameLastName},
hideSingleGroupFilter: ${hideSingleGroupFilter},
viewUserDisplayId: ${viewUserDisplayId},
viewUserProperty: ${viewUserProperty},
//officialPicturesByDefault: ${officialPicturesByDefault},
officialPictureMode: ${officialPicturesByDefault},
viewEmail: ${viewEmail},
Expand Down
4 changes: 3 additions & 1 deletion roster2/src/webapp/js/roster.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,14 @@
roster.render('members_header', {
viewEmail: roster.viewEmail,
viewUserDisplayId: roster.viewUserDisplayId,
viewUserProperty: roster.viewUserProperty,
viewProfile: roster.currentUserPermissions.viewProfile,
viewGroup : roster.currentUserPermissions.viewGroup,
viewPicture: true,
viewSiteVisits: roster.currentUserPermissions.viewSiteVisits,
viewConnections: ((undefined != window.friendStatus) && roster.viewConnections),
enrollmentsMode: enrollmentsMode,
showVisits: roster.showVisits
showVisits: roster.showVisits,
}, 'roster-members-content');
}

Expand Down Expand Up @@ -562,6 +563,7 @@
firstNameLastName: roster.firstNameLastName,
viewEmail: roster.viewEmail,
viewUserDisplayId: roster.viewUserDisplayId,
viewUserProperty: roster.viewUserProperty,
viewProfile: roster.currentUserPermissions.viewProfile,
viewGroup : roster.currentUserPermissions.viewGroup,
viewPicture: true,
Expand Down