本文整理汇总了PHP中CRM_Core_BAO_UFGroup::isProfileDoubleOptin方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_UFGroup::isProfileDoubleOptin方法的具体用法?PHP CRM_Core_BAO_UFGroup::isProfileDoubleOptin怎么用?PHP CRM_Core_BAO_UFGroup::isProfileDoubleOptin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_UFGroup
的用法示例。
在下文中一共展示了CRM_Core_BAO_UFGroup::isProfileDoubleOptin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
/**
* Process the user submitted custom data values.
*
*
* @return void
*/
public function postProcess()
{
$params = $this->controller->exportValues($this->_name);
//if the delete record button is clicked
if ($this->_deleteButtonName) {
if (!empty($_POST[$this->_deleteButtonName]) && $this->_recordId) {
$filterParams['id'] = $this->_customGroupId;
$returnProperties = array('is_multiple', 'table_name');
CRM_Core_DAO::commonRetrieve("CRM_Core_DAO_CustomGroup", $filterParams, $returnValues, $returnProperties);
if (!empty($returnValues['is_multiple'])) {
if ($tableName = CRM_Utils_Array::value('table_name', $returnValues)) {
$sql = "DELETE FROM {$tableName} WHERE id = %1 AND entity_id = %2";
$sqlParams = array(1 => array($this->_recordId, 'Integer'), 2 => array($this->_id, 'Integer'));
CRM_Core_DAO::executeQuery($sql, $sqlParams);
CRM_Core_Session::setStatus(ts('Your record has been deleted.'), ts('Deleted'), 'success');
}
}
return;
}
}
CRM_Utils_Hook::processProfile($this->_ufGroup['name']);
if (!empty($params['image_URL'])) {
CRM_Contact_BAO_Contact::processImageParams($params);
}
$greetingTypes = array('addressee' => 'addressee_id', 'email_greeting' => 'email_greeting_id', 'postal_greeting' => 'postal_greeting_id');
$details = array();
if ($this->_id) {
$contactDetails = CRM_Contact_BAO_Contact::getHierContactDetails($this->_id, $greetingTypes);
$details = $contactDetails[0][$this->_id];
}
if (!(!empty($details['addressee_id']) || !empty($details['email_greeting_id']) || CRM_Utils_Array::value('postal_greeting_id', $details))) {
$profileType = CRM_Core_BAO_UFField::getProfileType($this->_gid);
//Though Profile type is contact we need
//Individual/Household/Organization for setting Greetings.
if ($profileType == 'Contact') {
$profileType = 'Individual';
//if we editing Household/Organization.
if ($this->_id) {
$profileType = CRM_Contact_BAO_Contact::getContactType($this->_id);
}
}
if (CRM_Contact_BAO_ContactType::isaSubType($profileType)) {
$profileType = CRM_Contact_BAO_ContactType::getBasicType($profileType);
}
foreach ($greetingTypes as $key => $value) {
if (!array_key_exists($key, $params)) {
$params[$key] = CRM_Contact_BAO_Contact_Utils::defaultGreeting($profileType, $key);
}
}
}
$transaction = new CRM_Core_Transaction();
//used to send subscribe mail to the group which user want.
//if the profile double option in is enabled
$mailingType = array();
$result = NULL;
foreach ($params as $name => $values) {
if (substr($name, 0, 6) == 'email-') {
$result['email'] = $values;
}
}
//array of group id, subscribed by contact
$contactGroup = array();
if (!empty($params['group']) && CRM_Core_BAO_UFGroup::isProfileDoubleOptin()) {
$groupSubscribed = array();
if (!empty($result['email'])) {
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_DAO::VALUE_SEPARATOR, 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]);
}
}
}
}
//.........这里部分代码省略.........
示例2: formRule
/**
* Global validation rules for the form.
*
* @param array $fields
* Posted values of the form.
*
* @param $files
* @param $self
*
* @return array
* list of errors to be posted back to the form
*/
public static function formRule($fields, $files, $self)
{
$is_required = CRM_Utils_Array::value('is_required', $fields, FALSE);
$is_registration = CRM_Utils_Array::value('is_registration', $fields, FALSE);
$is_view = CRM_Utils_Array::value('is_view', $fields, FALSE);
$in_selector = CRM_Utils_Array::value('in_selector', $fields, FALSE);
$is_active = CRM_Utils_Array::value('is_active', $fields, FALSE);
$errors = array();
if ($is_view && $is_registration) {
$errors['is_registration'] = ts('View Only cannot be selected if this field is to be included on the registration form');
}
if ($is_view && $is_required) {
$errors['is_view'] = ts('A View Only field cannot be required');
}
$entityName = $fields['field_name'][0];
if (!$entityName) {
$errors['field_name'] = ts('Please select a field name');
}
if ($in_selector && in_array($entityName, array('Contribution', 'Participant', 'Membership', 'Activity'))) {
$errors['in_selector'] = ts("'In Selector' cannot be checked for %1 fields.", array(1 => $entityName));
}
$isCustomField = FALSE;
$profileFieldName = CRM_Utils_Array::value(1, $fields['field_name']);
if ($profileFieldName) {
//get custom field id
$customFieldId = explode('_', $profileFieldName);
if ($customFieldId[0] == 'custom') {
$customField = new CRM_Core_DAO_CustomField();
$customField->id = $customFieldId[1];
$customField->find(TRUE);
$isCustomField = TRUE;
if (!empty($fields['field_id']) && !$customField->is_active && $is_active) {
$errors['field_name'] = ts('Cannot set this field "Active" since the selected custom field is disabled.');
}
//check if profile already has a different multi-record custom set field configured
$customGroupId = CRM_Core_BAO_CustomField::isMultiRecordField($profileFieldName);
if ($customGroupId) {
if ($profileMultiRecordCustomGid = CRM_Core_BAO_UFField::checkMultiRecordFieldExists($self->_gid)) {
if ($customGroupId != $profileMultiRecordCustomGid) {
$errors['field_name'] = ts("You cannot configure multi-record custom fields belonging to different custom sets in one profile");
}
}
}
}
}
// Get list of fields already in the group
$groupFields = CRM_Core_BAO_UFGroup::getFields($fields['group_id'], FALSE, NULL, NULL, NULL, TRUE, NULL, TRUE);
// Check if we already added a primary field of the same communication type
self::formRulePrimaryCheck($fields, $profileFieldName, $groupFields, $errors);
//check profile is configured for double option process
//adding group field, email field should be present in the group
//fixed for issue CRM-2861 & CRM-4153
if (CRM_Core_BAO_UFGroup::isProfileDoubleOptin()) {
if (CRM_Utils_Array::value(1, $fields['field_name']) == 'group') {
$dao = new CRM_Core_BAO_UFField();
$dao->uf_group_id = $fields['group_id'];
$dao->find();
$emailField = FALSE;
while ($dao->fetch()) {
//check email field is present in the group
if ($dao->field_name == 'email') {
$emailField = TRUE;
break;
}
}
if (!$emailField) {
$disableSettingURL = CRM_Utils_System::url('civicrm/admin/setting/preferences/mailing', 'reset=1');
$errors['field_name'] = ts('Your site is currently configured to require double-opt in when users join (subscribe) to Group(s) via a Profile form. In this mode, you need to include an Email field in a Profile BEFORE you can add the Group(s) field. This ensures that an opt-in confirmation email can be sent. Your site administrator can disable double opt-in on the civimail admin settings: <em>%1</em>', array(1 => $disableSettingURL));
}
}
}
//fix for CRM-3037
$fieldType = $fields['field_name'][0];
//get the group type.
$groupType = CRM_Core_BAO_UFGroup::calculateGroupType($self->_gid, FALSE, CRM_Utils_Array::value('field_id', $fields));
switch ($fieldType) {
case 'Contact':
self::formRuleSubType($fieldType, $groupType, $errors);
break;
case 'Individual':
if (in_array('Activity', $groupType) || in_array('Household', $groupType) || in_array('Organization', $groupType)) {
//CRM-7603 - need to support activity + individual.
//$errors['field_name'] =
//ts( 'Cannot add or update profile field type Individual with combination of Household or Organization or Activity' );
if (in_array('Household', $groupType) || in_array('Organization', $groupType)) {
$errors['field_name'] = ts('Cannot add or update profile field type Individual with combination of Household or Organization');
}
} else {
//.........这里部分代码省略.........