You are here

function cas_roles_requirements in CAS roles 8

Same name and namespace in other branches
  1. 6 cas_roles.install \cas_roles_requirements()
  2. 7.2 cas_roles.install \cas_roles_requirements()
  3. 7 cas_roles.install \cas_roles_requirements()

Implements hook_requirements().

File

./cas_roles.install, line 22
Installation hooks for the CAS Attributes module.

Code

function cas_roles_requirements($phase) {
  $requirements = array();
  $t = get_t();
  if ($phase == 'runtime') {
    if (!function_exists('cas_phpcas_attributes')) {
      $requirements['cas_roles'] = array(
        'title' => $t('CAS'),
        'value' => $t('Outdated'),
        'severity' => REQUIREMENT_WARNING,
        'description' => $t('CAS roles requires <a href="@url">CAS</a> version 7.x-1.0 or later.', array(
          '@url' => 'http://drupal.org/project/cas',
        )),
      );
    }

    // Okay to call functions from cas.module since we are in the runtime
    // phase. We hide errors here in case phpcas could not be loaded.
    if ($version = @cas_phpcas_load()) {
      if (!method_exists('phpCAS', 'getAttributes')) {
        $requirements['cas_roles_phpcas'] = array(
          'title' => $t('phpCAS (Attribute support)'),
          'value' => $version,
          'severity' => REQUIREMENT_WARNING,
          'description' => $t('CAS roles requires <a href="@url">phpCAS</a> version 1.1.0 or later.', array(
            '@url' => 'https://wiki.jasig.org/display/CASC/phpCAS',
          )),
        );
      }
    }
  }
  return $requirements;
}