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;
*/
private Long phoneNumber;
- /**
- * A list of all public user profiles
- */
- private List<User> publicUserList;
-
/**
* Street
*/
*/
private Integer zipCode;
+ /**
+ * A list of all public user profiles
+ */
+ private List<User> visibleUserList;
+
+ /**
+ * Login bean (controller)
+ */
+ @Inject
+ private UserLoginWebController loginController;
+
/**
* Default constructor
*/
// 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
}
@Override
- public List<User> allPublicUsers () {
+ public List<User> allVisibleUsers () {
// Return it
- return Collections.unmodifiableList(this.publicUserList);
+ return Collections.unmodifiableList(this.visibleUserList);
}
@Override
// 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
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) &&
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
*/
*/
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
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
* <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 ();
}