You are here

function oauth_common_requirements in OAuth 1.0 7.4

Same name and namespace in other branches
  1. 6.3 oauth_common.install \oauth_common_requirements()
  2. 7.3 oauth_common.install \oauth_common_requirements()

Implements hook_requirements().

File

./oauth_common.install, line 11
Installation and schema related functions for the OAuth module

Code

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

  // Check that cURL library is available
  $curl_available = function_exists('curl_init');
  $requirements['oauth_common_curl'] = array(
    'title' => $t('OAuth'),
    'value' => $curl_available ? $t('cURL library Enabled') : $t('cURL library not found'),
  );
  if (!$curl_available) {
    $requirements['oauth_common_curl'] += array(
      'severity' => REQUIREMENT_ERROR,
      'description' => $t("DrupalOAuthClient requires the PHP <a href='!curl_url'>cURL</a> library.", array(
        '!curl_url' => 'http://php.net/manual/en/curl.setup.php',
      )),
    );
  }
  if ($phase == 'runtime') {

    // Check that OAuth library has been placed at the libraries directory
    if (!module_exists('libraries')) {
      module_enable(array(
        'libraries',
      ));
    }
    if ($path = libraries_get_path('oauth')) {
      $library = $path . '/OAuth.php';
      $requirements['oauth_lib'] = array(
        'title' => $t('OAuth library'),
      );
      if (!file_exists($library)) {
        $requirements['oauth_lib']['value'] = $t('Missing');
        $requirements['oauth_lib']['description'] = $t('You must download it from ' . '<a href="https://github.com/juampy72/OAuth-PHP" target="_blank">Github</a> ' . 'at https://github.com/juampy72/OAuth-PHP and place it at !library', array(
          '!library' => $library,
        ));
        $requirements['oauth_lib']['severity'] = REQUIREMENT_ERROR;
      }
      else {
        $requirements['oauth_lib']['value'] = $t('Installed');
        $requirements['oauth_lib']['severity'] = REQUIREMENT_OK;
      }
    }
  }
  return $requirements;
}