<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.3 |
+ | CiviCRM version 4.4 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2013 |
+--------------------------------------------------------------------+
protected $loggingDB;
function __construct() {
+ // don’t display the ‘Add these Contacts to Group’ button
+ $this->_add2groupSupported = FALSE;
+
+ $dsn = defined('CIVICRM_LOGGING_DSN') ? DB::parseDSN(CIVICRM_LOGGING_DSN) : DB::parseDSN(CIVICRM_DSN);
+ $this->loggingDB = $dsn['database'];
+
+ // used for redirect back to contact summary
+ $this->cid = CRM_Utils_Request::retrieve('cid', 'Integer', CRM_Core_DAO::$_nullObject);
+
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
),
);
- // don’t display the ‘Add these Contacts to Group’ button
- $this->_add2groupSupported = FALSE;
-
- $dsn = defined('CIVICRM_LOGGING_DSN') ? DB::parseDSN(CIVICRM_LOGGING_DSN) : DB::parseDSN(CIVICRM_DSN);
- $this->loggingDB = $dsn['database'];
-
- // used for redirect back to contact summary
- $this->cid = CRM_Utils_Request::retrieve('cid', 'Integer', CRM_Core_DAO::$_nullObject);
-
$logging = new CRM_Logging_Schema;
- $customTables = $logging->customDataLogTables();
+
+ // build _logTables for contact custom tables
+ $customTables = $logging->entityCustomDataLogTables('Contact');
foreach ($customTables as $table) {
$this->_logTables[$table] = array('fk' => 'entity_id', 'log_type' => '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'
+ );
+ }
+
+ // allow log tables to be extended via report hooks
+ CRM_Report_BAO_Hook::singleton()->alterLogTables($this, $this->_logTables);
+
parent::__construct();
}
$rows = array();
$tempColumns = "id int(10)";
- if (CRM_Utils_Array::value('log_action', $this->_params['fields'])) {
+ if (!empty($this->_params['fields']['log_action'])) {
$tempColumns .= ", log_action varchar(64)";
}
$tempColumns .= ", log_type varchar(64), log_user_id int(10), log_date timestamp";
- if (CRM_Utils_Array::value('altered_contact', $this->_params['fields'])) {
+ if (!empty($this->_params['fields']['altered_contact'])) {
$tempColumns .= ", altered_contact varchar(128)";
}
$tempColumns .= ", altered_contact_id int(10), log_conn_id int(11), is_deleted tinyint(4)";
- if (CRM_Utils_Array::value('display_name', $this->_params['fields'])) {
+ if (!empty($this->_params['fields']['display_name'])) {
$tempColumns .= ", display_name varchar(128)";
}
}
function getLogType($entity) {
- if (CRM_Utils_Array::value('log_type', $this->_logTables[$entity])) {
+ if (!empty($this->_logTables[$entity]['log_type'])) {
return $this->_logTables[$entity]['log_type'];
}
$logType = ucfirst(substr($entity, strrpos($entity, '_') + 1));
}
function getEntityValue($id, $entity, $logDate) {
- if (CRM_Utils_Array::value('bracket_info', $this->_logTables[$entity])) {
- if (CRM_Utils_Array::value('entity_column', $this->_logTables[$entity]['bracket_info'])) {
- $logTable = CRM_Utils_Array::value('table_name', $this->_logTables[$entity]) ? $this->_logTables[$entity]['table_name'] : $entity;
+ if (!empty($this->_logTables[$entity]['bracket_info'])) {
+ if (!empty($this->_logTables[$entity]['bracket_info']['entity_column'])) {
+ $logTable = !empty($this->_logTables[$entity]['table_name']) ? $this->_logTables[$entity]['table_name'] : $entity;
$sql = "
SELECT {$this->_logTables[$entity]['bracket_info']['entity_column']}
FROM `{$this->loggingDB}`.{$logTable}
}
function getEntityAction($id, $connId, $entity, $oldAction) {
- if (CRM_Utils_Array::value('action_column', $this->_logTables[$entity])) {
+ if (!empty($this->_logTables[$entity]['action_column'])) {
$sql = "select {$this->_logTables[$entity]['action_column']} from `{$this->loggingDB}`.{$entity} where id = %1 AND log_conn_id = %2";
$newAction = CRM_Core_DAO::singleValueQuery($sql, array(
1 => array($id, 'Integer'),