You are here

function casetracker_user_options in Case Tracker 6

Same name and namespace in other branches
  1. 7 casetracker.module \casetracker_user_options()

API function that returns valid user options.

4 calls to casetracker_user_options()
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_autocomplete in ./casetracker.module
Retrieve autocomplete suggestions for assign to user options.
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_views_handler_filter_user_options::get_value_options in includes/casetracker_views_handler_filter_user_options.inc

File

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

Code

function casetracker_user_options() {
  $users = array();
  $options = array();
  if ($view = views_get_view(variable_get('casetracker_view_assignee_options', 'casetracker_assignee_options'))) {
    $view
      ->set_display();
    $view
      ->set_items_per_page(0);
    $view
      ->execute();
    foreach ($view->result as $row) {
      $options[$row->uid] = $row->users_name;
    }
  }
  $anon_user = casetracker_default_assign_to();

  // fill in "Unassigned" value because view is not rendered and the redundant option in views is irrelevant
  // @TODO render the view before display so this isn't needed.
  if (isset($options[0])) {
    $options[0] = $anon_user;
  }
  elseif (in_array(variable_get('casetracker_default_assign_to', $anon_user), array(
    $anon_user,
    variable_get('anonymous', t('Anonymous')),
  ))) {
    $options = array(
      $anon_user,
    ) + $options;
  }
  return $options;
}