本文整理汇总了PHP中CRM_Core_BAO_UFGroup::retrieve方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_UFGroup::retrieve方法的具体用法?PHP CRM_Core_BAO_UFGroup::retrieve怎么用?PHP CRM_Core_BAO_UFGroup::retrieve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_UFGroup
的用法示例。
在下文中一共展示了CRM_Core_BAO_UFGroup::retrieve方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setDefaultValues
/**
* Set default values for the form.
* the default values are retrieved from the database
*
*
* @return void
*/
public function setDefaultValues()
{
if ($this->_addProfileBottom || $this->_addProfileBottomAdd) {
return;
}
$eventId = $this->_id;
$defaults = parent::setDefaultValues();
$this->setShowHide($defaults);
if (isset($eventId)) {
$params = array('id' => $eventId);
CRM_Event_BAO_Event::retrieve($params, $defaults);
$ufJoinParams = array('entity_table' => 'civicrm_event', 'module' => 'CiviEvent', 'entity_id' => $eventId);
list($defaults['custom_pre_id'], $defaults['custom_post']) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
// Get the id for the event registration profile
$eventRegistrationIdParams = $eventRegistrationIdDefaults = array('name' => 'event_registration');
CRM_Core_BAO_UFGroup::retrieve($eventRegistrationIdParams, $eventRegistrationIdDefaults);
// Set event registration as the default profile if none selected
if (!$defaults['custom_pre_id'] && count($defaults['custom_post']) == 0) {
$defaults['custom_pre_id'] = CRM_Utils_Array::value('id', $eventRegistrationIdDefaults);
}
if (isset($defaults['custom_post']) && is_numeric($defaults['custom_post'])) {
$defaults['custom_post_id'] = $defaults['custom_post'];
} elseif (!empty($defaults['custom_post'])) {
$defaults['custom_post_id'] = $defaults['custom_post'][0];
unset($defaults['custom_post'][0]);
$this->_profilePostMultiple = $defaults['custom_post'];
foreach ($defaults['custom_post'] as $key => $value) {
self::buildMultipleProfileBottom($this, $key);
$defaults["custom_post_id_multiple[{$key}]"] = $value;
}
}
$this->assign('profilePostMultiple', CRM_Utils_Array::value('custom_post', $defaults));
if (!empty($defaults['is_multiple_registrations'])) {
// CRM-4377: set additional participants’ profiles – set to ‘none’ if explicitly unset (non-active)
$ufJoinAddParams = array('entity_table' => 'civicrm_event', 'module' => 'CiviEvent_Additional', 'entity_id' => $eventId);
list($defaults['additional_custom_pre_id'], $defaults['additional_custom_post']) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinAddParams);
if (isset($defaults['additional_custom_post']) && is_numeric($defaults['additional_custom_post'])) {
$defaults['additional_custom_post_id'] = $defaults['additional_custom_post'];
} elseif (!empty($defaults['additional_custom_post'])) {
$defaults['additional_custom_post_id'] = $defaults['additional_custom_post'][0];
unset($defaults['additional_custom_post'][0]);
$this->_profilePostMultipleAdd = $defaults['additional_custom_post'];
foreach ($defaults['additional_custom_post'] as $key => $value) {
self::buildMultipleProfileBottom($this, $key, 'additional_', ts('Profile for Additional Participants'));
$defaults["additional_custom_post_id_multiple[{$key}]"] = $value;
}
}
$this->assign('profilePostMultipleAdd', CRM_Utils_Array::value('additional_custom_post', $defaults));
}
} else {
$defaults['is_email_confirm'] = 0;
}
// provide defaults for required fields if empty (and as a 'hint' for approval message field)
$defaults['registration_link_text'] = CRM_Utils_Array::value('registration_link_text', $defaults, ts('Register Now'));
$defaults['confirm_title'] = CRM_Utils_Array::value('confirm_title', $defaults, ts('Confirm Your Registration Information'));
$defaults['thankyou_title'] = CRM_Utils_Array::value('thankyou_title', $defaults, ts('Thank You for Registering'));
$defaults['approval_req_text'] = CRM_Utils_Array::value('approval_req_text', $defaults, ts('Participation in this event requires approval. Submit your registration request here. Once approved, you will receive an email with a link to a web page where you can complete the registration process.'));
if (!empty($defaults['registration_start_date'])) {
list($defaults['registration_start_date'], $defaults['registration_start_date_time']) = CRM_Utils_Date::setDateDefaults($defaults['registration_start_date'], 'activityDateTime');
}
if (!empty($defaults['registration_end_date'])) {
list($defaults['registration_end_date'], $defaults['registration_end_date_time']) = CRM_Utils_Date::setDateDefaults($defaults['registration_end_date'], 'activityDateTime');
}
return $defaults;
}
示例2: getProfileContact
/**
* Function to get the list of contacts for a profile
*
* @param $form object
*
* @access public
*/
function getProfileContact($gid)
{
$session =& CRM_Core_Session::singleton();
$params = $session->get('profileParams');
$details = array();
$ufGroupParam = array('id' => $gid);
require_once "CRM/Core/BAO/UFGroup.php";
CRM_Core_BAO_UFGroup::retrieve($ufGroupParam, $details);
// make sure this group can be mapped
if (!$details['is_map']) {
CRM_Core_Error::statusBounce(ts('This profile does not have the map feature turned on.'));
}
$groupId = CRM_Utils_Array::value('limit_listings_group_id', $details);
// add group id to params if a uf group belong to a any group
if ($groupId) {
if (CRM_Utils_Array::value('group', $params)) {
$params['group'][$groupId] = 1;
} else {
$params['group'] = array($groupId => 1);
}
}
$fields = CRM_Core_BAO_UFGroup::getListingFields(CRM_Core_Action::VIEW, CRM_Core_BAO_UFGroup::PUBLIC_VISIBILITY | CRM_Core_BAO_UFGroup::LISTINGS_VISIBILITY, false, $gid);
$returnProperties =& CRM_Contact_BAO_Contact::makeHierReturnProperties($fields);
$returnProperties['contact_type'] = 1;
$returnProperties['sort_name'] = 1;
$queryParams =& CRM_Contact_BAO_Query::convertFormValues($params, 1);
$query =& new CRM_Contact_BAO_Query($queryParams, $returnProperties, $fields);
$ids = $query->searchQuery(0, 0, null, false, false, false, true, false);
$contactIds = explode(',', $ids);
return $contactIds;
}
示例3: setDefaultValues
/**
* This function sets the default values for the form. Note that in edit/view mode
* the default values are retrieved from the database
*
* @access public
*
* @return void
*/
function setDefaultValues()
{
$defaults = array();
$showHide = new CRM_Core_ShowHideBlocks();
if ($this->_action == CRM_Core_Action::ADD) {
$defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_UFJoin');
}
//id fetched for Dojo Pane
$pId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
if (isset($pId)) {
$this->_id = $pId;
}
if (isset($this->_id)) {
$defaults['weight'] = CRM_Core_BAO_UFGroup::getWeight($this->_id);
$params = array('id' => $this->_id);
CRM_Core_BAO_UFGroup::retrieve($params, $defaults);
$defaults['group'] = CRM_Utils_Array::value('limit_listings_group_id', $defaults);
$defaults['add_contact_to_group'] = CRM_Utils_Array::value('add_to_group_id', $defaults);
//get the uf join records for current uf group
$ufJoinRecords = CRM_Core_BAO_UFGroup::getUFJoinRecord($this->_id);
foreach ($ufJoinRecords as $key => $value) {
$checked[$value] = 1;
}
$defaults['uf_group_type'] = isset($checked) ? $checked : "";
//get the uf join records for current uf group other than default modules
$otherModules = array();
$otherModules = CRM_Core_BAO_UFGroup::getUFJoinRecord($this->_id, TRUE, TRUE);
if (!empty($otherModules)) {
$otherModuleString = NULL;
foreach ($otherModules as $key) {
$otherModuleString .= " [ x ] <label>" . $key . "</label>";
}
$this->assign('otherModuleString', $otherModuleString);
}
$showAdvanced = 0;
$advFields = array('group', 'post_URL', 'cancel_URL', 'add_captcha', 'is_map', 'is_uf_link', 'is_edit_link', 'is_update_dupe', 'is_cms_user', 'is_proximity_search');
foreach ($advFields as $key) {
if (!empty($defaults[$key])) {
$showAdvanced = 1;
$this->_allPanes['Advanced Settings']['open'] = 'true';
break;
}
}
} else {
$defaults['is_active'] = 1;
$defaults['is_map'] = 0;
$defaults['is_update_dupe'] = 0;
$defaults['is_proximity_search'] = 0;
}
// Don't assign showHide elements to template in DELETE mode (fields to be shown and hidden don't exist)
if (!($this->_action & CRM_Core_Action::DELETE) && !($this->_action & CRM_Core_Action::DISABLE)) {
$showHide->addToTemplate();
}
$this->assign('allPanes', $this->_allPanes);
return $defaults;
}
示例4: setDefaultValues
/**
* This function sets the default values for the form. Note that in edit/view mode
* the default values are retrieved from the database
*
* @access public
* @return void
*/
function setDefaultValues()
{
$defaults = array();
if ($this->_action == CRM_CORE_ACTION_ADD) {
$defaults['weight'] = CRM_Core_BAO_UFGroup::getWeight();
$UFGroupType = CRM_Core_SelectValues::ufGroupTypes();
foreach ($UFGroupType as $key => $value) {
$checked[$key] = 1;
}
$defaults['uf_group_type'] = $checked;
}
if (isset($this->_id)) {
$defaults['weight'] = CRM_Core_BAO_UFGroup::getWeight($this->_id);
$params = array('id' => $this->_id);
CRM_Core_BAO_UFGroup::retrieve($params, $defaults);
$defaults['group'] = $defaults['limit_listings_group_id'];
//get the uf join records for current uf group
$ufJoinRecords = CRM_Core_BAO_UFGroup::getUFJoinRecord($this->_id);
foreach ($ufJoinRecords as $key => $value) {
$checked[$value] = 1;
}
$defaults['uf_group_type'] = $checked;
//get the uf join records for current uf group other than default modules
$otherModules = array();
$otherModules = CRM_Core_BAO_UFGroup::getUFJoinRecord($this->_id, true, true);
if (!empty($otherModules)) {
foreach ($otherModules as $key) {
$otherModuleString .= " [ x ] " . $key;
}
$this->assign('otherModuleString', $otherModuleString);
}
} else {
$defaults['is_active'] = 1;
}
return $defaults;
}
示例5: civicrm_api3_profile_submit
/**
* Submit a set of fields against a profile.
* Note choice of submit versus create is discussed CRM-13234 & related to the fact
* 'profile' is being treated as a data-entry entity
*
* @param array $params
*
* @throws API_Exception
* @return array API result array
*/
function civicrm_api3_profile_submit($params)
{
$profileID = _civicrm_api3_profile_getProfileID($params['profile_id']);
if (!CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_active')) {
//@todo declare pseudoconstant & let api do this
throw new API_Exception('Invalid value for profile_id');
}
$isContactActivityProfile = CRM_Core_BAO_UFField::checkContactActivityProfileType($profileID);
if (!empty($params['id']) && CRM_Core_BAO_UFField::checkProfileType($profileID) && !$isContactActivityProfile) {
throw new API_Exception('Update profiles including more than one entity not currently supported');
}
$contactParams = $activityParams = $missingParams = array();
$profileFields = civicrm_api3('profile', 'getfields', array('action' => 'submit', 'profile_id' => $profileID));
$profileFields = $profileFields['values'];
if ($isContactActivityProfile) {
civicrm_api3_verify_mandatory($params, NULL, array('activity_id'));
$errors = CRM_Profile_Form::validateContactActivityProfile($params['activity_id'], $params['contact_id'], $profileID);
if (!empty($errors)) {
throw new API_Exception(array_pop($errors));
}
}
foreach ($profileFields as $fieldName => $field) {
if (!isset($params[$fieldName])) {
continue;
}
$value = $params[$fieldName];
if ($params[$fieldName] && isset($params[$fieldName . '_id'])) {
$value = $params[$fieldName . '_id'];
}
$contactEntities = array('contact', 'individual', 'organization', 'household');
$locationEntities = array('email', 'address', 'phone', 'website', 'im');
$entity = strtolower(CRM_Utils_Array::value('entity', $field));
if ($entity && !in_array($entity, array_merge($contactEntities, $locationEntities))) {
$contactParams['api.' . $entity . '.create'][$fieldName] = $value;
//@todo we are not currently declaring this option
if (isset($params['batch_id']) && strtolower($entity) == 'contribution') {
$contactParams['api.' . $entity . '.create']['batch_id'] = $params['batch_id'];
}
if (isset($params[$entity . '_id'])) {
//todo possibly declare $entity_id in getfields ?
$contactParams['api.' . $entity . '.create']['id'] = $params[$entity . '_id'];
}
} else {
$contactParams[_civicrm_api3_profile_translate_fieldnames_for_bao($fieldName)] = $value;
}
}
if (isset($contactParams['api.contribution.create']) && isset($contactParams['api.membership.create'])) {
$contactParams['api.membership_payment.create'] = array('contribution_id' => '$value.api.contribution.create.id', 'membership_id' => '$value.api.membership.create.id');
}
if (isset($contactParams['api.contribution.create']) && isset($contactParams['api.participant.create'])) {
$contactParams['api.participant_payment.create'] = array('contribution_id' => '$value.api.contribution.create.id', 'participant_id' => '$value.api.participant.create.id');
}
$contactParams['contact_id'] = CRM_Utils_Array::value('contact_id', $params);
$contactParams['profile_id'] = $profileID;
$contactParams['skip_custom'] = 1;
$contactProfileParams = civicrm_api3_profile_apply($contactParams);
// Contact profile fields
$profileParams = $contactProfileParams['values'];
// If profile having activity fields
if ($isContactActivityProfile && !empty($activityParams)) {
$activityParams['id'] = $params['activity_id'];
$profileParams['api.activity.create'] = $activityParams;
}
$groups = $tags = array();
if (isset($profileParams['group'])) {
$groups = $profileParams['group'];
unset($profileParams['group']);
}
if (isset($profileParams['tag'])) {
$tags = $profileParams['tag'];
unset($profileParams['tag']);
}
return civicrm_api3('contact', 'create', $profileParams);
$ufGroupDetails = array();
$ufGroupParams = array('id' => $profileID);
CRM_Core_BAO_UFGroup::retrieve($ufGroupParams, $ufGroupDetails);
if (isset($profileFields['group'])) {
CRM_Contact_BAO_GroupContact::create($groups, $params['contact_id'], FALSE, 'Admin');
}
if (isset($profileFields['tag'])) {
CRM_Core_BAO_EntityTag::create($tags, 'civicrm_contact', $params['contact_id']);
}
if (!empty($ufGroupDetails['add_to_group_id'])) {
$contactIds = array($params['contact_id']);
CRM_Contact_BAO_GroupContact::addContactsToGroup($contactIds, $ufGroupDetails['add_to_group_id']);
}
return $result;
}
示例6: CRM_Profile_Selector_Listings
/**
* Class constructor
*
* @param string params the params for the where clause
*
* @return CRM_Contact_Selector_Profile
* @access public
*/
function CRM_Profile_Selector_Listings(&$params, &$customFields, $ufGroupId = null)
{
$this->_params = $params;
$this->_gid = $ufGroupId;
//get the details of the uf group
$ufGroupParam = array('id' => $ufGroupId);
CRM_Core_BAO_UFGroup::retrieve($ufGroupParam, $details);
$groupId = CRM_Utils_Array::value('limit_listings_group_id', $details);
// add group id to params if a uf group belong to a any group
if ($groupId) {
if (CRM_Utils_Array::value('group', $this->_params)) {
$this->_params['group'][$groupId] = 1;
} else {
$this->_params['group'] = array($groupId => 1);
}
}
$this->_fields = CRM_Core_BAO_UFGroup::getListingFields(CRM_CORE_ACTION_VIEW, CRM_CORE_BAO_UFGROUP_PUBLIC_VISIBILITY | CRM_CORE_BAO_UFGROUP_LISTINGS_VISIBILITY, false, $this->_gid);
// CRM_Core_Error::debug( 'p', $this->_params );
// CRM_Core_Error::debug( 'f', $this->_fields );
$this->_customFields =& $customFields;
$returnProperties =& CRM_Contact_BAO_Contact::makeHierReturnProperties($this->_fields);
$returnProperties['contact_type'] = 1;
$returnProperties['sort_name'] = 1;
$this->_query =& new CRM_Contact_BAO_Query($this->_params, $returnProperties, $this->_fields);
$this->_options =& $this->_query->_options;
//CRM_Core_Error::debug( 'q', $this->_query );
}
示例7: civicrm_api3_profile_set
/**
* Update Profile field values.
*
* @param array $params Associative array of property name/value
* pairs to update profile field values
*
* @return Updated Contact/ Activity object|CRM_Error
*
* @todo add example
* @todo add test cases
*
*/
function civicrm_api3_profile_set($params)
{
civicrm_api3_verify_mandatory($params, NULL, array('profile_id'));
if (!CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $params['profile_id'], 'is_active')) {
return civicrm_api3_create_error('Invalid value for profile_id');
}
$isContactActivityProfile = CRM_Core_BAO_UFField::checkContactActivityProfileType($params['profile_id']);
if (CRM_Core_BAO_UFField::checkProfileType($params['profile_id']) && !$isContactActivityProfile) {
return civicrm_api3_create_error('Can not retrieve values for profiles include fields for more than one record type.');
}
$contactParams = $activityParams = $missingParams = array();
$profileFields = CRM_Core_BAO_UFGroup::getFields($params['profile_id'], FALSE, NULL, NULL, NULL, FALSE, NULL, TRUE, NULL, CRM_Core_Permission::EDIT);
if ($isContactActivityProfile) {
civicrm_api3_verify_mandatory($params, NULL, array('activity_id'));
require_once 'CRM/Profile/Form.php';
$errors = CRM_Profile_Form::validateContactActivityProfile($params['activity_id'], $params['contact_id'], $params['profile_id']);
if (!empty($errors)) {
return civicrm_api3_create_error(array_pop($errors));
}
}
foreach ($profileFields as $fieldName => $field) {
if (CRM_Utils_Array::value('is_required', $field)) {
if (!CRM_Utils_Array::value($fieldName, $params) || empty($params[$fieldName])) {
$missingParams[] = $fieldName;
}
}
if (!isset($params[$fieldName])) {
continue;
}
$value = $params[$fieldName];
if ($params[$fieldName] && isset($params[$fieldName . '_id'])) {
$value = $params[$fieldName . '_id'];
}
if ($isContactActivityProfile && CRM_Utils_Array::value('field_type', $field) == 'Activity') {
$activityParams[$fieldName] = $value;
} else {
$contactParams[$fieldName] = $value;
}
}
if (!empty($missingParams)) {
return civicrm_api3_create_error("Missing required parameters for profile id {$params['profile_id']}: " . implode(', ', $missingParams));
}
$contactParams['version'] = 3;
$contactParams['contact_id'] = CRM_Utils_Array::value('contact_id', $params);
$contactParams['profile_id'] = $params['profile_id'];
$contactParams['skip_custom'] = 1;
$contactProfileParams = civicrm_api3_profile_apply($contactParams);
if (CRM_Utils_Array::value('is_error', $contactProfileParams)) {
return $contactProfileParams;
}
// Contact profile fields
$profileParams = $contactProfileParams['values'];
// If profile having activity fields
if ($isContactActivityProfile && !empty($activityParams)) {
$activityParams['id'] = $params['activity_id'];
$profileParams['api.activity.create'] = $activityParams;
}
$groups = $tags = array();
if (isset($profileParams['group'])) {
$groups = $profileParams['group'];
unset($profileParams['group']);
}
if (isset($profileParams['tag'])) {
$tags = $profileParams['tag'];
unset($profileParams['tag']);
}
$result = civicrm_api('contact', 'create', $profileParams);
if (CRM_Utils_Array::value('is_error', $result)) {
return $result;
}
$ufGroupDetails = array();
$ufGroupParams = array('id' => $params['profile_id']);
CRM_Core_BAO_UFGroup::retrieve($ufGroupParams, $ufGroupDetails);
if (isset($profileFields['group'])) {
CRM_Contact_BAO_GroupContact::create($groups, $params['contact_id'], FALSE, 'Admin');
}
if (isset($profileFields['tag'])) {
require_once 'CRM/Core/BAO/EntityTag.php';
CRM_Core_BAO_EntityTag::create($tags, 'civicrm_contact', $params['contact_id']);
}
if (CRM_Utils_Array::value('add_to_group_id', $ufGroupDetails)) {
$contactIds = array($params['contact_id']);
CRM_Contact_BAO_GroupContact::addContactsToGroup($contactIds, $ufGroupDetails['add_to_group_id']);
}
return $result;
}