本文整理汇总了PHP中CRM_Core_BAO_UFGroup::commonSendMail方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_UFGroup::commonSendMail方法的具体用法?PHP CRM_Core_BAO_UFGroup::commonSendMail怎么用?PHP CRM_Core_BAO_UFGroup::commonSendMail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_UFGroup
的用法示例。
在下文中一共展示了CRM_Core_BAO_UFGroup::commonSendMail方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendMail
/**
* Process that send e-mails
*
* @return void
* @access public
*/
static function sendMail($contactID, &$values, $participantId, $isTest = false, $returnMessageText = false)
{
require_once 'CRM/Core/BAO/UFGroup.php';
$template = CRM_Core_Smarty::singleton();
$gIds = array('custom_pre_id' => $values['custom_pre_id'], 'custom_post_id' => $values['custom_post_id']);
//get the params submitted by participant.
$participantParams = CRM_Utils_Array::value($participantId, $values['params'], array());
if (!$returnMessageText) {
//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) {
//get values of corresponding profile fields for notification
list($profileValues) = self::buildCustomDisplay($gId, null, $contactID, $template, $participantId, $isTest, true, $participantParams);
$val = array('id' => $gId, 'values' => $profileValues, 'email' => $email);
CRM_Core_BAO_UFGroup::commonSendMail($contactID, $val);
}
}
}
}
if ($values['event']['is_email_confirm'] || $returnMessageText) {
require_once 'CRM/Contact/BAO/Contact/Location.php';
//use primary email address, since we are not creating billing address for
//1. participant is pay later.
//2. participant might be additional participant.
//3. participant might be on waiting list.
//4. registration might require approval.
if (CRM_Utils_Array::value('is_pay_later', $values['params']) || CRM_Utils_Array::value('additionalParticipant', $values['params']) || CRM_Utils_Array::value('isOnWaitlist', $values['params']) || CRM_Utils_Array::value('isRequireApproval', $values['params']) || !CRM_Utils_Array::value('is_monetary', $values['event'])) {
list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID);
} else {
// get the billing location type
$locationTypes =& CRM_Core_PseudoConstant::locationType();
$bltID = array_search('Billing', $locationTypes);
list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID, false, $bltID);
}
//send email only when email is present
if (isset($email) || $returnMessageText) {
$preProfileID = $values['custom_pre_id'];
$postProfileID = $values['custom_post_id'];
if (CRM_Utils_Array::value('additionalParticipant', $values['params'])) {
$preProfileID = $values['additional_custom_pre_id'];
$postProfileID = $values['additional_custom_post_id'];
}
self::buildCustomDisplay($preProfileID, 'customPre', $contactID, $template, $participantId, $isTest, null, $participantParams);
self::buildCustomDisplay($postProfileID, 'customPost', $contactID, $template, $participantId, $isTest, null, $participantParams);
$sendTemplateParams = array('groupName' => 'msg_tpl_workflow_event', 'valueName' => 'event_online_receipt', 'contactId' => $contactID, 'isTest' => $isTest, 'tplParams' => array('email' => $email, 'confirm_email_text' => CRM_Utils_Array::value('confirm_email_text', $values['event']), 'isShowLocation' => CRM_Utils_Array::value('is_show_location', $values['event'])), 'PDFFilename' => 'civicrm.pdf');
// address required during receipt processing (pdf and email receipt)
if ($displayAddress = CRM_Utils_Array::value('address', $values)) {
$sendTemplateParams['tplParams']['address'] = $displayAddress;
$sendTemplateParams['tplParams']['contributeMode'] = null;
}
// set lineItem details
if ($lineItem = CRM_Utils_Array::value('lineItem', $values)) {
$sendTemplateParams['tplParams']['lineItem'] = $lineItem;
}
require_once 'CRM/Core/BAO/MessageTemplates.php';
if ($returnMessageText) {
list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplates::sendTemplate($sendTemplateParams);
return array('subject' => $subject, 'body' => $message, 'to' => $displayName, 'html' => $html);
} else {
$sendTemplateParams['from'] = "{$values['event']['confirm_from_name']} <{$values['event']['confirm_from_email']}>";
$sendTemplateParams['toName'] = $displayName;
$sendTemplateParams['toEmail'] = $email;
$sendTemplateParams['autoSubmitted'] = true;
$sendTemplateParams['cc'] = CRM_Utils_Array::value('cc_confirm', $values['event']);
$sendTemplateParams['bcc'] = CRM_Utils_Array::value('bcc_confirm', $values['event']);
CRM_Core_BAO_MessageTemplates::sendTemplate($sendTemplateParams);
}
}
}
}
示例2: sendMail
/**
* Process that send e-mails
*
* @param $contactID
* @param $values
* @param $participantId
* @param bool $isTest
* @param bool $returnMessageText
*
* @return void
* @access public
*/
static function sendMail($contactID, &$values, $participantId, $isTest = FALSE, $returnMessageText = FALSE)
{
$template = CRM_Core_Smarty::singleton();
$gIds = array('custom_pre_id' => $values['custom_pre_id'], 'custom_post_id' => $values['custom_post_id']);
//get the params submitted by participant.
$participantParams = CRM_Utils_Array::value($participantId, $values['params'], array());
if (!$returnMessageText) {
//send notification email if field values are set (CRM-1941)
foreach ($gIds as $key => $gIdValues) {
if ($gIdValues) {
if (!is_array($gIdValues)) {
$gIdValues = array($gIdValues);
}
foreach ($gIdValues as $gId) {
$email = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $gId, 'notify');
if ($email) {
//get values of corresponding profile fields for notification
list($profileValues) = self::buildCustomDisplay($gId, NULL, $contactID, $template, $participantId, $isTest, TRUE, $participantParams);
list($profileValues) = $profileValues;
$val = array('id' => $gId, 'values' => $profileValues, 'email' => $email);
CRM_Core_BAO_UFGroup::commonSendMail($contactID, $val);
}
}
}
}
}
if ($values['event']['is_email_confirm'] || $returnMessageText) {
list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID);
//send email only when email is present
if (isset($email) || $returnMessageText) {
$preProfileID = CRM_Utils_Array::value('custom_pre_id', $values);
$postProfileID = CRM_Utils_Array::value('custom_post_id', $values);
if (!empty($values['params']['additionalParticipant'])) {
$preProfileID = CRM_Utils_Array::value('additional_custom_pre_id', $values, $preProfileID);
$postProfileID = CRM_Utils_Array::value('additional_custom_post_id', $values, $postProfileID);
}
self::buildCustomDisplay($preProfileID, 'customPre', $contactID, $template, $participantId, $isTest, NULL, $participantParams);
self::buildCustomDisplay($postProfileID, 'customPost', $contactID, $template, $participantId, $isTest, NULL, $participantParams);
$sessions = CRM_Event_Cart_BAO_Conference::get_participant_sessions($participantId);
$tplParams = array_merge($values, $participantParams, array('email' => $email, 'confirm_email_text' => CRM_Utils_Array::value('confirm_email_text', $values['event']), 'isShowLocation' => CRM_Utils_Array::value('is_show_location', $values['event']), 'contributeMode' => CRM_Utils_Array::value('contributeMode', $template->_tpl_vars), 'participantID' => $participantId, 'conference_sessions' => $sessions, 'credit_card_number' => CRM_Utils_System::mungeCreditCard(CRM_Utils_Array::value('credit_card_number', $participantParams)), 'credit_card_exp_date' => CRM_Utils_Date::mysqlToIso(CRM_Utils_Date::format(CRM_Utils_Array::value('credit_card_exp_date', $participantParams)))));
// CRM-13890 : NOTE wait list condition need to be given so that
// wait list message is shown properly in email i.e. WRT online event registration template
if (empty($tplParams['participant_status']) && empty($values['params']['isOnWaitlist'])) {
$statusId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $participantId, 'status_id', 'id');
$tplParams['participant_status'] = CRM_Event_PseudoConstant::participantStatus($statusId, NULL, 'label');
}
$sendTemplateParams = array('groupName' => 'msg_tpl_workflow_event', 'valueName' => 'event_online_receipt', 'contactId' => $contactID, 'isTest' => $isTest, 'tplParams' => $tplParams, 'PDFFilename' => ts('confirmation') . '.pdf');
// address required during receipt processing (pdf and email receipt)
if ($displayAddress = CRM_Utils_Array::value('address', $values)) {
$sendTemplateParams['tplParams']['address'] = $displayAddress;
$sendTemplateParams['tplParams']['contributeMode'] = NULL;
}
// set lineItem details
if ($lineItem = CRM_Utils_Array::value('lineItem', $values)) {
// check if additional prticipant, if so filter only to relevant ones
// CRM-9902
if (!empty($values['params']['additionalParticipant'])) {
$ownLineItems = array();
foreach ($lineItem as $liKey => $liValue) {
$firstElement = array_pop($liValue);
if ($firstElement['entity_id'] == $participantId) {
$ownLineItems[0] = $lineItem[$liKey];
break;
}
}
if (!empty($ownLineItems)) {
$sendTemplateParams['tplParams']['lineItem'] = $ownLineItems;
}
} else {
$sendTemplateParams['tplParams']['lineItem'] = $lineItem;
}
}
if ($returnMessageText) {
list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
return array('subject' => $subject, 'body' => $message, 'to' => $displayName, 'html' => $html);
} else {
$sendTemplateParams['from'] = CRM_Utils_Array::value('confirm_from_name', $values['event']) . " <" . CRM_Utils_Array::value('confirm_from_email', $values['event']) . ">";
$sendTemplateParams['toName'] = $displayName;
$sendTemplateParams['toEmail'] = $email;
$sendTemplateParams['autoSubmitted'] = TRUE;
$sendTemplateParams['cc'] = CRM_Utils_Array::value('cc_confirm', $values['event']);
$sendTemplateParams['bcc'] = CRM_Utils_Array::value('bcc_confirm', $values['event']);
CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
}
}
}
}
示例3: 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'));
}
}
示例4: 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}");
}
示例5: 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();
}
示例6: 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);
//.........这里部分代码省略.........
示例7: 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();
//.........这里部分代码省略.........
示例8: 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
//.........这里部分代码省略.........
示例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;
//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.");
}
示例10: 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();
}