You are here

function twitter_form in Twitter 6.2

Generate a twitter posting form for the given user.

Parameters

$account: A Drupal user object.

1 call to twitter_form()
twitter_form_alter in ./twitter.module
Implementation of hook_form_alter().

File

./twitter.inc, line 20
A wrapper API for the Twitter microblogging service.

Code

function twitter_form($account = NULL) {
  drupal_add_js(drupal_get_path('module', 'twitter') . '/twitter.js', 'module');
  if (empty($account)) {
    global $user;
    $account = $user;
  }
  $twitter_accounts = drupal_map_assoc(array_keys(twitter_get_user_accounts($account->uid, TRUE)));
  if (count($twitter_accounts)) {
    $form = array();
    $form['status'] = array(
      '#type' => 'textfield',
      '#id' => 'twitter-textfield',
    );
    if (count($twitter_accounts) > 1) {
      $form['account'] = array(
        '#type' => 'select',
        '#title' => t('Account'),
        '#options' => $twitter_accounts,
        '#id' => 'twitter-account',
      );
    }
    else {
      $form['account'] = array(
        '#type' => 'value',
        '#value' => array_pop(array_keys($twitter_accounts)),
      );
    }
    return $form;
  }
}