本文整理汇总了PHP中CRM_Core_BAO_UFGroup::checkFieldsEmptyValues方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_UFGroup::checkFieldsEmptyValues方法的具体用法?PHP CRM_Core_BAO_UFGroup::checkFieldsEmptyValues怎么用?PHP CRM_Core_BAO_UFGroup::checkFieldsEmptyValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_UFGroup
的用法示例。
在下文中一共展示了CRM_Core_BAO_UFGroup::checkFieldsEmptyValues方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
/**
* Process the form after the input has been submitted and validated.
*/
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 (!empty($value['contact_sub_type']) && !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, NULL, TRUE);
if ($notify) {
$values = CRM_Core_BAO_UFGroup::checkFieldsEmptyValues($ufGroupId, $key, NULL);
CRM_Core_BAO_UFGroup::commonSendMail($key, $values);
}
}
CRM_Core_Session::setStatus('', ts("Updates Saved"), 'success');
if ($inValidSubtypeCnt) {
CRM_Core_Session::setStatus(ts('Contact Subtype field of 1 contact has not been updated.', array('plural' => 'Contact Subtype field of %count contacts has not been updated.', 'count' => $inValidSubtypeCnt)), ts('Invalid Subtype'));
}
}
示例2: 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}");
}
示例3: postProcess
//.........这里部分代码省略.........
if (!empty($addToGroupId)) {
//run same check whether group is a mailing list
$groupTypes = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $addToGroupId, 'group_type', 'id');
$groupType = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($groupTypes, 1, -1));
//filter group of mailing type and unset it from params
if (in_array(2, $groupType) && !empty($result['email']) && CRM_Core_BAO_UFGroup::isProfileAddToGroupDoubleOptin()) {
if (!count($contactGroup)) {
//array of group id, subscribed by contact
$contactGroup = array();
if ($this->_id) {
$contactGroups = new CRM_Contact_DAO_GroupContact();
$contactGroups->contact_id = $this->_id;
$contactGroups->status = 'Added';
$contactGroups->find();
$contactGroup = array();
while ($contactGroups->fetch()) {
$contactGroup[] = $contactGroups->group_id;
$groupSubscribed[$contactGroups->group_id] = 1;
}
}
}
//if group is already subscribed , ignore it
$groupExist = CRM_Utils_Array::key($addToGroupId, $contactGroup);
if (!isset($groupExist)) {
$mailingType[] = $addToGroupId;
$addToGroupId = NULL;
}
} else {
// since we are directly adding contact to group lets unset it from mailing
if ($key = array_search($addToGroupId, $mailingType)) {
unset($mailingType[$key]);
}
}
}
if ($this->_grid) {
$params['group'] = $groupSubscribed;
}
// commenting below code, since we potentially
// triggered maximum name field formatting cases during CRM-4430.
// CRM-4343
// $params['preserveDBName'] = true;
$profileFields = $this->_fields;
if ($this->_mode & self::MODE_EDIT && $this->_activityId && $this->_isContactActivityProfile) {
$profileFields = $activityParams = array();
foreach ($this->_fields as $fieldName => $field) {
if (CRM_Utils_Array::value('field_type', $field) == 'Activity') {
if (isset($params[$fieldName])) {
$activityParams[$fieldName] = $params[$fieldName];
}
if (isset($params['activity_date_time'])) {
$activityParams['activity_date_time'] = CRM_Utils_Date::processDate($params['activity_date_time'], $params['activity_date_time_time']);
}
if (!empty($params[$fieldName]) && isset($params["{$fieldName}_id"])) {
$activityParams[$fieldName] = $params["{$fieldName}_id"];
}
} else {
$profileFields[$fieldName] = $field;
}
}
if (!empty($activityParams)) {
$activityParams['version'] = 3;
$activityParams['id'] = $this->_activityId;
$activityParams['skipRecentView'] = TRUE;
civicrm_api('Activity', 'create', $activityParams);
}
}
if ($this->_multiRecord && $this->_recordId && $this->_multiRecordFields && $this->_recordExists) {
$params['customRecordValues'][$this->_recordId] = array_keys($this->_multiRecordFields);
}
$this->_id = CRM_Contact_BAO_Contact::createProfileContact($params, $profileFields, $this->_id, $addToGroupId, $this->_gid, $this->_ctype, TRUE);
//mailing type group
if (!empty($mailingType)) {
// we send in the contactID so we match the same groups and are exact, rather than relying on email
// CRM-8710
CRM_Mailing_Event_BAO_Subscribe::commonSubscribe($mailingType, $result, $this->_id, 'profile');
}
$ufGroups = array();
if ($this->_gid) {
$ufGroups[$this->_gid] = 1;
} elseif ($this->_mode == self::MODE_REGISTER) {
$ufGroups = CRM_Core_BAO_UFGroup::getModuleUFGroup('User Registration');
}
foreach ($ufGroups as $gId => $val) {
if ($notify = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $gId, 'notify')) {
$values = CRM_Core_BAO_UFGroup::checkFieldsEmptyValues($gId, $this->_id, NULL);
CRM_Core_BAO_UFGroup::commonSendMail($this->_id, $values);
}
}
//create CMS user (if CMS user option is selected in profile)
if (!empty($params['cms_create_account']) && $this->_mode == self::MODE_CREATE) {
$params['contactID'] = $this->_id;
if (!CRM_Core_BAO_CMSUser::create($params, $this->_mail)) {
CRM_Core_Session::setStatus(ts('Your profile is not saved and Account is not created.'), ts('Profile Error'), 'error');
CRM_Core_Error::debug_log_message("Rolling back transaction as CMSUser Create failed in Profile_Form for contact " . $params['contactID']);
$transaction->rollback();
return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/profile/create', 'reset=1&gid=' . $this->_gid));
}
}
$transaction->commit();
}
示例4: sendMail
/**
* Send the emails.
*
* @param int $contactID
* Contact id.
* @param array $values
* Associated array of fields.
* @param bool $isTest
* If in test mode.
* @param bool $returnMessageText
* Return the message text instead of sending the mail.
*
* @param null $fieldTypes
*
* @return void
*/
public static function sendMail($contactID, $values, $isTest = FALSE, $returnMessageText = FALSE, $fieldTypes = NULL)
{
$gIds = $params = array();
$email = NULL;
if (isset($values['custom_pre_id'])) {
$preProfileType = CRM_Core_BAO_UFField::getProfileType($values['custom_pre_id']);
if ($preProfileType == 'Membership' && !empty($values['membership_id'])) {
$params['custom_pre_id'] = array(array('member_id', '=', $values['membership_id'], 0, 0));
} elseif ($preProfileType == 'Contribution' && !empty($values['contribution_id'])) {
$params['custom_pre_id'] = array(array('contribution_id', '=', $values['contribution_id'], 0, 0));
}
$gIds['custom_pre_id'] = $values['custom_pre_id'];
}
if (isset($values['custom_post_id'])) {
$postProfileType = CRM_Core_BAO_UFField::getProfileType($values['custom_post_id']);
if ($postProfileType == 'Membership' && !empty($values['membership_id'])) {
$params['custom_post_id'] = array(array('member_id', '=', $values['membership_id'], 0, 0));
} elseif ($postProfileType == 'Contribution' && !empty($values['contribution_id'])) {
$params['custom_post_id'] = array(array('contribution_id', '=', $values['contribution_id'], 0, 0));
}
$gIds['custom_post_id'] = $values['custom_post_id'];
}
if (!empty($values['is_for_organization'])) {
if (!empty($values['membership_id'])) {
$params['onbehalf_profile'] = array(array('member_id', '=', $values['membership_id'], 0, 0));
} elseif (!empty($values['contribution_id'])) {
$params['onbehalf_profile'] = array(array('contribution_id', '=', $values['contribution_id'], 0, 0));
}
}
//check whether it is a test drive
if ($isTest && !empty($params['custom_pre_id'])) {
$params['custom_pre_id'][] = array('contribution_test', '=', 1, 0, 0);
}
if ($isTest && !empty($params['custom_post_id'])) {
$params['custom_post_id'][] = array('contribution_test', '=', 1, 0, 0);
}
if (!$returnMessageText && !empty($gIds)) {
//send notification email if field values are set (CRM-1941)
foreach ($gIds as $key => $gId) {
if ($gId) {
$email = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $gId, 'notify');
if ($email) {
$val = CRM_Core_BAO_UFGroup::checkFieldsEmptyValues($gId, $contactID, CRM_Utils_Array::value($key, $params), TRUE);
CRM_Core_BAO_UFGroup::commonSendMail($contactID, $val);
}
}
}
}
if (!empty($values['is_email_receipt']) || !empty($values['onbehalf_dupe_alert']) || $returnMessageText) {
$template = CRM_Core_Smarty::singleton();
// get the billing location type
if (!array_key_exists('related_contact', $values)) {
$locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
$billingLocationTypeId = array_search('Billing', $locationTypes);
} else {
// presence of related contact implies onbehalf of org case,
// where location type is set to default.
$locType = CRM_Core_BAO_LocationType::getDefault();
$billingLocationTypeId = $locType->id;
}
if (!array_key_exists('related_contact', $values)) {
list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID, FALSE, $billingLocationTypeId);
}
// get primary location email if no email exist( for billing location).
if (!$email) {
list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID);
}
if (empty($displayName)) {
list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID);
}
//for display profile need to get individual contact id,
//hence get it from related_contact if on behalf of org true CRM-3767
//CRM-5001 Contribution/Membership:: On Behalf of Organization,
//If profile GROUP contain the Individual type then consider the
//profile is of Individual ( including the custom data of membership/contribution )
//IF Individual type not present in profile then it is consider as Organization data.
$userID = $contactID;
if ($preID = CRM_Utils_Array::value('custom_pre_id', $values)) {
if (!empty($values['related_contact'])) {
$preProfileTypes = CRM_Core_BAO_UFGroup::profileGroups($preID);
//@todo - following line should not refer to undefined $postProfileTypes? figure out way to test
if (in_array('Individual', $preProfileTypes) || in_array('Contact', $postProfileTypes)) {
//Take Individual contact ID
$userID = CRM_Utils_Array::value('related_contact', $values);
//.........这里部分代码省略.........
示例5: postProcess
/**
* Process the user submitted custom data values.
*
* @access public
* @return void
*/
public function postProcess()
{
$params = $this->controller->exportValues($this->_name);
if ($this->_mode == self::MODE_REGISTER) {
require_once 'CRM/Core/BAO/Address.php';
CRM_Core_BAO_Address::setOverwrite(false);
}
require_once 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
//used to send subcribe mail to the group which user want.
//if the profile double option in is enabled
$mailingType = array();
$config =& CRM_Core_Config::singleton();
if ($config->profileDoubleOptIn && CRM_Utils_Array::value('group', $params)) {
$result = null;
foreach ($params as $name => $values) {
if (substr($name, 0, 6) == 'email-') {
$result['email'] = $values;
}
}
$groupSubscribed = array();
if (CRM_Utils_Array::value('email', $result)) {
require_once 'CRM/Contact/DAO/Group.php';
//array of group id, subscribed by contact
$contactGroup = array();
if ($this->_id) {
$contactGroups = new CRM_Contact_DAO_GroupContact();
$contactGroups->contact_id = $this->_id;
$contactGroups->status = 'Added';
$contactGroups->find();
$contactGroup = array();
while ($contactGroups->fetch()) {
$contactGroup[] = $contactGroups->group_id;
$groupSubscribed[$contactGroups->group_id] = 1;
}
}
foreach ($params['group'] as $key => $val) {
if (!$val) {
unset($params['group'][$key]);
continue;
}
$groupTypes = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $key, 'group_type', 'id');
$groupType = explode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, substr($groupTypes, 1, -1));
//filter group of mailing type and unset it from params
if (in_array(2, $groupType)) {
//if group is already subscribed , ignore it
$groupExist = CRM_Utils_Array::key($key, $contactGroup);
if (!isset($groupExist)) {
$mailingType[] = $key;
unset($params['group'][$key]);
}
}
}
}
}
if ($this->_grid) {
$params['group'] = $groupSubscribed;
}
// commenting below code, since we potentially
// triggered maximum name field formatting cases during CRM-4430.
// CRM-4343
// $params['preserveDBName'] = true;
$this->_id = CRM_Contact_BAO_Contact::createProfileContact($params, $this->_fields, $this->_id, $this->_addToGroupID, $this->_gid, $this->_ctype, true);
//mailing type group
if (!empty($mailingType)) {
require_once 'CRM/Mailing/Event/BAO/Subscribe.php';
CRM_Mailing_Event_BAO_Subscribe::commonSubscribe($mailingType, $result);
}
require_once 'CRM/Core/BAO/UFGroup.php';
$ufGroups = array();
if ($this->_gid) {
$ufGroups[$this->_gid] = 1;
} else {
if ($this->_mode == self::MODE_REGISTER) {
$ufGroups =& CRM_Core_BAO_UFGroup::getModuleUFGroup('User Registration');
}
}
foreach ($ufGroups as $gId => $val) {
if ($notify = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $gId, 'notify')) {
$values = CRM_Core_BAO_UFGroup::checkFieldsEmptyValues($gId, $this->_id, null);
CRM_Core_BAO_UFGroup::commonSendMail($this->_id, $values);
}
}
//create CMS user (if CMS user option is selected in profile)
if (CRM_Utils_Array::value('cms_create_account', $params) && $this->_mode == self::MODE_CREATE) {
$params['contactID'] = $this->_id;
require_once "CRM/Core/BAO/CMSUser.php";
if (!CRM_Core_BAO_CMSUser::create($params, $this->_mail)) {
CRM_Core_Session::setStatus(ts('Your profile is not saved and Account is not created.'));
$transaction->rollback();
return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/profile/create', 'reset=1&gid=' . $this->_gid));
}
}
$transaction->commit();
//.........这里部分代码省略.........
示例6: sendMail
/**
* Function to send the emails
*
* @param int $contactID contact id
* @param array $values associated array of fields
* @param boolean $isTest if in test mode
* @param boolean $returnMessageText return the message text instead of sending the mail
*
* @return void
* @access public
* @static
*/
static function sendMail($contactID, &$values, $isTest = false, $returnMessageText = false)
{
require_once "CRM/Core/BAO/UFField.php";
$gIds = array();
$params = array();
if (isset($values['custom_pre_id'])) {
$preProfileType = CRM_Core_BAO_UFField::getProfileType($values['custom_pre_id']);
if ($preProfileType == 'Membership' && CRM_Utils_Array::value('membership_id', $values)) {
$params['custom_pre_id'] = array(array('membership_id', '=', $values['membership_id'], 0, 0));
} else {
if ($preProfileType == 'Contribution' && CRM_Utils_Array::value('contribution_id', $values)) {
$params['custom_pre_id'] = array(array('contribution_id', '=', $values['contribution_id'], 0, 0));
}
}
$gIds['custom_pre_id'] = $values['custom_pre_id'];
}
if (isset($values['custom_post_id'])) {
$postProfileType = CRM_Core_BAO_UFField::getProfileType($values['custom_post_id']);
if ($postProfileType == 'Membership' && CRM_Utils_Array::value('membership_id', $values)) {
$params['custom_post_id'] = array(array('membership_id', '=', $values['membership_id'], 0, 0));
} else {
if ($postProfileType == 'Contribution' && CRM_Utils_Array::value('contribution_id', $values)) {
$params['custom_post_id'] = array(array('contribution_id', '=', $values['contribution_id'], 0, 0));
}
}
$gIds['custom_post_id'] = $values['custom_post_id'];
}
//check whether it is a test drive
if ($isTest && !empty($params['custom_pre_id'])) {
$params['custom_pre_id'][] = array('contribution_test', '=', 1, 0, 0);
}
if ($isTest && !empty($params['custom_post_id'])) {
$params['custom_post_id'][] = array('contribution_test', '=', 1, 0, 0);
}
if (!$returnMessageText) {
//send notification email if field values are set (CRM-1941)
require_once 'CRM/Core/BAO/UFGroup.php';
foreach ($gIds as $key => $gId) {
$email = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $gId, 'notify');
if ($email) {
$val = CRM_Core_BAO_UFGroup::checkFieldsEmptyValues($gId, $contactID, $params[$key]);
CRM_Core_BAO_UFGroup::commonSendMail($contactID, $val);
}
}
}
if (CRM_Utils_Array::value('is_email_receipt', $values) || CRM_Utils_Array::value('onbehalf_dupe_alert', $values)) {
$template =& CRM_Core_Smarty::singleton();
// get the billing location type
if (!array_key_exists('related_contact', $values)) {
$locationTypes =& CRM_Core_PseudoConstant::locationType();
$billingLocationTypeId = array_search('Billing', $locationTypes);
} else {
// presence of related contact implies onbehalf of org case,
// where location type is set to default.
require_once 'CRM/Core/BAO/LocationType.php';
$locType = CRM_Core_BAO_LocationType::getDefault();
$billingLocationTypeId = $locType->id;
}
require_once 'CRM/Contact/BAO/Contact/Location.php';
if (!array_key_exists('related_contact', $values)) {
list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID, false, $billingLocationTypeId);
} else {
list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID);
}
//for display profile need to get individual contact id,
//hence get it from related_contact if on behalf of org true CRM-3767.
//CRM-5001 Contribution/Membership:: On Behalf of Organization,
//If profile GROUP contain the Individual type then consider the
//profile is of Individual ( including the custom data of membership/contribution )
//IF Individual type not present in profile then it is consider as Organization data.
require_once 'CRM/Core/BAO/UFGroup.php';
$userID = $contactID;
if ($preID = CRM_Utils_Array::value('custom_pre_id', $values)) {
if (CRM_Utils_Array::value('related_contact', $values)) {
$preProfileTypes = CRM_Core_BAO_UFGroup::profileGroups($preID);
if (in_array('Individual', $preProfileTypes)) {
//Take Individual contact ID
$userID = CRM_Utils_Array::value('related_contact', $values);
}
}
self::buildCustomDisplay($preID, 'customPre', $userID, $template, $params['custom_pre_id']);
}
$userID = $contactID;
if ($postID = CRM_Utils_Array::value('custom_post_id', $values)) {
if (CRM_Utils_Array::value('related_contact', $values)) {
$postProfileTypes = CRM_Core_BAO_UFGroup::profileGroups($postID);
if (in_array('Individual', $postProfileTypes)) {
//Take Individual contact ID
//.........这里部分代码省略.........
示例7: 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;
//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_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);
}
}
CRM_Core_Session::setStatus("Your updates have been saved.");
}
示例8: postProcess
//.........这里部分代码省略.........
}
if ($this->_mode == self::MODE_REGISTER) {
require_once 'CRM/Core/BAO/Address.php';
CRM_Core_BAO_Address::setOverwrite(false);
}
require_once 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
//used to send subcribe mail to the group which user want.
//if the profile double option in is enabled
$mailingType = array();
$config = CRM_Core_Config::singleton();
if ($config->profileDoubleOptIn && CRM_Utils_Array::value('group', $params)) {
$result = null;
foreach ($params as $name => $values) {
if (substr($name, 0, 6) == 'email-') {
$result['email'] = $values;
}
}
$groupSubscribed = array();
if (CRM_Utils_Array::value('email', $result)) {
require_once 'CRM/Contact/DAO/Group.php';
//array of group id, subscribed by contact
$contactGroup = array();
if ($this->_id) {
$contactGroups = new CRM_Contact_DAO_GroupContact();
$contactGroups->contact_id = $this->_id;
$contactGroups->status = 'Added';
$contactGroups->find();
$contactGroup = array();
while ($contactGroups->fetch()) {
$contactGroup[] = $contactGroups->group_id;
$groupSubscribed[$contactGroups->group_id] = 1;
}
}
foreach ($params['group'] as $key => $val) {
if (!$val) {
unset($params['group'][$key]);
continue;
}
$groupTypes = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $key, 'group_type', 'id');
$groupType = explode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, substr($groupTypes, 1, -1));
//filter group of mailing type and unset it from params
if (in_array(2, $groupType)) {
//if group is already subscribed , ignore it
$groupExist = CRM_Utils_Array::key($key, $contactGroup);
if (!isset($groupExist)) {
$mailingType[] = $key;
unset($params['group'][$key]);
}
}
}
}
}
if (CRM_Utils_Array::value('add_to_group', $params)) {
$addToGroupId = $params['add_to_group'];
// since we are directly adding contact to group lets unset it from mailing
if ($key = array_search($addToGroupId, $mailingType)) {
unset($mailingType[$key]);
}
}
if ($this->_grid) {
$params['group'] = $groupSubscribed;
}
// commenting below code, since we potentially
// triggered maximum name field formatting cases during CRM-4430.
// CRM-4343
// $params['preserveDBName'] = true;
$this->_id = CRM_Contact_BAO_Contact::createProfileContact($params, $this->_fields, $this->_id, $this->_addToGroupID, $this->_gid, $this->_ctype, true);
//mailing type group
if (!empty($mailingType)) {
require_once 'CRM/Mailing/Event/BAO/Subscribe.php';
CRM_Mailing_Event_BAO_Subscribe::commonSubscribe($mailingType, $result);
}
require_once 'CRM/Core/BAO/UFGroup.php';
$ufGroups = array();
if ($this->_gid) {
$ufGroups[$this->_gid] = 1;
} else {
if ($this->_mode == self::MODE_REGISTER) {
$ufGroups =& CRM_Core_BAO_UFGroup::getModuleUFGroup('User Registration');
}
}
foreach ($ufGroups as $gId => $val) {
if ($notify = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $gId, 'notify')) {
$values = CRM_Core_BAO_UFGroup::checkFieldsEmptyValues($gId, $this->_id, null);
CRM_Core_BAO_UFGroup::commonSendMail($this->_id, $values);
}
}
//create CMS user (if CMS user option is selected in profile)
if (CRM_Utils_Array::value('cms_create_account', $params) && $this->_mode == self::MODE_CREATE) {
$params['contactID'] = $this->_id;
require_once "CRM/Core/BAO/CMSUser.php";
if (!CRM_Core_BAO_CMSUser::create($params, $this->_mail)) {
CRM_Core_Session::setStatus(ts('Your profile is not saved and Account is not created.'));
$transaction->rollback();
return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/profile/create', 'reset=1&gid=' . $this->_gid));
}
}
$transaction->commit();
}