bsw/jbe@0: local member = app.session.member bsw/jbe@0: local other_member = Member:by_id(param.get_id()) bsw/jbe@0: bsw/jbe@0: local public = param.get("public", atom.boolean) bsw/jbe@0: bsw/jbe@0: local contact = Contact:by_pk(member.id, other_member.id) bsw/jbe@0: bsw/jbe@0: if public == nil and contact then bsw/jbe@0: slot.put_into("error", _"Member is already saved in your contacts!") bsw/jbe@0: return false bsw/jbe@0: end bsw/jbe@0: bsw/jbe@0: if contact then bsw/jbe@0: contact:destroy() bsw/jbe@0: end bsw/jbe@0: bsw/jbe@0: contact = Contact:new() bsw/jbe@0: contact.member_id = member.id bsw/jbe@0: contact.other_member_id = other_member.id bsw/jbe@0: contact.public = public or false bsw/jbe@0: contact:save() bsw/jbe@0: