You are here

function cas_block in CAS 5

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

Provides login blog that only shows up when the user logs in.

File

./cas.module, line 656

Code

function cas_block($op = 'list', $delta = 0, $edit = array()) {
  global $user;
  if ($op == 'list') {
    $blocks[0]['info'] = t('CAS User login');
    return $blocks;
  }
  else {
    if ($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)))) {
            $edit = $_POST['edit'];
            $output = "<div class=\"user-login-block\">\n";

            // NOTE: special care needs to be taken because on pages with forms,
            // such as node and comment submission pages, the $edit variable
            // might already be set.
            $output .= l(t('Login'), 'cas');
            $output .= "</div>\n";
            $block['subject'] = t('User Login');
            $block['content'] = $output;
          }
          return $block;
      }
    }
  }
}