]> git.mxchange.org Git - addressbook-war.git/commitdiff
added/implemented bean method isProfileLinkVisible()
authorRoland Haeder <roland@mxchange.org>
Fri, 16 Oct 2015 17:27:10 +0000 (19:27 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 16 Oct 2015 17:28:26 +0000 (19:28 +0200)
src/java/org/mxchange/addressbook/beans/profile/UserProfileWebBean.java
src/java/org/mxchange/addressbook/beans/profile/UserProfileWebController.java

index f7fd28c77122d1ca98633e71b3789634311fbc32..520ef1709530a4a9950f7a2499f2ee7d6c64dfe0 100644 (file)
@@ -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)));
+       }
 }
index 219a7e9bdfa1eab5d73c9aaeba1428fe0ab53fad..f3cc9d11c18cea2c8d5a3ccec62853686d953db9 100644 (file)
@@ -31,12 +31,19 @@ public interface UserProfileWebController extends Serializable {
         * <p>
         * @return User instance
         */
-       public User getUser ();
+       User getUser ();
 
        /**
         * Setter for user instance
         * <p>
         * @param user User instance
         */
-       public void setUser (final User user);
+       void setUser (final User user);
+
+       /**
+        * Checks if the user profile link is visible
+        * <p>
+        * @return Whether the profile link is visible
+        */
+       boolean isProfileLinkVisible ();
 }