It would be awesome if there could be some integration between Flag Friend and Privatemsg.
More specifically, the option to limit privatemsg messages to only between users that are Friends.
Is it a possibility with Flag Friend module? I will be first on the list to help with extensive testing.

Thank you very much in advance!

Comments

sirkitree’s picture

I'm not likely to work on this myself, but would happily review any patches.

sirkitree’s picture

Status: Active » Closed (fixed)

closing due to inactivity - if a patch is provided, please reopen and I will review.

crea’s picture

Subscribing.

crea’s picture

Version: 6.x-1.x-dev » 6.x-2.x-dev

Moving to 2.x

crea’s picture

Assigned: Unassigned » crea
Status: Closed (fixed) » Active

I plan to add this eventually so let's open it.

BenK’s picture

Subscribing...

Donaldd’s picture

I also believe this would be great improvement for the flag friend module. So i tried to build this module with documentation Berdir provided however my skills are almost Null so the solution I came up with didn't work. With the following I still get every user of the site in the autocomplete field and I'm not able to send them a message, even my friends that I've selected with Flag friends are blocked. I used the following code in a module.


function mymodule_privatemsg_sql_autocomplete_alter(&$fragments, $search, $names) {
    global $user;
        // Extend the query that searches for usernames

          // $fragments is explained in the api documentation in detail

          // The query is already set up, it's searching for usernames which start with $search and are not $names (may be empty)
          // the main table is {user} a

          // for example, add a join on a table where the user connections are stored
          // and specify that only users connected with the current user should be loaded
         $fragments['inner_join'][] = 'INNER JOIN {flag_friend} f ON ((f.friend_uid = u.uid AND f.uid = %d) OR (f.uid = u.uid AND f.friend_uid = %d ))';
		          $fragments['query_args']['join'][] = $user->uid;
		          $fragments['query_args']['join'][] = $user->uid;
		        }

// This blocks messages between users, who are not related, it uses universal_relation_api so in theory should work with User Relationships and FriendsList modules, tested with User Relationships.

function mymodule_privatemsg_block_message($author, $recipients) {
  $blocked = array();
  foreach ($recipients as $recipient) {
    if (!module_invoke_all('socnet_is_related', $author->uid, $recipient->uid)) {
      $blocked[] = array(
        'uid' => $recipient->uid,
        'message' => t('!name is not a friend of yours.', array('!name' => $recipient->name))
      );
    }
  }
  return $blocked;
}

According to Berdir (maintainer of Privatemsg) it might have something to do with the fact that privatemsg_autocomplete_alter() isn't called and that socnet_is_related information isn't returned by flag friend. Does Flag friend implement these hooks?

Many thanks,
Donald

joecanti’s picture

subscribing

Definitely a good feature for the future,

Joe

sirkitree’s picture

Status: Active » Closed (won't fix)

This won't be implemented in 6.x-1.x or 6.x-2.x but is someone wants to write something for 7.x-1.x where future development efforts will be, please provide a patch and reopen.

YK85’s picture

Status: Closed (won't fix) » Active

Could this please remain active for hope of someone to contribute this integration?
Flag Friend is nice, but without privatemsg integration it loses a big aspect of many social networking style sites.
Thanks for the great work on Flag Friend!

sirkitree’s picture

Status: Active » Closed (won't fix)

Closing due to inactivity. Reopen if you have some code.

plessas’s picture

An approach for D7 is presented in http://drupal.org/node/778396#comment-6766412