| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
//CRM-13028 / NYSS-6933 - table => array (cols) - to be excluded from the update statement
private $exceptions = array(
- 'civicrm_job' => array('last_run'),
+ 'civicrm_job' => array('last_run'),
'civicrm_group' => array('cache_date'),
);
* Drop triggers for all logged tables.
*/
public function dropTriggers($tableName = NULL) {
- $dao = new CRM_Core_DAO;
+ $dao = new CRM_Core_DAO();
if ($tableName) {
$tableNames = array($tableName);
$dao->executeQuery("DROP TRIGGER IF EXISTS {$validName}_before_update");
$dao->executeQuery("DROP TRIGGER IF EXISTS {$validName}_before_delete");
- // after triggers
+ // after triggers
$dao->executeQuery("DROP TRIGGER IF EXISTS {$validName}_after_insert");
$dao->executeQuery("DROP TRIGGER IF EXISTS {$validName}_after_update");
$dao->executeQuery("DROP TRIGGER IF EXISTS {$validName}_after_delete");
/**
* Sync log tables and rebuild triggers.
*
- * @param bool $enableLogging: Ensure logging is enabled
+ * @param bool $enableLogging : Ensure logging is enabled
*
* @return void
*/
/**
* Add missing (potentially specified) log table columns for the given table.
*
- * @param $table
- * String name of the relevant table.
- * @param $cols
+ * @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 $rebuildTrigger
- * Boolean should we rebuild the triggers.
+ * @param bool $rebuildTrigger
+ * should we rebuild the triggers.
*
* @return void
*/
}
}
- /*
- * log_civicrm_contact.modified_date for example would always be copied from civicrm_contact.modified_date,
+ /**
+ * Log_civicrm_contact.modified_date for example would always be copied from civicrm_contact.modified_date,
* so there's no need for a default timestamp and therefore we remove such default timestamps
* also eliminate the NOT NULL constraint, since we always copy and schema can change down the road)
- */
- /**
+ *
* @param $query
*
* @return mixed
// add report instances
$domain_id = CRM_Core_Config::domainID();
foreach ($this->reports as $report) {
- $dao = new CRM_Report_DAO_ReportInstance;
- $dao->domain_id = $domain_id;
- $dao->report_id = $report;
- $dao->title = $titles[$report];
+ $dao = new CRM_Report_DAO_ReportInstance();
+ $dao->domain_id = $domain_id;
+ $dao->report_id = $report;
+ $dao->title = $titles[$report];
$dao->permission = 'administer CiviCRM';
- if ($report == 'logging/contact/summary')
+ if ($report == 'logging/contact/summary') {
$dao->is_reserved = 1;
+ }
$dao->insert();
}
}
if (!array_key_exists($dao->TABLE_NAME, $columnSpecs)) {
$columnSpecs[$dao->TABLE_NAME] = array();
}
- $columnSpecs[$dao->TABLE_NAME][$dao->COLUMN_NAME] =
- array(
- 'COLUMN_NAME' => $dao->COLUMN_NAME,
- 'DATA_TYPE' => $dao->DATA_TYPE,
- 'IS_NULLABLE' => $dao->IS_NULLABLE,
- 'COLUMN_DEFAULT' => $dao->COLUMN_DEFAULT
- );
+ $columnSpecs[$dao->TABLE_NAME][$dao->COLUMN_NAME] = array(
+ 'COLUMN_NAME' => $dao->COLUMN_NAME,
+ 'DATA_TYPE' => $dao->DATA_TYPE,
+ 'IS_NULLABLE' => $dao->IS_NULLABLE,
+ 'COLUMN_DEFAULT' => $dao->COLUMN_DEFAULT,
+ );
}
}
return $columnSpecs[$table];
*/
public function columnsWithDiffSpecs($civiTable, $logTable) {
$civiTableSpecs = $this->columnSpecsOf($civiTable);
- $logTableSpecs = $this->columnSpecsOf($logTable);
+ $logTableSpecs = $this->columnSpecsOf($logTable);
$diff = array('ADD' => array(), 'MODIFY' => array(), 'OBSOLETE' => array());
// 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();
}
$diff['MODIFY'][] = $col;
}
elseif ($civiTableSpecs[$col]['IS_NULLABLE'] != CRM_Utils_Array::value('IS_NULLABLE', $logTableSpecs[$col]) &&
- $logTableSpecs[$col]['IS_NULLABLE'] == 'NO') {
+ $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;
}
elseif ($civiTableSpecs[$col]['COLUMN_DEFAULT'] != CRM_Utils_Array::value('COLUMN_DEFAULT', $logTableSpecs[$col]) &&
- !strstr($civiTableSpecs[$col]['COLUMN_DEFAULT'], 'TIMESTAMP')) {
+ !strstr($civiTableSpecs[$col]['COLUMN_DEFAULT'], 'TIMESTAMP')
+ ) {
// if default property is different, and its not about a timestamp column, consider it
$diff['MODIFY'][] = $col;
}
$oldCols = array_diff(array_keys($logTableSpecs), array_keys($civiTableSpecs));
foreach ($oldCols as $col) {
if (!in_array($col, array('log_date', 'log_conn_id', 'log_user_id', 'log_action')) &&
- $logTableSpecs[$col]['IS_NULLABLE'] == 'NO') {
+ $logTableSpecs[$col]['IS_NULLABLE'] == 'NO'
+ ) {
// if its a column present only in log table, not among those used by log tables for special purpose, and not-null
$diff['OBSOLETE'][] = $col;
}
// delete report instances
$domain_id = CRM_Core_Config::domainID();
foreach ($this->reports as $report) {
- $dao = new CRM_Report_DAO_ReportInstance;
+ $dao = new CRM_Report_DAO_ReportInstance();
$dao->domain_id = $domain_id;
$dao->report_id = $report;
$dao->delete();
$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} (";
$sqlStmt = '';
foreach ($columns as $column) {
- $sqlStmt .= "NEW.$column, ";
+ $sqlStmt .= "NEW.$column, ";
$deleteSQL .= "OLD.$column, ";
}
- $sqlStmt .= "CONNECTION_ID(), @civicrm_user_id, '{eventName}');";
+ $sqlStmt .= "CONNECTION_ID(), @civicrm_user_id, '{eventName}');";
$deleteSQL .= "CONNECTION_ID(), @civicrm_user_id, '{eventName}');";
- $sqlStmt .= "END IF;";
+ $sqlStmt .= "END IF;";
$deleteSQL .= "END IF;";
$insertSQL .= $sqlStmt;
* where we want to do a mass cleanup but dont want to bother with
* 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');
}
}