You are here

function fb_requirements in Drupal for Facebook 6.2

Same name and namespace in other branches
  1. 6.3 fb.install \fb_requirements()
  2. 7.4 fb.install \fb_requirements()
  3. 7.3 fb.install \fb_requirements()

Implementation of hook_requirements().

File

./fb.install, line 11
Install file to support fb.module.

Code

function fb_requirements($phase) {
  $t = get_t();
  $items = array();

  // Disable these checks at install time, because failure then causes more
  // problems, due to module dependencies and Drupal's poor handling of
  // requirement errors.
  if ($phase != 'runtime') {
    return $items;
  }
  $status = array(
    'title' => $t('Drupal for Facebook Settings'),
  );
  if (function_exists('fb_settings')) {
    if ($phase == 'runtime') {
      $status['value'] = $t('Included');
    }
    $status['severity'] = REQUIREMENT_OK;
  }
  else {
    if ($phase == 'runtime') {
      $status['value'] = $t('Not included');
    }
    $status['severity'] = REQUIREMENT_ERROR;
    $path = drupal_get_path('module', 'fb');
    if (!$path) {

      // Not set during install.php
      $path = 'modules/fb';
    }
    $status['description'] = $t('Add something like <strong>include "%path";</strong> to your settings.php.', array(
      '%path' => $path . '/fb_settings.inc',
    ));
  }
  $items[] = $status;
  $status = array(
    'title' => $t('Facebook Client API'),
  );
  $fb_platform = variable_get('fb_api_file', 'facebook-platform/php/facebook.php');
  if (class_exists('Facebook')) {
    $status['description'] = $t('Facebook Client API loaded.');
    $status['severity'] = REQUIREMENT_OK;
    $status['value'] = $t('Loaded');
  }
  elseif (include $fb_platform) {

    // include() better than file_exists().
    $status['description'] = $t('Facebook client API found at %path', array(
      '%path' => $fb_platform,
    ));
    $status['severity'] = REQUIREMENT_OK;
    if ($phase == 'runtime') {
      $status['value'] = $t('Found');
    }
  }
  else {
    $status['description'] = $t('Facebook client API not found.  See modules/fb/README.txt');
    $status['severity'] = REQUIREMENT_ERROR;
    if ($phase == 'runtime') {
      $status['value'] = $t('Not found');
    }
  }
  $items[] = $status;
  return $items;
}