You are here

function fb_admin_settings in Drupal for Facebook 7.3

Same name and namespace in other branches
  1. 6.3 fb.admin.inc \fb_admin_settings()

Form callback for general settings.

1 string reference to 'fb_admin_settings'
fb_menu in ./fb.module
Implements hook_menu().

File

./fb.admin.inc, line 336
Admin pages and forms for Drupal for Facebook.

Code

function fb_admin_settings() {
  $form = array();

  // @TODO would be nice to automatically test whether HTTPS is supported.
  $form['fb_admin_secure'] = array(
    '#title' => t('Secure URLs'),
    '#type' => 'fieldset',
    '#description' => t('Canvas Pages and Page Tabs require a server that supports SSL encrypted HTTPS.  Without HTTPS, those features will only work in "sandbox mode."'),
  );
  $form['fb_admin_secure'][FB_VAR_SECURE_URLS] = array(
    '#type' => 'radios',
    '#title' => t('Use Secure URLs'),
    '#default_value' => variable_get(FB_VAR_SECURE_URLS, FB_SECURE_URLS_SOMETIMES),
    '#description' => t('This setting affects your applications\' website_url, canvas_url, secure_canvas_url, profile_tab_url, and secure_page_tab_url properties.'),
    '#options' => array(
      FB_SECURE_URLS_NEVER => t('Never use HTTPS. (I.e. this server does not support it.)'),
      FB_SECURE_URLS_SOMETIMES => t('Use HTTPS only when Facebook expects a secure URL. (Recommended.)'),
      FB_SECURE_URLS_ALWAYS => t('Always use HTTPS for both secure urls and also other url callbacks.'),
    ),
  );
  $form['fb_admin_session'] = array(
    '#title' => t('Sessions'),
    '#type' => 'fieldset',
    '#description' => t('Settings that control <a href="!auth_url" target=_blank>authentication</a> and session management when connected to Facebook.  These settings are relavant for Apps, but not Social Plugins.', array(
      '!auth_url' => 'http://developers.facebook.com/docs/authentication/',
    )),
    '#collapsible' => TRUE,
  );
  $form['fb_admin_session'][FB_VAR_USE_COOKIE] = array(
    '#type' => 'checkbox',
    '#title' => t('Use FB Cookie'),
    '#default_value' => variable_get(FB_VAR_USE_COOKIE, TRUE),
    '#description' => t('Tell Facebook\'s libraries to set and honor a cookie when user connects.  Makes facebook applications run smoother, but may fail when third-party cookies are denied by user\'s browser.'),
  );
  $form['fb_admin_session'][FB_VAR_USE_SESSION] = array(
    '#type' => 'checkbox',
    '#title' => t('Store tokens in session'),
    '#default_value' => variable_get(FB_VAR_USE_SESSION, TRUE),
    '#description' => t('Store tokens and data needed by facebook\'s libraries in Drupal\'s session.  Helps applications work even when third-party cookies are disabled.'),
  );
  $form['fb_admin_js'] = array(
    '#title' => t('Javascript'),
    '#type' => 'fieldset',
    '#description' => t('Settings that control the <a href="!url" target=_blank>Javascript SDK</a>. These settings are relavant for both Apps and not Social Plugins. <br/>The defaults are the recommended values.', array(
      '!url' => 'http://developers.facebook.com/docs/reference/javascript/',
    )),
    '#collapsible' => TRUE,
  );
  $form['fb_admin_js'][FB_VAR_JS_OAUTH] = array(
    '#type' => 'checkbox',
    '#title' => t('Use Oauth when initializing javascript.') . t(' - Deprecated'),
    '#default_value' => variable_get(FB_VAR_JS_OAUTH, TRUE),
    '#description' => t('Pass oauth TRUE to <a href=!url target=_blank>FB.init()</a>.  When checked, javascript SDK looks for new-style cookie named "fbsr_...".  When unchecked, looks for old-style cookie named "fbs_...".  When this and above options are unchecked, user will have to explicitly connect/disconnect from your site, logging in/out of facebook will not be automatically detected.', array(
      '!url' => 'http://developers.facebook.com/docs/reference/javascript/FB.init/',
    )),
    '#disabled' => TRUE,
  );
  $form['fb_admin_js'][FB_VAR_JS_GET_LOGIN_STATUS] = array(
    '#type' => 'checkbox',
    '#title' => t('Get login status when initializing javascript.'),
    '#default_value' => variable_get(FB_VAR_JS_GET_LOGIN_STATUS, TRUE),
    '#description' => t('Detect whether a connected user has logged into or out of facebook.  Uses FB.getLoginStatus().  This technique is recommended by Facebook; however, it has <a href=!url>bugs</a> and <a href=!url2>more bugs</a>.  If those bugs affect your site, you may want to disable this.', array(
      '!url' => 'http://developers.facebook.com/bugs/173032012783482',
      '!url2' => 'https://developers.facebook.com/bugs/240058389381072',
    )),
  );
  $form['fb_admin_js'][FB_VAR_JS_TEST_LOGIN_STATUS] = array(
    '#type' => 'checkbox',
    '#title' => t('Alternative verify login status when initializing javascript.') . t(' - Deprecated'),
    '#default_value' => variable_get(FB_VAR_JS_TEST_LOGIN_STATUS, FALSE),
    '#description' => t('When not using FB.getLoginStatus() (because it is <a href=!url target=_blank>buggy</a>) detect log out of facebook via a call to FB.api().  Does not detect a login (the user must explicitly click a connect button). This may add overhead on the client side to every page load.   This setting only takes effect when the setting above is unchecked.', array(
      '!url' => 'http://developers.facebook.com/bugs/173032012783482',
    )),
    '#disabled' => TRUE,
  );
  $form['fb_admin_js'][FB_VAR_JS_USE_SESSION] = array(
    '#type' => 'checkbox',
    '#title' => t('Use tokens in session to initialize javascript'),
    '#default_value' => variable_get(FB_VAR_JS_USE_SESSION, TRUE),
    '#description' => t('Pass access tokens in javascript settings.  This should help when browsers disable <a href=!url target=_blank>third-party cookies</a>.  However, it includes the access token in the page markup, where it could be intercepted if pages are not encrypted.', array(
      '!url' => 'http://developers.facebook.com/bugs/173032012783482',
    )),
  );
  $form['fb_username_performance'] = array(
    '#title' => t('Username Altering'),
    '#type' => 'fieldset',
    '#description' => t('Display human-readable names instead of <em>1234...@facebook</em>.  If some pages render very slowly, you may wish to disable username formatting.'),
    '#collapsible' => TRUE,
  );
  $form['fb_username_performance'][FB_VAR_ALTER_USERNAME] = array(
    '#type' => 'radios',
    '#title' => t('Alter Usernames'),
    '#default_value' => variable_get(FB_VAR_ALTER_USERNAME, FB_ALTER_USERNAME_NOT_THEMING),
    '#description' => t(''),
    '#options' => array(
      FB_ALTER_USERNAME_NEVER => t('<strong>Never</strong> - In email and page titles users might see unsightly names like <em>1234...@facebook</em>.'),
      FB_ALTER_USERNAME_NOT_THEMING => t('<strong>Smart</strong> - Change names in email and page titles, but skip in page markup.  Recommended; however, due to limitations of Drupal API, this only works when <a href=!url target=_blank>fb_connect.module overrides theme_username()</a>.', array(
        '!url' => url('admin/structure/fb/fb_connect'),
      )),
      FB_ALTER_USERNAME_ALWAYS => t('<strong>Always</strong> - May cause some pages to render slowly.'),
    ),
  );
  $form['fb_username_performance'][FB_VAR_ALTER_USERNAME_AND_CACHE] = array(
    '#type' => 'radios',
    '#title' => t('Cache Altered Usernames'),
    '#default_value' => variable_get(FB_VAR_ALTER_USERNAME_AND_CACHE, FB_ALTER_USERNAME_DONT_CACHE),
    '#description' => t(''),
    '#options' => array(
      FB_ALTER_USERNAME_AND_CACHE => t('<strong>On</strong> - Store names in local database, so that facebook servers are queried less often.'),
      FB_ALTER_USERNAME_DONT_CACHE => t('<strong>Off</strong> - Query facebook servers every time.  May impact performance.'),
    ),
  );
  $form['fb_admin_languages'] = array(
    '#title' => t('Languages and Locales'),
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
  );
  $form['fb_admin_languages'][FB_VAR_LANGUAGE_OVERRIDE] = array(
    '#title' => t("Use locale learned from facebook, if available."),
    '#type' => 'checkbox',
    '#return_value' => 'override',
    '#default_value' => variable_get(FB_VAR_LANGUAGE_OVERRIDE, 'override'),
    '#description' => t('Otherwise, use the mapping below when the local user\'s language is known.'),
  );
  foreach (language_list() as $language) {
    $form['fb_admin_languages']['fb_language_' . $language->language] = array(
      '#title' => t("Assigned Facebook's locale to @language", array(
        '@language' => t($language->name),
      )),
      '#type' => 'select',
      '#options' => fb_admin_i18n_list(),
      '#default_value' => variable_get('fb_language_' . $language->language, fb_admin_i18n_map($language->language)),
    );
  }
  return system_settings_form($form);
}