You are here

function crypt_blowfish_requirements in Web Service Clients 7

Same name and namespace in other branches
  1. 6.2 connections/clients_drupal/crypt_blowfish/crypt_blowfish.install \crypt_blowfish_requirements()
  2. 6 backends/clients_drupal/crypt_blowfish/crypt_blowfish.install \crypt_blowfish_requirements()
  3. 7.3 connections/clients_drupal/crypt_blowfish/crypt_blowfish.install \crypt_blowfish_requirements()
  4. 7.2 connections/clients_drupal/crypt_blowfish/crypt_blowfish.install \crypt_blowfish_requirements()

Implementation of hook_requirements

File

backends/clients_drupal/crypt_blowfish/crypt_blowfish.install, line 31
Checks blowfish configuration - directory and password are set

Code

function crypt_blowfish_requirements($phase) {
  $requirements = array();
  switch ($phase) {
    case 'install':
      break;
    case 'runtime':
      if (!variable_get('crypt_blowfish_cryptdir', FALSE)) {
        $requirements['crypt_blowfish_cryptdir'] = array(
          'title' => t('Blowfish'),
          'value' => t('Path to PEAR Blowfish library not set'),
          'severity' => REQUIREMENT_ERROR,
        );
      }
      else {
        $requirements['crypt_blowfish_cryptdir'] = array(
          'title' => t('Blowfish'),
          'value' => t('Path set to PEAR Blowfish library (%cryptdir)', array(
            '%cryptdir' => variable_get('crypt_blowfish_cryptdir', ''),
          )),
          'severity' => REQUIREMENT_OK,
        );

        // @todo fix error if not found
        if (Drupal_Crypt_Blowfish::getkey() == 'replace this with a strong password') {
          $requirements['crypt_blowfish_key'] = array(
            'title' => t('Blowfish'),
            'value' => t('Blowfish encryption key has not been set. Please edit the file crypt_blowfish_key.inc in %installdir', array(
              '%installdir' => drupal_get_path('module', 'crypt_blowfish'),
            )),
            'severity' => REQUIREMENT_ERROR,
          );
        }
        else {
          $requirements['crypt_blowfish_key'] = array(
            'title' => t('Blowfish'),
            'value' => t('Blowfish encryption key has been set'),
            'severity' => REQUIREMENT_OK,
          );
        }
      }
      break;
  }
  return $requirements;
}