Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
justinfreeman (Agileware)
Core
Commits
d3886a6c
Commit
d3886a6c
authored
11 years ago
by
Tim Otten
Browse files
Options
Downloads
Plain Diff
Merge pull request #801 from totten/migrate-tweaks
CRM-12621 - Migrate tweaks
parents
cca54422
32963c28
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CRM/Utils/Migrate/Export.php
+55
-2
55 additions, 2 deletions
CRM/Utils/Migrate/Export.php
CRM/Utils/Migrate/Import.php
+20
-2
20 additions, 2 deletions
CRM/Utils/Migrate/Import.php
with
75 additions
and
4 deletions
CRM/Utils/Migrate/Export.php
+
55
−
2
View file @
d3886a6c
...
...
@@ -263,6 +263,59 @@ class CRM_Utils_Migrate_Export {
$this
->
fetch
(
'mappingField'
,
'CRM_Core_DAO_MappingField'
);
}
/**
* @param array $customGroupIds list of custom groups to export
* @return void
*/
function
buildCustomGroups
(
$customGroupIds
)
{
$customGroupIdsSql
=
implode
(
','
,
array_filter
(
$customGroupIds
,
'is_numeric'
));
if
(
empty
(
$customGroupIdsSql
))
{
return
;
}
$sql
=
"
SELECT distinct(g.id), g.*
FROM civicrm_option_group g,
civicrm_custom_field f,
civicrm_custom_group cg
WHERE f.option_group_id = g.id
AND f.custom_group_id = cg.id
AND cg.id in (
$customGroupIdsSql
)
"
;
$this
->
fetch
(
'optionGroup'
,
'CRM_Core_DAO_OptionGroup'
,
$sql
);
$sql
=
"
SELECT distinct(v.id), v.*, g.name as prefix
FROM civicrm_option_value v,
civicrm_option_group g,
civicrm_custom_field f,
civicrm_custom_group cg
WHERE v.option_group_id = g.id
AND f.option_group_id = g.id
AND f.custom_group_id = cg.id
AND cg.id in (
$customGroupIdsSql
)
"
;
$this
->
fetch
(
'optionValue'
,
'CRM_Core_DAO_OptionValue'
,
$sql
);
$sql
=
"
SELECT cg.*
FROM civicrm_custom_group cg
WHERE cg.id in (
$customGroupIdsSql
)
"
;
$this
->
fetch
(
'customGroup'
,
'CRM_Core_DAO_CustomGroup'
,
$sql
);
$sql
=
"
SELECT f.*
FROM civicrm_custom_field f,
civicrm_custom_group cg
WHERE f.custom_group_id = cg.id
AND cg.id in (
$customGroupIdsSql
)
"
;
$this
->
fetch
(
'customField'
,
'CRM_Core_DAO_CustomField'
,
$sql
);
}
/**
* Render the in-memory representation as XML
*
...
...
@@ -296,7 +349,7 @@ class CRM_Utils_Migrate_Export {
$result
=
array
();
foreach
(
array_keys
(
$this
->
_xml
)
as
$key
)
{
if
(
!
empty
(
$this
->
_xml
[
$key
][
'data'
]))
{
$result
[
$this
->
_xml
[
$key
][
'name'
]
]
=
$this
->
_xml
[
$key
][
'data'
];
$result
[
$this
->
_xml
[
$key
][
'name'
]
]
=
array_values
(
$this
->
_xml
[
$key
][
'data'
]
)
;
}
}
return
$result
;
...
...
@@ -315,7 +368,7 @@ class CRM_Utils_Migrate_Export {
}
while
(
$dao
->
fetch
())
{
$this
->
_xml
[
$groupName
][
'data'
][]
=
$this
->
exportDAO
(
$this
->
_xml
[
$groupName
][
'name'
],
$dao
,
$mappedFields
);
$this
->
_xml
[
$groupName
][
'data'
][
$dao
->
id
]
=
$this
->
exportDAO
(
$this
->
_xml
[
$groupName
][
'name'
],
$dao
,
$mappedFields
);
if
(
$idNameFields
)
{
// index the id/name fields so that we can translate from FK ids to FK names
if
(
isset
(
$idNameFields
[
2
]))
{
...
...
This diff is collapsed.
Click to expand it.
CRM/Utils/Migrate/Import.php
+
20
−
2
View file @
d3886a6c
...
...
@@ -36,13 +36,31 @@ class CRM_Utils_Migrate_Import {
function
__construct
()
{
}
/**
* Import custom-data from an XML file
*
* @param string $file path to an XML file
* @throws CRM_Core_Exception
* @return void;
*/
function
run
(
$file
)
{
// read xml file
$dom
=
DomDocument
::
load
(
$file
);
$dom
=
new
DomDocument
();
if
(
!
$dom
->
load
(
$file
))
{
throw
new
CRM_Core_Exception
(
"Failed to parse XML file
\"
$file
\"
"
);
}
$dom
->
xinclude
();
$xml
=
simplexml_import_dom
(
$dom
);
return
$this
->
runXmlElement
(
$xml
);
}
/**
* Import custom-data from an XML element
*
* @param SimpleXMLElement $xml
* @return void
*/
function
runXmlElement
(
$xml
)
{
$idMap
=
array
(
'custom_group'
=>
array
(),
'option_group'
=>
array
(),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment