liquid_feedback_frontend

diff app/main/member/_action/update.lua @ 1309:32cc544d5a5b

Cumulative patch for upcoming frontend version 4
author bsw/jbe
date Sun Jul 15 14:07:29 2018 +0200 (2018-07-15)
parents 58f48a8a202a
children 757a87af4c83
line diff
     1.1 --- a/app/main/member/_action/update.lua	Thu Jun 23 03:30:57 2016 +0200
     1.2 +++ b/app/main/member/_action/update.lua	Sun Jul 15 14:07:29 2018 +0200
     1.3 @@ -1,28 +1,16 @@
     1.4 -local fields = {
     1.5 -  "organizational_unit",
     1.6 -  "internal_posts",
     1.7 -  "realname",
     1.8 -  "birthday",
     1.9 -  "address",
    1.10 -  "email",
    1.11 -  "xmpp_address",
    1.12 -  "website",
    1.13 -  "phone",
    1.14 -  "mobile_phone",
    1.15 -  "profession",
    1.16 -  "external_memberships",
    1.17 -  "external_posts"
    1.18 -}
    1.19 +local profile = app.session.member.profile
    1.20  
    1.21 -local update_args = { app.session.member }
    1.22 -
    1.23 -for i, field in ipairs(fields) do
    1.24 -  if not util.is_profile_field_locked(app.session.member, field) then
    1.25 -    param.update(app.session.member, field)
    1.26 +for i, field in ipairs(config.member_profile_fields) do
    1.27 +  if not util.is_profile_field_locked(app.session.member, field.id) then
    1.28 +    local value = param.get(field.id)
    1.29 +    if value == "" then 
    1.30 +      value = null
    1.31 +    end
    1.32 +    profile.profile[field.id] = value
    1.33    end
    1.34  end
    1.35  
    1.36 -if not util.is_profile_field_locked(app.session.member, "statement") then
    1.37 +if not util.is_profile_field_locked(profile, "statement") then
    1.38    local formatting_engine = param.get("formatting_engine") or config.enforce_formatting_engine
    1.39  
    1.40    local formatting_engine_valid = false
    1.41 @@ -38,24 +26,37 @@
    1.42  
    1.43    local statement = param.get("statement")
    1.44  
    1.45 -  if statement ~= app.session.member.statement or 
    1.46 -     formatting_engine ~= app.session.member.formatting_engine then
    1.47 -    app.session.member.formatting_engine = formatting_engine
    1.48 -    app.session.member.statement = statement
    1.49 -    app.session.member:render_content(true)
    1.50 +  if statement ~= profile.statement or 
    1.51 +     formatting_engine ~= profile.formatting_engine then
    1.52 +    profile.formatting_engine = formatting_engine
    1.53 +    profile.statement = statement
    1.54 +    profile:render_content(true)
    1.55    end
    1.56  
    1.57  end
    1.58  
    1.59 -if not util.is_profile_field_locked(app.session.member, "birthday") then
    1.60 -  if tostring(app.session.member.birthday) == "invalid_date" then
    1.61 -    app.session.member.birthday = nil
    1.62 +if not util.is_profile_field_locked(profile, "birthday") then
    1.63 +  if tostring(profile.birthday) == "invalid_date" then
    1.64 +    profile.birthday = nil
    1.65      slot.put_into("error", _"Date format is not valid. Please use following format: YYYY-MM-DD")
    1.66      return false
    1.67    end
    1.68  end
    1.69  
    1.70 -app.session.member:save()
    1.71 +local search_strings = {}
    1.72 +for i, field in ipairs(config.member_profile_fields) do
    1.73 +  if field.index and profile.profile[field.id] and #(profile.profile[field.id]) > 0 then
    1.74 +    search_strings[#search_strings+1] = profile.profile[field.id]
    1.75 +  end
    1.76 +end
    1.77 +
    1.78 +if profile.statement and #(profile.statement) > 0 then
    1.79 +  search_strings[#search_strings+1] = profile.statement
    1.80 +end
    1.81 +
    1.82 +profile.profile_text_data = table.concat(search_strings, " ")
    1.83 +
    1.84 +profile:save()
    1.85  
    1.86  
    1.87  slot.put_into("notice", _"Your page has been updated")

Impressum / About Us