You are here

function casetracker_settings in Case Tracker 6

Same name and namespace in other branches
  1. 5 casetracker.module \casetracker_settings()
  2. 7 casetracker_admin.inc \casetracker_settings()

Configures the various Case Tracker options; system_settings_form().

1 string reference to 'casetracker_settings'
casetracker_menu in ./casetracker.module
Implementation of hook_menu().

File

./casetracker_admin.inc, line 6

Code

function casetracker_settings() {
  $form = array();
  $form['casetracker_general'] = array(
    '#type' => 'fieldset',
    '#title' => t('General settings'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['casetracker_general']['casetracker_default_assign_to'] = array(
    '#type' => 'textfield',
    '#title' => t('Default assigned user'),
    '#autocomplete_path' => 'casetracker_autocomplete',
    '#required' => TRUE,
    '#default_value' => casetracker_default_assign_to(),
    '#description' => t('User to be assigned the case if one is not explicitly defined.'),
    '#element_validate' => array(
      'casetracker_default_assign_to_validate',
    ),
  );
  $form['casetracker_general']['casetracker_assign_to_widget'] = array(
    '#type' => 'select',
    '#title' => t('Assign to user widget'),
    '#options' => array(
      'flexible' => t('Flexible'),
      'select' => t('Select'),
      'radios' => t('Radios'),
      'autocomplete' => t('Autocomplete'),
    ),
    '#description' => t('Define which widget use to select the assigned user for a case. If you choose <strong>Flexible</strong> Case Tracker will use radios, select and autocomplete as widget depending of how many users can be assigned to the case.'),
    '#default_value' => variable_get('casetracker_assign_to_widget', 0),
  );
  foreach (array(
    'priority',
    'status',
    'type',
  ) as $realm) {
    $options = casetracker_realm_load($realm);
    $temp_keys = array_keys($options);
    $form['casetracker_general']['casetracker_default_case_' . $realm] = array(
      '#type' => 'select',
      '#options' => $options,
      '#title' => t('Default case %realm', array(
        '%realm' => $realm,
      )),
      '#default_value' => variable_get('casetracker_default_case_' . $realm, array_shift($temp_keys)),
      '#description' => t('%realm to be assigned the case if one is not explicitly defined.', array(
        '%realm' => ucfirst($realm),
      )),
    );
  }
  $node_types = node_get_types('names');
  $project_types = $node_types;
  unset($project_types['casetracker_basic_case']);
  $form['casetracker_general']['casetracker_project_node_types'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Project node types'),
    '#options' => $project_types,
    '#default_value' => variable_get('casetracker_project_node_types', array(
      'casetracker_basic_project',
    )),
    '#description' => t('Select the node types that will be considered Case Tracker projects.'),
  );
  $case_types = $node_types;
  unset($case_types['casetracker_basic_project']);
  $form['casetracker_general']['casetracker_case_node_types'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Case node types'),
    '#options' => $case_types,
    '#default_value' => variable_get('casetracker_case_node_types', array(
      'casetracker_basic_case',
    )),
    '#description' => t('Select the node types that will be considered Case Tracker cases.'),
  );
  $all_views = views_get_all_views();
  $node_views = array();
  $user_views = array();
  foreach ($all_views as $view) {
    if ($view->base_table == 'node') {
      $node_views[$view->name] = $view->name;
    }
    else {
      if ($view->base_table = 'users') {
        $user_views[$view->name] = $view->name;
      }
    }
  }
  $form['casetracker_general']['casetracker_view_project_options'] = array(
    '#type' => 'select',
    '#title' => t('Project options view'),
    '#options' => $node_views,
    '#default_value' => variable_get('casetracker_view_project_options', 'casetracker_project_options'),
    '#description' => t('Select the view from which to fill the project selector on the add case page.'),
  );
  $form['casetracker_general']['casetracker_view_assignee_options'] = array(
    '#type' => 'select',
    '#title' => t('Assignee options view'),
    '#options' => $user_views,
    '#default_value' => variable_get('casetracker_view_assignee_options', 'casetracker_assignee_options'),
    '#description' => t('Select the view from which to fill the user assignment options on the add case page.'),
  );
  $form['#submit'][] = 'casetracker_settings_submit';
  return system_settings_form($form);
}