From: Roland Haeder Date: Fri, 16 Oct 2015 20:02:36 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=68bdd9846e34c2e8a9209e86b68cda5339c63b03;p=addressbook-war.git Continued: - added/implemented bean method isProfileLinkVisibleById() - sorted members a bit - added bean property "user" - injected user bean (controller) - used above writes to lookup user id in database and get a user instance back, set in the bean - added/implemented bean method isUserIdEmpty() - added i18n for user profile mode and notices - you can only use converter OR validator - - updated jar(s) --- diff --git a/lib/juser-core.jar b/lib/juser-core.jar index 6c0c84ec..24dbe542 100644 Binary files a/lib/juser-core.jar and b/lib/juser-core.jar differ diff --git a/src/java/org/mxchange/addressbook/beans/profile/UserProfileWebBean.java b/src/java/org/mxchange/addressbook/beans/profile/UserProfileWebBean.java index 6adc75d9..c9e6e3ba 100644 --- a/src/java/org/mxchange/addressbook/beans/profile/UserProfileWebBean.java +++ b/src/java/org/mxchange/addressbook/beans/profile/UserProfileWebBean.java @@ -18,9 +18,12 @@ package org.mxchange.addressbook.beans.profile; import java.text.MessageFormat; import javax.enterprise.context.RequestScoped; +import javax.faces.view.facelets.FaceletException; import javax.inject.Inject; import javax.inject.Named; import org.mxchange.addressbook.beans.login.UserLoginWebController; +import org.mxchange.addressbook.beans.user.UserWebController; +import org.mxchange.jusercore.exceptions.UserNotFoundException; import org.mxchange.jusercore.model.user.User; import org.mxchange.jusercore.model.user.profilemodes.ProfileMode; @@ -44,6 +47,27 @@ public class UserProfileWebBean implements UserProfileWebController { @Inject private UserLoginWebController loginController; + /** + * User instance + */ + private User user; + + /** + * User controller + */ + @Inject + private UserWebController userController; + + @Override + public User getUser () { + return user; + } + + @Override + public void setUser (final User user) { + this.user = user; + } + @Override public boolean isProfileLinkVisible (final User user) { // Check on user @@ -68,4 +92,30 @@ public class UserProfileWebBean implements UserProfileWebController { // TODO: Add admin role somehow? return ((profileMode.equals(ProfileMode.PUBLIC)) || (this.loginController.isUserLoggedIn()) && (profileMode.equals(ProfileMode.MEMBERS))); } + + @Override + public boolean isProfileLinkVisibleById (final Long userId) { + // Init user instance + User u = null; + + try { + // Try to get it + u = this.userController.lookupUserById(userId); + } catch (final UserNotFoundException ex) { + // Throw again + throw new FaceletException(ex); + } + + // Set it here + this.setUser(u); + + // Is it null? + if (null == u) { + // Not found, not visible. + return false; + } + + // Ask other method + return this.isProfileLinkVisible(u); + } } diff --git a/src/java/org/mxchange/addressbook/beans/profile/UserProfileWebController.java b/src/java/org/mxchange/addressbook/beans/profile/UserProfileWebController.java index a9ad631f..f36702e2 100644 --- a/src/java/org/mxchange/addressbook/beans/profile/UserProfileWebController.java +++ b/src/java/org/mxchange/addressbook/beans/profile/UserProfileWebController.java @@ -34,4 +34,27 @@ public interface UserProfileWebController extends Serializable { * @return Whether the profile link is visible */ boolean isProfileLinkVisible (final User user); + + /** + * Checks if the user profile link is visible + *

+ * @param userId User id + *

+ * @return Whether the profile link is visible + */ + boolean isProfileLinkVisibleById (final Long userId); + + /** + * Getter for user instance + *

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

+ * @param user User instance + */ + void setUser (final User user); } diff --git a/src/java/org/mxchange/addressbook/beans/user/UserWebBean.java b/src/java/org/mxchange/addressbook/beans/user/UserWebBean.java index 6d45f7ce..3759a66e 100644 --- a/src/java/org/mxchange/addressbook/beans/user/UserWebBean.java +++ b/src/java/org/mxchange/addressbook/beans/user/UserWebBean.java @@ -830,4 +830,9 @@ public class UserWebBean implements UserWebController { this.setBirthday(user.getUserContact().getContactBirthday()); this.setComment(user.getUserContact().getContactComment()); } + + @Override + public boolean isUserIdEmpty () { + return ((this.getUserId() == null) || (this.getUserId() == 0)); + } } diff --git a/src/java/org/mxchange/addressbook/beans/user/UserWebController.java b/src/java/org/mxchange/addressbook/beans/user/UserWebController.java index dd79d6e0..f9644e2f 100644 --- a/src/java/org/mxchange/addressbook/beans/user/UserWebController.java +++ b/src/java/org/mxchange/addressbook/beans/user/UserWebController.java @@ -463,4 +463,11 @@ public interface UserWebController extends Serializable { * @return Whether at least one user has a public profile */ boolean isVisibleUserFound (); + + /** + * Checks if the user id is empty + *

+ * @return Whether the user id is empty + */ + boolean isUserIdEmpty (); } diff --git a/src/java/org/mxchange/localization/bundle_de_DE.properties b/src/java/org/mxchange/localization/bundle_de_DE.properties index 16e384a7..7498cb97 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -202,7 +202,8 @@ TABLE_HEADER_USER_LIST=Alle Benutzer auflisten TABLE_SUMMARY_USER_LIST=Diese Tabelle listet alle registrierten Benutzer aus, mit denen Sie Ihre Adressb\u00fccher teilen k\u00f6nnen. USER_PROFILE_LEGEND=\u00d6ffentlich einsehbares Profil: USER_PROFILE_LEGEND_TITLE=Machen Sie hier Einstellungen zu Ihrem im Internet \u00f6ffentlich einsehbarem Profil. -PUBLIC_USER_PROFILE_FLAG=Soll Ihr Profil im Internet einsehbar sein? +#TODO: Fix German umlaut! +USER_PROFILE_MODE=Wie soll Ihr Profil veroeffentlicht werden? PUBLIC_USER_PROFILE_NOT_CHOOSEN_MESSAGE=Bitte w\u00e4hlen Sie aus, ob Ihr Profil im Internet sichtbar sein soll. PUBLIC_PROFILE_ENABLED=Ist sichtbar PUBLIC_PROFILE_DISABLED=Ist nicht sichtbar @@ -249,3 +250,14 @@ ADDRESSBOOK_STATUS=Status: PAGE_TITLE_INDEX_SHOW_ADDRESSBOOK=\u00d6ffentlicher Teil des Adressbuchs anzeigen USER_PROFILE_NOT_PUBLICLY_VISIBLE=Das Benutzerprofil ist privat. PAGE_TITLE_LOGIN_USER_PROFILE=Benutzerprofil ansehen +#TODO: Fix German umlaut! +PUBLIC_USER_PROFILE=Oeffentliches Benutzerprofil +USER_PROFILE_MODE_INVISIBLE=Nicht sichtbar +USER_PROFILE_MODE_MEMBERS=Nur von Mitgliedern einsehbar +#TODO: Please fix German umlaut! +USER_PROFILE_MODE_PUBLIC=Fuer alle sichtbar +#TODO: Please fix German umlaut! +USER_PROFILE_MODE_SELECTION_NOTICE1=Stellen Sie auf "Verdeckt", kann niemand mit Ihnen Adressbuecher teilen. +#TODO: Please fix German umlaut! +USER_PROFILE_MODE_SELECTION_NOTICE2=Stellen Sie auf "Nur Mitglieder", koennen andere Mitglieder Ihnen Ihre Adressbuecher freigeben. +USER_PROFILE_MODE_SELECTION_NOTICE3=Stellen Sie auf "Alle", ist Ihr Profil im gesamten Internet sichtbar, auch Bots. diff --git a/src/java/org/mxchange/localization/bundle_en_US.properties b/src/java/org/mxchange/localization/bundle_en_US.properties index 4b7a0fe7..01d2063a 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -202,7 +202,7 @@ TABLE_HEADER_USER_LIST=List all users TABLE_SUMMARY_USER_LIST=This table lists all registered users you can share your address books with. USER_PROFILE_LEGEND=Publicly visible profile: USER_PROFILE_LEGEND_TITLE=Do settings here for your in Internet publicly visible profile. -PUBLIC_USER_PROFILE_FLAG=Should your profile be visible in Internet? +USER_PROFILE_MODE=How should your profile be published? PUBLIC_USER_PROFILE_NOT_CHOOSEN_MESSAGE=Please choose whether your profile should be visible in Internet. PUBLIC_PROFILE_ENABLED=Is visible PUBLIC_PROFILE_DISABLED=Is not visible @@ -249,3 +249,10 @@ ADDRESSBOOK_STATUS=Status: PAGE_TITLE_INDEX_SHOW_ADDRESSBOOK=Show public part of address book USER_PROFILE_NOT_PUBLICLY_VISIBLE=The user profile is private. PAGE_TITLE_LOGIN_USER_PROFILE=View user profile +PUBLIC_USER_PROFILE=Public user profile +USER_PROFILE_MODE_INVISIBLE=Invisible +USER_PROFILE_MODE_MEMBERS=Only visible to members +USER_PROFILE_MODE_PUBLIC=Visible for all +USER_PROFILE_MODE_SELECTION_NOTICE1=If you choose "Invisible", nobody can share address books with you. +USER_PROFILE_MODE_SELECTION_NOTICE2=If you choose "Only members", other users can start sharing address books with you. +USER_PROFILE_MODE_SELECTION_NOTICE3=If you choose "All" the whole Internet can view your profile, including bots. diff --git a/web/WEB-INF/templates/generic/form_personal_data.tpl b/web/WEB-INF/templates/generic/form_personal_data.tpl index 2b714b80..164e4ef3 100644 --- a/web/WEB-INF/templates/generic/form_personal_data.tpl +++ b/web/WEB-INF/templates/generic/form_personal_data.tpl @@ -197,7 +197,7 @@

- +
@@ -206,6 +206,16 @@
+ +
+
+
    +
  • #{msg.USER_PROFILE_MODE_SELECTION_NOTICE1}
  • +
  • #{msg.USER_PROFILE_MODE_SELECTION_NOTICE2}
  • +
  • #{msg.USER_PROFILE_MODE_SELECTION_NOTICE3}
  • +
+
+
diff --git a/web/WEB-INF/templates/generic/profile_mode_selection_box.tpl b/web/WEB-INF/templates/generic/profile_mode_selection_box.tpl index 9779bdb5..112cd241 100644 --- a/web/WEB-INF/templates/generic/profile_mode_selection_box.tpl +++ b/web/WEB-INF/templates/generic/profile_mode_selection_box.tpl @@ -6,7 +6,6 @@ xmlns:ui="http://java.sun.com/jsf/facelets"> - diff --git a/web/user/user_profile.xhtml b/web/user/user_profile.xhtml index 59f8e6a8..6fdf9e8e 100644 --- a/web/user/user_profile.xhtml +++ b/web/user/user_profile.xhtml @@ -10,7 +10,6 @@ - @@ -28,8 +27,14 @@ - - Here goes your content. + +
+ + + #{msg.PUBLIC_USER_PROFILE} + + +