$contactIdClause = "AND id = (select case_id FROM civicrm_case_contact WHERE contact_id = %3 LIMIT 1)";
break;
default:
- $contactIdClause = "AND contact_id = %3";
+ // allow tables to be extended by report hook query objects
+ list($contactIdClause, $join) = CRM_Report_BAO_Hook::singleton()->logDiffClause($this, $table);
+
+ if (empty($contactIdClause)) {
+ $contactIdClause = "AND contact_id = %3";
+ }
if ( strpos($table, 'civicrm_value') !== false ) {
$contactIdClause = "AND entity_id = %3";
}
}
elseif (substr($table, 0, 14) == 'civicrm_value_') {
list($titles[$table], $values[$table]) = $this->titlesAndValuesForCustomDataTable($table);
+ } else {
+ $titles[$table] = $values[$table] = array();
}
}
}
// allow log tables to be extended via report hooks
- CRM_Report_BAO_Hook::singleton()->alterLogTables($this->_logTables);
+ CRM_Report_BAO_Hook::singleton()->alterLogTables($this, $this->_logTables);
parent::__construct();
}
return $this->_queryObjects;
}
- public function alterLogTables(&$logTables) {
+ public function alterLogTables(&$reportObj, &$logTables) {
foreach (self::getSearchQueryObjects() as $obj) {
- $obj->alterLogTables($logTables);
+ $obj->alterLogTables($reportObj, $logTables);
}
}
+
+ public function logDiffClause(&$reportObj, $table) {
+ $contactIdClause = $join = '';
+ foreach (self::getSearchQueryObjects() as $obj) {
+ list($cidClause, $joinClause) = $obj->logDiffClause($reportObj, $table);
+ if ($joinClause)
+ $join .= $joinClause;
+ if ($cidClause)
+ $contactIdClause .= $cidClause;
+ }
+ return array($contactIdClause, $join);
+ }
}
\ No newline at end of file
*/
class CRM_Report_BAO_HookInterface {
- public function alterLogTables(&$logTables) {
+ public function alterLogTables(&$reportObj, &$logTables) {
return NULL;
}
+ public function logDiffClause(&$reportObj, $table) {
+ return array();
+ }
}
\ No newline at end of file
$this->tables[] = 'civicrm_activity';
$this->tables[] = 'civicrm_case';
+ // allow tables to be extended by report hook query objects
+ CRM_Report_BAO_Hook::singleton()->alterLogTables($this, $this->tables);
+
$this->detail = 'logging/contact/detail';
$this->summary = 'logging/contact/summary';