本文整理汇总了PHP中CRM_Core_DAO_Address::export方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_DAO_Address::export方法的具体用法?PHP CRM_Core_DAO_Address::export怎么用?PHP CRM_Core_DAO_Address::export使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_DAO_Address
的用法示例。
在下文中一共展示了CRM_Core_DAO_Address::export方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formatTokensForDisplay
/**
* Formats a token list for the select2 widget
*
* @param $tokens
* @return array
*/
public static function formatTokensForDisplay($tokens)
{
$sorted = $output = array();
// Sort in ascending order by ignoring word case
natcasesort($tokens);
// Attempt to place tokens into optgroups
// @todo These groupings could be better and less hackish. Getting them pre-grouped from upstream would be nice.
foreach ($tokens as $k => $v) {
// Check to see if this token is already in a group e.g. for custom fields
$split = explode(' :: ', $v);
if (!empty($split[1])) {
$sorted[$split[1]][] = array('id' => $k, 'text' => $split[0]);
} else {
$split = explode('.', trim($k, '{}'));
if (isset($split[1])) {
$entity = array_key_exists($split[1], CRM_Core_DAO_Address::export()) ? 'Address' : ucfirst($split[0]);
} else {
$entity = 'Contact';
}
$sorted[ts($entity)][] = array('id' => $k, 'text' => $v);
}
}
ksort($sorted);
foreach ($sorted as $k => $v) {
$output[] = array('text' => $k, 'children' => $v);
}
return $output;
}
示例2: array
/**
* combine all the exportable fields from the lower levels object
*
* currentlty we are using importable fields as exportable fields
*
* @param int $contactType contact Type
* $param boolean $status true while exporting primary contacts
* $param boolean $export true when used during export
*
* @return array array of exportable Fields
* @access public
*/
function &exportableFields($contactType = 'Individual', $status = false, $export = false)
{
if (empty($contactType)) {
$contactType = 'All';
}
$cacheKeyString = "exportableFields {$contactType}";
$cacheKeyString .= $export ? "_1" : "_0";
$cacheKeyString .= $status ? "_1" : "_0";
if (!self::$_exportableFields || !CRM_Utils_Array::value($cacheKeyString, self::$_exportableFields)) {
if (!self::$_exportableFields) {
self::$_exportableFields = array();
}
// check if we can retrieve from database cache
require_once 'CRM/Core/BAO/Cache.php';
$fields =& CRM_Core_BAO_Cache::getItem('contact fields', $cacheKeyString);
if (!$fields) {
$fields = array();
$fields = array_merge($fields, CRM_Contact_DAO_Contact::export());
// the fields are meant for contact types
if (in_array($contactType, array('Individual', 'Household', 'Organization', 'All'))) {
require_once 'CRM/Core/OptionValue.php';
$fields = array_merge($fields, CRM_Core_OptionValue::getFields('', $contactType));
}
// add current employer for individuals
$fields = array_merge($fields, array('current_employer' => array('name' => 'organization_name', 'title' => ts('Current Employer'))));
$locationType = array();
if ($status) {
$locationType['location_type'] = array('name' => 'location_type', 'where' => 'civicrm_location_type.name', 'title' => ts('Location Type'));
}
$IMProvider = array();
if ($status) {
$IMProvider['im_provider'] = array('name' => 'im_provider', 'where' => 'im_provider.name', 'title' => ts('IM Provider'));
}
$locationFields = array_merge($locationType, CRM_Core_DAO_Address::export(), CRM_Core_DAO_Phone::export(), CRM_Core_DAO_Email::export(), $IMProvider, CRM_Core_DAO_IM::export(true), CRM_Core_DAO_OpenID::export());
foreach ($locationFields as $key => $field) {
$locationFields[$key]['hasLocationType'] = true;
}
$fields = array_merge($fields, $locationFields);
//add world region
require_once "CRM/Core/DAO/Worldregion.php";
$fields = array_merge($fields, CRM_Core_DAO_Worldregion::export());
$fields = array_merge($fields, CRM_Contact_DAO_Contact::export());
if ($contactType != 'All') {
$fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport($contactType, $status, true));
} else {
foreach (array('Individual', 'Household', 'Organization') as $type) {
$fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport($type));
}
}
//fix for CRM-791
if ($export) {
$fields = array_merge($fields, array('groups' => array('title' => ts('Group(s)')), 'tags' => array('title' => ts('Tag(s)')), 'notes' => array('title' => ts('Note(s)'))));
} else {
$fields = array_merge($fields, array('group' => array('title' => ts('Group(s)')), 'tag' => array('title' => ts('Tag(s)')), 'note' => array('title' => ts('Note(s)'))));
}
//Sorting fields in alphabetical order(CRM-1507)
foreach ($fields as $k => $v) {
$sortArray[$k] = CRM_Utils_Array::value('title', $v);
}
$fields = array_merge($sortArray, $fields);
//unset the field which are not related to their contact type.
if ($contactType != 'All') {
$commonValues = array('Individual' => array('household_name', 'legal_name', 'sic_code', 'organization_name', 'email_greeting_custom', 'postal_greeting_custom', 'addressee_custom'), 'Household' => array('first_name', 'middle_name', 'last_name', 'job_title', 'gender_id', 'birth_date', 'organization_name', 'legal_name', 'legal_identifier', 'sic_code', 'home_URL', 'is_deceased', 'deceased_date', 'current_employer', 'email_greeting_custom', 'postal_greeting_custom', 'addressee_custom', 'individual_prefix', 'individual_suffix', 'gender'), 'Organization' => array('first_name', 'middle_name', 'last_name', 'job_title', 'gender_id', 'birth_date', 'household_name', 'email_greeting', 'postal_greeting', 'email_greeting_custom', 'postal_greeting_custom', 'individual_prefix', 'individual_suffix', 'gender', 'addressee_custom', 'is_deceased', 'deceased_date', 'current_employer'));
foreach ($commonValues[$contactType] as $value) {
unset($fields[$value]);
}
}
CRM_Core_BAO_Cache::setItem($fields, 'contact fields', $cacheKeyString);
}
self::$_exportableFields[$cacheKeyString] = $fields;
}
if (!$status) {
$fields = self::$_exportableFields[$cacheKeyString];
} else {
$fields = array_merge(array('' => array('title' => ts('- Contact Fields -'))), self::$_exportableFields[$cacheKeyString]);
}
return $fields;
}
示例3: array
/**
* Combine all the exportable fields from the lower levels object.
*
* Currently we are using importable fields as exportable fields
*
* @param int|string $contactType contact Type
* @param bool $status
* True while exporting primary contacts.
* @param bool $export
* True when used during export.
* @param bool $search
* True when used during search, might conflict with export param?.
*
* @param bool $withMultiRecord
*
* @return array
* array of exportable Fields
*/
public static function &exportableFields($contactType = 'Individual', $status = FALSE, $export = FALSE, $search = FALSE, $withMultiRecord = FALSE)
{
if (empty($contactType)) {
$contactType = 'All';
}
$cacheKeyString = "exportableFields {$contactType}";
$cacheKeyString .= $export ? '_1' : '_0';
$cacheKeyString .= $status ? '_1' : '_0';
$cacheKeyString .= $search ? '_1' : '_0';
//CRM-14501 it turns out that the impact of permissioning here is sometimes inconsistent. The field that
//calculates custom fields takes into account the logged in user & caches that for all users
//as an interim fix we will cache the fields by contact
$cacheKeyString .= '_' . CRM_Core_Session::getLoggedInContactID();
if (!self::$_exportableFields || !CRM_Utils_Array::value($cacheKeyString, self::$_exportableFields)) {
if (!self::$_exportableFields) {
self::$_exportableFields = array();
}
// check if we can retrieve from database cache
$fields = CRM_Core_BAO_Cache::getItem('contact fields', $cacheKeyString);
if (!$fields) {
$fields = CRM_Contact_DAO_Contact::export();
// The fields are meant for contact types.
if (in_array($contactType, array('Individual', 'Household', 'Organization', 'All'))) {
$fields = array_merge($fields, CRM_Core_OptionValue::getFields('', $contactType));
}
// add current employer for individuals
$fields = array_merge($fields, array('current_employer' => array('name' => 'organization_name', 'title' => ts('Current Employer'))));
$locationType = array('location_type' => array('name' => 'location_type', 'where' => 'civicrm_location_type.name', 'title' => ts('Location Type')));
$IMProvider = array('im_provider' => array('name' => 'im_provider', 'where' => 'civicrm_im.provider_id', 'title' => ts('IM Provider')));
$locationFields = array_merge($locationType, CRM_Core_DAO_Address::export(), CRM_Core_DAO_Phone::export(), CRM_Core_DAO_Email::export(), $IMProvider, CRM_Core_DAO_IM::export(TRUE), CRM_Core_DAO_OpenID::export());
$locationFields = array_merge($locationFields, CRM_Core_BAO_CustomField::getFieldsForImport('Address'));
foreach ($locationFields as $key => $field) {
$locationFields[$key]['hasLocationType'] = TRUE;
}
$fields = array_merge($fields, $locationFields);
//add world region
$fields = array_merge($fields, CRM_Core_DAO_Worldregion::export());
$fields = array_merge($fields, CRM_Contact_DAO_Contact::export());
//website fields
$fields = array_merge($fields, CRM_Core_DAO_Website::export());
if ($contactType != 'All') {
$fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport($contactType, $status, FALSE, $search, TRUE, $withMultiRecord));
} else {
foreach (array('Individual', 'Household', 'Organization') as $type) {
$fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport($type, FALSE, FALSE, $search, TRUE, $withMultiRecord));
}
}
//fix for CRM-791
if ($export) {
$fields = array_merge($fields, array('groups' => array('title' => ts('Group(s)'), 'name' => 'groups'), 'tags' => array('title' => ts('Tag(s)'), 'name' => 'tags'), 'notes' => array('title' => ts('Note(s)'), 'name' => 'notes')));
} else {
$fields = array_merge($fields, array('group' => array('title' => ts('Group(s)'), 'name' => 'group'), 'tag' => array('title' => ts('Tag(s)'), 'name' => 'tag'), 'note' => array('title' => ts('Note(s)'), 'name' => 'note')));
}
//Sorting fields in alphabetical order(CRM-1507)
foreach ($fields as $k => $v) {
$sortArray[$k] = CRM_Utils_Array::value('title', $v);
}
$fields = array_merge($sortArray, $fields);
//unset the field which are not related to their contact type.
if ($contactType != 'All') {
$commonValues = array('Individual' => array('household_name', 'legal_name', 'sic_code', 'organization_name', 'email_greeting_custom', 'postal_greeting_custom', 'addressee_custom'), 'Household' => array('first_name', 'middle_name', 'last_name', 'formal_title', 'job_title', 'gender_id', 'prefix_id', 'suffix_id', 'birth_date', 'organization_name', 'legal_name', 'legal_identifier', 'sic_code', 'home_URL', 'is_deceased', 'deceased_date', 'current_employer', 'email_greeting_custom', 'postal_greeting_custom', 'addressee_custom', 'prefix_id', 'suffix_id'), 'Organization' => array('first_name', 'middle_name', 'last_name', 'formal_title', 'job_title', 'gender_id', 'prefix_id', 'suffix_id', 'birth_date', 'household_name', 'email_greeting_custom', 'postal_greeting_custom', 'prefix_id', 'suffix_id', 'gender_id', 'addressee_custom', 'is_deceased', 'deceased_date', 'current_employer'));
foreach ($commonValues[$contactType] as $value) {
unset($fields[$value]);
}
}
CRM_Core_BAO_Cache::setItem($fields, 'contact fields', $cacheKeyString);
}
self::$_exportableFields[$cacheKeyString] = $fields;
}
if (!$status) {
$fields = self::$_exportableFields[$cacheKeyString];
} else {
$fields = array_merge(array('' => array('title' => ts('- Contact Fields -'))), self::$_exportableFields[$cacheKeyString]);
}
return $fields;
}
示例4: array
/**
* combine all the exportable fields from the lower levels object
*
* currentlty we are using importable fields as exportable fields
*
* @param int $contactType contact Type
* $param boolean $status true while exporting primary contacts
* $param boolean $export true when used during export
*
* @return array array of exportable Fields
* @access public
*/
function &exportableFields($contactType = 'Individual', $status = false, $export = false)
{
if (empty($contactType)) {
$contactType = 'All';
}
if (!$GLOBALS['_CRM_CONTACT_BAO_CONTACT']['_exportableFields'] || !CRM_Utils_Array::value($contactType, $GLOBALS['_CRM_CONTACT_BAO_CONTACT']['_exportableFields'])) {
if (!$GLOBALS['_CRM_CONTACT_BAO_CONTACT']['_exportableFields']) {
$GLOBALS['_CRM_CONTACT_BAO_CONTACT']['_exportableFields'] = array();
}
if (!$status) {
$fields = array();
} else {
$fields = array('' => array('title' => ts('- Contact Fields -')));
}
if ($contactType != 'All') {
require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_DAO_" . $contactType) . ".php";
eval('$fields = array_merge($fields, CRM_Contact_DAO_' . $contactType . '::export( ));');
} else {
foreach (array('Individual', 'Household', 'Organization') as $type) {
require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_DAO_" . $type) . ".php";
eval('$fields = array_merge($fields, CRM_Contact_DAO_' . $type . '::export( ));');
if ($type == 'Individual') {
$fields = array_merge($fields, CRM_Core_DAO_IndividualPrefix::export(true), CRM_Core_DAO_IndividualSuffix::export(true), CRM_Core_DAO_Gender::export(true));
}
}
}
// the fields are only meant for Individual contact type
if ($contactType == 'Individual') {
$fields = array_merge($fields, CRM_Core_DAO_IndividualPrefix::export(true), CRM_Core_DAO_IndividualSuffix::export(true), CRM_Core_DAO_Gender::export(true));
}
$locationType = array();
if ($status) {
$locationType['location_type'] = array('name' => 'location_type', 'where' => 'civicrm_location_type.name', 'title' => 'Location Type');
}
$IMProvider = array();
if ($status) {
$IMProvider['im_provider'] = array('name' => 'im_provider', 'where' => 'civicrm_im_provider.name', 'title' => 'IM Provider');
}
$locationFields = array_merge($locationType, CRM_Core_DAO_Location::export(), CRM_Core_DAO_Address::export(), CRM_Core_DAO_Phone::export(), CRM_Core_DAO_Email::export(), $IMProvider, CRM_Core_DAO_IM::export(true));
foreach ($locationFields as $key => $field) {
$locationFields[$key]['hasLocationType'] = true;
}
$fields = array_merge($fields, $locationFields);
$fields = array_merge($fields, CRM_Contact_DAO_Contact::export());
$fields = array_merge($fields, CRM_Core_DAO_Note::export());
if ($contactType != 'All') {
$fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport($contactType, $status));
} else {
foreach (array('Individual', 'Household', 'Organization') as $type) {
$fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport($type));
}
}
//fix for CRM-791
if ($export) {
$fields = array_merge($fields, array('groups' => array('title' => ts('Group(s)'))));
$fields = array_merge($fields, array('tags' => array('title' => ts('Tag(s)'))));
} else {
$fields = array_merge($fields, array('group' => array('title' => ts('Group(s)'))));
$fields = array_merge($fields, array('tag' => array('title' => ts('Tag(s)'))));
}
$GLOBALS['_CRM_CONTACT_BAO_CONTACT']['_exportableFields'][$contactType] = $fields;
}
return $GLOBALS['_CRM_CONTACT_BAO_CONTACT']['_exportableFields'][$contactType];
}