function twitter_post_form in Twitter 7.5
Same name and namespace in other branches
- 6.5 twitter_post/twitter_post.module \twitter_post_form()
- 6.3 twitter_post/twitter_post.module \twitter_post_form()
- 6.4 twitter_post/twitter_post.module \twitter_post_form()
- 7.3 twitter_post/twitter_post.module \twitter_post_form()
- 7.4 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 221 - Hook implementations for twitter_post module.
Code
function twitter_post_form($account = NULL) {
if (empty($account)) {
global $user;
$account = user_load($user->uid);
}
if (!user_access('post to twitter', $account)) {
return;
}
drupal_add_js(drupal_get_path('module', 'twitter_post') . '/twitter_post.js');
$access_global = user_access('post to twitter with global account', $account);
$twitter_accounts = twitter_load_authenticated_accounts($account->uid, $access_global);
// Only show Twitter accounts that are either global or are tied to this user.
$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),
'#id' => 'twitter-account',
);
}
return $form;
}
}