You are here

function cas_attributes_list in CAS Attributes 7

Same name and namespace in other branches
  1. 6.3 cas_attributes.admin.inc \cas_attributes_list()

Lists available CAS Attributes.

1 string reference to 'cas_attributes_list'
cas_attributes_menu in ./cas_attributes.module
Implements hook_menu().

File

./cas_attributes.admin.inc, line 142
Provides settings pages for the CAS Attributes module.

Code

function cas_attributes_list() {
  cas_phpcas_load();
  cas_phpcas_init();
  phpCAS::forceAuthentication();
  $attributes = phpCAS::getAttributes();
  $header = array(
    'Token',
    'Value',
  );
  $rows = array();
  foreach ($attributes as $attribute => $value) {
    if (is_array($value)) {
      $html = "";
      foreach ($value as $k => $v) {
        $html .= check_plain($v) . '<br />';
      }
      $rows[] = array(
        t('[cas:attribute:@attribute]', array(
          '@attribute' => drupal_strtolower($attribute),
        )),
        $html,
      );
    }
    else {
      $rows[] = array(
        t('[cas:attribute:@attribute]', array(
          '@attribute' => drupal_strtolower($attribute),
        )),
        check_plain($value),
      );
    }
  }
  if (empty($rows)) {
    $rows[] = array(
      'data' => array(
        array(
          'data' => t('No CAS attributes were returned by the CAS server.'),
          'colspan' => 2,
        ),
      ),
    );
  }
  return theme('table', array(
    'header' => $header,
    'rows' => $rows,
  ));
}