// Check all conditions (except for admin)
// TODO: Add admin role somehow?
- return ((profileMode.equals(ProfileMode.PUBLIC))
- || (this.loginController.isUserLoggedIn()) && (profileMode.equals(ProfileMode.MEMBERS)));
+ return ((profileMode.equals(ProfileMode.PUBLIC)) ||
+ (this.loginController.isUserLoggedIn()) && (profileMode.equals(ProfileMode.MEMBERS)));
+ }
+
+ @Override
+ public boolean isProfileLinkVisibleByUser (final User user) {
+ // Is the user instance valid?
+ if (null == user) {
+ // Throw NPE here
+ throw new NullPointerException("user is null");
+ } else if (user.getUserId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("user.userId is null");
+ } else if (user.getUserId() < 1) {
+ // Throw NPE again
+ throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId()));
+ }
+
+ // Set it here
+ this.setUser(user);
+
+ // Ask other method
+ return this.isProfileLinkVisible();
}
@Override
*/
boolean isProfileLinkVisible ();
+ /**
+ * Checks if given user's profile is visible to the currently logged-in
+ * user.
+ * <p>
+ * @param user User instance
+ * <p>
+ * @return Whether the profile link is visible
+ */
+ boolean isProfileLinkVisibleByUser (final User user);
+
/**
* Checks if the user profile link is visible
* <p>
<h:column>
<f:facet name="header">#{msg.LOGIN_START_SHARING_TITLE}</f:facet>
- <h:form acceptcharset="utf-8" id="startSharing" rendered="#{profileController.isProfileLinkVisible()}">
+ <h:form acceptcharset="utf-8" id="startSharing" rendered="#{profileController.isProfileLinkVisibleByUser(user)}">
<h:commandButton class="submit" id="submit" value="#{msg.LOGIN_START_SHARING_BUTTON}" action="#{shareController.startSharing(user, addressbookController.addressbook)}" title="#{msg.LOGIN_START_SHARING_BUTTON_TITLE}" />
</h:form>
</h:column>