You are here

function twitter_actions_set_status_action_form in Twitter 6.4

Same name and namespace in other branches
  1. 6.5 twitter_actions/twitter_actions.module \twitter_actions_set_status_action_form()
  2. 6.2 twitter_actions/twitter_actions.module \twitter_actions_set_status_action_form()
  3. 6.3 twitter_actions/twitter_actions.module \twitter_actions_set_status_action_form()
  4. 7.6 twitter_actions/twitter_actions.module \twitter_actions_set_status_action_form()
  5. 7.3 twitter_actions/twitter_actions.module \twitter_actions_set_status_action_form()
  6. 7.4 twitter_actions/twitter_actions.module \twitter_actions_set_status_action_form()
  7. 7.5 twitter_actions/twitter_actions.module \twitter_actions_set_status_action_form()

Return a form definition so the Send email action can be configured.

Parameters

$context: Default values (if we are editing an existing action instance).

Return value

Form definition.

File

twitter_actions/twitter_actions.module, line 34
Exposes Drupal actions for sending Twitter messages.

Code

function twitter_actions_set_status_action_form($context = array()) {

  // Set default values for form.
  $context += array(
    'account_id' => -1,
    'screen_name' => '',
    'message' => '',
  );
  $options = array();
  $results = db_query("SELECT screen_name FROM {twitter_account}");
  while ($row = db_fetch_array($results)) {
    $options[$row['screen_name']] = $row['screen_name'];
  }
  $form['screen_name'] = array(
    '#type' => 'select',
    '#title' => t('Twitter account name'),
    '#options' => $options,
    '#default_value' => $context['screen_name'],
    '#description' => t('The Twitter account which will be used to post to Twitter. It can be ' . 'added by editing a user account.'),
    '#required' => TRUE,
  );
  if (!count($options)) {
    $form['screen_name']['#description'] = t('You first need to add a Twitter account to one of ' . 'your users with rights for posting to Twitter.');
  }
  $form['message'] = array(
    '#type' => 'textarea',
    '#title' => t('Message'),
    '#default_value' => $context['message'],
    '#cols' => '80',
    '#rows' => '3',
    '#description' => t('The message that should be sent. The following tokens are available: ' . '%site_name, %username, %node_url, %node_type, %title, %teaser, %body, ' . '%tinyurl. Note that not all variables will be available in all contexts.'),
    '#required' => TRUE,
  );
  if (module_exists('token')) {
    $form['token_help'] = array(
      '#title' => t('Extra replacement tokens'),
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#description' => t('Prefer raw-text replacements for text to avoid problems with HTML entities!'),
    );
    $form['token_help']['help'] = array(
      '#value' => theme('token_help', 'node'),
    );
  }
  return $form;
}