I just started learning Drupal - so it's possible that I'm not doing something that I should be doing. With that out of the way...

- I tried sending an invite to a person whose email is already registered with the site
- the invite fails, saying the user is already a member of the site

It seems that the person should be "invited" to be your buddy - regardless of their site status.

Hope this is an actual issue, and thanks for all the great work!
-arnox

Comments

fago’s picture

Project: Buddylist » Invite
Version: 5.x-1.x-dev » 5.x-1.5

buddylist doesn't invite users.

smk-ka’s picture

Priority: Critical » Normal

Mhh... this can't be easily solved, which is why I tend to mark this issue won't fix.

Since you just started learning Drupal, the next bit might sound techy to you, but anyway, here's the reason why:
When an invitation has been accepted (ie. the invited user registers at the site), a notification will be fired. Third party modules can then react on this event:
1) Buddylist catches this event and adds both users to each others list of buddies.
2) Userpoints is another module, which allows to credit an arbitrary number of points per successful invitation.
We can't fire the notification for unsuccessful invitations, as this would cause to break (2) for obvious reasons.

The only thing I can currently think of would be adding a link to buddy/add to the "already registered" message you mentioned. But here I'm unsure whether this change should make it into the repository, since we currently do not have such 3rd party specific code in it. Thoughts, anybody?
--
Stefan Kudwien
www.unleashedmind.com

fago’s picture

what about displaying a message, that says that the user is already member of the site? you could also show a link to its user page by using theme_username..

arnox’s picture

Thanks for explaining the inner plumbings Stephan!

So here is a thought...

Instead of generating an error in invite.module, lines: 482-484, why not send the invite to the user and append the user's email address to the invite link, like:

http://my.site/user/register/555a6c15?'invited.user@email.address'

When the link is submitted to the site, the email in the link is checked for existing account:
- if email address match is found (user exists) - the invite is successful.
- if no match, go to register user form - no code changes required

I'm guessing that this change would be simple enough - if I only knew what I was doing :-)

Thanks,
-arnox

arnox’s picture

upon further research and some codingdebugging, this is where I'm at:

1. it seems to me that the buddylist module can not work properly with the invite module, because:
- fundamentally, inviting somebody to join a website is different from inviting somebody to be your buddy on the same website. The first problem is n->1, where as the second is n->1->n.
- only one invite to email X can be sent at a time - not practical
- person X may not accept invite from person A, but may accept one from person B, ..etc.
- users that are already members of the site are ignored, so there's no way to invite them to be your buddy
- so, it seems that you can't be a buddy to >1 person on the same site - when using the invite module

2. in order for above to work (and in general), the invite module may need some changes
- the invite table should have composite primary key on email and uid, so that different users can invite the same person, at the same time
- the invite link should include the invitee's email and invitor's user id as parameters, so that the invite can be processed efficiently with a minimal amount of queries

I wonder if the invite module could be made more flexible so that it would do its job, and serve depended modules better, or if the buddylist module just needs its own buddyinvite?

Again, I may be wrong about all this, so please let me know if I'm on the right track.

Thanks,
-arnox

smk-ka’s picture

I think we can achieve this without so much changes to the inner workings of invite.

We have to examine two cases:
1. A user has been invited, but not registered yet
2. The user is already a member of the site.

Regarding (1), we could simply allow multiple invitations to one and the same person, as long as he/she hasn't registered yet. When the person registers, only the user the invitation originated from will be processed through the invite API (fe. added to buddylist and/or awarded some points). Other users' invitations can't be taken into account, as this wouldn't make sense. Question: would we need a new option setting here, or would this be a minor change (or even a bug fix as this issue states)?

Now for (2), the user is already a member of the site: what you propose is essentially to not let the invitation fail but connect to buddylist instead, and let buddylist send an "Add to my buddy list" request. As the user is already a member of the site, there must not be fired any invite API events (so no points, for example, because no new registration).
--
Stefan Kudwien
http://www.unleashedmind.com

fago’s picture

I don't think that it's necessary to connect to buddylist. Just link to the users page, there the user can initiate the request on its own..

smk-ka’s picture

Assigned: Unassigned » smk-ka
Status: Active » Needs review
StatusFileSize
new875 bytes

Ok, I have recovered from featuritis, and chose to keep things simple. A link to the user's profile, that's it. Nothing more. Patch even applies to 4.7 branch ^^
--
Stefan Kudwien
www.unleashedmind.com

fago’s picture

Status: Needs review » Needs work

great! however you should use theme('username', $account); for generating the userlink.

smk-ka’s picture

StatusFileSize
new3.35 KB

Thanks for testing.

Agreed, theme_username() is a must-have. However, this resulted in slightly bigger changes, as I've snapped at the chance and properly updated all places that display usernames.

smk-ka’s picture

Status: Needs work » Needs review
StatusFileSize
new3.75 KB

The same, with a slight optimization applied.

smk-ka’s picture

Status: Needs review » Fixed

The patch has been committed to both dev branches with changes due to the new multiple invites option. Thank you all for finding the true solution :)
--
Stefan Kudwien
www.unleashedmind.com

Anonymous’s picture

Status: Fixed » Closed (fixed)