You are here

function forward_form in Forward 6

Same name and namespace in other branches
  1. 5 forward.module \forward_form()
  2. 7.3 forward.module \forward_form()
  3. 7 forward.module \forward_form()
  4. 7.2 forward.module \forward_form()

Form

5 string references to 'forward_form'
forward_block in ./forward.module
Implementation of hook_block().
forward_menu in ./forward.module
Menu Hooks
forward_mollom_form_info in ./forward.module
Implements hook_mollom_form_info().
forward_nodeapi in ./forward.module
Generate nodeapi integration, foward signup
forward_page in ./forward.module
Page

File

./forward.module, line 578

Code

function forward_form(&$form_state, $path = NULL, $title = NULL, $nodeapi = FALSE) {
  global $user;
  $emailtype = $path == 'epostcard' ? 'epostcard' : 'email';
  $form = array();
  $cid = array();
  if (preg_match("/\\?cid=/i", $path) == 1) {
    $paths = explode('?cid=', $path);
    $cid = array(
      'fragment' => 'comment-' . $paths[1],
    );
    $path = $paths[0];
  }
  if ($nodeapi == TRUE) {
    $form['message'] = array(
      '#type' => 'fieldset',
      '#title' => check_plain(t(variable_get('forward_link_title', 'Email this !type'), array(
        '!type' => 'page',
      ))),
      '#description' => '',
      '#collapsed' => TRUE,
      '#collapsible' => TRUE,
    );
  }
  $form['message']['instructions'] = array(
    '#type' => 'item',
    '#value' => filter_xss_admin(t(variable_get('forward_instructions', '<p>Thank you for your interest in spreading the word on !site.</p><p>NOTE: We only request your email address so that the person you are recommending the page to knows that you wanted them to see it, and that it is not junk mail. We do not capture any email address.</p>'), array(
      '!site' => variable_get('site_name', 'drupal'),
    ))),
  );
  $form['message']['email'] = array(
    '#type' => 'textfield',
    '#title' => t('Your Email'),
    '#size' => 58,
    '#maxlength' => 256,
    '#required' => TRUE,
  );
  $form['message']['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Your Name'),
    '#size' => 58,
    '#maxlength' => 256,
    '#required' => TRUE,
  );
  $form['message']['recipients'] = array(
    '#type' => 'textarea',
    '#title' => t('Send To'),
    //'#default_value' => str_replace(', ', "\n", $recipients),
    '#cols' => 50,
    '#rows' => 5,
    '#description' => t('Enter multiple addresses on separate lines or separate them with commas.'),
    '#required' => TRUE,
  );
  if ($emailtype == 'email' && $nodeapi == FALSE) {
    $form['message']['page'] = array(
      '#type' => 'item',
      '#title' => t('You are going to email the following'),
      '#value' => l($title, $path, $cid),
    );
  }
  $form['message']['subject'] = array(
    '#type' => 'item',
    '#title' => t('Message Subject'),
    '#value' => t(variable_get('forward_' . $emailtype . '_subject', '!name has sent you a message from !site'), array(
      '!name' => t('(Your Name)'),
      '!site' => variable_get('site_name', 'drupal'),
    )),
    '#description' => '',
    '#attributes' => array(
      'id' => 'forward-page-subject',
    ),
  );
  $form['message']['body'] = array(
    '#type' => 'item',
    '#title' => t('Message Body'),
    '#value' => t(variable_get('forward_' . $emailtype . '_message', '!name thought you would like to see the !site web site.'), array(
      '!name' => t('(Your Name)'),
      '!site' => variable_get('site_name', 'drupal'),
    )),
    '#description' => '',
    '#attributes' => array(
      'id' => 'forward-page-body',
    ),
  );
  if (variable_get('forward_message', 1) != 0) {
    $form['message']['message'] = array(
      '#type' => 'textarea',
      '#title' => t('Your Personal Message'),
      '#default_value' => '',
      '#cols' => 50,
      '#rows' => 10,
      '#description' => '',
      '#required' => variable_get('forward_message', 1) == 2 ? TRUE : FALSE,
    );
  }
  $form['message']['path'] = array(
    '#type' => 'hidden',
    '#value' => $path,
  );
  $form['message']['path_cid'] = array(
    '#type' => 'hidden',
    '#value' => !empty($cid['fragment']) ? '#' . $cid['fragment'] : '',
  );
  $form['message']['forward_footer'] = array(
    '#type' => 'hidden',
    '#value' => variable_get('forward_footer', ''),
  );
  if ($nodeapi) {

    // Collapsible form, ensure submit button within collapsible section
    $form['message']['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Send Message'),
    );
  }
  else {

    // Standard linked page, allow optimal captcha placement
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Send Message'),
    );
  }
  if ($user->uid != 0) {
    $form['message']['email']['#type'] = 'hidden';
    $form['message']['email']['#value'] = $user->mail;
    $form['message']['name']['#default_value'] = $user->name;
  }
  return $form;
}