In addition to porting buddies from the buddylist module, we should also port users' preferences re: email notifications to ease migration from buddylist.

Comments

sprsquish’s picture

Category: feature » task
gwen’s picture

I wrote a script that can be used to do this. We should add this functionality to the generic migrate module, but if folks can't wait, code follows:

<?php
  /**
   * This script converts users' buddylist mail settings to user relationships
   */

include_once 'includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

$query = "SELECT uid, data FROM {users}";
$result = db_query($query);
while ($object = db_fetch_object($result)) {
  $data = unserialize($user->data);
  if (isset($data['buddylist_mail'])) {
    $data['user_relationship_mailer_send_mail'] = $data['buddylist_mail'];
    unset($data['buddylist_mail']);
  }
  $data = serialize($data);
  $query = "UPDATE {users} SET data = '%s' WHERE uid = %d";
  db_query($query, $data, $object->uid);
}

If you want to run the script, copy code into some file at the docroot level (e.g. ur_buddylist_settings.php) and hit it from a browser.

gwen’s picture

I just noticed an error in code. The object variable that stores user data is $object, not $user. The correct code is:

<?php
  /**
   * This script converts users' buddylist mail settings to user relationships
   */

include_once 'includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

$query = "SELECT uid, data FROM {users}";
$result = db_query($query);
while ($object = db_fetch_object($result)) {
  $data = unserialize($object->data);
  if (isset($data['buddylist_mail'])) {
    $data['user_relationship_mailer_send_mail'] = $data['buddylist_mail'];
    unset($data['buddylist_mail']);
  }
  $data = serialize($data);
  $query = "UPDATE {users} SET data = '%s' WHERE uid = %d";
  db_query($query, $data, $object->uid);
}
prfctns6@gmail.com’s picture

I would recommend putting the serialize and UPDATE statement inside the if block. No point updating user records that haven't changed.

prfctns6@gmail.com’s picture

Status: Active » Fixed

I've integrated gwen's code into the migrate plugin, and have committed the changes.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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