You are here

function theme_casetracker_case_summary in Case Tracker 6

Same name and namespace in other branches
  1. 5 casetracker.module \theme_casetracker_case_summary()
  2. 7 casetracker.module \theme_casetracker_case_summary()

Theme the case summary shown at the beginning of a case's node.

Parameters

$case: The node object of the case being viewed.

$project: The node object of the project this case belongs to.

1 theme call to theme_casetracker_case_summary()
casetracker_nodeapi in ./casetracker.module
Implementation of hook_nodeapi().

File

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

Code

function theme_casetracker_case_summary($case, $project) {
  $last_comment = db_result(db_query('SELECT last_comment_timestamp FROM {node_comment_statistics} WHERE nid = %d', $case->nid));
  $rows = array();

  // On node preview the form logic can't translate assign_to back to a uid for
  // us so we need to be able handle it either way.
  if (is_numeric($case->casetracker->assign_to)) {
    $assign_to = user_load(array(
      'uid' => $case->casetracker->assign_to,
    ));
  }
  else {
    $assign_to = user_load(array(
      'name' => $case->casetracker->assign_to,
    ));
  }
  if (empty($assign_to) || $assign_to->uid == 0) {
    $rows[] = array(
      t('Assigned to:'),
      '<em>' . t('Unassigned') . '</em>',
    );
  }
  else {
    $rows[] = array(
      t('Assigned to:'),
      theme('username', $assign_to),
    );
  }
  $rows[] = array(
    t('Created:'),
    t('!username at !date', array(
      '!username' => theme('username', $case),
      '!date' => format_date($case->created, 'medium'),
    )),
  );
  $rows[] = array(
    t('Status:'),
    t('<strong>@status</strong> (@type / Priority @priority)', array(
      '@status' => casetracker_case_state_load($case->casetracker->case_status_id, 'status'),
      '@type' => casetracker_case_state_load($case->casetracker->case_type_id, 'type'),
      '@priority' => casetracker_case_state_load($case->casetracker->case_priority_id, 'priority'),
    )),
  );

  // On node preview a case may not have a nid, so we use some placeholder text.
  $case_id = isset($case->nid) ? $case->nid : t("NEW");
  $rows[] = array(
    t('Case ID:'),
    l($project->title, 'node/' . $case->casetracker->pid) . ': ' . $project->nid . '-' . $case_id,
  );
  if ($last_comment != $case->created) {
    $rows[] = array(
      t('Last modified:'),
      format_date($last_comment, 'medium'),
    );
  }
  $output = '<div class="case">';
  $output .= theme('table', NULL, $rows, array(
    'class' => 'summary',
  ));
  $output .= '</div>';
  return $output;
}