You are here

function casetracker_node_view in Case Tracker 7

Implements hook_node_view().

File

./casetracker.module, line 324
Enables the handling of projects and their cases.

Code

function casetracker_node_view($node, $view_mode, $langcode) {
  if (casetracker_is_case($node->type)) {

    // On preview the case will be an array, we want an object.
    if (isset($node->in_preview) && $node->in_preview) {
      $node->casetracker = (object) $node->casetracker;
    }

    // used in the breadcrumb and our theme function, mostly for nid and project number display.
    $project = node_load($node->casetracker->pid);
    if ($view_mode == "full") {
      $trail = array(
        l(t('Home'), NULL),
        l(t('Case Tracker'), 'casetracker/projects'),
        l($project->title, "node/{$node->casetracker->pid}"),
        l(t('All cases'), "casetracker/cases/{$node->casetracker->pid}/all"),
      );
      drupal_set_breadcrumb($trail);
    }
    $node->content['casetracker_case_summary'] = array(
      '#theme' => 'casetracker_case_summary',
      '#case' => $node,
      '#project' => $project,
      '#weight' => -10,
    );
  }
  if (casetracker_is_project($node->type)) {
    if ($view_mode == "full") {
      $trail = array(
        l(t('Home'), NULL),
        l(t('Case Tracker'), 'casetracker/projects'),
      );
      drupal_set_breadcrumb($trail);
    }
    $node->content['casetracker_project_summary'] = array(
      '#theme' => 'casetracker_project_summary',
      '#project' => $node,
      '#weight' => -10,
    );
  }
}