You are here

function forward_form in Forward 7

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.2 forward.module \forward_form()

Form

5 string references to 'forward_form'
forward_block_view in ./forward.module
Implements hook_block_view().
forward_menu in ./forward.module
Menu Hooks
forward_mollom_form_info in ./forward.module
Implements hook_mollom_form_info().
forward_node_view in ./forward.module
Generate links for pages
forward_page in ./forward.module
Page

File

./forward.module, line 586

Code

function forward_form($form, &$form_state, $path = NULL, $title = NULL, $nodeapi = FALSE) {
  global $base_url, $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,
      '#weight' => 10,
    );
  }
  $form['message']['instructions'] = array(
    '#type' => 'item',
    '#markup' => 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'),
      '#markup' => l($title, $path, $cid),
    );
  }
  $form['message']['subject'] = array(
    '#type' => 'item',
    '#title' => t('Message Subject'),
    '#markup' => 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' => '',
  );
  $form['message']['body'] = array(
    '#type' => 'item',
    '#title' => t('Message Body'),
    '#markup' => 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' => '',
  );
  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) {

    // 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;
}