There's a new system for creating buddy lists on your site. It's light weight and dependent upon Flag module. It's called Flag Friend.
While there are already a couple of modules out there that provide a user relationship or buddy list functionality, I was tasked to come up with a bare minimum system that utilized our current setup without adding a lot of overhead. I had already replaced Views Bookmark and Flag Content with Flag module on our platform and there had already been mention of the concept of reciprocity for flags to come up with a way to create an authorized relationship system using Flag module's API, so I dove in.
If you understand Flag module, it's actually quite simple in concept; simply create an entry that says this user "flagged" this piece of content. Currently you can flag nodes, comments and users. With the ability to flag users already in place, the only thing I really had to do was implement a way for users to send a message with the user flag (or friend request), notify a user that they were flagged and by whom, provide a mechanism for approving or denying this relationship, and then either record the relationship or remove the flag (unflag).
Once we got the ability to have "link types" for our flags, we also received the ability to send other data along with our flags. This is accomplished in the Flag Friend module, by first setting the link type to "confirm" which sends our user to a confirmation form when they use our flag. Since we have a confirmation form, we can then use hook_form_alter() to provide our users with a text area for typing in an optional message to send along with this flag/friend request as well as an additional submit handler to save this data to our {flag_friend_message} table.
This is handled by a couple different means. First of all, an email can be sent to the user if they so choose to be notified in this manner. If you have Messaging and Notifications installed in your system, the email will be queued to go out on the next cron run. Otherwise the standard drupal_mail() is run. There is also a persistent drupal_set_message() that is displayed when you have a pending friend request.
Flag friend provides a menu callback to user/N/friends which will show you two things. First, a list of pending friends (if there are any) and second, a list of all of your approved friendships (again, if you have any). Within the Pending list there is a link to Approve the flag/friend request or Deny it. The approval process allows you to send a message back to that user (email only) and then flags that user. The addition submit handler that is form_altered in then checks the status of the friend relationship, and if both users have each other flagged, the relationship is recorded in our {flag_friend} table and the flags are removed from the flag system. If denied, we simply remove the flag (unflag).
I can see the need for a full settings form coming into play, as well as some token implementation and maybe allowing the email template functions to be presented in text areas for users without theming skills to manipulate. But they'll come as the feature request start rolling in, assuming they do. ;) The D6 version will also be coming within the next couple of weeks as we migrate our whole platform to D6. So keep an eye out.
The 6.x version has been released and includes some nifty views integration.
Comments
great write-up! Flag Friend
great write-up!
Flag Friend module as you mentioned is really lightweight compared to other ones out there. Since it's built off of flag module any advancements made there will roll into this module, if not automatically then with minimal changes to the module code. I see good things for this module and flag module. Nice work dude.
Different
This is actually much more advanced than mine, which is two-directional but without approval or notification. Well done! Looking forward to D6 version.
Yay!
I was really hoping that someone would take up the challenge and develop a friend solution based on Flag. One of the features that I think is important is multiple lists or different types of lists. Is this possible with this module?
Let me describe a use case. On a music site, there are artists and members. Members can be fans of artists, but artists cannot be fans of members. However, they can be friends with each other. These are two distinct types of relationship: fan and friend.
Also, get this module into Drupal 6! Stop living in the past - contemporiiiiise, maaan! ;)
PS Where are the name/email/website form element at? :/
Lists
Separate lists can be done by just utilizing flag module itself with user flags. If there is no need for any sort of approval process, then you don't need Flag Friend. If members can be fans of artists, and not the other way 'round, then you would create a user flag for that artist (I'm guessing an artist is a user) and then users can flag the artist, in effect becoming a fan. Then Flag Friend module provides it's flag which needs approval. So something like:
Artist
- Become a fan
-- core user flag named 'fan'
- Add as friend
-- flag_friend user flag named 'friend'
I'm not sure how you would limit the artists from flagging other users, but then I'm unsure of what your entire setup contains.
I just changed commenting to go to approval, hopefully that helps with the random crappy links people keep putting in.
flag friend and drupal 5
I am trying to integrate the simple flag_friend with Drupal 5 and Views 1.x on a production site. My current biggest problem is the display of friends once you have made friends. I created a bookmark tab in my user accounts but cannot recreate that to do the same with users (Views 1.x issue?).
Can I create a simple view to execute code with an argument (the user)? In addition how can I prevent others to view a users friends, so that your friends are private?
Any ideas or suggestions are welcome.
Thanks.
how to add friend???
how to add friend or find friend?????
Please see
Please see http://drupal.org/node/361951