You are here

function webform_requirements in Webform 7.4

Same name and namespace in other branches
  1. 8.5 includes/webform.install.requirements.inc \webform_requirements()
  2. 6.3 webform.install \webform_requirements()
  3. 6.x includes/webform.install.requirements.inc \webform_requirements()

Implements hook_requirements().

File

./webform.install, line 694
Webform module install/schema hooks.

Code

function webform_requirements($phase) {
  $requirements = array();
  $t = get_t();

  // Ensure cURL exists if SimpleTest hasn't checked it already.
  if (!class_exists('ZipArchive')) {
    $requirements['webform_zip'] = array(
      'title' => $t('Zip archive support'),
      'value' => $t('Missing'),
      'severity' => REQUIREMENT_INFO,
      'description' => $t('PHP does not have the zip archive extension available. Webform module requires zip support for exporting submissions to Microsoft Excel.'),
    );
  }

  // Though the .info file specifies PHP version as well, this will prevent
  // users from upgrading from 3.x if their PHP version is too old.
  if (version_compare(phpversion(), '5.3') < 0) {
    $requirements['webform_php'] = array(
      'title' => $t('Webform PHP requirement'),
      'value' => phpversion(),
      'severity' => REQUIREMENT_ERROR,
      'description' => $t('Webform requires PHP 5.3 or higher.'),
    );
  }

  // Ensure that views is enabled as it is a new .info requirement starting
  // with version 7.x-4.0rc1. On installation, the .info file is sufficient to
  // cause the dependencies to be installed. On update, update.php will
  // respect this hook_requirements implementation, but as of drush 6.3.0 and
  // drush 7.0.0, drush updatedb will not. See:
  // https://github.com/drush-ops/drush/issues/1427
  if ($phase != 'install' && !module_exists('views')) {
    $requirements['webform_views'] = array(
      'title' => $t('Webform Views requirement'),
      'value' => $t('Missing'),
      'severity' => REQUIREMENT_ERROR,
      'description' => $t('Webform requires Views, which is not installed and enabled.'),
    );
  }
  return $requirements;
}