You are here

function fb_friend_select_process in Drupal for Facebook 7.4

1 string reference to 'fb_friend_select_process'
fb_element_info in ./fb.module
Implements hook_element_info().

File

./fb.module, line 592

Code

function fb_friend_select_process(&$element) {
  $element += array(
    '#fb_login_button' => array(
      'text' => t('Connect to Facebook'),
    ),
    // Text to render when javascript disabled.
    '#noscript' => t('Enable javascript to select your friends.'),
  );
  $fb_app = fb_get_app();

  // Without an active facebook app, the invite features cannot work.
  if (!$fb_app) {
    if (user_access('access administration pages')) {
      drupal_set_message(t('No Facebook Application configured.  The friend selector needs a <a href="!url">default application</a>.', array(
        '!url' => url(FB_PATH_ADMIN_CONFIG . '/settings/app'),
      )), 'error');
    }
    drupal_not_found();
    drupal_exit();
  }

  // Javascript required to render the names.
  if ($element['#noscript']) {
    $element['noscript'] = array(
      '#type' => 'markup',
      '#markup' => $element['#noscript'],
      '#prefix' => '<noscript>',
      '#suffix' => '</noscript>',
    );
  }

  // Show a connect button when user is not logged into facebook.
  $element['connect'] = array(
    '#type' => 'markup',
    '#markup' => theme('fb_login_button', $element['#fb_login_button']),
    '#prefix' => '<div class="fb_not_connected">',
    '#suffix' => '</div>',
  );

  // Add our module's javascript.
  drupal_add_library('system', 'ui.autocomplete');
  drupal_add_js(drupal_get_path('module', 'fb') . '/fb_friend_select.js', array(
    'type' => 'file',
    'scope' => 'header',
    'group' => JS_LIBRARY,
  ));
  $element['fb_names'] = array(
    '#type' => 'textfield',
    // '#title' => 'Foo',
    '#attributes' => array(
      'class' => array(
        'fb_friend_select_names',
        'fb_connected',
      ),
    ),
    // @todo default
    '#required' => $element['#required'],
  );

  // Pass requirement on to textfield.
  $element['#required'] = FALSE;
  $element['fb_uids'] = array(
    '#type' => 'hidden',
    //'#value' => array(), // @todo default.
    '#attributes' => array(
      'class' => array(
        'fb_friend_select_uids',
      ),
    ),
  );
  return $element;
}