You are here

function user_pathauto_bulkupdate in Pathauto 5

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

File

./pathauto_user.inc, line 120

Code

function user_pathauto_bulkupdate() {
  $query = "SELECT uid,name,src,dst FROM {users} LEFT JOIN {url_alias} ON CONCAT('user/', uid) = src WHERE uid > 0";
  $result = db_query($query);
  $user = db_fetch_object($result);
  $count = 0;
  $placeholders = array();
  while ($user) {
    $placeholders[t('[user]')] = pathauto_cleanstring($user->name);
    $placeholders[t('[uid]')] = $user->uid;
    $src = 'user/' . $user->uid;
    if ($alias = pathauto_create_alias('user', 'bulkupdate', $placeholders, $src)) {
      $count++;
    }
    $user = db_fetch_object($result);
  }
  drupal_set_message(format_plural($count, "Bulk update of users completed, one alias generated.", "Bulk update of users completed, @count aliases generated."));
}