You are here

function forward_page in Forward 6

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

Page

2 string references to 'forward_page'
forward_form_submit in ./forward.module
forward_menu in ./forward.module
Menu Hooks

File

./forward.module, line 516

Code

function forward_page() {
  if (module_exists('modalframe')) {

    // Send the Modal Frame javascript for parent windows to the page.
    modalframe_parent_js();

    // Add the client-side behaviors for the examples.
    drupal_add_js(drupal_get_path('module', 'modalframe_example') . '/modalframe_example.js');
  }
  drupal_set_html_head('<meta name="robots" content="noindex, nofollow" />');
  $nid = NULL;
  if (empty($_GET['path']) || $_GET['path'] == 'node/0') {
    return t('No path was selected to forward');
  }
  if (_forward_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(array(
      'nid' => $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(check_plain(t(variable_get('forward_epostcard_title', 'Send an e-Postcard'))));
  }
  else {
    $emailtype = 'page';
    $cid = '';
    if (!empty($_GET['cid'])) {
      $cid = '?cid=' . $_GET['cid'];
    }
    $form_state['values']['path'] .= $cid;
    drupal_set_title(check_plain(t(variable_get('forward_email_title', 'Forward this page'))));
  }
  return theme('forward_page', drupal_get_form('forward_form', $form_state['values']['path'], $node->title), $node);
}