You are here

function masquerade_ctools_user_from_masquerade_settings_form in Masquerade Extras 7.2

Same name and namespace in other branches
  1. 6.2 masquerade_ctools/plugins/relationships/user_from_masquerade.inc \masquerade_ctools_user_from_masquerade_settings_form()

Allow the user to configure the context in the UI.

@returns A form the user will see when configuring this plugin. @retval array

Parameters

array $form: The form (any inherited form structure or pre-defined properties).

array $form_state: The form state (current values, security tokens, etc).

1 string reference to 'masquerade_ctools_user_from_masquerade_settings_form'
user_from_masquerade.inc in masquerade_ctools/plugins/relationships/user_from_masquerade.inc
Allows the user to access related user info during a masquerade.

File

masquerade_ctools/plugins/relationships/user_from_masquerade.inc, line 111
Allows the user to access related user info during a masquerade.

Code

function masquerade_ctools_user_from_masquerade_settings_form($form, &$form_state) {
  $conf = $form_state['conf'];

  // Move the context source below our settings.
  $form['context']['#weight'] = 1;
  $form['context'][0]['#title'] = t('Source User');
  $form['context'][0]['#description'] = t('Who the masquerade will lookup the target user from.');
  $form['settings']['mode'] = array(
    '#weight' => 0,
    '#title' => t('Target user'),
    '#type' => 'radios',
    '#options' => array(
      'masquerader' => t('The person masquerading'),
      'masqueradee' => t('The person being masqueraded'),
    ),
    '#description' => t('Which person in the masquerade do you need access to?') . t('You should only need this relationship if you need the REVERSE of the "current user".'),
    '#default_value' => $conf['mode'],
  );

  // Unless a keyword is already set, we can change the keyword to be something
  // more appropriate based on the selected 'mode'.
  // For instance, if we want access to the person who is using our account,
  // the keyword should be "masquerader".
  // Conversely, if we want access to the person we ARE using, the
  // keyword should be "masqueradee".
  $form['keyword']['#default_value'] = !empty($conf['keyword']) ? $conf['keyword'] : $conf['mode'];
  return $form;
}