本文整理汇总了PHP中CRM_Core_BAO_UFField类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_UFField类的具体用法?PHP CRM_Core_BAO_UFField怎么用?PHP CRM_Core_BAO_UFField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Core_BAO_UFField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: browse
/**
* Browse all CiviCRM Profile group fields.
*
* @return void
* @access public
* @static
*/
function browse()
{
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
$ufField = array();
$ufFieldBAO = new CRM_Core_BAO_UFField();
// fkey is gid
$ufFieldBAO->uf_group_id = $this->_gid;
$ufFieldBAO->orderBy('weight', 'field_name');
$ufFieldBAO->find();
$otherModules = CRM_Core_BAO_UFGroup::getUFJoinRecord($this->_gid);
$this->assign('otherModules', $otherModules);
$isGroupReserved = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $this->_gid, 'is_reserved');
$this->assign('isGroupReserved', $isGroupReserved);
$profileType = CRM_Core_BAO_UFField::getProfileType($this->_gid);
if ($profileType == 'Contribution' || $profileType == 'Membership' || $profileType == 'Activity' || $profileType == 'Participant') {
$this->assign('skipCreate', TRUE);
}
$locationType = array();
$locationType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
$fields = CRM_Contact_BAO_Contact::exportableFields('All', FALSE, TRUE);
$fields = array_merge(CRM_Contribute_BAO_Contribution::getContributionFields(), $fields);
$select = array();
foreach ($fields as $name => $field) {
if ($name) {
$select[$name] = $field['title'];
}
}
$select['group'] = ts('Group(s)');
$select['tag'] = ts('Tag(s)');
$visibility = CRM_Core_SelectValues::ufVisibility();
while ($ufFieldBAO->fetch()) {
$ufField[$ufFieldBAO->id] = array();
$phoneType = $locType = '';
CRM_Core_DAO::storeValues($ufFieldBAO, $ufField[$ufFieldBAO->id]);
$ufField[$ufFieldBAO->id]['visibility_display'] = $visibility[$ufFieldBAO->visibility];
$ufField[$ufFieldBAO->id]['label'] = $ufFieldBAO->label;
$action = array_sum(array_keys($this->actionLinks()));
if ($ufFieldBAO->is_active) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
if ($ufFieldBAO->is_reserved) {
$action -= CRM_Core_Action::UPDATE;
$action -= CRM_Core_Action::DISABLE;
$action -= CRM_Core_Action::DELETE;
}
$ufField[$ufFieldBAO->id]['order'] = $ufField[$ufFieldBAO->id]['weight'];
$ufField[$ufFieldBAO->id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('id' => $ufFieldBAO->id, 'gid' => $this->_gid), ts('more'), FALSE, 'ufField.row.actions', 'UFField', $ufFieldBAO->id);
}
$returnURL = CRM_Utils_System::url('civicrm/admin/uf/group/field', "reset=1&action=browse&gid={$this->_gid}");
$filter = "uf_group_id = {$this->_gid}";
CRM_Utils_Weight::addOrder($ufField, 'CRM_Core_DAO_UFField', 'id', $returnURL, $filter);
$this->assign('ufField', $ufField);
// retrieve showBestResult from session
$session = CRM_Core_Session::singleton();
$showBestResult = $session->get('showBestResult');
$this->assign('showBestResult', $showBestResult);
$session->set('showBestResult', 0);
}
示例2: getSchema
/**
* Get a list of Backbone-Form models
*
* @param array $entityTypes model names ("IndividualModel")
* @return array; keys are model names ("IndividualModel") and values describe 'sections' and 'schema'
* @see js/model/crm.core.js
* @see js/model/crm.mappedcore.js
*/
static function getSchema($entityTypes)
{
// FIXME: Depending on context (eg civicrm/profile/create vs search-columns), it may be appropriate to
// pick importable or exportable fields
$entityTypes = array_unique($entityTypes);
$availableFields = NULL;
foreach ($entityTypes as $entityType) {
if (!$availableFields) {
$availableFields = CRM_Core_BAO_UFField::getAvailableFieldsFlat();
//dpm($availableFields);
}
switch ($entityType) {
case 'IndividualModel':
$civiSchema[$entityType] = self::convertCiviModelToBackboneModel('Individual', ts('Individual'), $availableFields);
break;
case 'ActivityModel':
$civiSchema[$entityType] = self::convertCiviModelToBackboneModel('Activity', ts('Activity'), $availableFields);
break;
case 'ContributionModel':
$civiSchema[$entityType] = self::convertCiviModelToBackboneModel('Contribution', ts('Contribution'), $availableFields);
break;
case 'MembershipModel':
$civiSchema[$entityType] = self::convertCiviModelToBackboneModel('Membership', ts('Membership'), $availableFields);
break;
case 'ParticipantModel':
$civiSchema[$entityType] = self::convertCiviModelToBackboneModel('Participant', ts('Participant'), $availableFields);
break;
default:
throw new CRM_Core_Exception("Unrecognized entity type: {$entityType}");
}
}
return $civiSchema;
}
示例3: buildQuickForm
function buildQuickForm()
{
// Build list of options for individual, org and household
// contact types.
$ind_profile_options = array();
$house_profile_options = array();
$org_profile_options = array();
try {
$params = array('rowCount' => 200);
$result = civicrm_api3('UFGroup', 'get', $params);
} catch (CiviCRM_API3_Exception $e) {
$error = $e->getMessage();
$session = CRM_Core_Session::singleton();
$session->setStatus(ts("Failed to get list of profiles."));
return;
}
reset($result['values']);
while (list($k, $v) = each($result['values'])) {
if (array_key_exists('group_type', $v) && $v['is_active'] == 1) {
$id = $v['id'];
// Ensure it's not a mixed type profile, because you cannot edit mixed type
// profiles
if (CRM_Core_BAO_UFField::checkProfileType($id)) {
continue;
}
if (is_array($v['group_type'])) {
// Just check the first one (this is arbitrary)
$group_type = array_pop($v['group_type']);
} else {
$group_type = $v['group_type'];
}
if (preg_match('/Individual/', $group_type)) {
$ind_profile_options[$id] = $v['title'];
}
if (preg_match('/Household/', $group_type)) {
$house_profile_options[$id] = $v['title'];
}
if (preg_match('/Organization/', $group_type)) {
$org_profile_options[$id] = $v['title'];
}
}
}
if (!empty($ind_profile_options)) {
$this->addElement('select', 'ind_profile_id', ts('Individual'), $ind_profile_options, NULL);
}
if (!empty($house_profile_options)) {
$this->addElement('select', 'house_profile_id', ts('Household'), $house_profile_options, NULL);
}
if (!empty($org_profile_options)) {
$this->addElement('select', 'org_profile_id', ts('Organization'), $org_profile_options, NULL);
}
$this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
}
示例4: preProcess
/**
* @param CRM_Contribute_Form_Contribution_Main|CRM_Event_Form_Registration_Register|CRM_Financial_Form_Payment $form
* @param null $type
* @param null $mode
*
* @throws Exception
*/
public static function preProcess(&$form, $type = NULL, $mode = NULL)
{
if ($type) {
$form->_type = $type;
} else {
$form->_type = CRM_Utils_Request::retrieve('type', 'String', $form);
}
if ($form->_type) {
$form->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($form->_type, $form->_mode);
}
if (empty($form->_paymentProcessor)) {
// This would happen when hitting the back-button on a multi-page form with a $0 selection in play.
return;
}
$form->set('paymentProcessor', $form->_paymentProcessor);
$form->_paymentObject = System::singleton()->getByProcessor($form->_paymentProcessor);
$form->assign('suppressSubmitButton', $form->_paymentObject->isSuppressSubmitButtons());
$form->assign('currency', CRM_Utils_Array::value('currency', $form->_values));
// also set cancel subscription url
if (!empty($form->_paymentProcessor['is_recur']) && !empty($form->_values['is_recur'])) {
$form->_values['cancelSubscriptionUrl'] = $form->_paymentObject->subscriptionURL(NULL, NULL, 'cancel');
}
if (!empty($form->_values['custom_pre_id'])) {
$profileAddressFields = array();
$fields = CRM_Core_BAO_UFGroup::getFields($form->_values['custom_pre_id'], FALSE, CRM_Core_Action::ADD, NULL, NULL, FALSE, NULL, FALSE, NULL, CRM_Core_Permission::CREATE, NULL);
foreach ((array) $fields as $key => $value) {
CRM_Core_BAO_UFField::assignAddressField($key, $profileAddressFields, array('uf_group_id' => $form->_values['custom_pre_id']));
}
if (count($profileAddressFields)) {
$form->set('profileAddressFields', $profileAddressFields);
}
}
//checks after setting $form->_paymentProcessor
// we do this outside of the above conditional to avoid
// saving the country/state list in the session (which could be huge)
CRM_Core_Payment_Form::setPaymentFieldsByProcessor($form, $form->_paymentProcessor, CRM_Utils_Request::retrieve('billing_profile_id', 'String'));
$form->assign_by_ref('paymentProcessor', $form->_paymentProcessor);
// check if this is a paypal auto return and redirect accordingly
//@todo - determine if this is legacy and remove
if (CRM_Core_Payment::paypalRedirect($form->_paymentProcessor)) {
$url = CRM_Utils_System::url('civicrm/contribute/transact', "_qf_ThankYou_display=1&qfKey={$form->controller->_key}");
CRM_Utils_System::redirect($url);
}
// make sure we have a valid payment class, else abort
if (!empty($form->_values['is_monetary']) && !$form->_paymentProcessor['class_name'] && empty($form->_values['is_pay_later'])) {
CRM_Core_Error::fatal(ts('Payment processor is not set for this page'));
}
if (!empty($form->_membershipBlock) && !empty($form->_membershipBlock['is_separate_payment']) && (!empty($form->_paymentProcessor['class_name']) && !$form->_paymentObject->supports('MultipleConcurrentPayments'))) {
CRM_Core_Error::fatal(ts('This contribution page is configured to support separate contribution and membership payments. This %1 plugin does not currently support multiple simultaneous payments, or the option to "Execute real-time monetary transactions" is disabled. Please contact the site administrator and notify them of this error', array(1 => $form->_paymentProcessor['payment_processor_type'])));
}
}
示例5: getSchema
/**
* Get a list of Backbone-Form models
*
* @param array $entityTypes
* Model names ("IndividualModel").
*
* @throws CRM_Core_Exception
* @return array; keys are model names ("IndividualModel") and values describe 'sections' and 'schema'
* @see js/model/crm.core.js
* @see js/model/crm.mappedcore.js
*/
public static function getSchema($entityTypes)
{
// FIXME: Depending on context (eg civicrm/profile/create vs search-columns), it may be appropriate to
// pick importable or exportable fields
$entityTypes = array_unique($entityTypes);
$availableFields = NULL;
$civiSchema = array();
foreach ($entityTypes as $entityType) {
if (!$availableFields) {
$availableFields = CRM_Core_BAO_UFField::getAvailableFieldsFlat();
}
switch ($entityType) {
case 'IndividualModel':
$civiSchema[$entityType] = self::convertCiviModelToBackboneModel('Individual', ts('Individual'), $availableFields);
break;
case 'OrganizationModel':
$civiSchema[$entityType] = self::convertCiviModelToBackboneModel('Organization', ts('Organization'), $availableFields);
break;
case 'HouseholdModel':
$civiSchema[$entityType] = self::convertCiviModelToBackboneModel('Household', ts('Household'), $availableFields);
break;
case 'ActivityModel':
$civiSchema[$entityType] = self::convertCiviModelToBackboneModel('Activity', ts('Activity'), $availableFields);
break;
case 'ContributionModel':
$civiSchema[$entityType] = self::convertCiviModelToBackboneModel('Contribution', ts('Contribution'), $availableFields);
break;
case 'MembershipModel':
$civiSchema[$entityType] = self::convertCiviModelToBackboneModel('Membership', ts('Membership'), $availableFields);
break;
case 'ParticipantModel':
$civiSchema[$entityType] = self::convertCiviModelToBackboneModel('Participant', ts('Participant'), $availableFields);
break;
case 'CaseModel':
$civiSchema[$entityType] = self::convertCiviModelToBackboneModel('Case', ts('Case'), $availableFields);
break;
default:
throw new CRM_Core_Exception("Unrecognized entity type: {$entityType}");
}
}
// Adding the oddball "formatting" field here because there's no other place to put it
foreach (array('Individual', 'Organization', 'Household') as $type) {
if (isset($civiSchema[$type . 'Model'])) {
$civiSchema[$type . 'Model']['schema'] += array('formatting' => array('type' => 'Markup', 'title' => ts('Free HTML'), 'civiFieldType' => 'Formatting', 'section' => 'formatting'));
$civiSchema[$type . 'Model']['sections'] += array('formatting' => array('title' => ts('Formatting'), 'is_addable' => FALSE));
}
}
return $civiSchema;
}
示例6: preProcess
//.........这里部分代码省略.........
$this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($defaultProcessorId, $this->_mode);
$this->assign_by_ref('paymentProcessor', $this->_paymentProcessor);
}
if (!CRM_Utils_System::isNull($this->_paymentProcessors)) {
foreach ($this->_paymentProcessors as $eachPaymentProcessor) {
// check selected payment processor is active
if (empty($eachPaymentProcessor)) {
CRM_Core_Error::fatal(ts('A payment processor configured for this page might be disabled (contact the site administrator for assistance).'));
}
// ensure that processor has a valid config
$this->_paymentObject =& CRM_Core_Payment::singleton($this->_mode, $eachPaymentProcessor, $this);
$error = $this->_paymentObject->checkConfig();
if (!empty($error)) {
CRM_Core_Error::fatal($error);
}
}
}
}
// get price info
// CRM-5095
CRM_Price_BAO_PriceSet::initSet($this, $this->_id, 'civicrm_contribution_page');
// this avoids getting E_NOTICE errors in php
$setNullFields = array('amount_block_is_active', 'honor_block_is_active', 'is_allow_other_amount', 'footer_text');
foreach ($setNullFields as $f) {
if (!isset($this->_values[$f])) {
$this->_values[$f] = NULL;
}
}
//check if Membership Block is enabled, if Membership Fields are included in profile
//get membership section for this contribution page
$this->_membershipBlock = CRM_Member_BAO_Membership::getMembershipBlock($this->_id);
$this->set('membershipBlock', $this->_membershipBlock);
if ($this->_values['custom_pre_id']) {
$preProfileType = CRM_Core_BAO_UFField::getProfileType($this->_values['custom_pre_id']);
}
if ($this->_values['custom_post_id']) {
$postProfileType = CRM_Core_BAO_UFField::getProfileType($this->_values['custom_post_id']);
}
if ((isset($postProfileType) && $postProfileType == 'Membership' || isset($preProfileType) && $preProfileType == 'Membership') && !$this->_membershipBlock['is_active']) {
CRM_Core_Error::fatal(ts('This page includes a Profile with Membership fields - but the Membership Block is NOT enabled. Please notify the site administrator.'));
}
$pledgeBlock = CRM_Pledge_BAO_PledgeBlock::getPledgeBlock($this->_id);
if ($pledgeBlock) {
$this->_values['pledge_block_id'] = CRM_Utils_Array::value('id', $pledgeBlock);
$this->_values['max_reminders'] = CRM_Utils_Array::value('max_reminders', $pledgeBlock);
$this->_values['initial_reminder_day'] = CRM_Utils_Array::value('initial_reminder_day', $pledgeBlock);
$this->_values['additional_reminder_day'] = CRM_Utils_Array::value('additional_reminder_day', $pledgeBlock);
//set pledge id in values
$pledgeId = CRM_Utils_Request::retrieve('pledgeId', 'Positive', $this);
//authenticate pledge user for pledge payment.
if ($pledgeId) {
$this->_values['pledge_id'] = $pledgeId;
//lets override w/ pledge campaign.
$this->_values['campaign_id'] = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_Pledge', $pledgeId, 'campaign_id');
self::authenticatePledgeUser();
}
}
$this->set('values', $this->_values);
$this->set('fields', $this->_fields);
}
// Handle PCP
$pcpId = CRM_Utils_Request::retrieve('pcpId', 'Positive', $this);
if ($pcpId) {
$pcp = CRM_PCP_BAO_PCP::handlePcp($pcpId, 'contribute', $this->_values);
$this->_pcpId = $pcp['pcpId'];
$this->_pcpBlock = $pcp['pcpBlock'];
示例7: _civicrm_api3_custom_field_flush_static_caches
/**
* Flush static caches in functions that might have stored available custom fields
*/
function _civicrm_api3_custom_field_flush_static_caches()
{
civicrm_api('custom_field', 'getfields', array('version' => 3, 'cache_clear' => 1));
CRM_Core_BAO_UFField::getAvailableFieldsFlat(TRUE);
}
示例8: formatProfileContactParams
/**
* Format profile contact parameters.
*
* @param array $params
* @param $fields
* @param int $contactID
* @param int $ufGroupId
* @param null $ctype
* @param bool $skipCustom
*
* @return array
*/
public static function formatProfileContactParams(&$params, &$fields, $contactID = NULL, $ufGroupId = NULL, $ctype = NULL, $skipCustom = FALSE)
{
$data = $contactDetails = array();
// get the contact details (hier)
if ($contactID) {
list($details, $options) = self::getHierContactDetails($contactID, $fields);
$contactDetails = $details[$contactID];
$data['contact_type'] = CRM_Utils_Array::value('contact_type', $contactDetails);
$data['contact_sub_type'] = CRM_Utils_Array::value('contact_sub_type', $contactDetails);
} else {
//we should get contact type only if contact
if ($ufGroupId) {
$data['contact_type'] = CRM_Core_BAO_UFField::getProfileType($ufGroupId);
//special case to handle profile with only contact fields
if ($data['contact_type'] == 'Contact') {
$data['contact_type'] = 'Individual';
} elseif (CRM_Contact_BAO_ContactType::isaSubType($data['contact_type'])) {
$data['contact_type'] = CRM_Contact_BAO_ContactType::getBasicType($data['contact_type']);
}
} elseif ($ctype) {
$data['contact_type'] = $ctype;
} else {
$data['contact_type'] = 'Individual';
}
}
//fix contact sub type CRM-5125
if (array_key_exists('contact_sub_type', $params) && !empty($params['contact_sub_type'])) {
$data['contact_sub_type'] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, (array) $params['contact_sub_type']) . CRM_Core_DAO::VALUE_SEPARATOR;
} elseif (array_key_exists('contact_sub_type_hidden', $params) && !empty($params['contact_sub_type_hidden'])) {
// if profile was used, and had any subtype, we obtain it from there
$data['contact_sub_type'] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, (array) $params['contact_sub_type_hidden']) . CRM_Core_DAO::VALUE_SEPARATOR;
}
if ($ctype == 'Organization') {
$data['organization_name'] = CRM_Utils_Array::value('organization_name', $contactDetails);
} elseif ($ctype == 'Household') {
$data['household_name'] = CRM_Utils_Array::value('household_name', $contactDetails);
}
$locationType = array();
$count = 1;
if ($contactID) {
//add contact id
$data['contact_id'] = $contactID;
$primaryLocationType = self::getPrimaryLocationType($contactID);
} else {
$defaultLocation = CRM_Core_BAO_LocationType::getDefault();
$defaultLocationId = $defaultLocation->id;
}
// get the billing location type
$locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
$billingLocationTypeId = array_search('Billing', $locationTypes);
$blocks = array('email', 'phone', 'im', 'openid');
$multiplFields = array('url');
// prevent overwritten of formatted array, reset all block from
// params if it is not in valid format (since import pass valid format)
foreach ($blocks as $blk) {
if (array_key_exists($blk, $params) && !is_array($params[$blk])) {
unset($params[$blk]);
}
}
$primaryPhoneLoc = NULL;
$session = CRM_Core_Session::singleton();
foreach ($params as $key => $value) {
$fieldName = $locTypeId = $typeId = NULL;
list($fieldName, $locTypeId, $typeId) = CRM_Utils_System::explode('-', $key, 3);
//store original location type id
$actualLocTypeId = $locTypeId;
if ($locTypeId == 'Primary') {
if ($contactID) {
if (in_array($fieldName, $blocks)) {
$locTypeId = self::getPrimaryLocationType($contactID, FALSE, $fieldName);
} else {
$locTypeId = self::getPrimaryLocationType($contactID, FALSE, 'address');
}
$primaryLocationType = $locTypeId;
} else {
$locTypeId = $defaultLocationId;
}
}
if (is_numeric($locTypeId) && !in_array($fieldName, $multiplFields) && substr($fieldName, 0, 7) != 'custom_') {
$index = $locTypeId;
if (is_numeric($typeId)) {
$index .= '-' . $typeId;
}
if (!in_array($index, $locationType)) {
$locationType[$count] = $index;
$count++;
}
$loc = CRM_Utils_Array::key($index, $locationType);
//.........这里部分代码省略.........
示例9: browse
/**
* Browse all uf data groups.
*
* @param
*
* @return void
*/
public function browse($action = NULL)
{
$ufGroup = array();
$allUFGroups = CRM_Core_BAO_UFGroup::getModuleUFGroup();
if (empty($allUFGroups)) {
return;
}
$ufGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id');
CRM_Utils_Hook::aclGroup(CRM_Core_Permission::ADMIN, NULL, 'civicrm_uf_group', $ufGroups, $allUFGroups);
foreach ($allUFGroups as $id => $value) {
$ufGroup[$id] = array();
$ufGroup[$id]['id'] = $id;
$ufGroup[$id]['title'] = $value['title'];
$ufGroup[$id]['created_id'] = $value['created_id'];
$ufGroup[$id]['created_by'] = CRM_Contact_BAO_Contact::displayName($value['created_id']);
$ufGroup[$id]['description'] = $value['description'];
$ufGroup[$id]['is_active'] = $value['is_active'];
$ufGroup[$id]['group_type'] = $value['group_type'];
$ufGroup[$id]['is_reserved'] = $value['is_reserved'];
// form all action links
$action = array_sum(array_keys(self::actionLinks()));
// update enable/disable links depending on uf_group properties.
if ($value['is_active']) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
// drop certain actions if the profile is reserved
if ($value['is_reserved']) {
$action -= CRM_Core_Action::UPDATE;
$action -= CRM_Core_Action::DISABLE;
$action -= CRM_Core_Action::DELETE;
}
$groupTypes = self::extractGroupTypes($value['group_type']);
// drop Create, Edit and View mode links if profile group_type is one of the following:
// Contribution, Membership, Activity, Participant, Case, Grant
$isMixedProfile = CRM_Core_BAO_UFField::checkProfileType($id);
if ($isMixedProfile) {
$action -= CRM_Core_Action::ADD;
$action -= CRM_Core_Action::ADVANCED;
$action -= CRM_Core_Action::BASIC;
$action -= CRM_Core_Action::PROFILE;
}
$ufGroup[$id]['group_type'] = self::formatGroupTypes($groupTypes);
$ufGroup[$id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('id' => $id), ts('more'), FALSE, 'ufGroup.row.actions', 'UFGroup', $id);
//get the "Used For" from uf_join
$ufGroup[$id]['module'] = implode(', ', CRM_Core_BAO_UFGroup::getUFJoinRecord($id, TRUE));
}
$this->assign('rows', $ufGroup);
}
示例10: getSurveyContactType
/**
* Decides the contact type for given survey.
*/
public static function getSurveyContactType($surveyId)
{
$contactType = NULL;
//apply filter of profile type on search.
$profileId = self::getSurveyProfileId($surveyId);
if ($profileId) {
$profileType = CRM_Core_BAO_UFField::getProfileType($profileId);
if (in_array($profileType, CRM_Contact_BAO_ContactType::basicTypes())) {
$contactType = $profileType;
}
}
return $contactType;
}
示例11: formRule
/**
* global validation rules for the form
*
* @param array $fields posted values of the form
*
* @return array list of errors to be posted back to the form
* @static
* @access public
*/
static function formRule($fields)
{
if (CRM_Core_BAO_UFField::checkProfileType($fields['uf_group_id'])) {
$errorMsg['uf_group_id'] = "You cannot select mix profile for batch update.";
}
if (!empty($errorMsg)) {
return $errorMsg;
}
return TRUE;
}
示例12: buildQuickForm
/**
* Build the form object.
*/
public function buildQuickForm()
{
// build profiles first so that we can determine address fields etc
// and then show copy address checkbox
$this->buildCustom($this->_values['custom_pre_id'], 'customPre');
$this->buildCustom($this->_values['custom_post_id'], 'customPost');
if (!empty($this->_fields) && !empty($this->_values['custom_pre_id'])) {
$profileAddressFields = array();
foreach ($this->_fields as $key => $value) {
CRM_Core_BAO_UFField::assignAddressField($key, $profileAddressFields, array('uf_group_id' => $this->_values['custom_pre_id']));
}
$this->set('profileAddressFields', $profileAddressFields);
}
// Build payment processor form
if (empty($_GET['onbehalf'])) {
CRM_Core_Payment_ProcessorForm::buildQuickForm($this);
// Return if we are in an ajax - this is probably redundant now as
// processor does not call this form for a snippet anymore - but unsure about
// cdType
if ($this->_snippet) {
return;
}
}
$config = CRM_Core_Config::singleton();
$contactID = $this->getContactID();
if ($contactID) {
$this->assign('contact_id', $contactID);
$this->assign('display_name', CRM_Contact_BAO_Contact::displayName($contactID));
}
if ($this->_onbehalf) {
CRM_Contribute_Form_Contribution_OnBehalfOf::buildQuickForm($this);
// Return if we are in an ajax callback
if ($this->_snippet) {
return;
}
}
$this->applyFilter('__ALL__', 'trim');
$this->add('text', "email-{$this->_bltID}", ts('Email Address'), array('size' => 30, 'maxlength' => 60, 'class' => 'email'), TRUE);
$this->addRule("email-{$this->_bltID}", ts('Email is not valid.'), 'email');
$pps = array();
//@todo - this should be replaced by a check as to whether billing fields are set
$onlinePaymentProcessorEnabled = FALSE;
if (!empty($this->_paymentProcessors)) {
foreach ($this->_paymentProcessors as $key => $name) {
if ($name['billing_mode'] == 1) {
$onlinePaymentProcessorEnabled = TRUE;
}
$pps[$key] = $name['name'];
}
}
if (!empty($this->_values['is_pay_later'])) {
$pps[0] = $this->_values['pay_later_text'];
}
if (count($pps) > 1) {
$this->addRadio('payment_processor_id', ts('Payment Method'), $pps, NULL, " ", TRUE);
} elseif (!empty($pps)) {
$key = array_keys($pps);
$key = array_pop($key);
$this->addElement('hidden', 'payment_processor_id', $key);
if ($key === 0) {
$this->assign('is_pay_later', $this->_values['is_pay_later']);
$this->assign('pay_later_text', $this->_values['pay_later_text']);
}
}
$contactID = $this->getContactID();
if ($this->getContactID() === 0) {
$this->addCidZeroOptions($onlinePaymentProcessorEnabled);
}
//build pledge block.
$this->_useForMember = 0;
//don't build membership block when pledge_id is passed
if (empty($this->_values['pledge_id'])) {
$this->_separateMembershipPayment = FALSE;
if (in_array('CiviMember', $config->enableComponents)) {
$isTest = 0;
if ($this->_action & CRM_Core_Action::PREVIEW) {
$isTest = 1;
}
if ($this->_priceSetId && CRM_Core_Component::getComponentID('CiviMember') == CRM_Utils_Array::value('extends', $this->_priceSet)) {
$this->_useForMember = 1;
$this->set('useForMember', $this->_useForMember);
}
$this->_separateMembershipPayment = CRM_Member_BAO_Membership::buildMembershipBlock($this, $this->_id, $this->_membershipContactID, TRUE, NULL, FALSE, $isTest);
}
$this->set('separateMembershipPayment', $this->_separateMembershipPayment);
}
$this->assign('useForMember', $this->_useForMember);
// If we configured price set for contribution page
// we are not allow membership signup as well as any
// other contribution amount field, CRM-5095
if (isset($this->_priceSetId) && $this->_priceSetId) {
$this->add('hidden', 'priceSetId', $this->_priceSetId);
// build price set form.
$this->set('priceSetId', $this->_priceSetId);
CRM_Price_BAO_PriceSet::buildPriceSet($this);
if ($this->_values['is_monetary'] && $this->_values['is_recur'] && empty($this->_values['pledge_id'])) {
self::buildRecur($this);
//.........这里部分代码省略.........
示例13: 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);
//.........这里部分代码省略.........
示例14: formRule
/**
* Global form rule.
*
* @param array $fields
* The input form values.
*
* @param $files
* @param int $contributionPageId
*
* @return bool|array
* true if no errors, else array of errors
*/
public static function formRule($fields, $files, $contributionPageId)
{
$errors = array();
$preProfileType = $postProfileType = NULL;
// for membership profile make sure Membership section is enabled
// get membership section for this contribution page
$dao = new CRM_Member_DAO_MembershipBlock();
$dao->entity_table = 'civicrm_contribution_page';
$dao->entity_id = $contributionPageId;
$membershipEnable = FALSE;
if ($dao->find(TRUE) && $dao->is_active) {
$membershipEnable = TRUE;
}
if ($fields['custom_pre_id']) {
$preProfileType = CRM_Core_BAO_UFField::getProfileType($fields['custom_pre_id']);
}
if ($fields['custom_post_id']) {
$postProfileType = CRM_Core_BAO_UFField::getProfileType($fields['custom_post_id']);
}
$errorMsg = ts('You must enable the Membership Block for this Contribution Page if you want to include a Profile with Membership fields.');
if ($preProfileType == 'Membership' && !$membershipEnable) {
$errors['custom_pre_id'] = $errorMsg;
}
if ($postProfileType == 'Membership' && !$membershipEnable) {
$errors['custom_post_id'] = $errorMsg;
}
$behalf = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $contributionPageId, 'is_for_organization');
if ($fields['custom_pre_id']) {
$errorMsg = ts('You should move the membership related fields in the "On Behalf" profile for this Contribution Page');
if ($preProfileType == 'Membership' && $behalf) {
$errors['custom_pre_id'] = isset($errors['custom_pre_id']) ? $errors['custom_pre_id'] . $errorMsg : $errorMsg;
}
}
if ($fields['custom_post_id']) {
$errorMsg = ts('You should move the membership related fields in the "On Behalf" profile for this Contribution Page');
if ($postProfileType == 'Membership' && $behalf) {
$errors['custom_post_id'] = isset($errors['custom_post_id']) ? $errors['custom_post_id'] . $errorMsg : $errorMsg;
}
}
return empty($errors) ? TRUE : $errors;
}
示例15: setIsActive
/**
* Update the is_active flag in the db.
*
* @param int $id
* Id of the database record.
* @param bool $is_active
* Value we want to set the is_active field.
*
* @return Object
* DAO object on success, null otherwise
*/
public static function setIsActive($id, $is_active)
{
// reset the cache
CRM_Core_BAO_Cache::deleteGroup('contact fields');
if (!$is_active) {
CRM_Core_BAO_UFField::setUFFieldStatus($id, $is_active);
}
return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_CustomGroup', $id, 'is_active', $is_active);
}