function user_pathauto_bulkupdate in Pathauto 6
Same name and namespace in other branches
- 5.2 pathauto_user.inc \user_pathauto_bulkupdate()
- 5 pathauto_user.inc \user_pathauto_bulkupdate()
Bulk generate aliases for all users without aliases.
File
- ./
pathauto_user.inc, line 115 - Hook implementations for user module integration.
Code
function user_pathauto_bulkupdate() {
$concat = _pathauto_sql_concat("'user/'", 'u.uid');
$sql = "SELECT u.uid FROM {users} u LEFT JOIN {url_alias} ua ON {$concat} = ua.src WHERE u.uid > 0 AND ua.src IS NULL";
$query = db_query_range($sql, 0, variable_get('pathauto_max_bulk_update', 50));
$count = 0;
$placeholders = array();
while ($uid = db_result($query)) {
$account = user_load($uid);
$placeholders = pathauto_get_placeholders('user', $account);
$source = 'user/' . $account->uid;
if (pathauto_create_alias('user', 'bulkupdate', $placeholders, $source, $account->uid)) {
$count++;
}
}
drupal_set_message(format_plural($count, 'Bulk generation of users completed, one alias generated.', 'Bulk generation of users completed, @count aliases generated.'));
}