I am looking for a way to allow privatemsg only between friends/fans.

Asked about that in Privatemsg issue list - won't fix (http://drupal.org/node/422510). They say: "Privatemsg provides the hooks and api functions which allow that but we can't provide integration with every friendlist/relationship module out there."

So is it possible for UR to come up with this feature?

Comments

henrijs.seso’s picture

StatusFileSize
new1.62 KB

Yes, its possible, i did some digging and here are my take one on this issue. This module will block messages to users who has no relationships with sender. It uses universal_relation_api.

Todo:
1) autocomplete field in message forms should be populated with friends only
2) send message to user link in profiles must not display for users with no relations

Known issues:
1) it displays Failed to send to ID 0 in user profiles, must add some line to check if uid = 0 and stop the script

If anyone cares, please take a look at code and see if things could be done better way, i am beginner and could use some advice.

henrijs.seso’s picture

Status: Active » Needs review
henrijs.seso’s picture

StatusFileSize
new1.45 KB

New, proper code, thanks to Berdir (http://drupal.org/node/371034).

No more known issues, just works. Will try to fix autocomplete.

henrijs.seso’s picture

StatusFileSize
new2.06 KB

One more change in code...

henrijs.seso’s picture

StatusFileSize
new1.41 KB

Updated with working autocomplete field.

Now this module does 2 things

1) blocks messages to users that has no relationships with sender and
2) feeds list of usernames with relationships to sender into new privatemsg To: autocomplete field.

Please test if you need something like this.

alex.k’s picture

Works great, thank you. One question: should privatemsg be allowed in both directions when relationship is one-way? Currently, if A is a fan of B, that gives A the right to write to B, but B cannot reply back to A.

Two possibilities:
* allow privatemsg in both directions even if relationship is one-way
* allow replies only from requestee back to requester (this would be really cool, but I don't know privatemsg enough to see if it's easy to do)

Other than that, great code.

SuleymanK’s picture

i need this module for 5.x

do you have time to backport this module?

alex.k’s picture

Committed code in #5, see http://drupal.org/cvs?commit=228152. Moved it into an include file in UR-API module, and also merged with a patch from #257748: Allow users to only accept PMs from people on their buddylist providing a checkbox in the user profile that allows users to choose if they want to restrict PMs to just relationships or allow everyone. The question in #6 remains open, if anyone wants to work on it. Thanks again @mansspams

alex.k’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

alex.k’s picture

alex.k’s picture

A ticket that requests a switch to turn the autocomplete portion on/off is #522078: privatemsg autocomplete works only for relationships

kvvnn’s picture

What do you think about adding an admin-side switch like this :

1) Let users decide to allow PM's for only friends or for all users (current)
2) Allow all users to PM each other (previous)
3) Allow the following relationship types to PM each other : (i guess a previous bug)
list of Relationships Types

vinoth.3v’s picture

Status: Closed (fixed) » Needs work

+1 for this request and Thanks for the fix. This switch greatly reduces the spam pms.

Now,

1, lets see one situation.

for any community site, there will be admin, moderators, etc. They must have a chance to send private messages regarding site ploicy, terms etc to others regardless of the User relationships they have.

for example, admin could send message to any user and they have to reply to. In that case we can't check user relationships.

ok, My idea is to have a permission 'send privatemsg to any'. so that, based on the roles we can set this permission.

2, what you think about 'receive privatemsg from any' ?

3, Admin have the default option to set is "allow to all, but users can change"
is any option to set default to "only confirmed relations" and lets users to change?

4, I think for admin:
option to set default method : "only to relations" / "to any users"
for users:
option to enable/disable
a new permission:
"allow override pm settings" (or some other best suitable term)

what you think?

alex.k’s picture

@4vinoth

Those would be nice features, for sure. The problem is, I don't use privatemsg and don't have the time to put towards that direction :( If somebody wants to co-own development of UR-Privatemsg integration that would surely be great.

alex.k’s picture

Status: Needs work » Fixed

A bugfix for #597112: Private Message autocomplete to multiple friends not working rewrote the way the autocomplete query is constructed, so testing that it still works for everyone would be appreciated. Please post any feedback in that issue.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.