本文整理汇总了PHP中CRM_Contact_BAO_Contact::getHierContactDetails方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_Contact::getHierContactDetails方法的具体用法?PHP CRM_Contact_BAO_Contact::getHierContactDetails怎么用?PHP CRM_Contact_BAO_Contact::getHierContactDetails使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_BAO_Contact
的用法示例。
在下文中一共展示了CRM_Contact_BAO_Contact::getHierContactDetails方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: setProfileDefaults
/**
* Set profile defaults.
*
* @param int $contactId
* Contact id.
* @param array $fields
* Associative array of fields.
* @param array $defaults
* Defaults array.
* @param bool $singleProfile
* True for single profile else false(batch update).
* @param int $componentId
* Id for specific components like contribute, event etc.
* @param null $component
*/
public static function setProfileDefaults($contactId, &$fields, &$defaults, $singleProfile = TRUE, $componentId = NULL, $component = NULL)
{
if (!$componentId) {
//get the contact details
list($contactDetails, $options) = CRM_Contact_BAO_Contact::getHierContactDetails($contactId, $fields);
$details = CRM_Utils_Array::value($contactId, $contactDetails);
$multipleFields = array('website' => 'url');
//start of code to set the default values
foreach ($fields as $name => $field) {
// skip pseudo fields
if (substr($name, 0, 9) == 'phone_ext') {
continue;
}
//set the field name depending upon the profile mode(single/batch)
if ($singleProfile) {
$fldName = $name;
} else {
$fldName = "field[{$contactId}][{$name}]";
}
if ($name == 'group') {
CRM_Contact_Form_Edit_TagsAndGroups::setDefaults($contactId, $defaults, CRM_Contact_Form_Edit_TagsAndGroups::GROUP, $fldName);
}
if ($name == 'tag') {
CRM_Contact_Form_Edit_TagsAndGroups::setDefaults($contactId, $defaults, CRM_Contact_Form_Edit_TagsAndGroups::TAG, $fldName);
}
if (!empty($details[$name]) || isset($details[$name])) {
//to handle custom data (checkbox) to be written
// to handle birth/deceased date, greeting_type and few other fields
if ($name == 'birth_date' || $name == 'deceased_date') {
list($defaults[$fldName]) = CRM_Utils_Date::setDateDefaults($details[$name], 'birth');
} elseif (in_array($name, CRM_Contact_BAO_Contact::$_greetingTypes)) {
$defaults[$fldName] = $details[$name . '_id'];
$defaults[$name . '_custom'] = $details[$name . '_custom'];
} elseif ($name == 'preferred_communication_method') {
$v = explode(CRM_Core_DAO::VALUE_SEPARATOR, $details[$name]);
foreach ($v as $item) {
if ($item) {
$defaults[$fldName . "[{$item}]"] = 1;
}
}
} elseif ($name == 'contact_sub_type') {
$defaults[$fldName] = explode(CRM_Core_DAO::VALUE_SEPARATOR, trim($details[$name], CRM_Core_DAO::VALUE_SEPARATOR));
} elseif ($name == 'world_region') {
$defaults[$fldName] = $details['worldregion_id'];
} elseif ($customFieldId = CRM_Core_BAO_CustomField::getKeyID($name)) {
//fix for custom fields
$customFields = CRM_Core_BAO_CustomField::getFields(CRM_Utils_Array::value('contact_type', $details));
// hack to add custom data for components
$components = array('Contribution', 'Participant', 'Membership', 'Activity');
foreach ($components as $value) {
$customFields = CRM_Utils_Array::crmArrayMerge($customFields, CRM_Core_BAO_CustomField::getFieldsForImport($value));
}
switch ($customFields[$customFieldId]['html_type']) {
case 'Multi-Select State/Province':
case 'Multi-Select Country':
case 'AdvMulti-Select':
case 'Multi-Select':
$v = explode(CRM_Core_DAO::VALUE_SEPARATOR, $details[$name]);
foreach ($v as $item) {
if ($item) {
$defaults[$fldName][$item] = $item;
}
}
break;
case 'CheckBox':
$v = explode(CRM_Core_DAO::VALUE_SEPARATOR, $details[$name]);
foreach ($v as $item) {
if ($item) {
$defaults[$fldName][$item] = 1;
// seems like we need this for QF style checkboxes in profile where its multiindexed
// CRM-2969
$defaults["{$fldName}[{$item}]"] = 1;
}
}
break;
case 'Select Date':
// CRM-6681, set defult values according to date and time format (if any).
$dateFormat = NULL;
if (!empty($customFields[$customFieldId]['date_format'])) {
$dateFormat = $customFields[$customFieldId]['date_format'];
}
if (empty($customFields[$customFieldId]['time_format'])) {
list($defaults[$fldName]) = CRM_Utils_Date::setDateDefaults($details[$name], NULL, $dateFormat);
} else {
$timeElement = $fldName . '_time';
//.........这里部分代码省略.........
示例3: preProcess
/**
* pre processing work done here.
*
* gets session variables for table name, id of entity in table, type of entity and stores them.
*
* @param
* @return void
*
* @access public
*/
function preProcess()
{
require_once 'CRM/Core/BAO/UFGroup.php';
$this->_id = $this->get('id');
$this->_gid = $this->get('gid');
if (!$this->_gid) {
$this->_gid = CRM_Utils_Request::retrieve('gid', $this, false, 0, 'GET');
}
// if we dont have a gid use the default, else just use that specific gid
if (($this->_mode == CRM_PROFILE_FORM_MODE_REGISTER || $this->_mode == CRM_PROFILE_FORM_MODE_CREATE) && !$this->_gid) {
$this->_fields = CRM_Core_BAO_UFGroup::getRegistrationFields($this->_action, $this->_mode);
} else {
if ($this->_mode == CRM_PROFILE_FORM_MODE_SEARCH) {
$this->_fields = CRM_Core_BAO_UFGroup::getListingFields($this->_action, CRM_CORE_BAO_UFGROUP_LISTINGS_VISIBILITY, false, $this->_gid, true);
} else {
$this->_fields = CRM_Core_BAO_UFGroup::getFields($this->_gid, false, $this->_action);
}
}
if (!is_array($this->_fields)) {
$session =& CRM_Core_Session::singleton();
CRM_Core_Session::setStatus(ts('This feature is not currently available.'));
return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm', 'reset=1'));
}
if ($this->_id) {
$defaults = array();
// get the contact details (hier)
list($contactDetails, $options) = CRM_Contact_BAO_Contact::getHierContactDetails($this->_id, $this->_fields);
$this->_contact = $details = $contactDetails[$this->_id];
//start of code to set the default values
foreach ($this->_fields as $name => $field) {
if (CRM_Utils_Array::value($name, $details)) {
//to handle custom data (checkbox) to be written
// to handle gender / suffix / prefix
if ($name == 'gender') {
$defaults[$name] = $details['gender_id'];
} else {
if ($name == 'individual_prefix') {
$defaults[$name] = $details['individual_prefix_id'];
} else {
if ($name == 'individual_suffix') {
$defaults[$name] = $details['individual_suffix_id'];
} else {
if (substr($name, 0, 6) == 'custom') {
/*
$cfID = CRM_Core_BAO_CustomField::getKeyID($name);
$cf =& new CRM_Core_BAO_CustomField();
$cf->id = $cfID;
if ( $cf->find( true ) ) {
switch($cf->html_type) {
case 'Select Date':
$defaults[$name] = CRM_Utils_Date::unformat( $details[$name], '-');
break;
case 'CheckBox':
$data = explode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, $details[$name]);
if (is_array($data)) {
foreach($data as $key) {
$checked[$key] = 1;
}
$defaults[$name] = $checked;
}
break;
default:
$defaults[$name] = $details[$name];
}
} */
} else {
$defaults[$name] = $details[$name];
}
}
}
}
} else {
$nameValue = explode('-', $name);
foreach ($details as $key => $value) {
if (is_numeric($nameValue[1])) {
//fixed for CRM-665
if ($nameValue[1] == $value['location_type_id']) {
if (CRM_Utils_Array::value($nameValue[0], $value)) {
//to handle stateprovince and country
if ($nameValue[0] == 'state_province') {
$defaults[$name] = $value['state_province_id'];
} else {
if ($nameValue[0] == 'country') {
$defaults[$name] = $value['country_id'];
} else {
if ($nameValue[0] == 'phone') {
if ($nameValue[2]) {
$defaults[$name] = $value['phone'][$nameValue[2]];
} else {
$defaults[$name] = $value['phone'][1];
//.........这里部分代码省略.........
示例4: setProfileDefaults
/**
* Function to set profile defaults
*
* @params int $contactId contact id
* @params array $fields associative array of fields
* @params array $defaults defaults array
* @params boolean $singleProfile true for single profile else false(batch update)
* @params int $componentId id for specific components like contribute, event etc
*
* @return null
* @static
* @access public
*/
static function setProfileDefaults($contactId, &$fields, &$defaults, $singleProfile = true, $componentId = null, $component = null)
{
if (!$componentId) {
//get the contact details
require_once 'CRM/Contact/BAO/Contact.php';
list($contactDetails, $options) = CRM_Contact_BAO_Contact::getHierContactDetails($contactId, $fields);
$details = $contactDetails[$contactId];
require_once 'CRM/Contact/Form/Edit/TagsAndGroups.php';
//start of code to set the default values
foreach ($fields as $name => $field) {
//set the field name depending upon the profile mode(single/batch)
if ($singleProfile) {
$fldName = $name;
} else {
$fldName = "field[{$contactId}][{$name}]";
}
if ($name == 'group') {
CRM_Contact_Form_Edit_TagsAndGroups::setDefaults($contactId, $defaults, CRM_Contact_Form_Edit_TagsAndGroups::GROUP, $fldName);
}
if ($name == 'tag') {
CRM_Contact_Form_Edit_TagsAndGroups::setDefaults($contactId, $defaults, CRM_Contact_Form_Edit_TagsAndGroups::TAG, $fldName);
}
if (CRM_Utils_Array::value($name, $details) || isset($details[$name])) {
//to handle custom data (checkbox) to be written
// to handle gender / suffix / prefix / greeting_type
if ($name == 'gender') {
$defaults[$fldName] = $details['gender_id'];
} else {
if ($name == 'individual_prefix') {
$defaults[$fldName] = $details['individual_prefix_id'];
} else {
if ($name == 'individual_suffix') {
$defaults[$fldName] = $details['individual_suffix_id'];
} else {
if ($name == 'birth_date' || $name == 'deceased_date') {
list($defaults[$fldName]) = CRM_Utils_Date::setDateDefaults($details[$name], 'birth');
} else {
if ($name == 'email_greeting') {
$defaults[$fldName] = $details['email_greeting_id'];
$defaults['email_greeting_custom'] = $details['email_greeting_custom'];
} else {
if ($name == 'postal_greeting') {
$defaults[$fldName] = $details['postal_greeting_id'];
$defaults['postal_greeting_custom'] = $details['postal_greeting_custom'];
} else {
if ($name == 'addressee') {
$defaults[$fldName] = $details['addressee_id'];
$defaults['addressee_custom'] = $details['addressee_custom'];
} else {
if ($name == 'preferred_communication_method') {
$v = explode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, $details[$name]);
foreach ($v as $item) {
if ($item) {
$defaults[$fldName . "[{$item}]"] = 1;
}
}
} else {
if ($name == 'world_region') {
$defaults[$fldName] = $details['worldregion_id'];
} else {
if ($customFieldId = CRM_Core_BAO_CustomField::getKeyID($name)) {
//fix for custom fields
$customFields = CRM_Core_BAO_CustomField::getFields(CRM_Utils_Array::value('Individual', $values));
// hack to add custom data for components
$components = array("Contribution", "Participant", "Membership");
foreach ($components as $value) {
$customFields = CRM_Utils_Array::crmArrayMerge($customFields, CRM_Core_BAO_CustomField::getFieldsForImport($value));
}
switch ($customFields[$customFieldId]['html_type']) {
case 'Multi-Select State/Province':
case 'Multi-Select Country':
case 'AdvMulti-Select':
case 'Multi-Select':
$v = explode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, $details[$name]);
foreach ($v as $item) {
if ($item) {
$defaults[$fldName][$item] = $item;
}
}
break;
case 'CheckBox':
$v = explode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, $details[$name]);
foreach ($v as $item) {
if ($item) {
$defaults[$fldName][$item] = 1;
// seems like we need this for QF style checkboxes in profile where its multiindexed
// CRM-2969
//.........这里部分代码省略.........
示例5: postProcess
/**
* Process the user submitted custom data values.
*
* @access public
* @return void
*/
public function postProcess()
{
$params = $this->controller->exportValues($this->_name);
if (CRM_Utils_Array::value('image_URL', $params)) {
CRM_Contact_BAO_Contact::processImageParams($params);
}
$greetingTypes = array('addressee' => 'addressee_id', 'email_greeting' => 'email_greeting_id', 'postal_greeting' => 'postal_greeting_id');
if ($this->_id) {
$contactDetails = CRM_Contact_BAO_Contact::getHierContactDetails($this->_id, $greetingTypes);
$details = $contactDetails[0][$this->_id];
}
if (!(CRM_Utils_Array::value('addressee_id', $details) || CRM_Utils_Array::value('email_greeting_id', $details) || 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);
}
$contactTypeFilters = array(1 => 'Individual', 2 => 'Household', 3 => 'Organization');
$filter = CRM_Utils_Array::key($profileType, $contactTypeFilters);
if ($filter) {
foreach ($greetingTypes as $key => $value) {
if (!array_key_exists($key, $params)) {
$defaultGreetingTypeId = CRM_Core_OptionGroup::values($key, null, null, null, "AND is_default =1\n AND (filter = \n {$filter} OR \n filter = 0 )", 'value');
$params[$key] = key($defaultGreetingTypeId);
}
}
}
if ($profileType == 'Organization') {
unset($params['email_greeting'], $params['postal_greeting']);
}
}
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
//.........这里部分代码省略.........