You are here

function fbconnect_requirements in Facebook Connect 6.2

Same name and namespace in other branches
  1. 8.2 fbconnect.install \fbconnect_requirements()
  2. 7.2 fbconnect.install \fbconnect_requirements()

Implements hook_requirements().

File

./fbconnect.install, line 11
Install, update and uninstall functions for the fbconnect module.

Code

function fbconnect_requirements($phase) {
  $requirements = array();
  $t = get_t();
  if (!function_exists('curl_init')) {
    $requirements['curl']['title'] = $t('cURL library');
    $requirements['curl']['value'] = $t('Not installed');
    $requirements['curl']['severity'] = REQUIREMENT_ERROR;
    $requirements['curl']['description'] = $t('The cURL library is not installed. Please check the <a href="@url">PHP cURL documentation</a> for information on how to correct this.', array(
      '@url' => 'http://www.php.net/manual/en/curl.setup.php',
    ));
  }
  if (!function_exists('json_decode')) {
    $requirements['json']['title'] = $t('JSON extension');
    $requirements['json']['value'] = $t('Not installed');
    $requirements['json']['severity'] = REQUIREMENT_ERROR;
    $requirements['json']['description'] = $t('The JSON library is not installed. Facebook needs the JSON PHP extension');
  }
  if ($phase == 'runtime') {
    drupal_load('module', 'fbconnect');
    _fbconnect_facebook_client_load_include();
    $requirements['facebook-php-sdk']['title'] = $t('Facebook PHP sdk');
    if (!class_exists('Facebook')) {
      $requirements['facebook-php-sdk']['value'] = $t('Not installed');
      $requirements['facebook-php-sdk']['severity'] = REQUIREMENT_ERROR;
      $requirements['facebook-php-sdk']['description'] = $t('Fbconnect : Facebook PHP library not found. See README.txt');
    }
    elseif (!constant('Facebook::VERSION')) {
      $requirements['facebook-php-sdk']['value'] = $t('Outdated version');
      $requirements['facebook-php-sdk']['severity'] = REQUIREMENT_ERROR;
      $requirements['facebook-php-sdk']['description'] = $t('Fbconnect : Installed Facebook PHP library is outdated. See README.txt');
    }
    else {
      $requirements['facebook-php-sdk']['value'] = l(constant('Facebook::VERSION'), 'http://github.com/facebook/php-sdk', array(
        'external' => TRUE,
      ));
      $requirements['facebook-php-sdk']['severity'] = REQUIREMENT_OK;
    }
    if (!fbconnect_get_config()) {
      $requirements['fbconnect_conf'] = array(
        'title' => $t('FBConnect'),
        'value' => $t('Not configured'),
        'severity' => REQUIREMENT_WARNING,
        'description' => $t('Please ensure that you entered Application ID and Secret Key. !link', array(
          '!link' => l($t('Settings page'), 'admin/settings/fbconnect'),
        )),
      );
    }
  }
  return $requirements;
}