<?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$
*
*/
class CRM_Utils_Migrate_Import {
/**
- *
*/
- function __construct() {
+ public function __construct() {
}
/**
* Import custom-data from an XML file
*
- * @param string $file path to an XML file
+ * @param string $file
+ * Path to an XML file.
* @throws CRM_Core_Exception
* @return void;
*/
- function run($file) {
+ public function run($file) {
// read xml file
$dom = new DomDocument();
- if (! $dom->load($file)) {
+ if (!$dom->load($file)) {
throw new CRM_Core_Exception("Failed to parse XML file \"$file\"");
}
$dom->xinclude();
* @param SimpleXMLElement $xml
* @return void
*/
- function runXmlElement($xml) {
+ public function runXmlElement($xml) {
$idMap = array(
'custom_group' => array(),
'option_group' => array(),
}
/**
- * @param $dao
+ * @param CRM_Core_DAO $dao
* @param $xml
* @param bool $save
* @param null $keyName
*
* @return bool
*/
- function copyData(&$dao, &$xml, $save = FALSE, $keyName = NULL) {
+ public function copyData(&$dao, &$xml, $save = FALSE, $keyName = NULL) {
if ($keyName) {
if (isset($xml->$keyName)) {
$dao->$keyName = (string ) $xml->$keyName;
array(
1 => $keyName,
2 => $dao->$keyName,
- 3 => $dao->__table
+ 3 => $dao->__table,
)
), '', 'info');
return FALSE;
}
}
- $fields = & $dao->fields();
+ $fields = &$dao->fields();
foreach ($fields as $name => $dontCare) {
if (isset($xml->$name)) {
$value = (string ) $xml->$name;
* @param $xml
* @param $idMap
*/
- function optionGroups(&$xml, &$idMap) {
+ public function optionGroups(&$xml, &$idMap) {
foreach ($xml->OptionGroups as $optionGroupsXML) {
foreach ($optionGroupsXML->OptionGroup as $optionGroupXML) {
$optionGroup = new CRM_Core_DAO_OptionGroup();
* @param $xml
* @param $idMap
*/
- function optionValues(&$xml, &$idMap) {
+ public function optionValues(&$xml, &$idMap) {
foreach ($xml->OptionValues as $optionValuesXML) {
foreach ($optionValuesXML->OptionValue as $optionValueXML) {
$optionValue = new CRM_Core_DAO_OptionValue();
/**
* @param $xml
*/
- function relationshipTypes(&$xml) {
+ public function relationshipTypes(&$xml) {
foreach ($xml->RelationshipTypes as $relationshipTypesXML) {
foreach ($relationshipTypesXML->RelationshipType as $relationshipTypeXML) {
/**
* @param $xml
*/
- function contributionTypes(&$xml) {
+ public function contributionTypes(&$xml) {
foreach ($xml->ContributionTypes as $contributionTypesXML) {
foreach ($contributionTypesXML->ContributionType as $contributionTypeXML) {
* @param $xml
* @param $idMap
*/
- function customGroups(&$xml, &$idMap) {
+ public function customGroups(&$xml, &$idMap) {
foreach ($xml->CustomGroups as $customGroupsXML) {
foreach ($customGroupsXML->CustomGroup as $customGroupXML) {
$customGroup = new CRM_Core_DAO_CustomGroup();
// fix extends stuff if it exists
if (isset($customGroupXML->extends_entity_column_value_option_group) &&
- isset($customGroupXML->extends_entity_column_value)) {
+ isset($customGroupXML->extends_entity_column_value)
+ ) {
$valueIDs = array();
$optionValues = explode(",", $customGroupXML->extends_entity_column_value);
$optValues = implode("','", $optionValues);
'String',
),
);
- $dao = & CRM_Core_DAO::executeQuery($sql, $params);
+ $dao = &CRM_Core_DAO::executeQuery($sql, $params);
while ($dao->fetch()) {
$valueIDs[] = $dao->value;
}
if (!empty($valueIDs)) {
$customGroup->extends_entity_column_value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR,
- $valueIDs
- ) . CRM_Core_DAO::VALUE_SEPARATOR;
+ $valueIDs
+ ) . CRM_Core_DAO::VALUE_SEPARATOR;
unset($valueIDs);
1 => array(
(string ) $customGroupXML->extends_entity_column_value_option_group,
'String',
- )
+ ),
);
$valueID = (int ) CRM_Core_DAO::singleValueQuery($sql, $params);
if ($valueID) {
if (is_array($optionIDs) && !empty($optionIDs)) {
$customGroup->extends_entity_column_value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR,
- array_keys($optionIDs)
- ) . CRM_Core_DAO::VALUE_SEPARATOR;
+ array_keys($optionIDs)
+ ) . CRM_Core_DAO::VALUE_SEPARATOR;
$saveAgain = TRUE;
}
* @param $xml
* @param $idMap
*/
- function customFields(&$xml, &$idMap) {
+ public function customFields(&$xml, &$idMap) {
// Re-index by group id so we can build out the custom fields one table
// at a time, and then rebuild the table triggers at the end, rather than
// rebuilding the table triggers after each field is added (which is
* @param $xml
* @param $idMap
*/
- function dbTemplateString(&$xml, &$idMap) {
+ public function dbTemplateString(&$xml, &$idMap) {
foreach ($xml->Persistent as $persistentXML) {
foreach ($persistentXML->Persistent as $persistent) {
$persistentObj = new CRM_Core_DAO_Persistent();
* @param $xml
* @param $idMap
*/
- function profileGroups(&$xml, &$idMap) {
+ public function profileGroups(&$xml, &$idMap) {
foreach ($xml->ProfileGroups as $profileGroupsXML) {
foreach ($profileGroupsXML->ProfileGroup as $profileGroupXML) {
$profileGroup = new CRM_Core_DAO_UFGroup();
*
* @throws Exception
*/
- function profileFields(&$xml, &$idMap) {
+ public function profileFields(&$xml, &$idMap) {
foreach ($xml->ProfileFields as $profileFieldsXML) {
foreach ($profileFieldsXML->ProfileField as $profileFieldXML) {
$profileField = new CRM_Core_DAO_UFField();
$cfID = CRM_Core_DAO::singleValueQuery($sql, $params);
if (!$cfID) {
CRM_Core_Error::fatal(ts("Could not find custom field for %1, %2, %3",
- array(
- 1 => $profileField->field_name,
- 2 => $tableName,
- 3 => $columnName
- )
- ) . "<br />");
+ array(
+ 1 => $profileField->field_name,
+ 2 => $tableName,
+ 3 => $columnName,
+ )
+ ) . "<br />");
}
$profileField->field_name = "custom_{$cfID}";
}
* @param $xml
* @param $idMap
*/
- function profileJoins(&$xml, &$idMap) {
+ public function profileJoins(&$xml, &$idMap) {
foreach ($xml->ProfileJoins as $profileJoinsXML) {
foreach ($profileJoinsXML->ProfileJoin as $profileJoinXML) {
$profileJoin = new CRM_Core_DAO_UFJoin();
}
}
}
-}
+}