The easy way to do this would be to edit the user profile view (/app/
profile/show) and put an additional condition near the comments
partial to test if the current_user is also a friend of the user being
displayed.
Something like (i have not tested this btw):
- if current_user and current_user. accepted_friendships.index @user
|| current_user == @user
%h2=:add_your_comment.l
%p= render :partial => 'comments/comment_form', :locals =>
{:commentable => @user}
This would hide the comments form from all but logged in users who are
not your friends. Note: you might need a bit of extra code to test the
friendship from the other direction as well. Also, there is possibly a
method for testing if someone is a current friend of a user, but I
don't know it off the top of my head.
Of course, this wouldn't stop someone from sending the correct params
through your controller action for creating new comments, so you would
probably want to put a similar test in your comment controller create
action as well (along with a test that it is a comment on an user,
rather than a post etc).
You would get extra points if you put a flag on the user that the user
can tick to turn on/off the ability for non-friends to comment on a
users profile.
Cheers.
On Nov 10, 6:48 am, RandFanatic <[email protected]> wrote:
> I don't want everyone to have the ability to comment on my profile -
> you must be my friend first! Also, I would like to limit the "Whats
> Fresh" to view only the activities of my friends. Any ideas on
> implementation would be appreciated.
>
> Thx.
--
You received this message because you are subscribed to the Google Groups
"CommunityEngine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/communityengine?hl=en.