You are here

function saml_sp_drupal_login_form_user_login_block_alter in SAML Service Provider 7.8

Same name and namespace in other branches
  1. 8.2 modules/saml_sp_drupal_login/saml_sp_drupal_login.module \saml_sp_drupal_login_form_user_login_block_alter()
  2. 7 modules/saml_sp_drupal_login/saml_sp_drupal_login.module \saml_sp_drupal_login_form_user_login_block_alter()
  3. 7.2 modules/saml_sp_drupal_login/saml_sp_drupal_login.module \saml_sp_drupal_login_form_user_login_block_alter()
  4. 7.3 modules/saml_sp_drupal_login/saml_sp_drupal_login.module \saml_sp_drupal_login_form_user_login_block_alter()

Implements hook_form_FORM_ID_alter().

File

modules/saml_sp_drupal_login/saml_sp_drupal_login.module, line 47
SAML Drupal Login

Code

function saml_sp_drupal_login_form_user_login_block_alter(&$form, &$form_state) {

  // Add a "Log in using @idp_name" link to the user-login form, which returns
  // the user back to the same page with the returnTo parameter.
  $idp_selection = variable_get('saml_sp_drupal_login__idp', '');
  $idp = saml_sp_idp_load($idp_selection);
  $items = array();
  $options = array(
    'query' => array(
      'returnTo' => url(current_path()),
    ),
  );
  $items[] = array(
    'data' => l(t('Log in using @idp_name', array(
      '@idp_name' => $idp->name,
    )), 'saml/drupal_login', $options),
    'class' => array(
      'saml-link',
    ),
  );
  $form['saml_sp_drupal_login_links'] = array(
    '#theme' => 'item_list',
    '#items' => $items,
    '#attributes' => array(
      'class' => array(
        'saml_sp_drupal_login-links',
      ),
    ),
    '#weight' => 1,
  );
  if (variable_get('saml_sp_drupal_login__force_saml_only', FALSE)) {
    drupal_goto('saml/drupal_login', array(
      'query' => array(
        'returnTo' => 'user',
      ),
    ));
  }
}