Exemple #1
0
  /**
   * Save profile the profile a {@link User}.
   *
   * @param name the name of the {@link User}.
   * @param email the email of the {@link User}.
   * @param fullname the fullname of the {@link User}.
   * @param birthday the birthday of the {@link User}.
   * @param website the website of the {@link User}.
   * @param profession the profession of the{@link User}.
   * @param employer the employer of the{@link User}.
   * @param biography the biography of the {@link User}.
   * @param oldPassword the old password of the {@link User}.
   * @param newPassword the new password of the {@link User}.
   * @throws ParseException
   */
  public static void saveProfile(
      String name,
      String email,
      String fullname,
      String birthday,
      String website,
      String profession,
      String employer,
      String biography,
      String oldPassword,
      String newPassword)
      throws ParseException {
    User user = Database.users().get(name);
    if (!userCanEditProfile(user)) {
      flash.error("secure.editprofileerror");
      Application.showprofile(user.getName());
    }
    if (email != null) {
      user.setEmail(email);
    }
    if (fullname != null) {
      user.setFullname(fullname);
    }
    if (birthday != null) {
      user.setDateOfBirth(birthday);
    }
    if (website != null) {
      user.setWebsite(website);
    }
    if (profession != null) {
      user.setProfession(profession);
    }
    if (employer != null) {
      user.setEmployer(employer);
    }
    if (biography != null) {
      user.setBiography(biography);
    }
    if (!newPassword.isEmpty()) {
      if (user.checkPW(oldPassword)) {
        user.setSHA1Password(newPassword);
      } else if (!user.checkPW(oldPassword)) {
        flash.error("secure.passwordChangeError");
      }
    }
    if (!oldPassword.isEmpty() && newPassword.isEmpty()) {
      flash.error("secure.passwordNewFieldEmptyError");
    }

    flash.success("secure.editprofileflash");
    Application.showprofile(user.getName());
  }
Exemple #2
0
 /**
  * Unblock a {@link User}.
  *
  * @param username the username of the {@link User} to be unblocked.
  */
 public static void unblockUser(String username) {
   User user = Database.users().get(username);
   User mod = Session.user();
   if (mod.isModerator() && mod != user) {
     user.unblock();
     flash.success("secure.unlockuserflash");
   }
   Application.showprofile(user.getName());
 }
Exemple #3
0
 /**
  * Block a {@link User}.
  *
  * @param username the username of the {@link User} to be unblocked.
  * @param reason the reason the {@link User} is being blocked.
  */
 public static void blockUser(String username, String reason) {
   User user = Database.users().get(username);
   User mod = Session.user();
   if (mod.isModerator() && mod != user) {
     if (reason.equals("")) {
       reason = "secure.blockreasonerror";
     }
     user.block(reason);
     flash.success("secure.blockuserflash");
   }
   Application.showprofile(user.getName());
 }