liquid_feedback_frontend
diff app/main/contact/_action/add_member.lua @ 0:3bfb2fcf7ab9
Version alpha1
| author | bsw/jbe |
|---|---|
| date | Wed Nov 18 12:00:00 2009 +0100 (2009-11-18) |
| parents | |
| children | 768faea1096d |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/app/main/contact/_action/add_member.lua Wed Nov 18 12:00:00 2009 +0100 1.3 @@ -0,0 +1,27 @@ 1.4 +local member = app.session.member 1.5 +local other_member = Member:by_id(param.get_id()) 1.6 + 1.7 +local public = param.get("public", atom.boolean) 1.8 + 1.9 +local contact = Contact:by_pk(member.id, other_member.id) 1.10 + 1.11 +if public == nil and contact then 1.12 + slot.put_into("error", _"Member is already saved in your contacts!") 1.13 + return false 1.14 +end 1.15 + 1.16 +if contact then 1.17 + contact:destroy() 1.18 +end 1.19 + 1.20 +contact = Contact:new() 1.21 +contact.member_id = member.id 1.22 +contact.other_member_id = other_member.id 1.23 +contact.public = public or false 1.24 +contact:save() 1.25 + 1.26 +if public then 1.27 + slot.put_into("notice", _"Member has been saved as public contact") 1.28 +else 1.29 + slot.put_into("notice", _"Member has been saved as private contact") 1.30 +end