You are here

function term_permissions_autocomplete_multiple in Taxonomy Term Permissions 6

Same name and namespace in other branches
  1. 7 term_permissions.module \term_permissions_autocomplete_multiple()

Returns JS array for Taxonomy Term Permissions autocomplete fields. Supports multiple entries separated by a comma.

1 string reference to 'term_permissions_autocomplete_multiple'
term_permissions_menu in ./term_permissions.module
Implementation of hook_menu().

File

./term_permissions.module, line 225
Allows access to terms in a vocabulary to be limited by user or role.

Code

function term_permissions_autocomplete_multiple($string) {

  // The user enters a comma-separated list of users. We only autocomplete the last user.
  $array = drupal_explode_tags($string);

  // Fetch last tag
  $last_string = trim(array_pop($array));
  $matches = array();
  $result = db_query_range("SELECT u.name FROM {users} u WHERE LOWER(u.name) LIKE LOWER('%s%%')", $last_string, 0, 10);
  $prefix = count($array) ? implode(', ', $array) . ', ' : '';
  while ($user = db_fetch_object($result)) {
    $matches[$prefix . $user->name] = check_plain($user->name);
  }
  if (module_exists('devel')) {
    $GLOBALS['devel_shutdown'] = FALSE;
  }
  exit(drupal_json($matches));
}