You are here

function casetracker_autocomplete in Case Tracker 7

Same name and namespace in other branches
  1. 5 casetracker.module \casetracker_autocomplete()
  2. 6 casetracker.module \casetracker_autocomplete()

Retrieve autocomplete suggestions for assign to user options.

@TODO: In order to get this down to 1 query and respect any custom views selected for use as user option filters, we need to:

  • Submit a patch to the Views user name filter/argument handler to support LIKE filtering.
  • Ensure that the custom view uses this handler or add it if does not.
  • Generate the query & result set using this modified View.
4 string references to 'casetracker_autocomplete'
casetracker_actions_set_assign_to_action_form in casetracker_actions/casetracker_actions.module
Select a user to assign for the Set Assign to action.
casetracker_case_form_common in ./casetracker.module
Common form elements for cases, generic enough for use either in a full node display, or in comment displays and updating. Default values are calculated based on an existing $form['nid']['#value'].
casetracker_menu in ./casetracker.module
Implements hook_menu().
casetracker_settings in ./casetracker_admin.inc
Configures the various Case Tracker options; system_settings_form().

File

./casetracker.module, line 929
Enables the handling of projects and their cases.

Code

function casetracker_autocomplete($string) {
  $matches = array();
  $options = casetracker_user_options();
  $result = db_select('users')
    ->fields('users', array(
    'name',
  ))
    ->condition('name', db_like($string) . '%', 'LIKE')
    ->range(0, 10)
    ->execute();
  foreach ($result as $user) {
    if (in_array($user->name, $options, TRUE)) {
      $matches[$user->name] = check_plain($user->name);
    }
  }

  // Special case for 'Unassigned'
  $unassigned = t('Unassigned');
  if (strpos(strtolower($unassigned), strtolower($string)) !== FALSE) {
    $matches[$unassigned] = $unassigned;
  }
  drupal_json_output($matches);
}