You are here

function ctools_context_user_settings_form in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 plugins/contexts/user.inc \ctools_context_user_settings_form()
1 string reference to 'ctools_context_user_settings_form'
user.inc in plugins/contexts/user.inc
Plugin to provide a user context

File

plugins/contexts/user.inc, line 62
Plugin to provide a user context

Code

function ctools_context_user_settings_form($conf) {
  ctools_include('dependent');
  $form['type'] = array(
    '#title' => t('Enter the context type'),
    '#type' => 'radios',
    '#options' => array(
      'select' => t('Select a user'),
      'current' => t('Logged in user'),
    ),
    '#default_value' => $conf['type'],
  );
  $form['user'] = array(
    '#title' => t('Enter a user name'),
    '#type' => 'textfield',
    '#maxlength' => 512,
    '#autocomplete_path' => 'user/autocomplete',
    '#process' => array(
      'ctools_dependent_process',
    ),
    '#dependency' => array(
      'radio:context[context_settings][type]' => array(
        'select',
      ),
    ),
  );
  if (!empty($conf['uid'])) {
    $info = user_load($conf['uid']);
    if ($info) {
      $form['user']['#description'] = t('Currently set to !link', array(
        '!link' => theme('username', $info),
      ));
    }
  }
  $form['uid'] = array(
    '#type' => 'value',
    '#value' => $conf['uid'],
  );
  $form['set_identifier'] = array(
    '#type' => 'checkbox',
    '#default_value' => FALSE,
    '#title' => t('Reset identifier to username'),
    '#description' => t('If checked, the identifier will be reset to the user name of the selected user.'),
    '#process' => array(
      'ctools_dependent_process',
    ),
    '#dependency' => array(
      'radio:context[context_settings][type]' => array(
        'select',
      ),
    ),
  );
  return $form;
}