diff --git a/Config/bootstrap.php b/Config/bootstrap.php new file mode 100644 index 0000000..db374f0 --- /dev/null +++ b/Config/bootstrap.php @@ -0,0 +1,4 @@ +settings[$Model->alias])) { + $this->settings[$Model->alias]['data_source'] = Configure::read('AuditLog.data_source'); $this->settings[$Model->alias]['ignore'] = array('created', 'updated', 'modified'); $this->settings[$Model->alias]['habtm'] = array(); if (!isset($settings['habtm'])) { @@ -173,6 +174,11 @@ public function afterSave(Model $Model, $created, $options = array()) { array('hasMany' => array('AuditLog.Audit')) ); + if(isset($this->settings[$Model->alias]['data_source'])) { + $Model->Audit->useDbConfig = $this->settings[$Model->alias]['data_source']; + $Model->Audit->AuditDelta->useDbConfig = $this->settings[$Model->alias]['data_source']; + } + // If a currentUser() method exists in the model class (or, of // course, in a superclass) the call that method to pull all user // data. Assume than an ID field exists. @@ -318,6 +324,10 @@ public function afterDelete(Model $Model) { ); $this->Audit = ClassRegistry::init('AuditLog.Audit'); + if(isset($this->settings[$Model->alias]['data_source'])) { + $this->Audit->useDbConfig = $this->settings[$Model->alias]['data_source']; + $this->Audit->AuditDelta->useDbConfig = $this->settings[$Model->alias]['data_source']; + } $this->Audit->create(); $this->Audit->save($data);