You are here

function cas_requirements in CAS 7

Same name and namespace in other branches
  1. 6.3 cas.install \cas_requirements()

Implements hook_requirements().

File

./cas.install, line 134
Installation hooks for the CAS module.

Code

function cas_requirements($phase) {
  $requirements = array();
  $t = get_t();
  if ($phase == 'runtime') {
    $phpcas_url = 'https://github.com/apereo/phpCAS/releases';
    $phpcas_doc = 'https://apereo.github.io/cas/6.0.x/integration/CAS-Clients.html';
    $requirements['phpcas']['title'] = $t('phpCAS');

    // 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()) {
      $requirements['phpcas']['value'] = $version;
      $requirements['phpcas']['severity'] = REQUIREMENT_INFO;
      $requirements['phpcas']['description'] = $t('Please check periodically for <a href="@phpcas_url">security updates</a> and <a href="@phpcas_doc">updated documentation</a> to phpCAS.', array(
        '@phpcas_url' => $phpcas_url,
        '@phpcas_doc' => $phpcas_doc,
      ));
    }
    else {
      $requirements['phpcas']['value'] = $t('Not found');
      $requirements['phpcas']['severity'] = REQUIREMENT_ERROR;
      $requirements['phpcas']['description'] = $t('phpCAS could not be loaded. Please <a href="@phpcas_url">download phpCAS</a> and <a href="@cas_url">configure its location</a>.', array(
        '@phpcas_url' => $phpcas_url,
        '@cas_url' => url('admin/config/people/cas'),
      ));
    }
    $cert = variable_get('cas_cert');
    if (empty($cert)) {
      $requirements['cas_cert'] = array(
        'title' => $t('CAS SSL certificate bundle'),
        'severity' => REQUIREMENT_ERROR,
        'value' => $t('Not set'),
        'description' => $t('The CAS authentication process is not completely secure. Please <a href="@settings_url">visit the CAS settings page</a> and provide the path to the certificate authority bundle.', array(
          '@settings_url' => url('admin/config/people/cas'),
        )),
      );
    }
  }
  return $requirements;
}