You are here

function disqus_sso_disqus_settings in Disqus 7

Computes the full settings associated with Disqus SSO.

These need to be merged into the settings for basic Disqus integration for actual usage.

Parameters

object|null $account:

Return value

array

1 call to disqus_sso_disqus_settings()
disqus_element_post_render in ./disqus.module
Post render function of the Disqus element to inject the Disqus JavaScript.

File

./disqus.module, line 915
The Disqus Drupal module.

Code

function disqus_sso_disqus_settings($account = NULL) {
  if (!isset($account)) {
    global $user;
    $account = $user;
  }
  $disqus['sso'] = array(
    'name' => variable_get('site_name', t('Drupal')),
    // The login window must be closed once the user logs in.
    'url' => url('user/login', array(
      'query' => array(
        'destination' => 'disqus/closewindow',
      ),
      'absolute' => TRUE,
    )),
    // The logout link must redirect back to the original page.
    'logout' => url('user/logout', array(
      'query' => array(
        'destination' => $_GET['q'],
      ),
      'absolute' => TRUE,
    )),
    'width' => 800,
    'height' => 600,
  );
  $managed_logo = variable_get('disqus_logo', '');
  $use_site_logo = variable_get('disqus_use_site_logo', TRUE);
  if (!$use_site_logo && $managed_logo != FALSE) {
    $disqus['sso']['button'] = file_create_url(file_load($managed_logo)->uri);
  }
  elseif ($logo = theme_get_setting('logo')) {
    $disqus['sso']['button'] = $logo;
  }
  else {
    $disqus['sso']['button'] = url('misc/druplicon.png', array(
      'absolute' => TRUE,
    ));
  }
  if ($favicon = theme_get_setting('favicon')) {
    $disqus['sso']['icon'] = $favicon;
  }

  // Stick the authentication requirements and data in the settings.
  $disqus['api_key'] = variable_get('disqus_publickey', '');
  $disqus['remote_auth_s3'] = disqus_sso_key_encode(disqus_sso_user_data($account));
  return $disqus;
}