You are here

cas.user.inc in CAS 6.3

Same filename and directory in other branches
  1. 7 cas.user.inc

Provides CAS user registration administrative pages.

File

cas.user.inc
View source
<?php

/**
 * @file
 * Provides CAS user registration administrative pages.
 */

/**
 * Creates a CAS user registration page.
 */
function cas_add_user_form() {
  $form = array();
  $form['account']['cas_name'] = array(
    '#type' => 'textfield',
    '#title' => t('CAS username'),
    '#required' => TRUE,
    '#default_value' => '',
    '#description' => t('Registration will proceed as if the user with the specified CAS username just logged in.'),
    '#element_validate' => array(
      '_cas_name_element_validate',
    ),
    '#weight' => -10,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Create new account'),
  );
  return $form;
}
function cas_add_user_form_submit($form, &$form_state) {
  $options = array(
    'invoke_cas_user_presave' => TRUE,
  );
  $account = cas_user_register($form_state['values']['cas_name'], $options);

  // Terminate if an error occurred while registering the user.
  if (!$account) {
    drupal_set_message(t("Error saving user account."), 'error');
    $form_state['redirect'] = '';
    return;
  }

  // Set these in case another module needs the values.
  $form_state['user'] = $account;
  $form_state['values']['uid'] = $account->uid;
  drupal_set_message(t('Created a new user account for <a href="@url">%name</a>. No e-mail has been sent.', array(
    '@url' => url("user/{$account->uid}"),
    '%name' => $account->name,
  )));
}

Functions

Namesort descending Description
cas_add_user_form Creates a CAS user registration page.
cas_add_user_form_submit