annotate app/main/member/_action/update.lua @ 1045:701a5cf6b067
Imported LiquidFeedback Frontend 3.0 branch
author |
bsw |
date |
Thu Jul 10 01:19:48 2014 +0200 (2014-07-10) |
parents |
6ef34f6a128e |
children |
58f48a8a202a |
rev |
line source |
bsw@286
|
1 local fields = {
|
bsw@2
|
2 "organizational_unit",
|
bsw@2
|
3 "internal_posts",
|
bsw@2
|
4 "realname",
|
bsw@2
|
5 "birthday",
|
bsw@2
|
6 "address",
|
bsw@2
|
7 "email",
|
bsw@2
|
8 "xmpp_address",
|
bsw@2
|
9 "website",
|
bsw@2
|
10 "phone",
|
bsw@2
|
11 "mobile_phone",
|
bsw@2
|
12 "profession",
|
bsw@2
|
13 "external_memberships",
|
bsw@397
|
14 "external_posts"
|
bsw@286
|
15 }
|
bsw@286
|
16
|
bsw@286
|
17 local update_args = { app.session.member }
|
bsw/jbe@0
|
18
|
bsw@286
|
19 for i, field in ipairs(fields) do
|
bsw@286
|
20 if not config.locked_profile_fields[field] then
|
bsw@286
|
21 param.update(app.session.member, field)
|
bsw@286
|
22 end
|
bsw@286
|
23 end
|
bsw@286
|
24
|
bsw@397
|
25 if not config.locked_profile_fields.statement then
|
bsw@1045
|
26 local formatting_engine = param.get("formatting_engine") or config.enforce_formatting_engine
|
bsw@931
|
27
|
bsw@931
|
28 local formatting_engine_valid = false
|
bsw@1045
|
29 for i, fe in pairs(config.formatting_engines) do
|
bsw@1045
|
30 if formatting_engine == fe.id then
|
bsw@931
|
31 formatting_engine_valid = true
|
bsw@931
|
32 end
|
bsw@931
|
33 end
|
bsw@931
|
34 if not formatting_engine_valid then
|
bsw@931
|
35 error("invalid formatting engine!")
|
bsw@931
|
36 end
|
bsw@931
|
37
|
bsw@931
|
38
|
bsw@397
|
39 local statement = param.get("statement")
|
bsw@931
|
40
|
bsw@931
|
41 if statement ~= app.session.member.statement or
|
bsw@931
|
42 formatting_engine ~= app.session.member.formatting_engine then
|
bsw@931
|
43 app.session.member.formatting_engine = formatting_engine
|
bsw@397
|
44 app.session.member.statement = statement
|
bsw@397
|
45 app.session.member:render_content(true)
|
bsw@397
|
46 end
|
bsw@931
|
47
|
bsw@397
|
48 end
|
bsw@397
|
49
|
bsw@286
|
50 if not config.locked_profile_fields.birthday then
|
bsw@286
|
51 if tostring(app.session.member.birthday) == "invalid_date" then
|
bsw@286
|
52 app.session.member.birthday = nil
|
bsw@286
|
53 slot.put_into("error", _"Date format is not valid. Please use following format: YYYY-MM-DD")
|
bsw@286
|
54 return false
|
bsw@286
|
55 end
|
bsw@75
|
56 end
|
bsw@75
|
57
|
bsw/jbe@0
|
58 app.session.member:save()
|
bsw/jbe@0
|
59
|
bsw/jbe@0
|
60
|
bsw@931
|
61 slot.put_into("notice", _"Your page has been updated")
|