You are here

function calendar_requirements in Calendar 5.2

Implementation of hook_requirements(). Added to be sure the Date API version matches this code so invalid functions are not called.

File

./calendar.install, line 11
Install File

Code

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

  // This is the minimum required version for the Date API so that it will work with this module.
  $required_version = 5.2;

  // Make sure the matching version of date_api is installed.
  // Use info instead of an error at install time since the problem may
  // just be that they were installed in the wrong order.
  switch ($phase) {
    case 'runtime':
      if (variable_get('date_api_version', 0) < $required_version) {
        $requirements['calendar_api_version'] = array(
          'title' => $t('Calendar requirements'),
          'value' => $t('The Calendar module requires a more current version of the Date API. Please check for a newer version.'),
          'severity' => REQUIREMENT_ERROR,
        );
      }
      break;
    case 'install':
      if (variable_get('date_api_version', 0) < $required_version) {
        $requirements['calendar_api_version'] = array(
          'title' => $t('Calendar requirements'),
          'value' => $t('The Calendar module requires the latest version of the Date API, be sure you are installing the latest versions of both modules.'),
          'severity' => REQUIREMENT_INFO,
        );
      }
      break;
  }
  return $requirements;
}