Project:Case Tracker
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

Case Tracker 1.0-beta8 does not support the diff module, and does not support reversion of revisions. There are two issues that need to be addressed to create a solution. The first is that Case Tracker overwrites records in table {casetracker_case}, even when revisions are required. This is easily remedied with a change in casetracker_nodeapi() to create new records when $node->required is TRUE. The second is that support for hook_diff() is required.

I have implemented the following patch in my copy of casetracker.module in casetracker_nodeapi() in the case 'update': section. It creates a new entry -- not an overwrite -- when a new revision is created by passing in an empty array for the primary keys. This permits reversions to pick up the old state of Case Tracker-specific variables.

- $primary = $node->revision ? array('nid') : array('nid', 'vid');
+ $primary = $node->revision ? array() : array('nid', 'vid');

I added support for the diff module (sufficient for my purposes) in a custom module.

/**
* Implementation of hook_diff() for types that do not currently support diff
*/
function MyCustomModule_diff($old_node, $new_node) {
  $result = array();
  $type = $new_node->type;
  if ( $type == 'casetracker_basic_case' ) {
    $result['case_status'] = array(
      '#name' => 'Status',
      '#old' => array( casetracker_case_state_load( $old_node->casetracker->case_status_id, 'status') ),
      '#new' => array( casetracker_case_state_load( $new_node->casetracker->case_status_id, 'status') ),
    );
    $result['case_priority'] = array(
      '#name' => 'Priority',
      '#old' => array( casetracker_case_state_load( $old_node->casetracker->case_priority_id, 'priority') ),
      '#new' => array( casetracker_case_state_load( $new_node->casetracker->case_priority_id, 'priority') ),
    );
    $result['case_type'] = array(
      '#name' => 'Case Type',
      '#old' => array( casetracker_case_state_load( $old_node->casetracker->case_type_id, 'type') ),
      '#new' => array( casetracker_case_state_load( $new_node->casetracker->case_type_id, 'type') ),
    );
    $result['case_pid'] = array(
      '#name' => 'Case Project ID',
      '#old' => array( $old_node->casetracker->pid ),
      '#new' => array( $new_node->casetracker->pid ),
    );
  }
  return $result;
}

Comments

#1

Version:6.x-1.0-beta8» 6.x-1.x-dev
Status:active» needs review

I turned the above manual modifications into a patch against casetracker-6.x-1.x-dev. Also changed case_pid to show the project title instead of nid.

AttachmentSize
casetracker_diff-953736-1.patch 1.92 KB

#2

Revised patch; this quells warnings when prior node versions don't have casetracker data.

AttachmentSize
casetracker_diff-953736-2.patch 2.17 KB

#3

Revised patch; this adds support for showing diffs in the "Assigned to" field.

AttachmentSize
casetracker_diff-953736-3.patch 2.45 KB

#4

Revised again, to handle when a case is changed from unassigned to assigned.

AttachmentSize
casetracker_diff-953736-4.patch 2.51 KB
nobody click here