<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
/**
* Populate $this->tables and $this->logs with current db state.
*/
- function __construct() {
+ public function __construct() {
$dao = new CRM_Contact_DAO_Contact();
$civiDBName = $dao->_database;
$this->tables = preg_grep('/^civicrm_import_job_/', $this->tables, PREG_GREP_INVERT);
$this->tables = preg_grep('/_cache$/', $this->tables, PREG_GREP_INVERT);
$this->tables = preg_grep('/_log/', $this->tables, PREG_GREP_INVERT);
- $this->tables = preg_grep('/^civicrm_task_action_temp_/', $this->tables, PREG_GREP_INVERT);
- $this->tables = preg_grep('/^civicrm_export_temp_/', $this->tables, PREG_GREP_INVERT);
$this->tables = preg_grep('/^civicrm_queue_/', $this->tables, PREG_GREP_INVERT);
$this->tables = preg_grep('/^civicrm_menu/', $this->tables, PREG_GREP_INVERT); //CRM-14672
+ $this->tables = preg_grep('/_temp_/', $this->tables, PREG_GREP_INVERT);
// do not log civicrm_mailing_event* tables, CRM-12300
$this->tables = preg_grep('/^civicrm_mailing_event_/', $this->tables, PREG_GREP_INVERT);
/**
* Return logging custom data tables.
*/
- function customDataLogTables() {
+ public function customDataLogTables() {
return preg_grep('/^log_civicrm_value_/', $this->logs);
}
/**
* Return custom data tables for specified entity / extends.
*/
- function entityCustomDataLogTables($extends) {
+ public function entityCustomDataLogTables($extends) {
$customGroupTables = array();
$customGroupDAO = CRM_Core_BAO_CustomGroup::getAllCustomGroupsByBaseEntity($extends);
$customGroupDAO->find();
/**
* Disable logging by dropping the triggers (but keep the log tables intact).
*/
- function disableLogging() {
+ public function disableLogging() {
$config = CRM_Core_Config::singleton();
$config->logging = FALSE;
/**
* Drop triggers for all logged tables.
*/
- function dropTriggers($tableName = NULL) {
+ public function dropTriggers($tableName = NULL) {
$dao = new CRM_Core_DAO;
if ($tableName) {
*
* @return void
*/
- function enableLogging() {
+ public function enableLogging() {
$this->fixSchemaDifferences(TRUE);
$this->addReports();
}
*
* @return void
*/
- function fixSchemaDifferences($enableLogging = FALSE) {
+ public function fixSchemaDifferences($enableLogging = FALSE) {
$config = CRM_Core_Config::singleton();
if ($enableLogging) {
$config->logging = TRUE;
/**
* Add missing (potentially specified) log table columns for the given table.
*
- * @param $table string name of the relevant table
- * @param $cols mixed array of columns to add or null (to check for the missing columns)
- * @param $rebuildTrigger boolean should we rebuild the triggers
+ * @param string $table
+ * name of the relevant table.
+ * @param array $cols
+ * Mixed array of columns to add or null (to check for the missing columns).
+ * @param bool $rebuildTrigger
+ * should we rebuild the triggers.
*
* @return void
*/
- function fixSchemaDifferencesFor($table, $cols = array(), $rebuildTrigger = FALSE) {
+ public function fixSchemaDifferencesFor($table, $cols = array(), $rebuildTrigger = FALSE) {
if (empty($table)) {
return FALSE;
}
/**
* @param bool $rebuildTrigger
*/
- function fixSchemaDifferencesForAll($rebuildTrigger = FALSE) {
+ public function fixSchemaDifferencesForAll($rebuildTrigger = FALSE) {
$diffs = array();
foreach ($this->tables as $table) {
if (empty($this->logs[$table])) {
*
* @return mixed
*/
- function fixTimeStampAndNotNullSQL($query) {
+ public function fixTimeStampAndNotNullSQL($query) {
$query = str_ireplace("TIMESTAMP NOT NULL", "TIMESTAMP NULL", $query);
$query = str_ireplace("DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP", '', $query);
$query = str_ireplace("DEFAULT CURRENT_TIMESTAMP", '', $query);
'COLUMN_NAME' => $dao->COLUMN_NAME,
'DATA_TYPE' => $dao->DATA_TYPE,
'IS_NULLABLE' => $dao->IS_NULLABLE,
- 'COLUMN_DEFAULT' => $dao->COLUMN_DEFAULT
+ 'COLUMN_DEFAULT' => $dao->COLUMN_DEFAULT,
);
}
}
*
* @return array
*/
- function columnsWithDiffSpecs($civiTable, $logTable) {
+ public function columnsWithDiffSpecs($civiTable, $logTable) {
$civiTableSpecs = $this->columnSpecsOf($civiTable);
$logTableSpecs = $this->columnSpecsOf($logTable);
// NOTE: we consider only those columns for modifications where there is a spec change, and that the column definition
// wasn't deliberately modified by fixTimeStampAndNotNullSQL() method.
foreach ($civiTableSpecs as $col => $colSpecs) {
- if (!isset($logTableSpecs[$col]) || !is_array($logTableSpecs[$col]) ) {
+ if (!isset($logTableSpecs[$col]) || !is_array($logTableSpecs[$col])) {
$logTableSpecs[$col] = array();
}
if ($civiTableSpecs[$col]['DATA_TYPE'] != CRM_Utils_Array::value('DATA_TYPE', $logTableSpecs[$col])) {
// if data-type is different, surely consider the column
$diff['MODIFY'][] = $col;
- } else if ($civiTableSpecs[$col]['IS_NULLABLE'] != CRM_Utils_Array::value('IS_NULLABLE', $logTableSpecs[$col]) &&
+ }
+ elseif ($civiTableSpecs[$col]['IS_NULLABLE'] != CRM_Utils_Array::value('IS_NULLABLE', $logTableSpecs[$col]) &&
$logTableSpecs[$col]['IS_NULLABLE'] == 'NO') {
// if is-null property is different, and log table's column is NOT-NULL, surely consider the column
$diff['MODIFY'][] = $col;
- } else if ($civiTableSpecs[$col]['COLUMN_DEFAULT'] != CRM_Utils_Array::value('COLUMN_DEFAULT', $logTableSpecs[$col]) &&
+ }
+ elseif ($civiTableSpecs[$col]['COLUMN_DEFAULT'] != CRM_Utils_Array::value('COLUMN_DEFAULT', $logTableSpecs[$col]) &&
!strstr($civiTableSpecs[$col]['COLUMN_DEFAULT'], 'TIMESTAMP')) {
// if default property is different, and its not about a timestamp column, consider it
$diff['MODIFY'][] = $col;
* @param null $tableName
* @param bool $force
*/
- function triggerInfo(&$info, $tableName = NULL, $force = FALSE) {
+ public function triggerInfo(&$info, $tableName = NULL, $force = FALSE) {
// check if we have logging enabled
$config =& CRM_Core_Config::singleton();
if (!$config->logging) {
$columns = $this->columnsOf($table, $force);
// only do the change if any data has changed
- $cond = array( );
+ $cond = array();
foreach ($columns as $column) {
// ignore modified_date changes
if ($column != 'modified_date' && !in_array($column, CRM_Utils_Array::value($table, $this->exceptions, array()))) {
}
}
$suppressLoggingCond = "@civicrm_disable_logging IS NULL OR @civicrm_disable_logging = 0";
- $updateSQL = "IF ( (" . implode( ' OR ', $cond ) . ") AND ( $suppressLoggingCond ) ) THEN ";
+ $updateSQL = "IF ( (" . implode(' OR ', $cond) . ") AND ( $suppressLoggingCond ) ) THEN ";
if ($this->useDBPrefix) {
$sqlStmt = "INSERT INTO `{$this->db}`.log_{tableName} (";
* an audit trail
*
* @static
- * @public
*/
- static function disableLoggingForThisConnection( ) {
+ public static function disableLoggingForThisConnection() {
// do this only if logging is enabled
- $config = CRM_Core_Config::singleton( );
- if ( $config->logging ) {
- CRM_Core_DAO::executeQuery( 'SET @civicrm_disable_logging = 1' );
+ $config = CRM_Core_Config::singleton();
+ if ($config->logging) {
+ CRM_Core_DAO::executeQuery('SET @civicrm_disable_logging = 1');
}
}
}
-