You are here

function theme_casetracker_comment_changes in Case Tracker 6

Same name and namespace in other branches
  1. 7 casetracker.module \theme_casetracker_comment_changes()

Displays the changes a comment has made to the case fields.

Parameters

$case_data: An array of both 'old' and 'new' objects that contains the before and after values this comment has changed.

1 theme call to theme_casetracker_comment_changes()
casetracker_comment in ./casetracker.module
Implementation of hook_comment().

File

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

Code

function theme_casetracker_comment_changes($old, $new) {
  $rows = array();
  $fields = array(
    'pid' => t('Project'),
    'title' => t('Title'),
    'case_status_id' => t('Status'),
    'assign_to' => t('Assigned'),
    'case_priority_id' => t('Priority'),
    'case_type_id' => t('Type'),
  );
  foreach ($fields as $field => $label) {
    if ($new->{$field} != $old->{$field}) {
      switch ($field) {
        case 'pid':
          $old_title = db_result(db_query("SELECT title FROM {node} WHERE nid = %d", $old->pid));
          $new_title = db_result(db_query("SELECT title FROM {node} WHERE nid = %d", $new->pid));
          $old->{$field} = l($old_title, "node/{$old->pid}");
          $new->{$field} = l($new_title, "node/{$new->pid}");
          break;
        case 'case_status_id':
          $old->{$field} = check_plain(casetracker_case_state_load($old->{$field}, 'status'));
          $new->{$field} = check_plain(casetracker_case_state_load($new->{$field}, 'status'));
          break;
        case 'assign_to':
          $old->{$field} = check_plain(casetracker_get_name($old->{$field}));
          $new->{$field} = check_plain(casetracker_get_name($new->{$field}));
          break;
        case 'case_priority_id':
          $old->{$field} = check_plain(casetracker_case_state_load($old->{$field}, 'priority'));
          $new->{$field} = check_plain(casetracker_case_state_load($new->{$field}, 'priority'));
          break;
        case 'case_type_id':
          $old->{$field} = check_plain(casetracker_case_state_load($old->{$field}, 'type'));
          $new->{$field} = check_plain(casetracker_case_state_load($new->{$field}, 'type'));
          break;
      }
      $rows[] = array(
        t('@label: !old » !new', array(
          '@label' => $label,
          '!old' => $old->{$field},
          '!new' => $new->{$field},
        )),
      );
    }
  }
  if (!empty($rows)) {
    return theme('table', NULL, $rows, array(
      'class' => 'case_changes',
    ));
  }
}