Details
Description
When a user views an Activity in a Case - if the Activity has prior revisions they should be able to follow a link to view a list of those revisions, and then be able to view any of those prior revisions.
Implementation
--------------------
1. Create a new BAO method for Case/Activity which detects whether a given activity record has 1 or more prior revisions. Input params are activityID and originalID from the record being viewed. The SQL for this is:
SELECT count( id ) AS cnt
FROM civicrm_activity
WHERE (id = $originalID OR original_id =545)
AND is_current_revision =0
If cnt > 0, assign $revisionURL value to ActivityView.tpl.
- If cnt = 1, this should link to ActivityView for that activity (the revision). Include a way for the template to know that a prior revision (not the latest one) is being viewed. Perhaps a GET param (cur=0) ??
- If cnt > 1 This should be a link to a new page (ActivityRevision) which simply lists all prior revisions of THIS activity record.
2. Create new page to "List Revisions" for a given activity. This page is a simple 3 column table listing:
Title = "Prior Revisions - $activitySubject".
Created By Created On
-------------- --------------------- -----------
Dr. Jay Ott October 1, 2008 View
Query to retrieve this listing is:
SELECT c.display_name, cl.modified_date, ca.id as activityID
FROM civicrm_log cl, civicrm_contact c, civicrm_activity ca
WHERE (ca.id = $originalID OR ca.original_id =$originalID)
AND ca.is_current_revision =0
AND cl.entity_id = ca.id
AND cl.modified_id = c.id
3. Clicking view from this listing goes to the existing ActivityView form (which is using the jquery overlay dialog) - but with data from the selected revision of the activity. As noted above, include some GET param so the template can display a link to "View current revision" in the 3rd cell of the 1st row.
Query to get activityID of current revision when looking at any other revision depends on whether prior revision is the "original" or an intermediate revision.The "original_id" will be NULL if this is the original copy - so in this case:
SELECT id from civicrm_activity where original_id = $thisActivityID and is_current_revision = 1
If original_id of the revision being reviewed is NOT NULL:
SELECT id from civicrm_activity where original_id = $thisActivityOriginalID and is_current_revision = 1