function fb_user_form_alter in Drupal for Facebook 5
Same name and namespace in other branches
- 5.2 fb_user.module \fb_user_form_alter()
- 6.3 fb_user.module \fb_user_form_alter()
- 6.2 fb_user.module \fb_user_form_alter()
- 7.3 fb_user.module \fb_user_form_alter()
File
- ./
fb_user.module, line 561 - This module allows Drupal user records to be associated with Facebook user ids. It can create local user accounts when Facebook users visit an application's canvas pages.
Code
function fb_user_form_alter($form_id, &$form) {
//drupal_set_message("fb_user_form_alter($form_id) " . dpr($form, 1));
// Add our settings to the fb_app edit form.
if (is_array($form['fb_app_data'])) {
$node = $form['#node'];
$fb_app_data = fb_app_get_data($node->fb_app);
$fb_user_data = $fb_app_data['fb_user'];
$form['fb_app_data']['fb_user'] = array(
'#type' => 'fieldset',
'#title' => t('Facebook user settings'),
'#tree' => TRUE,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['fb_app_data']['fb_user']['require_login'] = array(
'#type' => 'radios',
'#title' => t('Require Login'),
'#description' => t('When viewing canvas pages, how strict do you want to be? Most FBML applications will not want \'Allow anyone\' because facebook allows no persistent session; features like drupal_set_message() will not work properly. Also facebook does not allow form submissions unless the user logs in.'),
'#options' => array(
FB_USER_OPTION_ALLOW_ANON => t('Allow anyone'),
FB_USER_OPTION_REQUIRE_LOGIN => t('Allow logged-in users'),
FB_USER_OPTION_REQUIRE_ADD => t('Allow users who have added this app to their profile'),
),
'#default_value' => $fb_user_data['require_login'],
'#required' => TRUE,
);
// TODO: fix this so that it prompts for username with autocomplete, not a uid.
$form['fb_app_data']['fb_user']['not_logged_in_uid'] = array(
'#type' => 'textfield',
'#title' => t('Not logged in user (uid)'),
'#description' => t('If allowing non-logged in users, when such a user visits the site, which Drupal user should they be treated as? Use 0 for the anonymous user (recommended - this feature is experimental and likely to disappear).'),
'#default_value' => $fb_user_data['not_logged_in_uid'],
);
$form['fb_app_data']['fb_user']['logged_in_uid'] = array(
'#type' => 'textfield',
'#title' => t('Logged in user (uid)'),
'#description' => t('If allowing logged in users, when such a user visits the site, and they do not have a local Drupal account, which Drupal user should they be treated as? Use 0 for the Anonymous user, or create a dedicated account for this purpose.'),
'#default_value' => $fb_user_data['logged_in_uid'],
);
$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 automatically and map the local account to the Facebook account. This happens whenever the user visits a canvas page, except user/ pages and the landing page for anonymous users.'),
'#options' => array(
FB_USER_OPTION_CREATE_NEVER => t('Never (user/register page will still work)'),
FB_USER_OPTION_CREATE_LOGIN => t('If user has logged in'),
FB_USER_OPTION_CREATE_ADD => t('If user has added this app'),
),
'#default_value' => $fb_user_data['create_account'],
'#required' => TRUE,
);
$form['fb_app_data']['fb_user']['map_account'] = array(
'#type' => 'radios',
'#title' => t('Map Accounts'),
'#description' => t('This option maps a Facebook account to a previously created local account, when a user logs in or registers via a canvas page.'),
'#options' => array(
FB_USER_OPTION_MAP_NEVER => t('Never map accounts'),
FB_USER_OPTION_MAP_ALWAYS => t('Map account when user logs in or registers'),
),
'#default_value' => $fb_user_data['map_account'],
'#required' => TRUE,
);
// TODO: prompt for role with a select. Don't make user figure out id
$form['fb_app_data']['fb_user']['new_user_rid'] = array(
'#type' => 'select',
'#title' => t('New user role'),
'#options' => user_roles(1),
'#description' => t('When a user has added this application, they will receive this role.'),
'#default_value' => $fb_user_data['new_user_rid'],
);
$form['fb_app_data']['fb_user']['unique_account'] = array(
'#type' => 'checkbox',
'#title' => t('Make Local Account Unique'),
'#description' => t('When creating a local account, a unique account will apply only to this app. A non-unique account will be shared by all apps which do not have this checked.'),
'#default_value' => $fb_user_data['unique_account'],
);
}
}