当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Contact_DAO_Contact::import方法代码示例

本文整理汇总了PHP中CRM_Contact_DAO_Contact::import方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_DAO_Contact::import方法的具体用法?PHP CRM_Contact_DAO_Contact::import怎么用?PHP CRM_Contact_DAO_Contact::import使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Contact_DAO_Contact的用法示例。


在下文中一共展示了CRM_Contact_DAO_Contact::import方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: import

 /**
  * handle the values in import mode
  *
  * @param int $onDuplicate the code for what action to take on duplicates
  * @param array $values the array of values belonging to this line
  *
  * @return boolean      the result of this processing
  * @access public
  */
 function import($onDuplicate, &$values, $doGeocodeAddress = false)
 {
     $config =& CRM_Core_Config::singleton();
     $this->_unparsedStreetAddressContacts = array();
     if (!$doGeocodeAddress) {
         // CRM-5854, reset the geocode method to null to prevent geocoding
         $config->geocodeMethod = null;
     }
     // first make sure this is a valid line
     //$this->_updateWithId = false;
     $response = $this->summary($values);
     $statusFieldName = $this->_statusFieldName;
     if ($response != CRM_Import_Parser::VALID) {
         $importRecordParams = array($statusFieldName => 'INVALID', "{$statusFieldName}Msg" => "Invalid (Error Code: {$response})");
         $this->updateImportRecord($values[count($values) - 1], $importRecordParams);
         return $response;
     }
     $params =& $this->getActiveFieldParams();
     $formatted = array('contact_type' => $this->_contactType);
     static $contactFields = null;
     if ($contactFields == null) {
         require_once "CRM/Contact/DAO/Contact.php";
         $contactFields =& CRM_Contact_DAO_Contact::import();
     }
     //check if external identifier exists in database
     if (CRM_Utils_Array::value('external_identifier', $params) && (CRM_Utils_Array::value('id', $params) || in_array($onDuplicate, array(CRM_Import_Parser::DUPLICATE_SKIP, CRM_Import_Parser::DUPLICATE_NOCHECK)))) {
         require_once "CRM/Contact/BAO/Contact.php";
         if ($internalCid = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params['external_identifier'], 'id', 'external_identifier')) {
             if ($internalCid != CRM_Utils_Array::value('id', $params)) {
                 $errorMessage = ts('External Identifier already exists in database.');
                 array_unshift($values, $errorMessage);
                 $importRecordParams = array($statusFieldName => 'ERROR', "{$statusFieldName}Msg" => $errorMessage);
                 $this->updateImportRecord($values[count($values) - 1], $importRecordParams);
                 return CRM_Import_Parser::ERROR;
             }
         }
     }
     if (!empty($this->_contactSubType)) {
         $params['contact_sub_type'] = $this->_contactSubType;
     }
     if ($subType = CRM_Utils_Array::value('contact_sub_type', $params)) {
         if (CRM_Contact_BAO_ContactType::isExtendsContactType($subType, $this->_contactType, false, 'label')) {
             $subTypes = CRM_Contact_BAO_ContactType::subTypePairs($this->_contactType, false, null);
             $params['contact_sub_type'] = array_search($subType, $subTypes);
         } elseif (!CRM_Contact_BAO_ContactType::isExtendsContactType($subType, $this->_contactType)) {
             $message = "Mismatched or Invalid Contact SubType.";
             array_unshift($values, $message);
             return CRM_Import_Parser::NO_MATCH;
         }
     }
     //get contact id to format common data in update/fill mode,
     //if external identifier is present, CRM-4423
     if ($this->_updateWithId && !CRM_Utils_Array::value('id', $params) && CRM_Utils_Array::value('external_identifier', $params)) {
         if ($cid = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params['external_identifier'], 'id', 'external_identifier')) {
             $formatted['id'] = $cid;
         }
     }
     //format common data, CRM-4062
     $this->formatCommonData($params, $formatted, $contactFields);
     $relationship = false;
     $createNewContact = true;
     // Support Match and Update Via Contact ID
     if ($this->_updateWithId) {
         $createNewContact = false;
         if (!CRM_Utils_Array::value('id', $params) && CRM_Utils_Array::value('external_identifier', $params)) {
             if ($cid) {
                 $params['id'] = $cid;
             } else {
                 //update contact if dedupe found contact id, CRM-4148
                 $dedupeParams = $formatted;
                 //special case to check dedupe if external id present.
                 //if we send external id dedupe will stop.
                 unset($dedupeParams['external_identifier']);
                 $checkDedupe = _civicrm_duplicate_formatted_contact($dedupeParams);
                 if (civicrm_duplicate($checkDedupe)) {
                     $matchingContactIds = explode(',', $checkDedupe['error_message']['params'][0]);
                     if (count($matchingContactIds) == 1) {
                         $params['id'] = array_pop($matchingContactIds);
                     } else {
                         $message = "More than one matching contact found for given criteria.";
                         array_unshift($values, $message);
                         $this->_retCode = CRM_Import_Parser::NO_MATCH;
                     }
                 } else {
                     $createNewContact = true;
                 }
             }
         }
         $error = _civicrm_duplicate_formatted_contact($formatted);
         if (civicrm_duplicate($error)) {
             $matchedIDs = explode(',', $error['error_message']['params'][0]);
//.........这里部分代码省略.........
开发者ID:bhirsch,项目名称:voipdev,代码行数:101,代码来源:Contact.php

示例2: importableFields

 /**
  * Combine all the importable fields from the lower levels object.
  *
  * The ordering is important, since currently we do not have a weight
  * scheme. Adding weight is super important
  *
  * @param int|string $contactType contact Type
  * @param bool $status
  *   Status is used to manipulate first title.
  * @param bool $showAll
  *   If true returns all fields (includes disabled fields).
  * @param bool $isProfile
  *   If its profile mode.
  * @param bool $checkPermission
  *   If false, do not include permissioning clause (for custom data).
  *
  * @param bool $withMultiCustomFields
  *
  * @return array
  *   array of importable Fields
  */
 public static function importableFields($contactType = 'Individual', $status = FALSE, $showAll = FALSE, $isProfile = FALSE, $checkPermission = TRUE, $withMultiCustomFields = FALSE)
 {
     if (empty($contactType)) {
         $contactType = 'All';
     }
     $cacheKeyString = "importableFields {$contactType}";
     $cacheKeyString .= $status ? '_1' : '_0';
     $cacheKeyString .= $showAll ? '_1' : '_0';
     $cacheKeyString .= $isProfile ? '_1' : '_0';
     $cacheKeyString .= $checkPermission ? '_1' : '_0';
     $fields = CRM_Utils_Array::value($cacheKeyString, self::$_importableFields);
     if (!$fields) {
         // check if we can retrieve from database cache
         $fields = CRM_Core_BAO_Cache::getItem('contact fields', $cacheKeyString);
     }
     if (!$fields) {
         $fields = CRM_Contact_DAO_Contact::import();
         // get the fields thar are meant for contact types
         if (in_array($contactType, array('Individual', 'Household', 'Organization', 'All'))) {
             $fields = array_merge($fields, CRM_Core_OptionValue::getFields('', $contactType));
         }
         $locationFields = array_merge(CRM_Core_DAO_Address::import(), CRM_Core_DAO_Phone::import(), CRM_Core_DAO_Email::import(), CRM_Core_DAO_IM::import(TRUE), CRM_Core_DAO_OpenID::import());
         $locationFields = array_merge($locationFields, CRM_Core_BAO_CustomField::getFieldsForImport('Address', FALSE, FALSE, FALSE, FALSE));
         foreach ($locationFields as $key => $field) {
             $locationFields[$key]['hasLocationType'] = TRUE;
         }
         $fields = array_merge($fields, $locationFields);
         $fields = array_merge($fields, CRM_Contact_DAO_Contact::import());
         $fields = array_merge($fields, CRM_Core_DAO_Note::import());
         //website fields
         $fields = array_merge($fields, CRM_Core_DAO_Website::import());
         $fields['url']['hasWebsiteType'] = TRUE;
         if ($contactType != 'All') {
             $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport($contactType, $showAll, TRUE, FALSE, FALSE, $withMultiCustomFields));
             //unset the fields, which are not related to their
             //contact type.
             $commonValues = array('Individual' => array('household_name', 'legal_name', 'sic_code', 'organization_name'), 'Household' => array('first_name', 'middle_name', 'last_name', 'formal_title', 'job_title', 'gender_id', 'prefix_id', 'suffix_id', 'birth_date', 'organization_name', 'legal_name', 'legal_identifier', 'sic_code', 'home_URL', 'is_deceased', 'deceased_date'), 'Organization' => array('first_name', 'middle_name', 'last_name', 'formal_title', 'job_title', 'gender_id', 'prefix_id', 'suffix_id', 'birth_date', 'household_name', 'is_deceased', 'deceased_date'));
             foreach ($commonValues[$contactType] as $value) {
                 unset($fields[$value]);
             }
         } else {
             foreach (array('Individual', 'Household', 'Organization') as $type) {
                 $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport($type, $showAll, FALSE, FALSE, FALSE, $withMultiCustomFields));
             }
         }
         if ($isProfile) {
             $fields = array_merge($fields, array('group' => array('title' => ts('Group(s)'), 'name' => 'group'), 'tag' => array('title' => ts('Tag(s)'), 'name' => 'tag'), 'note' => array('title' => ts('Note(s)'), 'name' => 'note'), 'communication_style_id' => array('title' => ts('Communication Style'), 'name' => 'communication_style_id')));
         }
         //Sorting fields in alphabetical order(CRM-1507)
         $fields = CRM_Utils_Array::crmArraySortByField($fields, 'title');
         CRM_Core_BAO_Cache::setItem($fields, 'contact fields', $cacheKeyString);
     }
     self::$_importableFields[$cacheKeyString] = $fields;
     if (!$isProfile) {
         if (!$status) {
             $fields = array_merge(array('do_not_import' => array('title' => ts('- do not import -'))), self::$_importableFields[$cacheKeyString]);
         } else {
             $fields = array_merge(array('' => array('title' => ts('- Contact Fields -'))), self::$_importableFields[$cacheKeyString]);
         }
     }
     return $fields;
 }
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:83,代码来源:Contact.php

示例3: array

 /**
  * combine all the importable fields from the lower levels object
  *
  * The ordering is important, since currently we do not have a weight
  * scheme. Adding weight is super important and should be done in the
  * next week or so, before this can be called complete.
  *
  * @param int     $contactType contact Type
  * @param boolean $status  status is used to manipulate first title
  * @param boolean $showAll if true returns all fields (includes disabled fields)
  * @param boolean $isProfile if its profile mode
  *
  * @return array array of importable Fields
  * @access public
  */
 function &importableFields($contactType = 'Individual', $status = false, $showAll = false, $isProfile = false)
 {
     if (empty($contactType)) {
         $contactType = 'All';
     }
     $cacheKeyString = "importableFields {$contactType}";
     $cacheKeyString .= $status ? "_1" : "_0";
     $cacheKeyString .= $showAll ? "_1" : "_0";
     $cacheKeyString .= $isProfile ? "_1" : "_0";
     if (!self::$_importableFields || !CRM_Utils_Array::value($cacheKeyString, self::$_importableFields)) {
         if (!self::$_importableFields) {
             self::$_importableFields = array();
         }
         // check if we can retrieve from database cache
         require_once 'CRM/Core/BAO/Cache.php';
         $fields =& CRM_Core_BAO_Cache::getItem('contact fields', $cacheKeyString);
         if (!$fields) {
             $fields = CRM_Contact_DAO_Contact::import();
             require_once "CRM/Core/OptionValue.php";
             // get the fields thar are meant for contact types
             if (in_array($contactType, array('Individual', 'Household', 'Organization', 'All'))) {
                 $fields = array_merge($fields, CRM_Core_OptionValue::getFields('', $contactType));
             }
             $locationFields = array_merge(CRM_Core_DAO_Address::import(), CRM_Core_DAO_Phone::import(), CRM_Core_DAO_Email::import(), CRM_Core_DAO_IM::import(true), CRM_Core_DAO_OpenID::import());
             foreach ($locationFields as $key => $field) {
                 $locationFields[$key]['hasLocationType'] = true;
             }
             $fields = array_merge($fields, $locationFields);
             $fields = array_merge($fields, CRM_Contact_DAO_Contact::import());
             $fields = array_merge($fields, CRM_Core_DAO_Note::import());
             if ($contactType != 'All') {
                 $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport($contactType, $showAll, true));
                 //unset the fields, which are not related to their
                 //contact type.
                 $commonValues = array('Individual' => array('household_name', 'legal_name', 'sic_code', 'organization_name'), 'Household' => array('first_name', 'middle_name', 'last_name', 'job_title', 'gender_id', 'birth_date', 'organization_name', 'legal_name', 'legal_identifier', 'sic_code', 'home_URL', 'is_deceased', 'deceased_date'), 'Organization' => array('first_name', 'middle_name', 'last_name', 'job_title', 'gender_id', 'birth_date', 'household_name', 'email_greeting', 'email_greeting_custom', 'postal_greeting', 'postal_greeting_custom', 'is_deceased', 'deceased_date'));
                 foreach ($commonValues[$contactType] as $value) {
                     unset($fields[$value]);
                 }
             } else {
                 foreach (array('Individual', 'Household', 'Organization') as $type) {
                     $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport($type, $showAll));
                 }
             }
             if ($isProfile) {
                 $fields = array_merge($fields, array('group' => array('title' => ts('Group(s)')), 'tag' => array('title' => ts('Tag(s)')), 'note' => array('title' => ts('Note(s)'))));
             }
             //Sorting fields in alphabetical order(CRM-1507)
             foreach ($fields as $k => $v) {
                 $sortArray[$k] = $v['title'];
             }
             asort($sortArray);
             $fields = array_merge($sortArray, $fields);
             CRM_Core_BAO_Cache::setItem($fields, 'contact fields', $cacheKeyString);
         }
         self::$_importableFields[$cacheKeyString] = $fields;
     }
     if (!$isProfile) {
         if (!$status) {
             $fields = array_merge(array('do_not_import' => array('title' => ts('- do not import -'))), self::$_importableFields[$cacheKeyString]);
         } else {
             $fields = array_merge(array('' => array('title' => ts('- Contact Fields -'))), self::$_importableFields[$cacheKeyString]);
         }
     }
     return $fields;
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:80,代码来源:Contact.php

示例4: import

 /**
  * Handle the values in import mode.
  *
  * @param int $onDuplicate
  *   The code for what action to take on duplicates.
  * @param array $values
  *   The array of values belonging to this line.
  *
  * @param bool $doGeocodeAddress
  *
  * @return bool
  *   the result of this processing
  */
 public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE)
 {
     $config = CRM_Core_Config::singleton();
     $this->_unparsedStreetAddressContacts = array();
     if (!$doGeocodeAddress) {
         // CRM-5854, reset the geocode method to null to prevent geocoding
         $config->geocodeMethod = NULL;
     }
     // first make sure this is a valid line
     //$this->_updateWithId = false;
     $response = $this->summary($values);
     $statusFieldName = $this->_statusFieldName;
     if ($response != CRM_Import_Parser::VALID) {
         $importRecordParams = array($statusFieldName => 'INVALID', "{$statusFieldName}Msg" => "Invalid (Error Code: {$response})");
         $this->updateImportRecord($values[count($values) - 1], $importRecordParams);
         return $response;
     }
     $params =& $this->getActiveFieldParams();
     $formatted = array('contact_type' => $this->_contactType);
     static $contactFields = NULL;
     if ($contactFields == NULL) {
         $contactFields = CRM_Contact_DAO_Contact::import();
     }
     //check if external identifier exists in database
     if (!empty($params['external_identifier']) && (!empty($params['id']) || in_array($onDuplicate, array(CRM_Import_Parser::DUPLICATE_SKIP, CRM_Import_Parser::DUPLICATE_NOCHECK)))) {
         if ($internalCid = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params['external_identifier'], 'id', 'external_identifier')) {
             if ($internalCid != CRM_Utils_Array::value('id', $params)) {
                 $errorMessage = ts('External ID already exists in Database.');
                 array_unshift($values, $errorMessage);
                 $importRecordParams = array($statusFieldName => 'ERROR', "{$statusFieldName}Msg" => $errorMessage);
                 $this->updateImportRecord($values[count($values) - 1], $importRecordParams);
                 return CRM_Import_Parser::DUPLICATE;
             }
         }
     }
     if (!empty($this->_contactSubType)) {
         $params['contact_sub_type'] = $this->_contactSubType;
     }
     if ($subType = CRM_Utils_Array::value('contact_sub_type', $params)) {
         if (CRM_Contact_BAO_ContactType::isExtendsContactType($subType, $this->_contactType, FALSE, 'label')) {
             $subTypes = CRM_Contact_BAO_ContactType::subTypePairs($this->_contactType, FALSE, NULL);
             $params['contact_sub_type'] = array_search($subType, $subTypes);
         } elseif (!CRM_Contact_BAO_ContactType::isExtendsContactType($subType, $this->_contactType)) {
             $message = "Mismatched or Invalid Contact Subtype.";
             array_unshift($values, $message);
             return CRM_Import_Parser::NO_MATCH;
         }
     }
     // Get contact id to format common data in update/fill mode,
     // prioritising a dedupe rule check over an external_identifier check, but falling back on ext id.
     if ($this->_updateWithId && empty($params['id'])) {
         $possibleMatches = $this->getPossibleContactMatches($params);
         foreach ($possibleMatches as $possibleID) {
             $params['id'] = $formatted['id'] = $possibleID;
         }
     }
     //format common data, CRM-4062
     $this->formatCommonData($params, $formatted, $contactFields);
     $relationship = FALSE;
     $createNewContact = TRUE;
     // Support Match and Update Via Contact ID
     if ($this->_updateWithId && isset($params['id'])) {
         $createNewContact = FALSE;
         // @todo - it feels like all the rows from here to the end of the IF
         // could be removed in favour of a simple check for whether the contact_type & id match
         // the call to the deprecated function seems to add no value other that to do an additional
         // check for the contact_id & type.
         $error = _civicrm_api3_deprecated_duplicate_formatted_contact($formatted);
         if (CRM_Core_Error::isAPIError($error, CRM_Core_ERROR::DUPLICATE_CONTACT)) {
             $matchedIDs = explode(',', $error['error_message']['params'][0]);
             if (count($matchedIDs) >= 1) {
                 $updateflag = TRUE;
                 foreach ($matchedIDs as $contactId) {
                     if ($params['id'] == $contactId) {
                         $contactType = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params['id'], 'contact_type');
                         if ($formatted['contact_type'] == $contactType) {
                             //validation of subtype for update mode
                             //CRM-5125
                             $contactSubType = NULL;
                             if (!empty($params['contact_sub_type'])) {
                                 $contactSubType = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params['id'], 'contact_sub_type');
                             }
                             if (!empty($contactSubType) && (!CRM_Contact_BAO_ContactType::isAllowEdit($params['id'], $contactSubType) && $contactSubType != CRM_Utils_Array::value('contact_sub_type', $formatted))) {
                                 $message = "Mismatched contact SubTypes :";
                                 array_unshift($values, $message);
                                 $updateflag = FALSE;
                                 $this->_retCode = CRM_Import_Parser::NO_MATCH;
//.........这里部分代码省略.........
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:101,代码来源:Contact.php

示例5: array

 /**
  * combine all the importable fields from the lower levels object
  *
  * The ordering is important, since currently we do not have a weight
  * scheme. Adding weight is super important and should be done in the
  * next week or so, before this can be called complete.
  *
  * @param int     $contactType contact Type
  * @param boolean $status  status is used to manipulate first title
  * @param boolean $showAll if true returns all fields (includes disabled fields)
  *
  * @return array array of importable Fields
  * @access public
  */
 function &importableFields($contactType = 'Individual', $status = false, $showAll = false)
 {
     if (empty($contactType)) {
         $contactType = 'All';
     }
     if (!$GLOBALS['_CRM_CONTACT_BAO_CONTACT']['_importableFields'] || !CRM_Utils_Array::value($contactType, $GLOBALS['_CRM_CONTACT_BAO_CONTACT']['_importableFields'])) {
         if (!$GLOBALS['_CRM_CONTACT_BAO_CONTACT']['_importableFields']) {
             $GLOBALS['_CRM_CONTACT_BAO_CONTACT']['_importableFields'] = array();
         }
         if (!$status) {
             $fields = array('do_not_import' => array('title' => ts('- do not import -')));
         } else {
             $fields = array('' => array('title' => ts('- Contact Fields -')));
         }
         if ($contactType != 'All') {
             require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_DAO_" . $contactType) . ".php";
             eval('$tmpFields = array_merge($fields, CRM_Contact_DAO_' . $contactType . '::import( ));');
             $fields = array_merge($fields, $tmpFields);
         } else {
             foreach (array('Individual', 'Household', 'Organization') as $type) {
                 require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_DAO_" . $type) . ".php";
                 eval('$tmpFields = array_merge($fields, CRM_Contact_DAO_' . $type . '::import( ));');
                 $fields = array_merge($fields, $tmpFields);
             }
         }
         // the fields are only meant for Individual contact type
         if ($contactType == 'Individual' || $contactType == 'All') {
             $fields = array_merge($fields, CRM_Core_DAO_IndividualPrefix::import(true), CRM_Core_DAO_IndividualSuffix::import(true), CRM_Core_DAO_Gender::import(true));
         }
         $locationFields = array_merge(CRM_Core_DAO_Location::import(), CRM_Core_DAO_Address::import(), CRM_Core_DAO_Phone::import(), CRM_Core_DAO_Email::import(), CRM_Core_DAO_IM::import(true));
         foreach ($locationFields as $key => $field) {
             $locationFields[$key]['hasLocationType'] = true;
         }
         $fields = array_merge($fields, $locationFields);
         $fields = array_merge($fields, CRM_Contact_DAO_Contact::import());
         $fields = array_merge($fields, CRM_Core_DAO_Note::import());
         if ($contactType != 'All') {
             $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport($contactType, $showAll));
         } else {
             foreach (array('Individual', 'Household', 'Organization') as $type) {
                 $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport($type, $showAll));
             }
         }
         $GLOBALS['_CRM_CONTACT_BAO_CONTACT']['_importableFields'][$contactType] = $fields;
     }
     return $GLOBALS['_CRM_CONTACT_BAO_CONTACT']['_importableFields'][$contactType];
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:61,代码来源:Contact.php


注:本文中的CRM_Contact_DAO_Contact::import方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。