protected $loggingDB;
/**
- *
*/
public function __construct() {
// don’t display the ‘Add these Contacts to Group’ button
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
- $this->_logTables =
- array(
- 'log_civicrm_contact' => array(
- 'fk' => 'id',
+ $this->_logTables = array(
+ 'log_civicrm_contact' => array(
+ 'fk' => 'id',
+ ),
+ 'log_civicrm_email' => array(
+ 'fk' => 'contact_id',
+ 'log_type' => 'Contact',
+ ),
+ 'log_civicrm_phone' => array(
+ 'fk' => 'contact_id',
+ 'log_type' => 'Contact',
+ ),
+ 'log_civicrm_address' => array(
+ 'fk' => 'contact_id',
+ 'log_type' => 'Contact',
+ ),
+ 'log_civicrm_note' => array(
+ 'fk' => 'entity_id',
+ 'entity_table' => TRUE,
+ 'bracket_info' => array(
+ 'table' => 'log_civicrm_note',
+ 'column' => 'subject',
),
- 'log_civicrm_email' => array(
- 'fk' => 'contact_id',
- 'log_type' => 'Contact',
+ ),
+ 'log_civicrm_note_comment' => array(
+ 'fk' => 'entity_id',
+ 'table_name' => 'log_civicrm_note',
+ 'joins' => array(
+ 'table' => 'log_civicrm_note',
+ 'join' => "entity_log_civireport.entity_id = fk_table.id AND entity_log_civireport.entity_table = 'civicrm_note'",
),
- 'log_civicrm_phone' => array(
- 'fk' => 'contact_id',
- 'log_type' => 'Contact',
+ 'entity_table' => TRUE,
+ 'bracket_info' => array(
+ 'table' => 'log_civicrm_note',
+ 'column' => 'subject',
),
- 'log_civicrm_address' => array(
- 'fk' => 'contact_id',
- 'log_type' => 'Contact',
+ ),
+ 'log_civicrm_group_contact' => array(
+ 'fk' => 'contact_id',
+ 'bracket_info' => array(
+ 'entity_column' => 'group_id',
+ 'table' => 'log_civicrm_group',
+ 'column' => 'title',
),
- 'log_civicrm_note' => array(
- 'fk' => 'entity_id',
- 'entity_table' => TRUE,
- 'bracket_info' => array(
- 'table' => 'log_civicrm_note',
- 'column' => 'subject',
- ),
+ 'action_column' => 'status',
+ 'log_type' => 'Group',
+ ),
+ 'log_civicrm_entity_tag' => array(
+ 'fk' => 'entity_id',
+ 'bracket_info' => array(
+ 'entity_column' => 'tag_id',
+ 'table' => 'log_civicrm_tag',
+ 'column' => 'name',
),
- 'log_civicrm_note_comment' => array(
- 'fk' => 'entity_id',
- 'table_name' => 'log_civicrm_note',
- 'joins' => array(
- 'table' => 'log_civicrm_note',
- 'join' => "entity_log_civireport.entity_id = fk_table.id AND entity_log_civireport.entity_table = 'civicrm_note'",
- ),
- 'entity_table' => TRUE,
- 'bracket_info' => array(
- 'table' => 'log_civicrm_note',
- 'column' => 'subject',
- ),
+ 'entity_table' => TRUE,
+ ),
+ 'log_civicrm_relationship' => array(
+ 'fk' => 'contact_id_a',
+ 'bracket_info' => array(
+ 'entity_column' => 'relationship_type_id',
+ 'table' => 'log_civicrm_relationship_type',
+ 'column' => 'label_a_b',
),
- 'log_civicrm_group_contact' => array(
- 'fk' => 'contact_id',
- 'bracket_info' => array(
- 'entity_column' => 'group_id',
- 'table' => 'log_civicrm_group',
- 'column' => 'title',
- ),
- 'action_column' => 'status',
- 'log_type' => 'Group',
+ ),
+ 'log_civicrm_activity_for_target' => array(
+ 'fk' => 'contact_id',
+ 'table_name' => 'log_civicrm_activity',
+ 'joins' => array(
+ 'table' => 'log_civicrm_activity_contact',
+ 'join' => "(entity_log_civireport.id = fk_table.activity_id AND fk_table.record_type_id = {$targetID})",
),
- 'log_civicrm_entity_tag' => array(
- 'fk' => 'entity_id',
- 'bracket_info' => array(
- 'entity_column' => 'tag_id',
- 'table' => 'log_civicrm_tag',
- 'column' => 'name',
- ),
- 'entity_table' => TRUE,
+ 'bracket_info' => array(
+ 'entity_column' => 'activity_type_id',
+ 'options' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE),
),
- 'log_civicrm_relationship' => array(
- 'fk' => 'contact_id_a',
- 'bracket_info' => array(
- 'entity_column' => 'relationship_type_id',
- 'table' => 'log_civicrm_relationship_type',
- 'column' => 'label_a_b',
- ),
+ 'log_type' => 'Activity',
+ ),
+ 'log_civicrm_activity_for_assignee' => array(
+ 'fk' => 'contact_id',
+ 'table_name' => 'log_civicrm_activity',
+ 'joins' => array(
+ 'table' => 'log_civicrm_activity_contact',
+ 'join' => "entity_log_civireport.id = fk_table.activity_id AND fk_table.record_type_id = {$assigneeID}",
),
- 'log_civicrm_activity_for_target' => array(
- 'fk' => 'contact_id',
- 'table_name' => 'log_civicrm_activity',
- 'joins' => array(
- 'table' => 'log_civicrm_activity_contact',
- 'join' => "(entity_log_civireport.id = fk_table.activity_id AND fk_table.record_type_id = {$targetID})",
- ),
- 'bracket_info' => array(
- 'entity_column' => 'activity_type_id',
- 'options' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE),
- ),
- 'log_type' => 'Activity',
+ 'bracket_info' => array(
+ 'entity_column' => 'activity_type_id',
+ 'options' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE),
),
- 'log_civicrm_activity_for_assignee' => array(
- 'fk' => 'contact_id',
- 'table_name' => 'log_civicrm_activity',
- 'joins' => array(
- 'table' => 'log_civicrm_activity_contact',
- 'join' => "entity_log_civireport.id = fk_table.activity_id AND fk_table.record_type_id = {$assigneeID}",
- ),
- 'bracket_info' => array(
- 'entity_column' => 'activity_type_id',
- 'options' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE),
- ),
- 'log_type' => 'Activity',
+ 'log_type' => 'Activity',
+ ),
+ 'log_civicrm_activity_for_source' => array(
+ 'fk' => 'contact_id',
+ 'table_name' => 'log_civicrm_activity',
+ 'joins' => array(
+ 'table' => 'log_civicrm_activity_contact',
+ 'join' => "entity_log_civireport.id = fk_table.activity_id AND fk_table.record_type_id = {$sourceID}",
),
- 'log_civicrm_activity_for_source' => array(
- 'fk' => 'contact_id',
- 'table_name' => 'log_civicrm_activity',
- 'joins' => array(
- 'table' => 'log_civicrm_activity_contact',
- 'join' => "entity_log_civireport.id = fk_table.activity_id AND fk_table.record_type_id = {$sourceID}",
- ),
- 'bracket_info' => array(
- 'entity_column' => 'activity_type_id',
- 'options' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE),
- ),
- 'log_type' => 'Activity',
+ 'bracket_info' => array(
+ 'entity_column' => 'activity_type_id',
+ 'options' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE),
),
- 'log_civicrm_case' => array(
- 'fk' => 'contact_id',
- 'joins' => array(
- 'table' => 'log_civicrm_case_contact',
- 'join' => 'entity_log_civireport.id = fk_table.case_id',
- ),
- 'bracket_info' => array(
- 'entity_column' => 'case_type_id',
- 'options' => CRM_Case_PseudoConstant::caseType('title', FALSE),
- ),
+ 'log_type' => 'Activity',
+ ),
+ 'log_civicrm_case' => array(
+ 'fk' => 'contact_id',
+ 'joins' => array(
+ 'table' => 'log_civicrm_case_contact',
+ 'join' => 'entity_log_civireport.id = fk_table.case_id',
),
- );
+ 'bracket_info' => array(
+ 'entity_column' => 'case_type_id',
+ 'options' => CRM_Case_PseudoConstant::caseType('title', FALSE),
+ ),
+ ),
+ );
- $logging = new CRM_Logging_Schema;
+ $logging = new CRM_Logging_Schema();
// build _logTables for contact custom tables
$customTables = $logging->entityCustomDataLogTables('Contact');
// build _logTables for address custom tables
$customTables = $logging->entityCustomDataLogTables('Address');
foreach ($customTables as $table) {
- $this->_logTables[$table] =
- array(
- 'fk' => 'contact_id',// for join of fk_table with contact table
- 'joins' => array(
- 'table' => 'log_civicrm_address', // fk_table
- 'join' => 'entity_log_civireport.entity_id = fk_table.id',
- ),
- 'log_type' => 'Contact',
- );
+ $this->_logTables[$table] = array(
+ 'fk' => 'contact_id', // for join of fk_table with contact table
+ 'joins' => array(
+ 'table' => 'log_civicrm_address', // fk_table
+ 'join' => 'entity_log_civireport.entity_id = fk_table.id',
+ ),
+ 'log_type' => 'Contact',
+ );
}
// allow log tables to be extended via report hooks
$entityID = $id;
}
-
if ($entityID && $logDate &&
array_key_exists('table', $this->_logTables[$entity]['bracket_info'])
) {