function pmperson_user_autocomplete in Drupal PM (Project Management) 7
Generates list of pmperson for autocomplete widget.
1 string reference to 'pmperson_user_autocomplete'
- pmperson_menu in pmperson/
pmperson.module - Implements hook_menu().
File
- pmperson/
pmperson.module, line 383
Code
function pmperson_user_autocomplete($string = '') {
$matches = array();
if ($string) {
$query = db_select('users', 'u')
->fields('u', array(
'name',
'uid',
))
->condition('name', db_like($string) . '%', 'LIKE');
$subquery = db_select('pmperson', 'stp');
$subquery
->addField('stp', 'user_uid', 'uid');
$query
->condition('uid', $subquery, 'NOT IN');
$result = $query
->execute();
foreach ($result as $row) {
$matches[$row->name] = check_plain($row->name);
}
drupal_json_output($matches);
}
}