From: Roland Haeder Date: Fri, 16 Oct 2015 17:27:10 +0000 (+0200) Subject: added/implemented bean method isProfileLinkVisible() X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e811c1c9d58b45416a3ed051c55ddb46ca5e90ed;p=addressbook-war.git added/implemented bean method isProfileLinkVisible() --- diff --git a/src/java/org/mxchange/addressbook/beans/profile/UserProfileWebBean.java b/src/java/org/mxchange/addressbook/beans/profile/UserProfileWebBean.java index f7fd28c7..520ef170 100644 --- a/src/java/org/mxchange/addressbook/beans/profile/UserProfileWebBean.java +++ b/src/java/org/mxchange/addressbook/beans/profile/UserProfileWebBean.java @@ -21,6 +21,7 @@ import javax.inject.Inject; import javax.inject.Named; import org.mxchange.addressbook.beans.login.UserLoginWebController; import org.mxchange.jusercore.model.user.User; +import org.mxchange.jusercore.model.user.profilemodes.ProfileMode; /** * A web request bean for user profiles @@ -56,4 +57,20 @@ public class UserProfileWebBean implements UserProfileWebController { public void setUser (final User user) { this.user = user; } + + @Override + public boolean isProfileLinkVisible () { + // Default profile mode is not visible + ProfileMode profileMode = ProfileMode.INVISIBLE; + + // Is the user set? + if (this.getUser() instanceof User) { + // Get profile mode from user + profileMode = this.getUser().getUserProfileMode(); + } + + // Check all conditions (except for admin) + // TODO: Add admin role somehow? + return ((profileMode.equals(ProfileMode.PUBLIC)) || (this.loginController.isUserLoggedIn()) && (profileMode.equals(ProfileMode.MEMBERS))); + } } diff --git a/src/java/org/mxchange/addressbook/beans/profile/UserProfileWebController.java b/src/java/org/mxchange/addressbook/beans/profile/UserProfileWebController.java index 219a7e9b..f3cc9d11 100644 --- a/src/java/org/mxchange/addressbook/beans/profile/UserProfileWebController.java +++ b/src/java/org/mxchange/addressbook/beans/profile/UserProfileWebController.java @@ -31,12 +31,19 @@ public interface UserProfileWebController extends Serializable { *

* @return User instance */ - public User getUser (); + User getUser (); /** * Setter for user instance *

* @param user User instance */ - public void setUser (final User user); + void setUser (final User user); + + /** + * Checks if the user profile link is visible + *

+ * @return Whether the profile link is visible + */ + boolean isProfileLinkVisible (); }