Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

5067 trigger hook

  • Loading branch information...
commit 6d8477ed082eebfdf319f8ba73a140aa39f9bf4f 1 parent 0da9211
@lcdservices lcdservices authored
View
48 civicrm/custom/php/CRM/Logging/Schema.php
@@ -107,7 +107,9 @@ function disableLogging()
{
if (!$this->isEnabled()) return;
- $this->dropTriggers();
+ //$this->dropTriggers();
+ //NYSS invoke the meta trigger creation call
+ CRM_Core_DAO::triggerRebuild( );
$this->deleteReports();
}
@@ -274,37 +276,6 @@ private function createLogTableFor($table)
}
/**
- * Create triggers populating the relevant log table every time the given table changes.
- */
- function createTriggersFor($table)
- {
- if ($table != 'civicrm_contact' and !$this->isEnabled()) return;
-
- $columns = $this->columnsOf($table);
-
- $queries = array();
- foreach (array('Insert', 'Update', 'Delete') as $action) {
- $trigger = "{$table}_after_" . strtolower($action);
- $queries[] = "DROP TRIGGER IF EXISTS $trigger";
- $query = "CREATE TRIGGER $trigger AFTER $action ON $table FOR EACH ROW INSERT INTO `{$this->db}`.log_$table (";
- foreach ($columns as $column) {
- $query .= "$column, ";
- }
- $query .= "log_conn_id, log_user_id, log_action) VALUES (";
- foreach ($columns as $column) {
- $query .= $action == 'Delete' ? "OLD.$column, " : "NEW.$column, ";
- }
- $query .= "CONNECTION_ID(), @civicrm_user_id, '$action')";
- $queries[] = $query;
- }
-
- $dao = new CRM_Core_DAO;
- foreach ($queries as $query) {
- $dao->executeQuery($query);
- }
- }
-
- /**
* Create triggers for all logged tables.
*/
/*private function createTriggers()
@@ -335,19 +306,6 @@ private function deleteReports()
}
/**
- * Drop triggers for all logged tables.
- */
- private function dropTriggers()
- {
- $dao = new CRM_Core_DAO;
- foreach ($this->tables as $table) {
- $dao->executeQuery("DROP TRIGGER IF EXISTS {$table}_after_insert");
- $dao->executeQuery("DROP TRIGGER IF EXISTS {$table}_after_update");
- $dao->executeQuery("DROP TRIGGER IF EXISTS {$table}_after_delete");
- }
- }
-
- /**
* Predicate whether logging is enabled.
*/
public function isEnabled()
View
8 modules/civicrm/CRM/Core/Invoke.php
@@ -72,6 +72,14 @@ static function invoke( $args )
// also reset navigation
require_once 'CRM/Core/BAO/Navigation.php';
CRM_Core_BAO_Navigation::resetNavigation( );
+
+ // also cleanup all caches //NYSS
+ $config->cleanupCaches( );
+
+ // also rebuild triggers if set //NYSS 5067
+ if ( CRM_Utils_Request::retrieve( 'triggerRebuild', 'Boolean', CRM_Core_DAO::$_nullObject, false, 0, 'GET' ) ) {
+ CRM_Core_DAO::triggerRebuild( );
+ }
return CRM_Utils_System::redirect( );
} else {
Please sign in to comment.
Something went wrong with that request. Please try again.