You are here

function cas_block in CAS 6.3

Same name and namespace in other branches
  1. 5.4 cas.module \cas_block()
  2. 5 cas.module \cas_block()
  3. 5.3 cas.module \cas_block()
  4. 6 cas.module \cas_block()
  5. 6.2 cas.module \cas_block()

Implements hook_block().

Provides CAS login block for anonymous users.

File

./cas.module, line 655
Enables users to authenticate via a Central Authentication Service (CAS) Cas will currently work if the auto registration is turned on and will create user accounts automatically.

Code

function cas_block($op = 'list', $delta = 0, $edit = array()) {
  global $user;
  if ($op == 'list') {
    $blocks[0]['info'] = t('CAS login');
    return $blocks;
  }
  elseif ($op == 'view') {
    $block = array();
    switch ($delta) {
      case 0:

        // For usability's sake, avoid showing two login forms on one page.
        if (!$user->uid && !(arg(0) == 'user' && !is_numeric(arg(1)))) {
          $block['subject'] = t('User login');
          $block['content'] = drupal_get_form('cas_login_block');
        }
        return $block;
    }
  }
}