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;
@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
// 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);
+ }
}
* @return Whether the profile link is visible
*/
boolean isProfileLinkVisible (final User user);
+
+ /**
+ * Checks if the user profile link is visible
+ * <p>
+ * @param userId User id
+ * <p>
+ * @return Whether the profile link is visible
+ */
+ boolean isProfileLinkVisibleById (final Long userId);
+
+ /**
+ * Getter for user instance
+ * <p>
+ * @return User instance
+ */
+ User getUser ();
+
+ /**
+ * Setter for user instance
+ * <p>
+ * @param user User instance
+ */
+ void setUser (final User user);
}
this.setBirthday(user.getUserContact().getContactBirthday());
this.setComment(user.getUserContact().getContactComment());
}
+
+ @Override
+ public boolean isUserIdEmpty () {
+ return ((this.getUserId() == null) || (this.getUserId() == 0));
+ }
}
* @return Whether at least one user has a public profile
*/
boolean isVisibleUserFound ();
+
+ /**
+ * Checks if the user id is empty
+ * <p>
+ * @return Whether the user id is empty
+ */
+ boolean isUserIdEmpty ();
}
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
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.
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
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.
<div class="table_row">
<div class="table_left">
- <h:outputLabel for="publicUserProfileFlag" value="#{msg.PUBLIC_USER_PROFILE_FLAG}" />
+ <h:outputLabel for="publicUserProfileFlag" value="#{msg.USER_PROFILE_MODE}" />
</div>
<div class="table_right">
<div class="clear"></div>
</div>
+
+ <div class="table_row">
+ <div class="para notice">
+ <ul>
+ <li>#{msg.USER_PROFILE_MODE_SELECTION_NOTICE1}</li>
+ <li>#{msg.USER_PROFILE_MODE_SELECTION_NOTICE2}</li>
+ <li>#{msg.USER_PROFILE_MODE_SELECTION_NOTICE3}</li>
+ </ul>
+ </div>
+ </div>
</fieldset>
</div>
</ui:composition>
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:selectOneMenu class="select" id="profileMode" value="#{userController.userProfileMode}">
- <f:selectItem itemValue="" itemLabel="#{msg.NONE_SELECTED}" />
<f:selectItems value="#{profileMode.allProfileModes}" var="m" itemValue="#{m}" itemLabel="#{msg[m.messageKey]}" />
</h:selectOneMenu>
</ui:composition>
<f:viewParam id="userId" name="userId" value="#{userController.userId}" required="true" requiredMessage="#{msg.PARAMETER_USER_ID_MISSING}" converterMessage="#{msg.PARAMETER_USER_ID_INVALID}" validatorMessage="#{msg.PARAMETER_USER_ID_NOT_FOUND}">
<f:convertNumber for="userId" type="number" minIntegerDigits="1" maxIntegerDigits="20" />
<f:validator for="userId" validatorId="UserIdValidator" />
- <f:converter for="userId" converterId="UserConverter" />
</f:viewParam>
</f:metadata>
<ui:include src="/WEB-INF/templates/generic/userid_error.tpl" />
</c:when>
- <c:when test="#{profileController.isProfileLinkVisible(userController.user)}">
- Here goes your content.
+ <c:when test="#{profileController.isProfileLinkVisibleById(userController.userId)}">
+ <div align="center">
+ <h:panelGrid styleClass="table" headerClass="table_header" footerClass="table_footer">
+ <f:facet name="header">
+ #{msg.PUBLIC_USER_PROFILE}
+ </f:facet>
+ </h:panelGrid>
+ </div>
</c:when>
<c:otherwise>