From: Roland Haeder <roland@mxchange.org>
Date: Fri, 16 Oct 2015 17:12:21 +0000 (+0200)
Subject: Continued:
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=016479b464899f3bfd00e264a5f335c7eb1f342a;p=jfinancials-war.git

Continued:
- sorted members
- now that there are member-visible users the public user list doesn't fit to naming convention -> renamed
- injected login controller for checking if the user is logged-in
- for this the new business method allMemberPublicVisibleUsers() is called
- updated jar(s)
---

diff --git a/lib/juser-core.jar b/lib/juser-core.jar
index ff5b3c74..703a0b80 100644
Binary files a/lib/juser-core.jar and b/lib/juser-core.jar differ
diff --git a/lib/juser-lib.jar b/lib/juser-lib.jar
index d4090c07..b7bd137e 100644
Binary files a/lib/juser-lib.jar and b/lib/juser-lib.jar differ
diff --git a/src/java/org/mxchange/addressbook/beans/user/UserWebBean.java b/src/java/org/mxchange/addressbook/beans/user/UserWebBean.java
index 97cdd0a0..4aa9d47d 100644
--- a/src/java/org/mxchange/addressbook/beans/user/UserWebBean.java
+++ b/src/java/org/mxchange/addressbook/beans/user/UserWebBean.java
@@ -26,10 +26,12 @@ import javax.annotation.PostConstruct;
 import javax.enterprise.context.SessionScoped;
 import javax.enterprise.event.Observes;
 import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
 import javax.inject.Named;
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
+import org.mxchange.addressbook.beans.login.UserLoginWebController;
 import org.mxchange.jcontacts.contact.Contact;
 import org.mxchange.jcontacts.contact.UserContact;
 import org.mxchange.jcontacts.contact.gender.Gender;
@@ -157,11 +159,6 @@ public class UserWebBean implements UserWebController {
 	 */
 	private Long phoneNumber;
 
-	/**
-	 * A list of all public user profiles
-	 */
-	private List<User> publicUserList;
-
 	/**
 	 * Street
 	 */
@@ -207,6 +204,17 @@ public class UserWebBean implements UserWebController {
 	 */
 	private Integer zipCode;
 
+	/**
+	 * A list of all public user profiles
+	 */
+	private List<User> visibleUserList;
+
+	/**
+	 * Login bean (controller)
+	 */
+	@Inject
+	private UserLoginWebController loginController;
+
 	/**
 	 * Default constructor
 	 */
@@ -268,7 +276,7 @@ public class UserWebBean implements UserWebController {
 		// Is the account public?
 		if (registeredUser.getUserProfileMode().equals(ProfileMode.PUBLIC)) {
 			// Also add it to this list
-			this.publicUserList.add(registeredUser);
+			this.visibleUserList.add(registeredUser);
 		}
 
 		// Trace message
@@ -276,9 +284,9 @@ public class UserWebBean implements UserWebController {
 	}
 
 	@Override
-	public List<User> allPublicUsers () {
+	public List<User> allVisibleUsers () {
 		// Return it
-		return Collections.unmodifiableList(this.publicUserList);
+		return Collections.unmodifiableList(this.visibleUserList);
 	}
 
 	@Override
@@ -640,8 +648,14 @@ public class UserWebBean implements UserWebController {
 		// Get full email address list for reducing EJB calls
 		this.emailAddressList = this.userBean.getEmailAddressList();
 
-		// Initialize user list
-		this.publicUserList = this.userBean.allPublicUsers();
+		// Is the user logged-in?
+		if (this.loginController.isUserLoggedIn()) {
+			// Is logged-in, so load also users visible to memebers
+			this.visibleUserList = this.userBean.allMemberPublicVisibleUsers();
+		} else {
+			// Initialize user list
+			this.visibleUserList = this.userBean.allPublicUsers();
+		}
 	}
 
 	@Override
@@ -649,11 +663,6 @@ public class UserWebBean implements UserWebController {
 		return ((this.emailAddressList instanceof List) && (this.emailAddressList.contains(user.getUserContact().getContactEmailAddress())));
 	}
 
-	@Override
-	public boolean isPublicUserRegistered () {
-		return ((this.publicUserList instanceof List) && (this.publicUserList.size() > 0));
-	}
-
 	@Override
 	public boolean isRequiredPersonalDataSet () {
 		return ((this.getUserName() != null) &&
@@ -686,10 +695,14 @@ public class UserWebBean implements UserWebController {
 		return ((this.userNameList instanceof List) && (this.userNameList.contains(user.getUserName())));
 	}
 
+	@Override
+	public boolean isVisibleUserFound () {
+		return ((this.visibleUserList instanceof List) && (this.visibleUserList.size() > 0));
+	}
+
 	/**
 	 * Adds user's name and email address to bean's internal list. It also
-	 * updates the public user list if the user has decided to have a public
-	 * profile on registration.
+	 * updates the public user list if the user has decided to ha	}
 	 * <p>
 	 * @param user User instance
 	 */
diff --git a/src/java/org/mxchange/addressbook/beans/user/UserWebController.java b/src/java/org/mxchange/addressbook/beans/user/UserWebController.java
index a0bf8d59..9a71ae45 100644
--- a/src/java/org/mxchange/addressbook/beans/user/UserWebController.java
+++ b/src/java/org/mxchange/addressbook/beans/user/UserWebController.java
@@ -33,12 +33,19 @@ import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
  */
 public interface UserWebController extends Serializable {
 
+	/**
+	 * Event observer for new user registrations
+	 * <p>
+	 * @param event User registration event
+	 */
+	void afterRegistrationEvent (final UserRegisteredEvent event);
+
 	/**
 	 * All public user profiles
 	 * <p>
 	 * @return A list of all public user profiles
 	 */
-	List<User> allPublicUsers ();
+	List<User> allVisibleUsers ();
 
 	/**
 	 * Creates an instance from all properties
@@ -370,32 +377,32 @@ public interface UserWebController extends Serializable {
 	void setUserPasswordRepeat (final String userPasswordRepeat);
 
 	/**
-	 * ZIP code
+	 * Getter for user profile mode
 	 * <p>
-	 * @return the zipCode
+	 * @return User profile mode
 	 */
-	Integer getZipCode ();
+	ProfileMode getUserProfileMode ();
 
 	/**
-	 * ZIP code
+	 * Setter for user profile mode
 	 * <p>
-	 * @param zipCode the zipCode to set
+	 * @param userProfileMode User profile mode
 	 */
-	void setZipCode (final Integer zipCode);
+	void setUserProfileMode (final ProfileMode userProfileMode);
 
 	/**
-	 * Getter for user profile mode
+	 * ZIP code
 	 * <p>
-	 * @return User profile mode
+	 * @return the zipCode
 	 */
-	ProfileMode getUserProfileMode ();
+	Integer getZipCode ();
 
 	/**
-	 * Setter for user profile mode
+	 * ZIP code
 	 * <p>
-	 * @param userProfileMode User profile mode
+	 * @param zipCode the zipCode to set
 	 */
-	void setUserProfileMode (final ProfileMode userProfileMode);
+	void setZipCode (final Integer zipCode);
 
 	/**
 	 * Checks whether user instance's email address is used
@@ -442,12 +449,5 @@ public interface UserWebController extends Serializable {
 	 * <p>
 	 * @return Whether at least one user has a public profile
 	 */
-	boolean isPublicUserRegistered ();
-
-	/**
-	 * Event observer for new user registrations
-	 * <p>
-	 * @param event User registration event
-	 */
-	void afterRegistrationEvent (final UserRegisteredEvent event);
+	boolean isVisibleUserFound ();
 }
diff --git a/web/user/user_list.xhtml b/web/user/user_list.xhtml
index 9b32294a..286620b9 100644
--- a/web/user/user_list.xhtml
+++ b/web/user/user_list.xhtml
@@ -19,7 +19,7 @@
 					#{msg.TABLE_HEADER_USER_LIST}
 				</div>
 
-				<h:dataTable id="userList" var="user" value="#{userController.allPublicUsers()}" headerClass="table_header_column25" summary="#{msg.TABLE_SUMMARY_USER_LIST}" rendered="#{userController.isPublicUserRegistered()}">
+				<h:dataTable id="userList" var="user" value="#{userController.allVisibleUsers()}" headerClass="table_header_column25" summary="#{msg.TABLE_SUMMARY_USER_LIST}" rendered="#{userController.isVisibleUserFound()}">
 					<h:column>
 						<f:facet name="header">#{msg.USER_ID}</f:facet>
 						<ui:include id="userProfileLink" src="/WEB-INF/templates/generic/user_profile_link.tpl">