Merge pull request #6360 from monishdeb/search-fixes-master
[civicrm-core.git] / CRM / Logging / Reverter.php
index 86a9a4f66bffe1243be602c2497858382afd5699..9b95118a3268f9587e80aa7257ea7dd0f4caf7ee 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.6                                                |
+ | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
  * $Id$
  *
  */
@@ -42,10 +42,10 @@ class CRM_Logging_Reverter {
    * @param $log_date
    */
   public function __construct($log_conn_id, $log_date) {
-    $dsn               = defined('CIVICRM_LOGGING_DSN') ? DB::parseDSN(CIVICRM_LOGGING_DSN) : DB::parseDSN(CIVICRM_DSN);
-    $this->db          = $dsn['database'];
+    $dsn = defined('CIVICRM_LOGGING_DSN') ? DB::parseDSN(CIVICRM_LOGGING_DSN) : DB::parseDSN(CIVICRM_DSN);
+    $this->db = $dsn['database'];
     $this->log_conn_id = $log_conn_id;
-    $this->log_date    = $log_date;
+    $this->log_date = $log_date;
   }
 
   /**
@@ -116,7 +116,7 @@ class CRM_Logging_Reverter {
         // DAO-based tables
 
         case in_array($table, array_keys($daos)):
-          $dao = new $daos[$table];
+          $dao = new $daos[$table]();
           foreach ($row as $id => $changes) {
             $dao->id = $id;
             foreach ($changes as $field => $value) {
@@ -132,13 +132,14 @@ class CRM_Logging_Reverter {
             $dao->reset();
           }
           break;
+
         // custom data tables
 
         case in_array($table, array_keys($ctypes)):
           foreach ($row as $id => $changes) {
             $inserts = array('id' => '%1');
             $updates = array();
-            $params  = array(1 => array($id, 'Integer'));
+            $params = array(1 => array($id, 'Integer'));
             $counter = 2;
             foreach ($changes as $field => $value) {
               // don’t try reverting a field that’s no longer there
@@ -154,8 +155,8 @@ class CRM_Logging_Reverter {
                   $value = CRM_Utils_Date::isoToMysql($value);
                   break;
               }
-              $inserts[$field]  = "%$counter";
-              $updates[]        = "$field = %$counter";
+              $inserts[$field] = "%$counter";
+              $updates[] = "$field = %$counter";
               $params[$counter] = array($value, $ctypes[$table][$field]);
               $counter++;
             }
@@ -188,7 +189,7 @@ class CRM_Logging_Reverter {
         return;
       }
 
-      $dao = new CRM_Contact_DAO_Contact;
+      $dao = new CRM_Contact_DAO_Contact();
       $dao->id = $cid;
       if ($dao->find(TRUE)) {
         // CRM-8102: MySQL can’t parse its own dates
@@ -198,4 +199,5 @@ class CRM_Logging_Reverter {
       }
     }
   }
+
 }