You are here

function signup_node_view in Signup 7

Implements hook_node_view().

File

./signup.module, line 875
The Signup module (http://drupal.org/project/signup) manages replies to nodes. In particular, it's good for event management. Signup supports sending reminder emails and automatically closing signups for nodes with a start time, via the Event…

Code

function signup_node_view($node, $view_mode = 'full') {

  // If this is a signup node, figure out what (if anything) to print.
  // Only include any of this if we're trying to view the node as
  // a page, not during the view from comment validation, etc.
  if ($view_mode == 'full' && _signup_needs_output($node)) {
    $info_location = variable_get('signup_form_location', 'node');
    $list_location = variable_get('signup_display_signup_user_list', 'embed-view');
    if ($info_location == 'node' || $list_location == 'embed-view') {
      module_load_include('inc', 'signup', 'includes/node_output');
    }
    if ($info_location == 'node') {
      $signup_info = _signup_node_output($node);
      if (!empty($signup_info)) {
        if (module_exists('content')) {

          // Due to a bug in CCK (http://drupal.org/node/363456), we need
          // to call this function twice to ensure we get the real value.
          // The bug is present when you first enable the setting to
          // display in the node instead of a separate tab, or when you
          // first upgrade to the version that contains this code.
          content_extra_field_weight($node->type, 'signup_node_info');
          $weight = content_extra_field_weight($node->type, 'signup_node_info');
        }
        else {
          $weight = variable_get('signup_info_node_weight_' . $node->type, 10);
        }
        $node->content['signup'] = array(
          '#markup' => $signup_info,
          '#weight' => $weight,
        );
      }
    }
    if ($list_location == 'embed-view') {
      $signup_list = signup_user_list_output($node);
      if (!empty($signup_list)) {
        if (module_exists('content')) {

          // Call this twice to work-around a bug in CCK (#363456).
          content_extra_field_weight($node->type, 'signup_node_list');
          $weight = content_extra_field_weight($node->type, 'signup_node_list');
        }
        else {
          $weight = variable_get('signup_list_node_weight_' . $node->type, 11);
        }
        $node->content['signup_list'] = array(
          '#markup' => $signup_list,
          '#weight' => $weight,
        );
      }
    }
  }
}