You are here

function signup_broadcast_form in Signup 5.2

Same name and namespace in other branches
  1. 6.2 includes/broadcast.inc \signup_broadcast_form()
  2. 6 includes/broadcast.inc \signup_broadcast_form()
  3. 7 includes/broadcast.inc \signup_broadcast_form()

Form builder for the signup broadcast form.

Parameters

$node: The node that the broadcast form is being attached to.

1 string reference to 'signup_broadcast_form'
signup_menu in ./signup.module
Implementation of hook_menu().

File

./signup.module, line 2612
The Signup module (http://drupal.org/project/signup) manages replies to nodes. In particular, it's good for event management. Signup supports sending reminder emails and automatically closing signups for nodes with a start time, via the Event…

Code

function signup_broadcast_form($node) {

  // Seems lame we need this here, but apparently, we do. :(
  drupal_set_title(check_plain($node->title));
  $addresses = signup_get_email_addresses($node->nid);
  if (empty($addresses)) {
    $form['no_users'] = array(
      '#value' => t('No users have signup up for this %node_type.', array(
        '%node_type' => node_get_types('name', $node->type),
      )),
    );
    return $form;
  }
  $tokens = array(
    '%node_title',
    '%node_url',
    '%user_name',
    '%user_mail',
  );
  $tokens = array_merge($tokens, signup_extra_tokens($node));
  sort($tokens);
  if (module_exists('token')) {
    $token_text = t('Supported string substitutions: %tokens, and any tokens in the %replacement_tokens list.', array(
      '%tokens' => implode(', ', $tokens),
      '%replacement_tokens' => t('Replacement tokens'),
    ));
  }
  else {
    $token_text = t('Supported string substitutions: %tokens.', array(
      '%tokens' => implode(', ', $tokens),
    ));
  }
  $form['subject'] = array(
    '#type' => 'textfield',
    '#title' => t('Subject'),
    '#required' => TRUE,
  );
  $form['message'] = array(
    '#type' => 'textarea',
    '#title' => t('Message body'),
    '#required' => TRUE,
    '#description' => t('Body of the email message you wish to send to all users who have signed up for this %node_type. !token_description', array(
      '%node_type' => node_get_types('name', $node->type),
      '!token_description' => $token_text,
    )),
    '#rows' => 10,
  );
  if (module_exists('token')) {
    _signup_token_help($form, 'message_tokens_fieldset');
  }
  $form['copy'] = array(
    '#type' => 'checkbox',
    '#title' => t('Send yourself a copy.'),
  );
  $form['send'] = array(
    '#type' => 'submit',
    '#value' => t('Send'),
  );
  $form['nid'] = array(
    '#type' => 'value',
    '#value' => $node->nid,
  );
  global $user;
  if (user_access('administer site configuration')) {
    $form['from'] = array(
      '#type' => 'textfield',
      '#title' => t('From'),
      '#required' => TRUE,
      '#default_value' => $user->mail,
      '#weight' => '-10',
    );
  }
  else {
    $form['from'] = array(
      '#value' => t('This message will be sent from: %from', array(
        '%from' => $user->mail,
      )),
      '#pre' => '<strong>',
      '#post' => '</strong>',
    );
  }
  return $form;
}