You are here

function twitter_post_form in Twitter 7.4

Same name and namespace in other branches
  1. 6.5 twitter_post/twitter_post.module \twitter_post_form()
  2. 6.3 twitter_post/twitter_post.module \twitter_post_form()
  3. 6.4 twitter_post/twitter_post.module \twitter_post_form()
  4. 7.3 twitter_post/twitter_post.module \twitter_post_form()
  5. 7.5 twitter_post/twitter_post.module \twitter_post_form()

Generate a twitter posting form for the given user.

Parameters

$account: A Drupal user object.

1 call to twitter_post_form()
twitter_post_form_alter in twitter_post/twitter_post.module
Implements hook_form_alter().

File

twitter_post/twitter_post.module, line 120
Main hooks for twitter post module

Code

function twitter_post_form($account = NULL) {
  drupal_add_js(drupal_get_path('module', 'twitter_post') . '/twitter_post.js');
  if (empty($account)) {
    $account = user_load($GLOBALS['user']->uid);
  }
  if (!user_access('post to twitter', $account)) {
    return;
  }
  $options = array();
  foreach ($account->twitter_accounts as $twitter_account) {
    $options[$twitter_account->id] = $twitter_account->screen_name;
  }
  if (count($options)) {
    $form = array();
    $form['status'] = array(
      '#type' => 'textfield',
      '#id' => 'twitter-textfield',
    );
    if (count($options) > 1) {
      $form['account'] = array(
        '#type' => 'select',
        '#title' => t('Account'),
        '#options' => $options,
        '#id' => 'twitter-account',
      );
    }
    else {
      $options_keys = array_keys($options);
      $form['account'] = array(
        '#type' => 'value',
        '#value' => array_pop($options_keys),
      );
    }
    return $form;
  }
}