You are here

function tracker_pathauto_bulkupdate in Pathauto 5.2

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

Bulk generate aliases for user trackers without aliases.

File

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

Code

function tracker_pathauto_bulkupdate() {

  // We do the double CONCAT because Pgsql8.1 doesn't support more than three arguments to CONCAT
  // Hopefully some day we can remove that.
  $query = "SELECT uid, name, src, dst FROM {users} LEFT JOIN {url_alias} ON CONCAT(CONCAT('user/', CAST(uid AS CHAR)), '/track') = 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 . '/track';
    if (pathauto_create_alias('tracker', 'bulkupdate', $placeholders, $src, $user->uid)) {
      $count++;
    }
  }
  drupal_set_message(format_plural($count, 'Bulk generation of user tracker pages completed, one alias generated.', 'Bulk generation of user tracker pages completed, @count aliases generated.'));
}