本文整理汇总了PHP中CRM_Contact_BAO_Contact::createProfileContact方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_Contact::createProfileContact方法的具体用法?PHP CRM_Contact_BAO_Contact::createProfileContact怎么用?PHP CRM_Contact_BAO_Contact::createProfileContact使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_BAO_Contact
的用法示例。
在下文中一共展示了CRM_Contact_BAO_Contact::createProfileContact方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createContact
function createContact(&$input, &$ids, &$objects)
{
$params = array();
$billingID = $ids['billing'];
$lookup = array('first_name', 'last_name', "street_address-{$billingID}", "city-{$billingID}", "state-{$billingID}", "postal_code-{$billingID}", "country-{$billingID}");
foreach ($lookup as $name) {
$params[$name] = $input[$name];
}
if (!empty($params)) {
// update contact record
$contact = CRM_Contact_BAO_Contact::createProfileContact($params, CRM_Core_DAO::$_nullArray, $ids['contact']);
}
return TRUE;
}
示例2: civicrm_dwutils_get_deduped_contact
function civicrm_dwutils_get_deduped_contact($params) {
require_once 'CRM/Dedupe/Finder.php';
$dedupeParams = CRM_Dedupe_Finder::formatParams($params, 'Individual');
$ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, 'Individual');
$fields = array();
foreach($params as $key => $value) {
if(strncmp($key, 'fields_', 7) == 0) {
$new_key = str_replace('fields_', '', $key);
$fields[$new_key] = 1;
unset($params[$key]);
}
}
print_r($fields);
$contact_id = CRM_Utils_Array::value( 0, $ids );
$contact_result =& CRM_Contact_BAO_Contact::createProfileContact( $params, $fields, $contact_id );
return $contact_result;
}
示例3: postProcess
/**
* Function to process the form
*
* @access public
*
* @return None
*/
public function postProcess()
{
$params = $this->controller->exportValues($this->getName());
if (!$this->_contactID && isset($params['cms_create_account'])) {
foreach ($params as $key => $value) {
if (substr($key, 0, 5) == 'email' && !empty($value)) {
list($fieldName, $locTypeId) = CRM_Utils_System::explode('-', $key, 2);
$isPrimary = 0;
if ($locTypeId == 'Primary') {
$locTypeDefault = CRM_Core_BAO_LocationType::getDefault();
$locTypeId = NULL;
if ($locTypeDefault) {
$locTypeId = $locTypeDefault->id;
}
$isPrimary = 1;
}
$params['email'] = array();
$params['email'][1]['email'] = $value;
$params['email'][1]['location_type_id'] = $locTypeId;
$params['email'][1]['is_primary'] = $isPrimary;
}
}
}
$dedupeParams = CRM_Dedupe_Finder::formatParams($params, 'Individual');
$dedupeParams['check_permission'] = FALSE;
$ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, 'Individual', 'Unsupervised');
if ($ids) {
$this->_contactID = $ids['0'];
}
$contactID = CRM_Contact_BAO_Contact::createProfileContact($params, $this->_fields, $this->_contactID);
$this->set('contactID', $contactID);
if (!empty($params['email'])) {
$params['email'] = $params['email'][1]['email'];
}
CRM_Contribute_BAO_Contribution_Utils::createCMSUser($params, $contactID, 'email');
}
示例4: createHonorContact
/**
* Function to create is honor of
*
* @param array $params associated array of fields (by reference)
* @param int $honorId honor Id
*
* @return contact id
*/
function createHonorContact(&$params, $honorId = null)
{
$honorParams = array('first_name' => $params["honor_first_name"], 'last_name' => $params["honor_last_name"], 'prefix_id' => $params["honor_prefix_id"], 'email-Primary' => $params["honor_email"]);
if (!$honorId) {
require_once "CRM/Core/BAO/UFGroup.php";
$honorParams['email'] = $params["honor_email"];
require_once 'CRM/Dedupe/Finder.php';
$dedupeParams = CRM_Dedupe_Finder::formatParams($honorParams, 'Individual');
$dedupeParams['check_permission'] = false;
$ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, 'Individual');
// if we find more than one contact, use the first one
$honorId = CRM_Utils_Array::value(0, $ids);
}
$contact =& CRM_Contact_BAO_Contact::createProfileContact($honorParams, CRM_Core_DAO::$_nullArray, $honorId);
return $contact;
}
示例5: createContact
/**
* method for creating contact
*
*
*/
function createContact(&$formatted, &$contactFields, $onDuplicate, $contactId = null, $requiredCheck = true)
{
$dupeCheck = false;
$newContact = null;
if (is_null($contactId) && $onDuplicate != CRM_Import_Parser::DUPLICATE_NOCHECK) {
$dupeCheck = (bool) $onDuplicate;
}
//get the prefix id etc if exists
CRM_Contact_BAO_Contact::resolveDefaults($formatted, true);
require_once 'api/v2/Contact.php';
// setting required check to false, CRM-2839
// plus we do our own required check in import
$error = civicrm_contact_check_params($formatted, $dupeCheck, true, false);
if (is_null($error) && civicrm_error(_civicrm_validate_formatted_contact($formatted))) {
$error = _civicrm_validate_formatted_contact($formatted);
}
$newContact = $error;
if (is_null($error)) {
if ($contactId) {
$this->formatParams($formatted, $onDuplicate, (int) $contactId);
}
// pass doNotResetCache flag since resetting and rebuilding cache could be expensive.
$config =& CRM_Core_Config::singleton();
$config->doNotResetCache = 1;
$cid = CRM_Contact_BAO_Contact::createProfileContact($formatted, $contactFields, $contactId, null, null, $formatted['contact_type']);
$config->doNotResetCache = 0;
$contact = array('contact_id' => $cid);
$defaults = array();
$newContact = CRM_Contact_BAO_Contact::retrieve($contact, $defaults);
}
//get the id of the contact whose street address is not parsable, CRM-5886
if ($this->_parseStreetAddress && $newContact->address) {
foreach ($newContact->address as $address) {
if ($address['street_address'] && (!CRM_Utils_Array::value('street_number', $address) || !CRM_Utils_Array::value('street_name', $address))) {
$this->_unparsedStreetAddressContacts[] = array('id' => $newContact->id, 'streetAddress' => $address['street_address']);
}
}
}
return $newContact;
}
示例6: find_or_create_contact
/**
* @param null $registeringContactID
* @param array $fields
*
* @return int|mixed|null
*/
static function find_or_create_contact($registeringContactID = NULL, $fields = array())
{
$contact_id = self::find_contact($fields);
if ($contact_id) {
return $contact_id;
}
$contact_params = array('email-Primary' => CRM_Utils_Array::value('email', $fields, NULL), 'first_name' => CRM_Utils_Array::value('first_name', $fields, NULL), 'last_name' => CRM_Utils_Array::value('last_name', $fields, NULL), 'is_deleted' => CRM_Utils_Array::value('is_deleted', $fields, TRUE));
$no_fields = array();
$contact_id = CRM_Contact_BAO_Contact::createProfileContact($contact_params, $no_fields, NULL);
if (!$contact_id) {
CRM_Core_Error::displaySessionError("Could not create or match a contact with that email address. Please contact the webmaster.");
}
return $contact_id;
}
示例7: processFormSubmission
//.........这里部分代码省略.........
}
}
}
foreach ($addToGroups as $k) {
if (array_key_exists($k, $subscribeGroupIds)) {
unset($addToGroups[$k]);
}
}
if (empty($contactID)) {
$dupeParams = $params;
if (!empty($dupeParams['onbehalf'])) {
unset($dupeParams['onbehalf']);
}
if (!empty($dupeParams['honor'])) {
unset($dupeParams['honor']);
}
$dedupeParams = CRM_Dedupe_Finder::formatParams($dupeParams, 'Individual');
$dedupeParams['check_permission'] = FALSE;
$ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, 'Individual');
// if we find more than one contact, use the first one
$contactID = CRM_Utils_Array::value(0, $ids);
// Fetch default greeting id's if creating a contact
if (!$contactID) {
foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) {
if (!isset($params[$greeting])) {
$params[$greeting] = CRM_Contact_BAO_Contact_Utils::defaultGreeting('Individual', $greeting);
}
}
}
$contactType = NULL;
} else {
$contactType = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactID, 'contact_type');
}
$contactID = CRM_Contact_BAO_Contact::createProfileContact($params, $fields, $contactID, $addToGroups, NULL, $contactType, TRUE);
// Make the contact ID associated with the contribution available at the Class level.
// Also make available to the session.
//@todo consider handling this in $this->getContactID();
$this->set('contactID', $contactID);
$this->_contactID = $contactID;
//get email primary first if exist
$subscriptionEmail = array('email' => CRM_Utils_Array::value('email-Primary', $params));
if (!$subscriptionEmail['email']) {
$subscriptionEmail['email'] = CRM_Utils_Array::value("email-{$this->_bltID}", $params);
}
// subscribing contact to groups
if (!empty($subscribeGroupIds) && $subscriptionEmail['email']) {
CRM_Mailing_Event_BAO_Subscribe::commonSubscribe($subscribeGroupIds, $subscriptionEmail, $contactID);
}
// If onbehalf-of-organization contribution / signup, add organization
// and it's location.
if (isset($this->_values['onbehalf_profile_id']) && isset($behalfOrganization['organization_name'])) {
$ufFields = array();
foreach ($this->_fields['onbehalf'] as $name => $value) {
$ufFields[$name] = 1;
}
self::processOnBehalfOrganization($behalfOrganization, $contactID, $this->_values, $this->_params, $ufFields);
} elseif (!empty($this->_membershipContactID) && $contactID != $this->_membershipContactID) {
// this is an onbehalf renew case for inherited membership. For e.g a permissioned member of household,
// store current user id as related contact for later use for mailing / activity..
$this->_values['related_contact'] = $contactID;
$this->_params['related_contact'] = $contactID;
// swap contact like we do for on-behalf-org case, so parent/primary membership is affected
$contactID = $this->_membershipContactID;
}
// lets store the contactID in the session
// for things like tell a friend
示例8: getContactID
/**
* Retrieve a contact ID and if not present.
*
* Create one with this email
*
* @param string $email
* @param string $name
* @param bool $create
* @param string $mail
*
* @return int|null
*/
public static function getContactID($email, $name = NULL, $create = TRUE, &$mail)
{
$dao = CRM_Contact_BAO_Contact::matchContactOnEmail($email, 'Individual');
$contactID = NULL;
if ($dao) {
$contactID = $dao->contact_id;
}
$result = NULL;
CRM_Utils_Hook::emailProcessorContact($email, $contactID, $result);
if (!empty($result)) {
if ($result['action'] == self::EMAILPROCESSOR_IGNORE) {
return NULL;
}
if ($result['action'] == self::EMAILPROCESSOR_OVERRIDE) {
return $result['contactID'];
}
// else this is now create individual
// so we just fall out and do what we normally do
}
if ($contactID) {
return $contactID;
}
if (!$create) {
return NULL;
}
// contact does not exist, lets create it
$params = array('contact_type' => 'Individual', 'email-Primary' => $email);
CRM_Utils_String::extractName($name, $params);
return CRM_Contact_BAO_Contact::createProfileContact($params, CRM_Core_DAO::$_nullArray);
}
示例9: postProcess
/**
* process the form after the input has been submitted and validated
*
* @access public
*
* @return None
*/
public function postProcess()
{
$params = $this->exportValues();
$ufGroupId = $this->get('ufGroupId');
$notify = NULL;
$inValidSubtypeCnt = 0;
//send profile notification email if 'notify' field is set
$notify = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $ufGroupId, 'notify');
foreach ($params['field'] as $key => $value) {
//CRM-5521
//validate subtype before updating
if (CRM_Utils_Array::value('contact_sub_type', $value) && !CRM_Contact_BAO_ContactType::isAllowEdit($key)) {
unset($value['contact_sub_type']);
$inValidSubtypeCnt++;
}
$value['preserveDBName'] = $this->_preserveDefault;
//parse street address, CRM-7768
self::parseStreetAddress($value, $this);
CRM_Contact_BAO_Contact::createProfileContact($value, $this->_fields, $key, NULL, $ufGroupId);
if ($notify) {
$values = CRM_Core_BAO_UFGroup::checkFieldsEmptyValues($ufGroupId, $key, NULL);
CRM_Core_BAO_UFGroup::commonSendMail($key, $values);
}
}
$statusMsg = ts("Your updates have been saved.");
if ($inValidSubtypeCnt) {
$statusMsg .= ' ' . ts('Contact SubType field of %1 number of contact(s) has not been updated.', array(1 => $inValidSubtypeCnt));
}
CRM_Core_Session::setStatus("{$statusMsg}");
}
示例10: createContact
/**
* method for creating contact
*
*
*/
function createContact(&$formatted, &$contactFields, $onDuplicate, $contactId = null, $requiredCheck = true)
{
$dupeCheck = false;
$newContact = null;
if (is_null($contactId) && $onDuplicate != CRM_Import_Parser::DUPLICATE_NOCHECK) {
$dupeCheck = (bool) $onDuplicate;
}
//get the prefix id etc if exists
CRM_Contact_BAO_Contact::resolveDefaults($formatted, true);
require_once 'api/v2/Contact.php';
// setting required check to false, CRM-2839
// plus we do our own required check in import
$error = civicrm_contact_check_params($formatted, $dupeCheck, true, false);
if (is_null($error) && civicrm_error(_civicrm_validate_formatted_contact($formatted))) {
$error = _civicrm_validate_formatted_contact($formatted);
}
$newContact = $error;
if (is_null($error)) {
if ($contactId) {
$this->formatParams($formatted, $onDuplicate, (int) $contactId);
}
$cid = CRM_Contact_BAO_Contact::createProfileContact($formatted, $contactFields, $contactId, null, null, $formatted['contact_type']);
$contact = array('contact_id' => $cid);
$defaults = array();
$newContact = CRM_Contact_BAO_Contact::retrieve($contact, $defaults);
}
return $newContact;
}
示例11: civicrm_replace_contact_formatted
/**
* @todo What does this do? If it's still useful, figure out where it should live and what it should be named.
*
* @deprecated deprecated since version 2.2.3
*/
function civicrm_replace_contact_formatted($contactId, &$params, &$fields)
{
//$contact = civcrm_get_contact(array('contact_id' => $contactId));
$delContact = array('contact_id' => $contactId);
civicrm_contact_delete($delContact);
$cid = CRM_Contact_BAO_Contact::createProfileContact($params, $fields, NULL, NULL, NULL, $params['contact_type']);
return civicrm_create_success($cid);
}
示例12: submit
//.........这里部分代码省略.........
$params['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $formValues);
}
$this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($formValues['payment_processor_id'], $this->_mode);
//get the payment processor id as per mode.
$params['payment_processor_id'] = $formValues['payment_processor_id'] = $this->_paymentProcessor['id'];
$now = date('YmdHis');
$fields = array();
// set email for primary location.
$fields['email-Primary'] = 1;
$formValues['email-5'] = $formValues['email-Primary'] = $this->_memberEmail;
$params['register_date'] = $now;
// now set the values for the billing location.
foreach ($this->_fields as $name => $dontCare) {
$fields[$name] = 1;
}
// also add location name to the array
$formValues["address_name-{$this->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $formValues) . ' ' . CRM_Utils_Array::value('billing_middle_name', $formValues) . ' ' . CRM_Utils_Array::value('billing_last_name', $formValues);
$formValues["address_name-{$this->_bltID}"] = trim($formValues["address_name-{$this->_bltID}"]);
$fields["address_name-{$this->_bltID}"] = 1;
//ensure we don't over-write the payer's email with the member's email
if ($this->_contributorContactID == $this->_contactID) {
$fields["email-{$this->_bltID}"] = 1;
}
$nameFields = array('first_name', 'middle_name', 'last_name');
foreach ($nameFields as $name) {
$fields[$name] = 1;
if (array_key_exists("billing_{$name}", $formValues)) {
$formValues[$name] = $formValues["billing_{$name}"];
$formValues['preserveDBName'] = TRUE;
}
}
if ($this->_contributorContactID == $this->_contactID) {
//see CRM-12869 for discussion of why we don't do this for separate payee payments
CRM_Contact_BAO_Contact::createProfileContact($formValues, $fields, $this->_contributorContactID, NULL, NULL, CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactID, 'contact_type'));
}
// add all the additional payment params we need
$formValues["state_province-{$this->_bltID}"] = $formValues["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($formValues["billing_state_province_id-{$this->_bltID}"]);
$formValues["country-{$this->_bltID}"] = $formValues["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($formValues["billing_country_id-{$this->_bltID}"]);
$formValues['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($formValues);
$formValues['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($formValues);
$formValues['ip_address'] = CRM_Utils_System::ipAddress();
$formValues['amount'] = $params['total_amount'];
$formValues['currencyID'] = $config->defaultCurrency;
$formValues['description'] = ts("Contribution submitted by a staff person using member's credit card for signup");
$formValues['invoiceID'] = md5(uniqid(rand(), TRUE));
$formValues['financial_type_id'] = $params['financial_type_id'];
// at this point we've created a contact and stored its address etc
// all the payment processors expect the name and address to be in the
// so we copy stuff over to first_name etc.
$paymentParams = $formValues;
$paymentParams['contactID'] = $this->_contributorContactID;
//CRM-10377 if payment is by an alternate contact then we need to set that person
// as the contact in the payment params
if ($this->_contributorContactID != $this->_contactID) {
if (!empty($formValues['soft_credit_type_id'])) {
$softParams['contact_id'] = $params['contact_id'];
$softParams['soft_credit_type_id'] = $formValues['soft_credit_type_id'];
}
}
if (!empty($formValues['send_receipt'])) {
$paymentParams['email'] = $this->_contributorEmail;
}
CRM_Core_Payment_Form::mapParams($this->_bltID, $formValues, $paymentParams, TRUE);
// CRM-7137 -for recurring membership,
// we do need contribution and recurring records.
$result = NULL;
示例13: CRM_Core_DAO_UFMatch
//.........这里部分代码省略.........
if (!$ufmatch->find(TRUE)) {
$transaction = new CRM_Core_Transaction();
$dao = NULL;
if (!empty($_POST) && !$isLogin) {
$params = $_POST;
$params['email'] = $uniqId;
$dedupeParams = CRM_Dedupe_Finder::formatParams($params, 'Individual');
$dedupeParams['check_permission'] = FALSE;
$ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, 'Individual');
if (!empty($ids) && Civi::settings()->get('uniq_email_per_site')) {
// restrict dupeIds to ones that belong to current domain/site.
$siteContacts = CRM_Core_BAO_Domain::getContactList();
foreach ($ids as $index => $dupeId) {
if (!in_array($dupeId, $siteContacts)) {
unset($ids[$index]);
}
}
// re-index the array
$ids = array_values($ids);
}
if (!empty($ids)) {
$dao = new CRM_Core_DAO();
$dao->contact_id = $ids[0];
}
} else {
$dao = CRM_Contact_BAO_Contact::matchContactOnEmail($uniqId, $ctype);
}
$found = FALSE;
if ($dao) {
// ensure there does not exists a contact_id / uf_id pair
// in the DB. This might be due to multiple emails per contact
// CRM-9091
$sql = "\nSELECT id\nFROM civicrm_uf_match\nWHERE contact_id = %1\nAND domain_id = %2\n";
$params = array(1 => array($dao->contact_id, 'Integer'), 2 => array(CRM_Core_Config::domainID(), 'Integer'));
$conflict = CRM_Core_DAO::singleValueQuery($sql, $params);
if (!$conflict) {
$found = TRUE;
$ufmatch->contact_id = $dao->contact_id;
$ufmatch->uf_name = $uniqId;
}
}
if (!$found) {
if ($config->userSystem->is_drupal) {
$mail = 'mail';
} elseif ($uf == 'WordPress') {
$mail = 'user_email';
} else {
$mail = 'email';
}
if (is_object($user)) {
$params = array('email-Primary' => $user->{$mail});
}
if ($ctype == 'Organization') {
$params['organization_name'] = $uniqId;
} elseif ($ctype == 'Household') {
$params['household_name'] = $uniqId;
}
if (!$ctype) {
$ctype = "Individual";
}
$params['contact_type'] = $ctype;
// extract first / middle / last name
// for joomla
if ($uf == 'Joomla' && $user->name) {
CRM_Utils_String::extractName($user->name, $params);
}
if ($uf == 'WordPress') {
if ($user->first_name) {
$params['first_name'] = $user->first_name;
}
if ($user->last_name) {
$params['last_name'] = $user->last_name;
}
}
$contactId = CRM_Contact_BAO_Contact::createProfileContact($params, CRM_Core_DAO::$_nullArray);
$ufmatch->contact_id = $contactId;
$ufmatch->uf_name = $uniqId;
}
// check that there are not two CMS IDs matching the same CiviCRM contact - this happens when a civicrm
// user has two e-mails and there is a cms match for each of them
// the gets rid of the nasty fata error but still reports the error
$sql = "\nSELECT uf_id\nFROM civicrm_uf_match\nWHERE ( contact_id = %1\nOR uf_name = %2\nOR uf_id = %3 )\nAND domain_id = %4\n";
$params = array(1 => array($ufmatch->contact_id, 'Integer'), 2 => array($ufmatch->uf_name, 'String'), 3 => array($ufmatch->uf_id, 'Integer'), 4 => array($ufmatch->domain_id, 'Integer'));
$conflict = CRM_Core_DAO::singleValueQuery($sql, $params);
if (!$conflict) {
$ufmatch = CRM_Core_BAO_UFMatch::create((array) $ufmatch);
$ufmatch->free();
$newContact = TRUE;
$transaction->commit();
} else {
$msg = ts("Contact ID %1 is a match for %2 user %3 but has already been matched to %4", array(1 => $ufmatch->contact_id, 2 => $uf, 3 => $ufmatch->uf_id, 4 => $conflict));
unset($conflict);
}
}
if ($status) {
return $newContact;
} else {
return $ufmatch;
}
}
示例14: updateContactFields
/**
* Update contact fields.
*
* @param int $contactID
* @param array $params
* @param array $fields
* @param CRM_Core_Form $form
*
* @return int
*/
public static function updateContactFields($contactID, $params, $fields, &$form)
{
//add the contact to group, if add to group is selected for a
//particular uf group
// get the add to groups
$addToGroups = array();
if (!empty($form->_fields)) {
foreach ($form->_fields as $key => $value) {
if (!empty($value['add_to_group_id'])) {
$addToGroups[$value['add_to_group_id']] = $value['add_to_group_id'];
}
}
}
// check for profile double opt-in and get groups to be subscribed
$subscribeGroupIds = CRM_Core_BAO_UFGroup::getDoubleOptInGroupIds($params, $contactID);
foreach ($addToGroups as $k) {
if (array_key_exists($k, $subscribeGroupIds)) {
unset($addToGroups[$k]);
}
}
// since we are directly adding contact to group lets unset it from mailing
if (!empty($addToGroups)) {
foreach ($addToGroups as $groupId) {
if (isset($subscribeGroupIds[$groupId])) {
unset($subscribeGroupIds[$groupId]);
}
}
}
if ($contactID) {
$ctype = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactID, 'contact_type');
if (array_key_exists('contact_id', $params) && empty($params['contact_id'])) {
// we unset this here because the downstream function ignores the contactID we give it
// if it is set & it is difficult to understand the implications of 'fixing' this downstream
// but if we are passing a contact id into this function it's reasonable to assume we don't
// want it ignored
unset($params['contact_id']);
}
$contactID = CRM_Contact_BAO_Contact::createProfileContact($params, $fields, $contactID, $addToGroups, NULL, $ctype, TRUE);
} else {
foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) {
if (!isset($params[$greeting . '_id'])) {
$params[$greeting . '_id'] = CRM_Contact_BAO_Contact_Utils::defaultGreeting('Individual', $greeting);
}
}
$contactID = CRM_Contact_BAO_Contact::createProfileContact($params, $fields, NULL, $addToGroups, NULL, NULL, TRUE);
$form->set('contactID', $contactID);
}
//get email primary first if exist
$subscribtionEmail = array('email' => CRM_Utils_Array::value('email-Primary', $params));
if (!$subscribtionEmail['email']) {
$subscribtionEmail['email'] = CRM_Utils_Array::value("email-{$form->_bltID}", $params);
}
// subscribing contact to groups
if (!empty($subscribeGroupIds) && $subscribtionEmail['email']) {
CRM_Mailing_Event_BAO_Subscribe::commonSubscribe($subscribeGroupIds, $subscribtionEmail, $contactID);
}
return $contactID;
}
示例15: processBillingAddress
/**
* Add the billing address to the contact who paid.
*/
protected function processBillingAddress()
{
$fields = array();
// set email for primary location.
$fields['email-Primary'] = 1;
$this->_params['email-5'] = $this->_params['email-Primary'] = $this->_contributorEmail;
// also add location name to the array
$this->_params["address_name-{$this->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $this->_params) . ' ' . CRM_Utils_Array::value('billing_middle_name', $this->_params) . ' ' . CRM_Utils_Array::value('billing_last_name', $this->_params);
$this->_params["address_name-{$this->_bltID}"] = trim($this->_params["address_name-{$this->_bltID}"]);
$fields["address_name-{$this->_bltID}"] = 1;
$fields["email-{$this->_bltID}"] = 1;
list($hasBillingField, $addressParams) = CRM_Contribute_BAO_Contribution::getPaymentProcessorReadyAddressParams($this->_params, $this->_bltID);
$addressParams['preserveDBName'] = TRUE;
if ($hasBillingField) {
$addressParams = array_merge($this->_params, $addressParams);
//here we are setting up the billing contact - if different from the member they are already created
// but they will get billing details assigned
CRM_Contact_BAO_Contact::createProfileContact($addressParams, $fields, $this->_contributorContactID, NULL, NULL, CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactID, 'contact_type'));
}
}