You are here

function twitter_post_form in Twitter 6.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. 7.3 twitter_post/twitter_post.module \twitter_post_form()
  4. 7.4 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
Implementation of hook_form_alter().

File

twitter_post/twitter_post.module, line 212
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', 'module');
  if (empty($account)) {
    global $user;
    $account = $user;
  }
  if (!user_access('post to twitter', $account)) {
    return;
  }
  $twitter_accounts = twitter_get_user_accounts($account->uid);
  $options = array();
  foreach ($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;
  }
}