You are here

function fboauth_settings_form in Facebook OAuth (FBOAuth) 7

Same name and namespace in other branches
  1. 6 includes/fboauth.pages.inc \fboauth_settings_form()
  2. 7.2 includes/fboauth.pages.inc \fboauth_settings_form()

Menu callback; Display the settings form for Facebook OAuth.

1 string reference to 'fboauth_settings_form'
fboauth_menu in ./fboauth.module
Implements hook_menu().

File

includes/fboauth.pages.inc, line 11
Administrative pages and functions for Facebook OAuth module.

Code

function fboauth_settings_form($form, &$form_state) {
  module_load_include('inc', 'fboauth', 'includes/fboauth.fboauth');
  $form['fboauth_id'] = array(
    '#type' => 'textfield',
    '#title' => t('App ID'),
    '#size' => 20,
    '#maxlengh' => 50,
    '#description' => t('To use Facebook connect, a Facebook Application must be created. Set up your app in <a href="http://www.facebook.com/developers/apps.php">my apps</a> on Facebook.') . ' ' . t('Enter your App ID here.'),
    '#default_value' => variable_get('fboauth_id', ''),
  );
  $form['fboauth_secret'] = array(
    '#type' => 'textfield',
    '#title' => t('App Secret'),
    '#size' => 40,
    '#maxlengh' => 50,
    '#description' => t('To use Facebook connect, a Facebook Application must be created. Set up your app in <a href="http://www.facebook.com/developers/apps.php">my apps</a> on Facebook.') . ' ' . t('Enter your App Secret here.'),
    '#default_value' => variable_get('fboauth_secret', ''),
  );
  $form['fboauth_anon_connect'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow anonymous users to connect an existing unconnected drupal account to their Facebook account?'),
    '#description' => t('Should anonymous users be able to connect an existing unconnected drupal account to a Facebook account based solely on an email address match?'),
    '#default_value' => variable_get('fboauth_anon_connect', TRUE),
  );
  $form['fboauth_basic_mapping'] = array(
    '#type' => 'fieldset',
    '#title' => t('Basic mapping'),
  );
  $form['fboauth_basic_mapping']['fboauth_user_email'] = array(
    '#type' => 'checkbox',
    '#title' => t('Import Facebook e-mail address'),
    '#description' => t('Importing Facebook e-mail addresses requires additional confirmation from the end-user, but it is <strong>strongly recommended</strong> to ensure proper user functionality (password reset, newsletter functionality, etc). If not used, providing a user with some kind of proxy e-mail address is recommended.'),
    '#default_value' => variable_get('fboauth_user_email', TRUE),
  );
  $form['fboauth_basic_mapping']['fboauth_user_picture'] = array(
    '#type' => 'checkbox',
    '#title' => t('Import Facebook user picture'),
    '#description' => t('Import the Facebook picture to the built-in user picture.'),
    '#default_value' => variable_get('fboauth_user_picture', 'picture') === 'picture',
    '#return_value' => 'picture',
    '#access' => variable_get('user_pictures', 0),
  );
  $form['fboauth_basic_mapping']['fboauth_user_username'] = array(
    '#type' => 'radios',
    '#title' => t('User name import'),
    '#options' => array(
      'username' => t('Facebook username (i.e. johnsmith)'),
      'name' => t('Real name (i.e. John Smith)'),
    ),
    '#description' => t('Select the Facebook value used to set the user\'s name when connecting with Facebook.'),
    '#default_value' => variable_get('fboauth_user_username', 'username'),
  );

  // If Profile module exists, allow mapping of individual properties.
  if (module_exists('profile')) {
    module_load_include('inc', 'fboauth', 'includes/fboauth.profile');
    fboauth_profile_form_alter($form, $form_state);
  }

  // Add in Field module mapping options, which are always available.
  module_load_include('inc', 'fboauth', 'includes/fboauth.field');
  fboauth_field_form_alter($form, $form_state);
  $form['permissions'] = array(
    '#type' => 'fieldset',
    '#title' => t('Advanced permission settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#description' => t('If using profile mapping, the necessary permissions will automatically requested and these settings do not need adjustment. If handling mapping manually or integrating with a custom module, you may request additional permissions for your application here. Requesting more information from users may make them less likely to trust your website. Adding additional permissions after a user has connected will require additional confirmation of the new permissions upon next login. For more information about properties these, read the <a href="http://developers.facebook.com/docs/reference/api/user/">Facebook User API</a>. Note that enabling more permissions here <strong>does not import more data</strong>. It just makes this information available for you to access in a custom module.'),
    '#tree' => FALSE,
    '#weight' => 20,
  );
  $properties = fboauth_user_properties();
  $property_options = array();
  foreach ($properties as $property => $property_info) {
    $property_options[$property] = '[' . $property . '] ' . $property_info['label'];
  }
  $property_options['email'] .= ' (' . t('Strongly recommended to ensure proper account functionality.') . ')';
  $form['permissions']['fboauth_user_properties'] = array(
    '#title' => t('Request additional permission to the following'),
    '#type' => 'checkboxes',
    '#options' => $property_options,
    '#default_value' => variable_get('fboauth_user_properties', array()),
    '#description' => t('The following properties are always available: id, name, first_name, last_name, gender, locale, link, username, third_party_id, timezone, updated_time, and verified.'),
  );
  $connections = fboauth_user_connections();
  $connection_options = array();
  foreach ($connections as $connection => $connection_info) {
    $connection_options[$connection] = '[' . $connection . '] ' . $connection_info['label'];
  }
  $form['permissions']['fboauth_user_connections'] = array(
    '#title' => t('Connections and extended permissions'),
    '#type' => 'checkboxes',
    '#options' => $connection_options,
    '#default_value' => variable_get('fboauth_user_connections', array()),
    '#description' => t('Requesting this any of this information is rarely useful during the login process. It is often better to set up dedicated permission requests after the user has created an account for extended access.'),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#weight' => 100,
  );
  return $form;
}