You are here

function fbconnect_form_alter in Facebook Connect 5

Same name and namespace in other branches
  1. 6.2 fbconnect.module \fbconnect_form_alter()
  2. 6 fbconnect.module \fbconnect_form_alter()

Impletementation of hook_form_alter.

File

./fbconnect.module, line 704
This module allows site visitors to connect and register with facebook account

Code

function fbconnect_form_alter($form_id, &$form) {
  if ($form_id == 'user_login' && $_GET['destination'] == 'fbconnect') {
    unset($_REQUEST['destination']);
    $msg = t('Please log in, in order to link your account with Facebook Connect');
    drupal_set_message($msg);
    $form['#submit']['fbconnect_redirect_submit'] = array();
    return;
  }

  // Render fbconnect on login form.
  if ($form_id == 'user_login_block' || $form_id == 'user_login') {
    $cnx_msg = t('Sign in using Facebook');
    $items[] = array(
      'data' => $cnx_msg . fbconnect_render_button(),
      'class' => 'fbconnect-button',
    );
    $form['fbconnect_button'] = array(
      '#value' => theme('item_list', $items),
      '#attributes' => array(
        'class' => 'fbconnect-button',
      ),
      '#weight' => 1,
    );
  }

  // Warning msg on user edit.
  if ($form_id == 'user_edit' && variable_get('user_pictures', 0)) {
    if (fbconnect_user_avatar_setting(arg(1))) {
      $msg = t('You are currently using your Facebook picture, if you delete or load a new picture, your facebook picture will no longer be updated.');
      drupal_set_message($msg);
    }
    $form['#submit']['fbconnect_user_edit_submit'] = array();
  }
  if (!fbconnect_get_fbuid()) {
    return;
  }

  // Facebook feed checkbox on comment form.
  if ($form_id == 'comment_form' && variable_get('fbconnect_com_feed', NULL)) {
    $text = fbconnect_render_fb_favicon() . t('Publish Facebook story feed');
    $form['fbconnect_feed'] = array(
      '#type' => 'checkbox',
      '#title' => $text,
      '#default_value' => 1,
      '#weight' => 0,
    );
    $form['#submit']['fbconnect_comment_feed_submit'] = array();
  }
}