uid); return; case 'delete': search_wipe($user->uid, 'users'); return; } } /** * Implementation of hook_search(). */ function userindex_search($op, $keys = NULL) { switch ($op) { case 'reset': db_query("UPDATE {search_dataset} SET reindex = %d WHERE type = 'users'", time()); return; case 'status': $total = db_result(db_query('SELECT COUNT(*) FROM {users} WHERE status = 1')); $remaining = db_result(db_query("SELECT COUNT(*) FROM {users} u LEFT JOIN {search_dataset} d ON d.type = 'users' AND d.sid = u.uid WHERE u.status = 1 AND (d.sid IS NULL OR d.reindex <> 0)")); return array('remaining' => $remaining, 'total' => $total); } } /** * Implementation of hook_update_index(). */ function userindex_update_index() { $limit = (int)variable_get('search_cron_limit', 100); $result = db_query_range('SELECT u.uid FROM {users} u LEFT JOIN {search_dataset} d ON d.type = "users" AND d.sid = u.uid WHERE d.sid IS NULL OR d.reindex <> 0 ORDER BY d.reindex ASC, u.uid ASC', 0, $limit); while ($user = db_fetch_object($result)) { _userindex_index_user($user); } } /** * Internal help function to index a single user and optionally it's profile * fields too. * * @todo * Add the possibility for other modules to add to the searchable text by * invoking something like 'update index' in hook_user(). */ function _userindex_index_user($user) { $user = user_load($user->uid); $text = '