Merge branch 4.6 into master
[civicrm-core.git] / CRM / Utils / Migrate / ImportJSON.php
index 071d8cc7e1c2c6c0b58429806b8a1fb5586544b5..f39587968bc16b691455506826796c835f6188f4 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | 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$
  *
  */
@@ -39,9 +39,8 @@ class CRM_Utils_Migrate_ImportJSON {
   protected $_saveMapping;
 
   /**
-   *
    */
-  function __construct() {
+  public function __construct() {
     $this->_lookupCache = array();
     $this->_saveMapping = array();
   }
@@ -49,7 +48,7 @@ class CRM_Utils_Migrate_ImportJSON {
   /**
    * @param $file
    */
-  function run($file) {
+  public function run($file) {
     $json = file_get_contents($file);
 
     $decodedContacts = json_decode($json);
@@ -78,7 +77,7 @@ class CRM_Utils_Migrate_ImportJSON {
   /**
    * @param $contact
    */
-  function contact(&$contact) {
+  public function contact(&$contact) {
     $this->restore($contact,
       'CRM_Contact_DAO_Contact',
       array('id' => 'civicrm_contact'),
@@ -89,7 +88,7 @@ class CRM_Utils_Migrate_ImportJSON {
   /**
    * @param $email
    */
-  function email(&$email) {
+  public function email(&$email) {
     $this->restore($email,
       'CRM_Core_DAO_Email',
       array('contact_id' => 'civicrm_contact')
@@ -99,7 +98,7 @@ class CRM_Utils_Migrate_ImportJSON {
   /**
    * @param $phone
    */
-  function phone(&$phone) {
+  public function phone(&$phone) {
     $this->restore($phone,
       'CRM_Core_DAO_Phone',
       array('contact_id' => 'civicrm_contact')
@@ -109,7 +108,7 @@ class CRM_Utils_Migrate_ImportJSON {
   /**
    * @param $address
    */
-  function address(&$address) {
+  public function address(&$address) {
     $this->restore($address,
       'CRM_Core_DAO_Address',
       array('contact_id' => 'civicrm_contact')
@@ -119,7 +118,7 @@ class CRM_Utils_Migrate_ImportJSON {
   /**
    * @param $note
    */
-  function note(&$note) {
+  public function note(&$note) {
     $this->restore($note,
       'CRM_Core_DAO_Note',
       array('contact_id' => 'civicrm_contact'),
@@ -130,7 +129,7 @@ class CRM_Utils_Migrate_ImportJSON {
   /**
    * @param $relationship
    */
-  function relationship(&$relationship) {
+  public function relationship(&$relationship) {
     $this->restore($relationship,
       'CRM_Contact_DAO_Relationship',
       array(
@@ -144,7 +143,7 @@ class CRM_Utils_Migrate_ImportJSON {
    * @param $activity
    * @param $activityContacts
    */
-  function activity($activity, $activityContacts) {
+  public function activity($activity, $activityContacts) {
     $this->restore($activity,
       'CRM_Activity_DAO_Activity',
       NULL,
@@ -164,7 +163,7 @@ class CRM_Utils_Migrate_ImportJSON {
    * @param $group
    * @param $groupContact
    */
-  function group($group, $groupContact) {
+  public function group($group, $groupContact) {
     $this->restore($group,
       'CRM_Contact_DAO_Group',
       NULL,
@@ -184,7 +183,7 @@ class CRM_Utils_Migrate_ImportJSON {
    * @param $tag
    * @param $entityTag
    */
-  function tag($tag, $entityTag) {
+  public function tag($tag, $entityTag) {
     $this->restore($tag,
       'CRM_Core_DAO_Tag',
       array(
@@ -208,8 +207,8 @@ class CRM_Utils_Migrate_ImportJSON {
    * @param null $lookUpMapping
    * @param null $dateFields
    */
-  function restore(&$chunk, $daoName, $lookUpMapping = NULL, $dateFields = NULL) {
-    $object   = new $daoName();
+  public function restore(&$chunk, $daoName, $lookUpMapping = NULL, $dateFields = NULL) {
+    $object = new $daoName();
     $tableName = $object->__table;
 
     if (is_array($lookUpMapping)) {
@@ -227,7 +226,7 @@ class CRM_Utils_Migrate_ImportJSON {
     $columns = $chunk[0];
     foreach ($chunk as $key => $value) {
       if ($key) {
-        $object   = new $daoName();
+        $object = new $daoName();
         foreach ($columns as $k => $column) {
           if ($column == 'id') {
             $childID = $value[$k];
@@ -261,7 +260,7 @@ class CRM_Utils_Migrate_ImportJSON {
     }
   }
 
-  function saveCache() {
+  public function saveCache() {
     $sql = "INSERT INTO civicrm_migration_mapping (master_id, slave_id, entity_table ) VALUES ";
 
     foreach ($this->_lookupCache as $tableName => & $values) {
@@ -280,9 +279,9 @@ class CRM_Utils_Migrate_ImportJSON {
   }
 
   /**
-   * @param $tableName
+   * @param string $tableName
    */
-  function populateCache($tableName) {
+  public function populateCache($tableName) {
     if (isset($this->_lookupCache[$tableName])) {
       return;
     }
@@ -300,5 +299,5 @@ WHERE entity_table = '{$tableName}'
       $this->_lookupCache[$dao->slave_id] = $dao->master_id;
     }
   }
-}
 
+}