You are here

function forward_form in Forward 7.2

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

Callback function for the forward Form

7 string references to 'forward_form'
forward_block_view in ./forward.module
Implements hook_block_view().
forward_form_alter in ./forward.module
Implements hook_form_alter().
forward_menu in ./forward.module
Implements hook_menu().
forward_mollom_form_info in ./forward.module
Implements hook_mollom_form_info().
forward_node_view in ./forward.module
Implements hook_node_view().

... See full list

File

./forward.module, line 369

Code

function forward_form($form, &$form_state, $path = NULL, $node = NULL, $nodeapi = FALSE) {
  global $base_url, $user;
  $emailtype = $path == 'epostcard' ? 'epostcard' : 'email';
  $cid = array();
  if (preg_match("/\\?cid=/i", $path) == 1) {
    $paths = explode('?cid=', $path);
    $cid = array(
      'fragment' => 'comment-' . $paths[1],
    );
    $path = $paths[0];
  }
  if (isset($node->type)) {
    $forward_link_type = variable_get('forward_link_type', 0) ? node_type_get_name($node->type) : t('page');
  }
  else {
    $forward_link_type = t('page');
  }
  if ($nodeapi == TRUE) {
    $form['message'] = array(
      '#type' => 'fieldset',
      '#title' => check_plain(t(variable_get('forward_link_title', 'Email this !type'), array(
        '!type' => $forward_link_type,
      ))),
      '#description' => '',
      '#collapsed' => TRUE,
      '#collapsible' => TRUE,
      '#weight' => 10,
    );
  }

  // Insert an H1 if for colorbox node overlay, otherwise the overlay appears without a title
  if (variable_get('forward_colorbox_enable', 0) && isset($_GET['overlay']) && $_GET['overlay'] == 'cboxnode') {
    $title = t(variable_get('forward_email_title', 'Forward this page to a friend'));
    $form['message']['extra_title'] = array(
      '#markup' => '<h1>' . $title . '</h1>',
    );
  }
  $form['message']['instructions'] = array(
    '#type' => 'item',
    '#markup' => filter_xss_admin(token_replace(t(variable_get('forward_instructions', '<p>Thank you for your interest in spreading the word on [site:name].</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>')))),
  );
  $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'),
    '#cols' => 50,
    '#rows' => 5,
    '#description' => t('Enter multiple addresses on separate lines or separate them with commas.'),
    '#required' => TRUE,
  );
  if ($emailtype == 'email' && $nodeapi == FALSE && isset($node->title)) {
    $form['message']['page'] = array(
      '#type' => 'item',
      '#title' => t('You are going to email the following'),
      '#markup' => l($node->title, $path, $cid),
    );
  }
  if (isset($node->type)) {
    $form['message']['subject'] = array(
      '#type' => 'item',
      '#title' => t('Message Subject'),
      '#markup' => token_replace(t(variable_get('forward_' . $emailtype . '_subject', '[forward:sender] has sent you a message from [site:name]')), array(
        'forward' => array(),
        'node' => $node,
      )),
      '#description' => '',
    );
    $form['message']['body'] = array(
      '#type' => 'item',
      '#title' => t('Message Body'),
      '#markup' => token_replace(t(variable_get('forward_' . $emailtype . '_message', '[forward:sender] thought you would like to see the [site:name] web site.')), array(
        'forward' => array(),
        'node' => $node,
      )),
      '#description' => '',
    );
  }
  else {
    $form['message']['subject'] = array(
      '#type' => 'item',
      '#title' => t('Message Subject'),
      '#markup' => token_replace(t(variable_get('forward_' . $emailtype . '_subject', '[forward:sender] has sent you a message from [site:name]')), array(
        'forward' => array(),
      )),
      '#description' => '',
    );
    $form['message']['body'] = array(
      '#type' => 'item',
      '#title' => t('Message Body'),
      '#markup' => token_replace(t(variable_get('forward_' . $emailtype . '_message', '[forward:sender] thought you would like to see the [site:name] web site.')), array(
        'forward' => array(),
      )),
      '#description' => '',
    );
  }
  if (variable_get('forward_message', 1) != 0) {
    $form['message']['message'] = array(
      '#type' => 'textarea',
      '#title' => t('Your Personal Message'),
      '#default_value' => '',
      '#cols' => 50,
      '#rows' => 5,
      '#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) {

    // When using a collapsible form on the node page, move submit button into fieldset
    $form['message']['actions'] = array(
      '#type' => 'actions',
    );
    $form['message']['actions']['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Send Message'),
    );
  }
  else {

    // When using a separate form page, use actions directly so Mollom knows where to place its content
    $form['actions'] = array(
      '#type' => 'actions',
    );
    $form['actions']['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Send Message'),
    );
  }
  if ($user->uid != 0) {
    if (user_access('override email address')) {
      $form['message']['email']['#default_value'] = $user->mail;
    }
    else {
      $form['message']['email']['#type'] = 'hidden';
      $form['message']['email']['#value'] = $user->mail;
    }
    $form['message']['name']['#default_value'] = $user->name;
  }
  return $form;
}