You are here

function casetracker_autocomplete in Case Tracker 6

Same name and namespace in other branches
  1. 5 casetracker.module \casetracker_autocomplete()
  2. 7 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
Implementation of hook_menu().
casetracker_settings in ./casetracker_admin.inc
Configures the various Case Tracker options; system_settings_form().

File

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

Code

function casetracker_autocomplete($string) {
  $matches = array();
  $options = casetracker_user_options();
  $result = db_query_range("SELECT name FROM {users} WHERE LOWER(name) LIKE LOWER('%s%%')", $string, 0, 10);
  while ($user = db_fetch_object($result)) {
    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($matches);
}