Package net.pterodactylus.sone.data

Examples of net.pterodactylus.sone.data.Profile


   */
  @Override
  protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
    super.processTemplate(request, templateContext);
    Sone currentSone = getCurrentSone(request.getToadletContext());
    Profile profile = currentSone.getProfile();

    /* get parameters from request. */
    String fieldId = request.getHttpRequest().getParam("field");
    Field field = profile.getFieldById(fieldId);
    if (field == null) {
      throw new RedirectException("invalid.html");
    }

    /* process POST request. */
    if (request.getMethod() == Method.POST) {
      if (request.getHttpRequest().getPartAsStringFailsafe("confirm", 4).equals("true")) {
        fieldId = request.getHttpRequest().getParam("field");
        field = profile.getFieldById(fieldId);
        if (field == null) {
          throw new RedirectException("invalid.html");
        }
        profile.removeField(field);
        currentSone.setProfile(profile);
      }
      throw new RedirectException("editProfile.html#profile-fields");
    }

View Full Code Here


  /**
   * {@inheritDoc}
   */
  @Override
  public Object get(TemplateContext templateContext, Object object, String member) {
    Profile profile = (Profile) object;
    if ("avatar".equals(member)) {
      Sone currentSone = (Sone) templateContext.get("currentSone");
      if (currentSone == null) {
        /* not logged in? don’t show custom avatars, then. */
        return null;
      }
      String avatarId = profile.getAvatar();
      if (avatarId == null) {
        return null;
      }
      if (core.getImage(avatarId, false) == null) {
        /* avatar ID but no matching image? show nothing. */
        return null;
      }
      Sone remoteSone = profile.getSone();
      if (remoteSone.isLocal()) {
        /* always show your own avatars. */
        return avatarId;
      }
      ShowCustomAvatars showCustomAvatars = currentSone.getOptions().<ShowCustomAvatars> getEnumOption("ShowCustomAvatars").get();
View Full Code Here

   * @param sone
   *            The Sone to get the nice name for
   * @return The nice name of the Sone
   */
  public static String getNiceName(Sone sone) {
    Profile profile = sone.getProfile();
    String firstName = profile.getFirstName();
    String middleName = profile.getMiddleName();
    String lastName = profile.getLastName();
    if (firstName == null) {
      if (lastName == null) {
        return String.valueOf(sone.getName());
      }
      return lastName;
View Full Code Here

TOP

Related Classes of net.pterodactylus.sone.data.Profile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.