As I'm using Advanced Profile Kit (APK) for user profiles and the intention of APK to move towards Flag Friend integration, I'm interested in the possibilities to migrate an existing buddylist2 installation to Flag Friend.
This would also be an interesting feature to enlarge the installed base of Flag Friend.

Are there any thoughts on this?

Comments

sirkitree’s picture

I haven't used buddylist in a while, but I think that it's db structure is similar in that there is a table that holds the user to user relationship. This could be migrated to the flag_friend table which does the same thing. Flag friend uses the Flag modules table to track who wants to be a friend with another, but requires a reciprocal flagging in order to create the relationship. I think buddylist has an option that you do not need to reciprocate, and I'm not sure how that is accomplished there, so I'm not sure how you would migrate pending relationships exactly.

sirkitree’s picture

Status: Active » Closed (won't fix)

Closing due to inactivity. I'm not likely to write this unless I come across a site migration in the future in which case I'll reopen this and post/integrate the code.

drupalina’s picture

+1 for this feature!
There are a lot of sites out there (like mine) that have been using Buddylist in 5.x because there was no other such module at that time. And over the years they have built communities and relationships using Buddylist. I can imagine that for most of such sites migration to 6.x is a major obstacle because there is no easy data migration from Buddylist to FlagFriend.

And besides, because Buddylist was the only such module, both User Relationships and FriendsList provide a migration sub-module for migrating from buddylist.

Please-please allow for migrating from buddylist

Subscribing...

sirkitree’s picture

I will allow it if someone writes it. However, I do not even support the 5.x branch anymore, but anyone is free to write a migration and post it here.

dgtlmoon’s picture

I really hope this helps someone out there, i just parked this in a drush callback to make my migration life easier, but do whatever pleases you.

this assumes your flag_friend type is id=2;


  $result = db_select('buddylist', 'b')
    ->fields('b', array('uid', 'buddy', 'timestamp', 'received'))
    ->groupBy('uid')
    ->execute();

  foreach ($result as $row) {
    // get all the buddy's that are mutual, these go into friend_flag
    $query = db_query("select :uid as uid, buddy as friend_uid, :timestamp as created from buddylist where uid=:uid and buddy in (select uid from buddylist where buddy=:uid);", array(
      'uid' => $row->uid,
      'timestamp' => $row->timestamp
    ));
    $values = $query->fetchAll(PDO::FETCH_ASSOC);
    $query = db_insert('flag_friend')->fields(array('uid', 'friend_uid', 'created'));
    foreach ($values as $record) {
      $query->values($record);
    }
    $query->execute();


    // get all the buddy's that arent mutual, these go into flag content as a request
    $query = db_query("select :uid as uid, buddy as content_id, :timestamp as timestamp from buddylist where uid=:uid and buddy NOT in (select uid from buddylist where buddy=:uid);", array(
      'uid' => $row->uid,
      'timestamp' => $row->timestamp
    ));
    $values = $query->fetchAll(PDO::FETCH_ASSOC);
    $query = db_insert('flag_content')->fields(array('fid', 'content_type', 'content_id', 'uid', 'timestamp'));
    foreach ($values as $record) {
      $record['fid'] = 2; // @note: You need to set this!
      $record['content_type'] = 'user';
      $query->values($record);
    }
    $query->execute();

  }