/*
- * Sone - EditProfilePage.java - Copyright © 2010 David Roden
+ * Sone - EditProfilePage.java - Copyright © 2010–2013 David Roden
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Integer birthDay = profile.getBirthDay();
Integer birthMonth = profile.getBirthMonth();
Integer birthYear = profile.getBirthYear();
+ String avatarId = profile.getAvatar();
List<Field> fields = profile.getFields();
if (request.getMethod() == Method.POST) {
if (request.getHttpRequest().getPartAsStringFailsafe("save-profile", 4).equals("true")) {
birthDay = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("birth-day", 256).trim());
birthMonth = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("birth-month", 256).trim());
birthYear = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("birth-year", 256).trim());
+ avatarId = request.getHttpRequest().getPartAsStringFailsafe("avatarId", 36);
profile.setFirstName(firstName.length() > 0 ? firstName : null);
profile.setMiddleName(middleName.length() > 0 ? middleName : null);
profile.setLastName(lastName.length() > 0 ? lastName : null);
profile.setBirthDay(birthDay).setBirthMonth(birthMonth).setBirthYear(birthYear);
+ profile.setAvatar(webInterface.getCore().getImage(avatarId, false));
for (Field field : fields) {
String value = request.getHttpRequest().getPartAsStringFailsafe("field-" + field.getId(), 400);
field.setValue(value);
templateContext.set("birthDay", birthDay);
templateContext.set("birthMonth", birthMonth);
templateContext.set("birthYear", birthYear);
+ templateContext.set("avatarId", avatarId);
templateContext.set("fields", fields);
}
* @return The parsed ID, or {@code null} if there was no part matching the
* given string
*/
- private String getFieldId(FreenetRequest request, String partNameStart) {
+ private static String getFieldId(FreenetRequest request, String partNameStart) {
for (String partName : request.getHttpRequest().getParts()) {
if (partName.startsWith(partNameStart)) {
return partName.substring(partNameStart.length());