function user_badges_badge_autocomplete in User Badges 6
Same name and namespace in other branches
- 6.2 user_badges.module \user_badges_badge_autocomplete()
- 7 user_badges.module \user_badges_badge_autocomplete()
- 7.2 user_badges.module \user_badges_badge_autocomplete()
- 7.3 user_badges.module \user_badges_badge_autocomplete()
Menu callback; Retrieve a JSON object containing autocomplete suggestions for badges
1 string reference to 'user_badges_badge_autocomplete'
- user_badges_menu in ./
user_badges.module - Implements hook_menu().
File
- ./
user_badges.module, line 482 - @brief User Badges module file
Code
function user_badges_badge_autocomplete($string = '') {
$matches = array();
if (preg_match('/^[^(]+/', $string, $searchstring)) {
$trimstring = trim($searchstring[0]);
$result = db_query_range("SELECT * FROM {user_badges_badges} WHERE name LIKE '%%%s%%'", $trimstring, 0, 10);
while ($badge = db_fetch_object($result)) {
$matches[$badge->name . ' (' . t('Badge ID') . ' ' . $badge->bid . ')'] = check_plain($badge->name) . ' ' . theme('user_badge', $badge);
}
}
drupal_json($matches);
}