You are here

function fb_user_admin_form_alter in Drupal for Facebook 6.3

Same name and namespace in other branches
  1. 7.3 fb_user.admin.inc \fb_user_admin_form_alter()

Not truly hook_form_alter(), this is called from fb_user_form_alter().

1 call to fb_user_admin_form_alter()
fb_user_form_alter in ./fb_user.module
Implements hook_form_alter().

File

./fb_user.admin.inc, line 111
Admin pages and forms for user settings.

Code

function fb_user_admin_form_alter(&$form, &$form_state, $form_id) {

  // Add our settings to the fb_app edit form.
  if (isset($form['fb_app_data'])) {
    $fb_app = $form['#fb_app'];
    $fb_user_data = _fb_user_get_config($fb_app);
    $form['fb_app_data']['fb_user'] = array(
      '#type' => 'fieldset',
      '#title' => t('Facebook user settings'),
      '#tree' => TRUE,
      '#collapsible' => TRUE,
      '#collapsed' => isset($fb_app->label),
    );
    $form['fb_app_data']['fb_user']['create_account'] = array(
      '#type' => 'radios',
      '#title' => t('Create local account'),
      '#description' => t('This option will create a local account and an entry in the fb_user table when a user authorizes a canvas page or connects using Facebook Connect.  If not, Drupal\'s built in user registration will still work.'),
      '#options' => array(
        FB_USER_OPTION_CREATE_NEVER => t('Do not create accounts automatically'),
        FB_USER_OPTION_CREATE_LOGIN => t('If user has authorized the app'),
      ),
      '#default_value' => $fb_user_data['create_account'],
      '#required' => TRUE,
    );
    $default = $fb_user_data['map_account'];
    if (!is_array($default)) {

      // This check is for backward compatibility.  Should be removed eventually.
      $default = array(
        $default,
      );
    }
    $form['fb_app_data']['fb_user']['map_account'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Map accounts'),
      '#description' => t('Mapping an account means creating an entry in the fb_user table.  This allows Drupal to know which Facebook id corresponds to which local uid. <br/>Matching based on email works when the email extended permission is requested and only if the user is not already mapped to another account.'),
      '#options' => array(
        FB_USER_OPTION_MAP_ALWAYS => t('Map account when both local uid and Facebook id are known'),
        FB_USER_OPTION_MAP_EMAIL => t('Map account when Facebook email exactly matches local account'),
      ),
      '#default_value' => $default,
    );
    $options = array(
      0 => t('<none>'),
    ) + user_roles(1);
    unset($options[DRUPAL_ANONYMOUS_RID]);
    unset($options[DRUPAL_AUTHENTICATED_RID]);

    // Choose a role to be granted to anyone who authorizes the app.
    $form['fb_app_data']['fb_user']['new_user_rid'] = array(
      '#type' => 'select',
      '#title' => t('Permanent role'),
      '#options' => $options,
      '#description' => t('When a local user has authorized the app, the user will be <em>permanently</em> granted this role, in addition to the default <em>authenticated user</em>.'),
      '#default_value' => $fb_user_data['new_user_rid'],
    );

    // Choose a role to be granted only while connected.
    $form['fb_app_data']['fb_user']['connected_user_rid'] = array(
      '#type' => 'select',
      '#title' => t('Temporary role only when connected <em>(advanced feature, use caution)</em>'),
      '#options' => $options,
      '#description' => t('Role granted <em>temporarily</em> while any user (even <em>Anonymous</em>) is connected to facebook. <br/><strong>Important:</strong> Create a role explicitly for this purpose.  Do not select a role that you assign to users on a permanent basis.'),
      '#default_value' => $fb_user_data['connected_user_rid'],
    );
  }
}