function realname_update_index in Real Name 6
Implements hook_update_index().
File
- ./
realname.module, line 656
Code
function realname_update_index() {
if (variable_get('realname_search_enable', FALSE)) {
$start = variable_get('realname_last_index', -1) + 1;
$limit = (int) variable_get('search_cron_limit', 100);
$how_many = db_result(db_query("SELECT COUNT(*) FROM {users} WHERE status = 1 AND uid >= %d", $start));
$limit = min($limit, $how_many);
if ($limit < 1) {
return;
}
watchdog('RealName', 'Indexing up to !limit users, starting at !start', array(
'!start' => $start,
'!limit' => $limit,
), WATCHDOG_NOTICE);
$result = db_query_range("SELECT uid FROM {users} WHERE status = 1 AND uid >= %d ORDER BY uid", $start, 0, $limit);
while ($uid = db_result($result)) {
$account = user_load(array(
'uid' => $uid,
));
$index_text = realname_make_name($account);
if (variable_get('realname_search_login', FALSE)) {
$index_text .= ' ' . $account->name;
}
search_index($account->uid, 'realname', $index_text);
variable_set('realname_last_index', $account->uid);
}
}
}