<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
+ | Copyright CiviCRM LLC. All rights reserved. |
| |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ | This work is published under the GNU AGPLv3 license with some |
+ | permitted exceptions and without any warranty. For full license |
+ | and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2019
+ * @copyright CiviCRM LLC https://civicrm.org/licensing
*/
abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser {
if ($mode == self::MODE_IMPORT) {
$query .= " WHERE $statusFieldName = 'NEW'";
}
- $dao = new CRM_Core_DAO();
- $db = $dao->getDatabaseConnection();
- $result = $db->query($query);
- while ($values = $result->fetchRow(DB_FETCHMODE_ORDERED)) {
+ $result = CRM_Core_DAO::executeQuery($query);
+
+ while ($result->fetch()) {
+ $values = array_values($result->toArray());
$this->_rowCount++;
/* trim whitespace around the values */
* @return array
*/
public function getColumnPatterns() {
+ CRM_Core_Error::deprecatedFunctionWarning('no longer used- use CRM_Contact_Import_MetadataTrait');
$values = [];
foreach ($this->_fields as $name => $field) {
$values[$name] = $field->_columnPattern;
$store->set('fields', $this->getSelectValues());
$store->set('fieldTypes', $this->getSelectTypes());
- $store->set('columnPatterns', $this->getColumnPatterns());
- $store->set('dataPatterns', $this->getDataPatterns());
$store->set('columnCount', $this->_activeFieldCount);
$store->set('totalRowCount', $this->_totalCount);
// Note
// Custom
- // Cache the various object fields
- static $fields = [];
-
// first add core contact values since for other Civi modules they are not added
$contactFields = CRM_Contact_DAO_Contact::fields();
_civicrm_api3_store_values($contactFields, $values, $params);
return TRUE;
}
+ // Cache the various object fields
+ // @todo - remove this after confirming this is just a compilation of other-wise-cached fields.
+ static $fields = [];
+
if (isset($values['individual_prefix'])) {
if (!empty($params['prefix_id'])) {
$prefixes = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id');
}
// Check for custom field values
-
- if (empty($fields['custom'])) {
- $fields['custom'] = &CRM_Core_BAO_CustomField::getFields(CRM_Utils_Array::value('contact_type', $values),
- FALSE, FALSE, NULL, NULL, FALSE, FALSE, FALSE
- );
- }
+ $customFields = CRM_Core_BAO_CustomField::getFields(CRM_Utils_Array::value('contact_type', $values),
+ FALSE, FALSE, NULL, NULL, FALSE, FALSE, FALSE
+ );
foreach ($values as $key => $value) {
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
// check if it's a valid custom field id
- if (!array_key_exists($customFieldID, $fields['custom'])) {
+ if (!array_key_exists($customFieldID, $customFields)) {
return civicrm_api3_create_error('Invalid custom field ID');
}
else {
if (!array_key_exists($blockFieldName, $values)) {
continue;
}
+ $blockIndex = $values['location_type_id'] . (!empty($values['phone_type_id']) ? '_' . $values['phone_type_id'] : '');
// block present in value array.
if (!array_key_exists($blockFieldName, $params) || !is_array($params[$blockFieldName])) {
}
_civicrm_api3_store_values($fields[$block], $values,
- $params[$blockFieldName][$values['location_type_id']]
+ $params[$blockFieldName][$blockIndex]
);
- $this->fillPrimary($params[$blockFieldName][$values['location_type_id']], $values, $block, CRM_Utils_Array::value('id', $params));
+ $this->fillPrimary($params[$blockFieldName][$blockIndex], $values, $block, CRM_Utils_Array::value('id', $params));
if (empty($params['id']) && (count($params[$blockFieldName]) == 1)) {
- $params[$blockFieldName][$values['location_type_id']]['is_primary'] = TRUE;
+ $params[$blockFieldName][$blockIndex]['is_primary'] = TRUE;
}
// we only process single block at a time.