You are here

function aes_requirements in AES encryption 8.2

Same name and namespace in other branches
  1. 6 aes.install \aes_requirements()
  2. 7 aes.install \aes_requirements()

Implements hook_requirements().

File

./aes.install, line 17
Install/uninstall handling for AES.

Code

function aes_requirements($phase) {
  $aesImplementations = AES::get_available_implementations();
  if ($aesImplementations['mcrypt'] === false && $aesImplementations['phpseclib'] === false) {
    $requirementSeverity = REQUIREMENT_ERROR;
    $value = t('The AES encryption module requires at least one of two things to function: Either the PHP Mcrypt extension has to be installed on the web server, or the PHP Secure Communications Library (phpseclib) needs to be installed in the AES directory. Check the README.txt for more information.');
  }
  else {
    $requirementSeverity = REQUIREMENT_OK;
    if ($aesImplementations['mcrypt'] && $aesImplementations['phpseclib']) {
      $value = t('Both MCrypt and PHP Secure Communications Library are available.');
    }
    else {
      if ($aesImplementations['mcrypt']) {
        $value = t('MCrypt is available.');
      }
      else {
        $value = t('PHP Secure Communications Library is available.');
      }
    }
  }
  $requirements['aes_lib'] = array(
    'title' => t('[AES encryption implementation]'),
    'value' => $value,
    'severity' => $requirementSeverity,
  );
  $requirementSeverity = REQUIREMENT_OK;
  $value = t("The 'active' config directory found.");
  try {
    config_get_config_directory(CONFIG_ACTIVE_DIRECTORY);
  } catch (\Exception $e) {
    $requirementSeverity = REQUIREMENT_ERROR;
    $value = t("Requirements error - cannot install AES: No 'active' config directory found. Please define it in your settings.php file.");
  }
  $requirements['aes_config_dir'] = array(
    'title' => t('[AES config directory]'),
    'value' => $value,
    'severity' => $requirementSeverity,
  );
  return $requirements;
}