You are here

function lti_tool_provider_user_attributes in LTI Tool Provider 7

Menu page callback.

Configure settings for mapping user attributes from the LTI context variables.

Parameters

array $form: The form.

array $form_state: The form state.

Return value

array The form.

1 string reference to 'lti_tool_provider_user_attributes'
lti_tool_provider_menu in ./lti_tool_provider.module
Implements hook_menu().

File

./lti_tool_provider.admin.inc, line 23
Admin forms for LTI Tool Provider module.

Code

function lti_tool_provider_user_attributes($form, &$form_state) {
  $form['description'] = array(
    '#type' => 'item',
    '#title' => t('LTI Context to User Attribute Mapping'),
    '#description' => 'Choose the user attributes to be mapped from each LTI context variable.',
  );
  $fields_array = _lti_tool_provider_retrieve_user_field_types('TEXT');
  $lis_list = lti_tool_provider_user_mapping_lis_details();
  $saved_settings = variable_get('lti_tool_provider_user_attribute_mapping', array());
  $form['mapping'] = array(
    '#tree' => TRUE,
    '#theme' => 'table',
    '#header' => array(
      t('LTI Context Variable'),
      t('User Attribute'),
    ),
    '#rows' => array(),
  );
  foreach ($lis_list as $detail) {
    $variable = array(
      '#type' => 'item',
      '#title' => check_plain($detail),
    );
    $value = $saved_settings[$detail];
    $attribute = array(
      '#type' => 'select',
      '#options' => $fields_array,
      '#default_value' => $value,
    );
    $form['mapping'][] = array(
      'variable' => &$variable,
      'attribute' => &$attribute,
    );
    $form['mapping']['#rows'][] = array(
      array(
        'data' => &$variable,
      ),
      array(
        'data' => &$attribute,
      ),
    );
    unset($variable);
    unset($attribute);
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save User Attributes'),
  );
  return $form;
}