You are here

function theme_cas_service_validate_attributes in CAS 6.3

Same name and namespace in other branches
  1. 7 cas_server.response.inc \theme_cas_service_validate_attributes()

Returns CAS attributes as part of a CAS 2.0 service response.

Parameters

$attributes: The CAS attributes for the user

$style: Must be one of:

  • 'jasig' (default)
  • 'rubycas'
  • 'name-value'
1 theme call to theme_cas_service_validate_attributes()
theme_cas_service_validate_success in ./cas_server.response.inc
Returns a CAS 2.0 service response for a validation success.

File

./cas_server.response.inc, line 38
Response callbacks for the CAS Server module.

Code

function theme_cas_service_validate_attributes($attributes = array(), $style = 'jasig') {
  $output = '';
  switch ($style) {
    case 'jasig':
    default:
      $output .= "<cas:attributes>\n";
      $output .= "<cas:attraStyle>Jasig</cas:attraStyle>\n";
      foreach ($attributes as $name => $values) {
        foreach ((array) $values as $value) {
          $output .= strtr("<cas:!name>!value</cas:!name>\n", array(
            '!name' => $name,
            '!value' => $value,
          ));
        }
      }
      $output .= "</cas:attributes>\n";
      break;
    case 'rubycas':
      $output .= "<cas:attraStyle>RubyCAS</cas:attraStyle>\n";
      foreach ($attributes as $name => $values) {
        foreach ((array) $values as $value) {
          $output .= strtr("<cas:!name>!value</cas:!name>\n", array(
            '!name' => $name,
            '!value' => $value,
          ));
        }
      }
      break;
    case 'name-value':
      $output .= "<cas:attribute name='attraStyle' value='Name-Value' />\n";
      foreach ($attributes as $name => $values) {
        foreach ((array) $values as $value) {
          $output .= strtr("<cas:attribute name='!name' value='!value' />\n", array(
            '!name' => $name,
            '!value' => $value,
          ));
        }
      }
      break;
  }
  return $output;
}