You are here

function blog_pathauto_bulkupdate in Pathauto 5

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

File

./pathauto_user.inc, line 143

Code

function blog_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 = 'blog/' . $user->uid;
    if ($alias = pathauto_create_alias('blog', 'bulkupdate', $placeholders, $src)) {
      $count++;
    }
    $user = db_fetch_object($result);
  }
  drupal_set_message(format_plural($count, "Bulk update of user blogs completed, one alias generated.", "Bulk update of user blogs completed, @count aliases generated."));
}