From 68bdd9846e34c2e8a9209e86b68cda5339c63b03 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Fri, 16 Oct 2015 22:02:36 +0200 Subject: [PATCH] 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) --- lib/juser-core.jar | Bin 28830 -> 28891 bytes .../beans/profile/UserProfileWebBean.java | 50 ++++++++++++++++++ .../profile/UserProfileWebController.java | 23 ++++++++ .../addressbook/beans/user/UserWebBean.java | 5 ++ .../beans/user/UserWebController.java | 7 +++ .../localization/bundle_de_DE.properties | 14 ++++- .../localization/bundle_en_US.properties | 9 +++- .../templates/generic/form_personal_data.tpl | 12 ++++- .../generic/profile_mode_selection_box.tpl | 1 - web/user/user_profile.xhtml | 11 ++-- 10 files changed, 125 insertions(+), 7 deletions(-) diff --git a/lib/juser-core.jar b/lib/juser-core.jar index 6c0c84ec3a4aa2d7f6afaf8aa489c846041de01a..24dbe54287ff32e63ba82aa0c4093b43ed0d9e61 100644 GIT binary patch delta 800 zcmZwEUr19?90%~|pUmawX!RaWcewkVJK zJ7cr~TFveT!)zruwEXG&!kR#Yr=Pv*v9ZN21Di27S6^5j2^uFE$i>F34t%s=&12JN z-A~oMmwVo*Ub1sLF@43`tAR^_*SaR`{p4IOG@vCKV0BqJ*%=dC9c^azu|TywTH~27 z;Xv`KNEY&lWTiooOw_?qMsgVw_TN459Fsn~oV@tBwxtEA| z>ZLwa`@fDW2YoL;*Ya}}b~EW#TF+`pwVB&exGd&QsolGn8bn%2`GGDS26Fl&c$^M` zjr1t^nK83+#);R58SiE#0FGv3U@;p3zp@!{Hdg>|b82$tlSsGoWuPypTrQN5eiUXv zt~jmx+i>=^IDwjP@;q3boCJMS7r=ul8E~a2h?V63dRZ$aFwtE$^O`ZXPp~pa+{7$n PT6Uw{qFqTU7e#*nZmkfS delta 1096 zcmZ9LOH30{6o&tq>GZ__ZJ{8vXp0pnh`fAI1SA3?5(!D8lr$wGlsAGdT&U5wbV;rY zA-;l2(uEHwi7{&8LL)K8xM2atAR7{wE_9;{&$*RooMi5I|8wsB@0rQDpEi`+8;a4@ zp_%M}6_`&<8$tC!V*0>cbuKZz>f`ZekVa9Y)G(q-17lWcW~?i943FBxh^cK1zZMjZ z+%&PK+F5R@p;WYy(WiAV9%-$F!u+C-o0*+PyVNu3evS1DM_AIC9h31XcSPm* zyWEJ08SsWo&bdTaoBMrt)|v+J+aO+*1;tIjQ(W+7CZGD|HN6T>REyJrO5SumFv_Nj zC6A@|LfNw9#R?^#)0f-Jb>_p)*Vc6QZdrL#teF8#T<-2V(qw}Pd+ew{r3HBwRN3J` zH4inM*=vQ%ihXvP?q_|#ifm@B6>et8f;tNhCi5e2)r@UykY}JC4GQYSx7xZ)1KZJP zpb&=)bC`Nu8M-SaGtDnaYl}z=_m~!u9`4Z>kr_@xS)daX6o}8U zJWr~eGVGS8mjAs9)B(=kC9^u85N`)UbSH!wmtEcx=PnZG2jLMNA#>~hV!#pb0f=djdw!ef?`%EyuP(=gzxS|sGvzQ}8sPA6G20ca 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} + + +
-- 2.39.5