You are here

function user_pathauto_bulkupdate in Pathauto 5.2

Same name and namespace in other branches
  1. 5 pathauto_user.inc \user_pathauto_bulkupdate()
  2. 6 pathauto_user.inc \user_pathauto_bulkupdate()

Bulk generate aliases for all users without aliases.

File

./pathauto_user.inc, line 92
Hook implementations for user module integration.

Code

function user_pathauto_bulkupdate() {
  $query = "SELECT uid, name, src, dst FROM {users} LEFT JOIN {url_alias} ON CONCAT('user/', CAST(uid AS CHAR)) = src WHERE uid > 0 AND src IS NULL";
  $result = db_query_range($query, 0, variable_get('pathauto_max_bulk_update', 50));
  $count = 0;
  $placeholders = array();
  while ($user = db_fetch_object($result)) {
    $placeholders = pathauto_get_placeholders('user', $user);
    $src = 'user/' . $user->uid;
    if (pathauto_create_alias('user', 'bulkupdate', $placeholders, $src, $user->uid)) {
      $count++;
    }
  }
  drupal_set_message(format_plural($count, 'Bulk generation of users completed, one alias generated.', 'Bulk generation of users completed, @count aliases generated.'));
}