You are here

function forward_page in Forward 7

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

Page

3 string references to 'forward_page'
forward_form_submit in ./forward.module
@todo Please document this function.
forward_mail in ./forward.module
Implements hook_mail().
forward_menu in ./forward.module
Menu Hooks

File

./forward.module, line 516

Code

function forward_page() {

  // Tell SEO to ignore this page
  if (variable_get('forward_link_noindex', 1)) {
    $element = array(
      '#type' => 'html_tag',
      '#tag' => 'meta',
      '#attributes' => array(
        'name' => 'robots',
        'content' => 'noindex, nofollow',
      ),
    );
    drupal_add_html_head($element, 'forward_meta_noindex');
  }

  // Get node or path being forwarded
  $nid = NULL;
  if (empty($_GET['path']) || $_GET['path'] == 'node/0') {
    return t('No path was selected to forward');
  }
  if (url_is_external($_GET['path'])) {
    return t('You cannot forward an external URL.');
  }
  if (!empty($_GET['path'])) {
    $form_state['values']['path'] = drupal_get_normal_path($_GET['path']);
    $ret = preg_match("/^node\\/(.*)/i", $form_state['values']['path'], $matches);
    if ($ret == 1) {
      $nid = $matches[1];
    }
  }
  if (is_numeric($nid)) {

    // we have a node
    $node = node_load($nid);
    if (!node_access('view', $node)) {

      // Access is denied
      return drupal_access_denied();
    }
    $form_state['values']['path'] = 'node/' . $node->nid;
  }
  else {
    $args = explode('/', $form_state['values']['path']);
    if ($args[0] == 'admin') {
      return drupal_access_denied();
    }
    $node = new stdClass();
    $node->title = $form_state['values']['path'];
  }
  if ($form_state['values']['path'] == 'epostcard') {
    $emailtype = 'postcard';
    drupal_set_title(t(variable_get('forward_epostcard_title', 'Send an e-Postcard')));
  }
  else {
    $emailtype = 'page';
    if (!empty($_GET['cid'])) {
      $cid = '?cid=' . $_GET['cid'];
      $form_state['values']['path'] .= $cid;
    }
    drupal_set_title(t(variable_get('forward_email_title', 'Forward this page to a friend')));
  }
  return drupal_get_form('forward_form', $form_state['values']['path'], $node->title);
}