X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FMigrate%2FImportJSON.php;h=2de4dced64eb0ad381fd735f9754d573fd532293;hb=c52174d854bcc01af1e112d3bb0eee0e201d65e6;hp=40cc321cd8d05ca7950223b4dbf1e90fb7d8d8aa;hpb=adc13f865ee7ced5d485e801528f2481fb6da0b0;p=civicrm-core.git diff --git a/CRM/Utils/Migrate/ImportJSON.php b/CRM/Utils/Migrate/ImportJSON.php index 40cc321cd8..2de4dced64 100644 --- a/CRM/Utils/Migrate/ImportJSON.php +++ b/CRM/Utils/Migrate/ImportJSON.php @@ -1,9 +1,9 @@ _lookupCache = array(); $this->_saveMapping = array(); } + /** + * @param $file + */ function run($file) { $json = file_get_contents($file); @@ -56,8 +62,7 @@ class CRM_Utils_Migrate_ImportJSON { $this->note($decodedContacts->civicrm_note); $this->relationship($decodedContacts->civicrm_relationship); $this->activity($decodedContacts->civicrm_activity, - $decodedContacts->civicrm_activity_target, - $decodedContacts->civicrm_activity_assignment + $decodedContacts->civicrm_activity_contact ); $this->group($decodedContacts->civicrm_group, $decodedContacts->civicrm_group_contact @@ -70,13 +75,20 @@ class CRM_Utils_Migrate_ImportJSON { CRM_Core_Config::clearDBCache(); } + /** + * @param $contact + */ function contact(&$contact) { $this->restore($contact, 'CRM_Contact_DAO_Contact', - array('id' => 'civicrm_contact') + array('id' => 'civicrm_contact'), + array('birth_date', 'deceased_date', 'created_date', 'modified_date') ); } + /** + * @param $email + */ function email(&$email) { $this->restore($email, 'CRM_Core_DAO_Email', @@ -84,6 +96,9 @@ class CRM_Utils_Migrate_ImportJSON { ); } + /** + * @param $phone + */ function phone(&$phone) { $this->restore($phone, 'CRM_Core_DAO_Phone', @@ -91,6 +106,9 @@ class CRM_Utils_Migrate_ImportJSON { ); } + /** + * @param $address + */ function address(&$address) { $this->restore($address, 'CRM_Core_DAO_Address', @@ -98,13 +116,20 @@ class CRM_Utils_Migrate_ImportJSON { ); } + /** + * @param $note + */ function note(&$note) { $this->restore($note, 'CRM_Core_DAO_Note', - array('contact_id' => 'civicrm_contact') + array('contact_id' => 'civicrm_contact'), + array('modified_date') ); } + /** + * @param $relationship + */ function relationship(&$relationship) { $this->restore($relationship, 'CRM_Contact_DAO_Relationship', @@ -115,32 +140,35 @@ class CRM_Utils_Migrate_ImportJSON { ); } - function activity($activity, $activityTarget, $activityAssignment) { + /** + * @param $activity + * @param $activityContacts + */ + function activity($activity, $activityContacts) { $this->restore($activity, 'CRM_Activity_DAO_Activity', - array('source_contact_id' => 'civicrm_contact') - ); - - $this->restore($activityTarget, - 'CRM_Activity_DAO_ActivityTarget', - array( - 'target_contact_id' => 'civicrm_contact', - 'activity_id' => 'civicrm_activity', - ) + NULL, + array('activity_date_time') ); - $this->restore($activityAssignment, - 'CRM_Activity_DAO_ActivityAssignment', + $this->restore($activityContacts, + 'CRM_Activity_DAO_ActivityContact', array( - 'assignee_contact_id' => 'civicrm_contact', + 'contact_id' => 'civicrm_contact', 'activity_id' => 'civicrm_activity', ) ); } + /** + * @param $group + * @param $groupContact + */ function group($group, $groupContact) { $this->restore($group, - 'CRM_Contact_DAO_Group' + 'CRM_Contact_DAO_Group', + NULL, + array('cache_date', 'refresh_date') ); $this->restore($groupContact, @@ -152,6 +180,10 @@ class CRM_Utils_Migrate_ImportJSON { ); } + /** + * @param $tag + * @param $entityTag + */ function tag($tag, $entityTag) { $this->restore($tag, 'CRM_Core_DAO_Tag', @@ -170,7 +202,13 @@ class CRM_Utils_Migrate_ImportJSON { ); } - function restore(&$chunk, $daoName, $lookUpMapping = NULL) { + /** + * @param $chunk + * @param string $daoName + * @param null $lookUpMapping + * @param null $dateFields + */ + function restore(&$chunk, $daoName, $lookUpMapping = NULL, $dateFields = NULL) { $object = new $daoName(); $tableName = $object->__table; @@ -205,6 +243,9 @@ class CRM_Utils_Migrate_ImportJSON { if (array_key_exists($column, $lookUpMapping)) { $object->$column = $this->_lookupCache[$lookUpMapping[$column]][$value[$k]]; } + elseif (!empty($dateFields) && in_array($column, $dateFields)) { + $object->$column = CRM_Utils_Date::isoToMysql($value[$k]); + } else { $object->$column = $value[$k]; } @@ -238,6 +279,9 @@ class CRM_Utils_Migrate_ImportJSON { } } + /** + * @param string $tableName + */ function populateCache($tableName) { if (isset($this->_lookupCache[$tableName])) { return;