You are here

function twitter_actions_set_status_action_form in Twitter 7.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. 6.4 twitter_actions/twitter_actions.module \twitter_actions_set_status_action_form()
  5. 7.6 twitter_actions/twitter_actions.module \twitter_actions_set_status_action_form()
  6. 7.3 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()

Returns a form definition so the Twitter 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 44
Exposes Drupal actions for sending Twitter messages.

Code

function twitter_actions_set_status_action_form($context) {
  $options = array();
  $results = db_query("SELECT screen_name FROM {twitter_account}");
  foreach ($results as $result) {
    $options[$result->screen_name] = $result->screen_name;
  }

  // Set default values for form.
  $form['screen_name'] = array(
    '#type' => 'select',
    '#title' => t('Twitter account name'),
    '#options' => $options,
    '#default_value' => isset($context['screen_name']) ? $context['screen_name'] : '',
    '#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' => isset($context['message']) ? $context['message'] : '',
    '#cols' => '80',
    '#rows' => '3',
    '#description' => t('The message that should be sent. You may include the following variables: ' . '%site_name, %username, %node_url, %node_type, %title, %summary, %body, ' . '%tinyurl. Not all variables will be available in all contexts.'),
    '#required' => TRUE,
  );
  return $form;
}