You are here

function hybridauth_get_config in HybridAuth Social Login 7.2

Same name and namespace in other branches
  1. 6.2 hybridauth.module \hybridauth_get_config()
  2. 7 hybridauth.auth.inc \hybridauth_get_config()

Returns HybridAuth config.

1 call to hybridauth_get_config()
hybridauth_get_instance in ./hybridauth.module
Returns HybridAuth object or exception code.

File

./hybridauth.module, line 882
Main file for the HybridAuth module.

Code

function hybridauth_get_config() {
  $config =& drupal_static(__FUNCTION__, NULL);
  if (!isset($config)) {
    $logfile = file_directory_temp() . '/hybridauth.debug.log';
    $hybridauth_debug = variable_get('hybridauth_debug', FALSE);
    if ($hybridauth_debug && file_put_contents($logfile, PHP_EOL . 'HYBRIDAUTH DEBUG LOG START' . PHP_EOL . PHP_EOL, FILE_APPEND) === FALSE) {
      watchdog('hybridauth', 'Failed to write to debug log file @logfile.', array(
        '@logfile' => $logfile,
      ), WATCHDOG_ERROR);
      $hybridauth_debug = FALSE;
    }
    $config = array(
      'base_url' => url('hybridauth/endpoint', array(
        'absolute' => TRUE,
        'language' => _hybridauth_language_default(),
      )),
      'providers' => array(),
      'debug_mode' => $hybridauth_debug,
      'debug_file' => $logfile,
    );

    // Special case Facebook: we need to provide a language-aware base URL
    // because otherwise there is a redirect_uri mismatch in the Facebook SDK.
    if ($_GET['q'] === 'hybridauth/window/Facebook') {
      $config['base_url'] = url('hybridauth/endpoint', array(
        'absolute' => TRUE,
      ));
    }
    if ($proxy = variable_get('hybridauth_proxy', NULL)) {
      $config['proxy'] = $proxy;
    }
    foreach (hybridauth_get_enabled_providers() as $provider_id => $provider_name) {
      if ($provider_config = hybridauth_get_provider_config($provider_id)) {
        $config['providers'][$provider_id] = $provider_config;
      }
    }
  }
  return $config;
}