You are here

function shib_auth_custom_data in Shibboleth Authentication 7.4

Same name and namespace in other branches
  1. 6.4 shib_auth_forms.inc \shib_auth_custom_data()

Form constructor for the shib_auth custom form.

Generate the custom email and username provider form.

See also

shib_auth_custom_data_validate()

shib_auth_custom_data_submit()

3 string references to 'shib_auth_custom_data'
shib_auth_custom_form in ./shib_auth.module
Displays custom form if either customization or consent options are enabled.
shib_auth_init in ./shib_auth.module
Creates a new user, if necessary, based on information from the handler.
shib_auth_menu in ./shib_auth.module
Implements hook_menu().

File

./shib_auth_forms.inc, line 129
Drupal forms of the Shibboleth authentication module.

Code

function shib_auth_custom_data($form, &$form_state) {
  $form = array();

  // Decide if the user is already registered, but a new consent version is
  // present.
  $authmap_username = db_select('shib_authmap', 'c')
    ->fields('c')
    ->condition('targeted_id', shib_auth_getenv(shib_auth_config('username_variable')), '=')
    ->execute()
    ->fetchAssoc();

  // If the user already registered, display a message about consent version
  // change.
  if ($authmap_username) {
    $form['consent'] = array(
      '#value' => t('The terms of use document has been modified since your last login with id @targetedid. Please read it carefully, and click on Submit if you accept the new version. Version you have accepted: @accepted - document version: @documentver', array(
        '@targetedid' => $authmap_username['targeted_id'],
        '@accepted' => $authmap_username['consentver'],
        '@documentver' => shib_auth_config('terms_ver'),
      )),
    );
  }
  else {

    // Username textfield is writable, if define_username variable is true.
    if (shib_auth_config('define_username')) {
      $form['custom_username'] = array(
        '#type' => 'textfield',
        '#title' => t('Desired username'),
        '#default_value' => shib_auth_getenv(shib_auth_config('username_variable')),
        '#size' => 60,
      );
    }
    else {
      $form['custom_usernamem'] = array(
        '#markup' => t('<b>Username:</b> <br />'),
      );
      $form['custom_username'] = array(
        '#markup' => shib_auth_getenv(shib_auth_config('username_variable')),
        '#suffix' => '<br />',
      );
    }
    if (shib_auth_config('enable_custom_mail')) {

      // Mail textfield is writable, if define_username variable is true.
      $form['custom_mail'] = array(
        '#type' => 'textfield',
        '#title' => t('Email'),
        '#default_value' => shib_auth_getenv(shib_auth_config('email_variable')),
        '#size' => 60,
      );
    }
    else {
      $form['custom_mailm'] = array(
        '#markup' => '<b>' . t('Email:') . '</b><br />',
      );
      $form['custom_mail'] = array(
        '#markup' => shib_auth_getenv(shib_auth_config('email_variable')),
        '#suffix' => '<br />',
      );
    }
  }

  // Display terms of use link, if it is required by admin.
  if (shib_auth_config('terms_accept')) {
    $form['accept'] = array(
      '#type' => 'checkbox',
      '#title' => t('I accept the <a href="@link" target="_blank">terms and conditions</a>', array(
        '@link' => url(shib_auth_config('terms_url')),
      )),
    );
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Send'),
  );
  $form['cancel'] = array(
    '#type' => 'submit',
    '#value' => t('Cancel'),
  );
  return $form;
}