You are here

function drupagram_actions_set_status_action_form in Drupagram 7

Returns a form definition so the Instagram action can be configured.

Parameters

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

Return value

Form definition.

File

drupagram_actions/drupagram_actions.module, line 44
Exposes Drupal actions for sending Instagram messages.

Code

function drupagram_actions_set_status_action_form($context) {
  $options = array();
  $results = db_query("SELECT username FROM {drupagram_account}");
  foreach ($results as $result) {
    $options[$result->username] = $result->username;
  }

  // Set default values for form.
  $form['username'] = array(
    '#type' => 'select',
    '#title' => t('Instagram account name'),
    '#options' => $options,
    '#default_value' => isset($context['username']) ? $context['username'] : '',
    '#required' => TRUE,
  );
  if (!count($options)) {
    $form['username']['#description'] = t('You first need to add a Instagram account to one of ' . 'your users with rights for posting to Instagram.');
  }
  $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;
}