function _drupalchat_ur_autocomplete in DrupalChat 6.2
Same name and namespace in other branches
- 7.2 drupalchat.module \_drupalchat_ur_autocomplete()
- 7 drupalchat.module \_drupalchat_ur_autocomplete()
Implements autocomplete feature for UR Integration.
1 string reference to '_drupalchat_ur_autocomplete'
- drupalchat_menu in ./
drupalchat.module - Implementaiton of hook_menu()
File
- ./
drupalchat.module, line 307 - Module code for DrupalChat.
Code
function _drupalchat_ur_autocomplete($string) {
$array = drupal_explode_tags($string);
// Fetch last value
$last_string = drupal_strtolower(array_pop($array));
$matches = array();
// Select rows that match the string
$query = db_query("SELECT name FROM {user_relationship_types} WHERE name LIKE '%%%s%%' LIMIT 10", $last_string);
$prefix = count($array) ? drupal_implode_tags($array) . ', ' : '';
// add matches to $matches
while ($row = db_fetch_object($query)) {
if (!in_array($row->name, $array)) {
$matches[$prefix . $row->name] = check_plain($row->name);
}
}
// return for JS
drupal_json($matches);
}