You are here

function forward_form in Forward 5

Same name and namespace in other branches
  1. 6 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

4 string references to 'forward_form'
forward_menu in ./forward.module
Menu Hooks
forward_nodeapi in ./forward.module
Generate nodeapi integration, foward signup
forward_page in ./forward.module
Form
forward_share_tab in ./forward.module
Implementation of hook_share_tab().

File

./forward.module, line 378

Code

function forward_form($path = NULL, $title = NULL, $nodeapi = FALSE) {
  global $base_url, $user;
  $form = array();
  $cid = NULL;
  if ($path == 'epostcard') {
    $emailtype = 'postcard';
  }
  else {
    $emailtype = 'email';
    if (!empty($_GET['cid'])) {
      $cid = 'comment-' . $_GET['cid'];
    }
  }
  if ($nodeapi == TRUE) {
    $form['message'] = array(
      '#type' => 'fieldset',
      '#title' => t('Forward this page to a friend'),
      '#description' => '',
      '#collapsed' => true,
      '#collapsible' => true,
    );
  }
  $form['instructions'] = array(
    '#type' => 'item',
    '#value' => 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['yemail'] = array(
    '#type' => 'textfield',
    '#title' => t('Your Email'),
    '#default_value' => $user->mail,
    '#size' => 58,
    '#maxlength' => 256,
    '#required' => true,
  );
  if ($user->mail && !user_access('override email address')) {
    $form['yemail']['#disabled'] = true;
    $form['yemail']['#value'] = $user->mail;
  }
  $form['yname'] = array(
    '#type' => 'textfield',
    '#title' => t('Your Name'),
    '#default_value' => $user->name,
    '#size' => 58,
    '#maxlength' => 256,
    '#required' => true,
  );
  $form['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.  You can only email up to !number recipients', array(
      '!number' => variable_get('forward_flood_control', 10),
    )),
    '#required' => true,
  );
  if ($emailtype == 'email' && $nodeapi == FALSE) {
    $form['page'] = array(
      '#type' => 'item',
      '#title' => t('You are going to email the following'),
      '#value' => l($title, $path, NULL, NULL, $cid),
    );
  }
  $form['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' => '',
  );
  $form['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' => '',
  );
  $form['message'] = array(
    '#type' => 'textarea',
    '#title' => t('Your Personal Message'),
    '#default_value' => '',
    '#cols' => 50,
    '#rows' => 10,
    '#description' => '',
    '#required' => true,
  );
  $form['path'] = array(
    '#type' => 'hidden',
    '#value' => $path,
  );
  $form['path_cid'] = array(
    '#type' => 'hidden',
    '#value' => !empty($cid) ? '#' . $cid : '',
  );
  $form['forward_footer'] = array(
    '#type' => 'hidden',
    '#value' => variable_get('forward_footer', ''),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Send Message'),
  );
  if ($nodeapi == TRUE) {
    $nodeapiform['message'] = array(
      '#type' => 'fieldset',
      '#title' => t('Forward this page to a friend'),
      '#description' => '',
      '#collapsed' => true,
      '#collapsible' => true,
    );
    foreach ($form as $key => $value) {
      $nodeapiform['message'][$key] = $value;
    }

    //print '<pre>'.print_r($nodeapiform,1).'</pre>';
    return $nodeapiform;
  }
  else {
    return $form;
  }
}