| 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
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.
#2
Revised patch; this quells warnings when prior node versions don't have casetracker data.
#3
Revised patch; this adds support for showing diffs in the "Assigned to" field.
#4
Revised again, to handle when a case is changed from unassigned to assigned.