function user_pathauto_bulk_update_batch_process in Pathauto 6.2
Same name and namespace in other branches
- 7 pathauto.pathauto.inc \user_pathauto_bulk_update_batch_process()
Batch processing callback; Generate aliases for users.
1 string reference to 'user_pathauto_bulk_update_batch_process'
- _user_pathauto in ./
pathauto.pathauto.inc - Implements hook_pathauto().
File
- ./
pathauto.pathauto.inc, line 253 - Pathauto integration for core modules.
Code
function user_pathauto_bulk_update_batch_process(&$context) {
if (!isset($context['sandbox']['current'])) {
$context['sandbox']['count'] = 0;
$context['sandbox']['current'] = 0;
}
$concat = _pathauto_sql_concat("'user/'", 'u.uid');
$sql = "SELECT u.uid FROM {users} u LEFT JOIN {url_alias} ua ON {$concat} = ua.src WHERE ua.src IS NULL AND u.uid > %d ORDER BY u.uid";
$args = array(
$context['sandbox']['current'],
);
// Get the total amount of items to process.
if (!isset($context['sandbox']['total'])) {
$context['sandbox']['total'] = db_result(db_query(_pathauto_sql_count($sql), $args));
// If there are no nodes to update, the stop immediately.
if (!$context['sandbox']['total']) {
$context['finished'] = 1;
return;
}
}
$query = db_query_range($sql, $args, 0, 25);
$uids = array();
while ($uid = db_result($query)) {
$uids[] = $uid;
}
pathauto_user_update_alias_multiple($uids, 'bulkupdate', array(
'alias blog' => FALSE,
));
$context['sandbox']['count'] += count($uids);
$context['sandbox']['current'] = max($uids);
$context['message'] = t('Updated alias for user @uid.', array(
'@uid' => end($uids),
));
if ($context['sandbox']['count'] >= $context['sandbox']['total']) {
$context['finished'] = 1;
}
else {
$context['finished'] = $context['sandbox']['count'] / $context['sandbox']['total'];
}
}