diff --git a/src/main/java/smithereen/routes/SettingsRoutes.java b/src/main/java/smithereen/routes/SettingsRoutes.java index cf6d35e4..f85f33c4 100644 --- a/src/main/java/smithereen/routes/SettingsRoutes.java +++ b/src/main/java/smithereen/routes/SettingsRoutes.java @@ -109,6 +109,11 @@ public static Object updateProfileGeneral(Request req, Response resp, Account se String last=req.queryParams("last_name"); String middle=req.queryParams("middle_name"); String maiden=req.queryParams("maiden_name"); + String about=req.queryParams("about"); + if(StringUtils.isNotEmpty(about)) + about=preprocessPostHTML(about, null); + else + about=null; int _gender=parseIntOrDefault(req.queryParams("gender"), 0); if(_gender<0 || _gender>2) _gender=0; @@ -130,7 +135,7 @@ public static Object updateProfileGeneral(Request req, Response resp, Account se if(first.length()<2){ message=Utils.lang(req).get("err_name_too_short"); }else{ - UserStorage.changeBasicInfo(self.user, first, last, middle, maiden, gender, bdate); + UserStorage.changeBasicInfo(self.user, first, last, middle, maiden, gender, bdate, about); message=Utils.lang(req).get("profile_info_updated"); } self.user=UserStorage.getById(self.user.id); diff --git a/src/main/java/smithereen/storage/UserStorage.java b/src/main/java/smithereen/storage/UserStorage.java index 7926173d..424fcc5a 100644 --- a/src/main/java/smithereen/storage/UserStorage.java +++ b/src/main/java/smithereen/storage/UserStorage.java @@ -446,17 +446,20 @@ public static void putInvite(int userID, byte[] code, int signups) throws SQLExc stmt.execute(); } - public static void changeBasicInfo(User user, String firstName, String lastName, String middleName, String maidenName, User.Gender gender, java.sql.Date bdate) throws SQLException{ + public static void changeBasicInfo(User user, String firstName, String lastName, String middleName, String maidenName, User.Gender gender, java.sql.Date bdate, String about) throws SQLException{ Connection conn=DatabaseConnectionManager.getConnection(); - PreparedStatement stmt=conn.prepareStatement("UPDATE `users` SET `fname`=?, `lname`=?, `gender`=?, `bdate`=?, middle_name=?, maiden_name=? WHERE `id`=?"); - stmt.setString(1, firstName); - stmt.setString(2, lastName); - stmt.setInt(3, gender.ordinal()); - stmt.setDate(4, bdate); - stmt.setString(5, middleName); - stmt.setString(6, maidenName); - stmt.setInt(7, user.id); - stmt.execute(); + new SQLQueryBuilder() + .update("users") + .where("id=?", user.id) + .value("fname", firstName) + .value("lname", lastName) + .value("gender", gender) + .value("bdate", bdate) + .value("middle_name", middleName) + .value("maiden_name", maidenName) + .value("about", about) + .createStatement() + .execute(); synchronized(UserStorage.class){ removeFromCache(user); } diff --git a/src/main/resources/templates/common/profile_edit_general.twig b/src/main/resources/templates/common/profile_edit_general.twig index 7b9bdf22..83bd0dd9 100644 --- a/src/main/resources/templates/common/profile_edit_general.twig +++ b/src/main/resources/templates/common/profile_edit_general.twig @@ -14,6 +14,7 @@ {'value': 2, 'label': L('gender_female'), 'selected': currentUser.gender=='FEMALE'} ]) }} {{ form.textInput('bdate', L('birth_date'), currentUser.birthDate, {'type': 'date', 'max': todayDate}) }} + {{ form.textArea('about', L('profile_about'), currentUser.summary) }} {{ form.footer(L('save')) }} {{ form.end() }}