本文整理汇总了PHP中CRM_Core_OptionGroup::lookupValues方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_OptionGroup::lookupValues方法的具体用法?PHP CRM_Core_OptionGroup::lookupValues怎么用?PHP CRM_Core_OptionGroup::lookupValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_OptionGroup
的用法示例。
在下文中一共展示了CRM_Core_OptionGroup::lookupValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
//.........这里部分代码省略.........
}
}
}
$names[] = "status";
} elseif (!empty($this->_returnProperties)) {
$names = self::makeProperties($this->_returnProperties);
} else {
$names = self::$_properties;
}
$multipleSelectFields = array('preferred_communication_method' => 1);
$links = self::links($this->_context, $this->_contextMenu, $this->_key);
//check explicitly added contact to a Smart Group.
$groupID = CRM_Utils_Array::key('1', $this->_formValues['group']);
$pseudoconstants = array();
// for CRM-3157 purposes
if (in_array('world_region', $names)) {
$pseudoconstants['world_region'] = array('dbName' => 'world_region_id', 'values' => CRM_Core_PseudoConstant::worldRegion());
}
$seenIDs = array();
while ($result->fetch()) {
$row = array();
$this->_query->convertToPseudoNames($result);
// the columns we are interested in
foreach ($names as $property) {
if ($property == 'status') {
continue;
}
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($property)) {
$row[$property] = CRM_Core_BAO_CustomField::getDisplayValue($result->{$property}, $cfID, $this->_options, $result->contact_id);
} elseif ($multipleSelectFields && array_key_exists($property, $multipleSelectFields)) {
$key = $property;
$paramsNew = array($key => $result->{$property});
$name = array($key => array('newName' => $key, 'groupName' => $key));
CRM_Core_OptionGroup::lookupValues($paramsNew, $name, FALSE);
$row[$key] = $paramsNew[$key];
} elseif (strpos($property, '-im')) {
$row[$property] = $result->{$property};
if (!empty($result->{$property})) {
$imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
$providerId = $property . "-provider_id";
$providerName = $imProviders[$result->{$providerId}];
$row[$property] = $result->{$property} . " ({$providerName})";
}
} elseif (in_array($property, array('addressee', 'email_greeting', 'postal_greeting'))) {
$greeting = $property . '_display';
$row[$property] = $result->{$greeting};
} elseif (isset($pseudoconstants[$property])) {
$row[$property] = CRM_Utils_Array::value($result->{$pseudoconstants[$property]['dbName']}, $pseudoconstants[$property]['values']);
} elseif (strpos($property, '-url') !== FALSE) {
$websiteUrl = '';
$websiteKey = 'website-1';
$propertyArray = explode('-', $property);
$websiteFld = $websiteKey . '-' . array_pop($propertyArray);
if (!empty($result->{$websiteFld})) {
$websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id');
$websiteType = $websiteTypes[$result->{"{$websiteKey}-website_type_id"}];
$websiteValue = $result->{$websiteFld};
$websiteUrl = "<a href=\"{$websiteValue}\">{$websiteValue} ({$websiteType})</a>";
}
$row[$property] = $websiteUrl;
} else {
$row[$property] = isset($result->{$property}) ? $result->{$property} : NULL;
}
}
if (!empty($result->postal_code_suffix)) {
$row['postal_code'] .= "-" . $result->postal_code_suffix;
示例2: exportComponents
//.........这里部分代码省略.........
break;
default:
$row[$fldValue] = $iterationDAO->{$daoField};
break;
}
}
}
} elseif (array_key_exists($field, $contactRelationshipTypes)) {
$relDAO = CRM_Utils_Array::value($iterationDAO->contact_id, $allRelContactArray[$field]);
$relationQuery[$field]->convertToPseudoNames($relDAO);
foreach ($value as $relationField => $relationValue) {
if (is_object($relDAO) && property_exists($relDAO, $relationField)) {
$fieldValue = $relDAO->{$relationField};
if ($relationField == 'phone_type_id') {
$fieldValue = $phoneTypes[$relationValue];
} elseif ($relationField == 'provider_id') {
$fieldValue = CRM_Utils_Array::value($relationValue, $imProviders);
} elseif (is_object($relDAO) && in_array($relationField, array('email_greeting', 'postal_greeting', 'addressee'))) {
//special case for greeting replacement
$fldValue = "{$relationField}_display";
$fieldValue = $relDAO->{$fldValue};
}
} elseif (is_object($relDAO) && $relationField == 'state_province') {
$fieldValue = CRM_Core_PseudoConstant::stateProvince($relDAO->state_province_id);
} elseif (is_object($relDAO) && $relationField == 'country') {
$fieldValue = CRM_Core_PseudoConstant::country($relDAO->country_id);
} else {
$fieldValue = '';
}
$field = $field . '_';
if (array_key_exists($relationField, $multipleSelectFields)) {
$param = array($relationField => $fieldValue);
$names = array($relationField => array('newName' => $relationField, 'groupName' => $relationField));
CRM_Core_OptionGroup::lookupValues($param, $names, FALSE);
$fieldValue = $param[$relationField];
}
if (is_object($relDAO) && $relationField == 'id') {
$row[$field . $relationField] = $relDAO->contact_id;
} elseif (is_array($relationValue) && $relationField == 'location') {
foreach ($relationValue as $ltype => $val) {
foreach (array_keys($val) as $fld) {
$type = explode('-', $fld);
$fldValue = "{$ltype}-" . $type[0];
if (!empty($type[1])) {
$fldValue .= "-" . $type[1];
}
// CRM-3157: localise country, region (both have ‘country’ context)
// and state_province (‘province’ context)
switch (TRUE) {
case !is_object($relDAO):
$row[$field . '_' . $fldValue] = '';
break;
case in_array('country', $type):
case in_array('world_region', $type):
$row[$field . '_' . $fldValue] = $i18n->crm_translate($relDAO->{$fldValue}, array('context' => 'country'));
break;
case in_array('state_province', $type):
$row[$field . '_' . $fldValue] = $i18n->crm_translate($relDAO->{$fldValue}, array('context' => 'province'));
break;
default:
$row[$field . '_' . $fldValue] = $relDAO->{$fldValue};
break;
}
}
}
} elseif (isset($fieldValue) && $fieldValue != '') {
示例3: array
//.........这里部分代码省略.........
}
}
}
$multipleSelectFields = array('preferred_communication_method' => 1);
$multiRecordTableId = NULL;
if ($this->_multiRecordTableName) {
$multiRecordTableId = "{$this->_multiRecordTableName}_id";
}
// we need to determine of overlay profile should be shown
$showProfileOverlay = CRM_Core_BAO_UFGroup::showOverlayProfile();
while ($result->fetch()) {
$this->_query->convertToPseudoNames($result);
if (isset($result->country)) {
// the query returns the untranslated country name
$i18n = CRM_Core_I18n::singleton();
$result->country = $i18n->translate($result->country);
}
$row = array();
$empty = TRUE;
$row[] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id, $showProfileOverlay);
if ($result->sort_name) {
$row[] = $result->sort_name;
$empty = FALSE;
} else {
continue;
}
foreach ($names as $name) {
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name)) {
$row[] = CRM_Core_BAO_CustomField::getDisplayValue($result->{$name}, $cfID, $this->_options, $result->contact_id);
} elseif (substr($name, -4) == '-url' && !empty($result->{$name})) {
$url = CRM_Utils_System::fixURL($result->{$name});
$typeId = substr($name, 0, -4) . "-website_type_id";
$typeName = CRM_Core_PseudoConstant::getLabel('CRM_Core_DAO_Website', 'website_type_id', $result->{$typeId});
if ($typeName) {
$row[] = "<a href=\"{$url}\">{$result->{$name}} ({$typeName})</a>";
} else {
$row[] = "<a href=\"{$url}\">{$result->{$name}}</a>";
}
} elseif ($name == 'preferred_language') {
$row[] = CRM_Core_PseudoConstant::getLabel('CRM_Contact_DAO_Contact', 'preferred_language', $result->{$name});
} elseif ($multipleSelectFields && array_key_exists($name, $multipleSelectFields)) {
$paramsNew = array($name => $result->{$name});
$name = array($name => array('newName' => $name, 'groupName' => $name));
CRM_Core_OptionGroup::lookupValues($paramsNew, $name, FALSE);
$row[] = $paramsNew[$key];
} elseif (strpos($name, '-im')) {
if (!empty($result->{$name})) {
$providerId = $name . "-provider_id";
$providerName = CRM_Core_PseudoConstant::getLabel('CRM_Core_DAO_IM', 'provider_id', $result->{$providerId});
$row[] = $result->{$name} . " ({$providerName})";
} else {
$row[] = '';
}
} elseif (strpos($name, '-phone-')) {
$phoneExtField = str_replace('phone', 'phone_ext', $name);
if (isset($result->{$phoneExtField})) {
$row[] = $result->{$name} . " (" . $result->{$phoneExtField} . ")";
} else {
$row[] = $result->{$name};
}
} elseif (in_array($name, array('addressee', 'email_greeting', 'postal_greeting'))) {
$dname = $name . '_display';
$row[] = $result->{$dname};
} elseif (in_array($name, array('birth_date', 'deceased_date'))) {
$row[] = CRM_Utils_Date::customFormat($result->{$name});
} elseif (isset($result->{$name})) {
$row[] = $result->{$name};
} else {
$row[] = '';
}
if (!empty($result->{$name})) {
$empty = FALSE;
}
}
$newLinks = $links;
$params = array('id' => $result->contact_id, 'gid' => implode(',', $this->_profileIds));
// pass record id param to view url for multi record view
if ($multiRecordTableId && $newLinks) {
if ($result->{$multiRecordTableId}) {
if ($newLinks[CRM_Core_Action::VIEW]['url'] == 'civicrm/profile/view') {
$newLinks[CRM_Core_Action::VIEW]['qs'] .= "&multiRecord=view&recordId=%%recordId%%&allFields=1";
$params['recordId'] = $result->{$multiRecordTableId};
}
}
}
if ($this->_linkToUF) {
$ufID = CRM_Core_BAO_UFMatch::getUFId($result->contact_id);
if (!$ufID) {
unset($newLinks[CRM_Core_Action::PROFILE]);
} else {
$params['ufID'] = $ufID;
}
}
$row[] = CRM_Core_Action::formLink($newLinks, $mask, $params, ts('more'), FALSE, 'profile.selector.row', 'Contact', $result->contact_id);
if (!$empty) {
$rows[] = $row;
}
}
return $rows;
}
示例4: getValues
/**
* Fetch the object and store the values in the values array.
*
* @param array $params
* Input parameters to find object.
* @param array $values
* Output values of the object.
*
* @return CRM_Contact_BAO_Contact|null
* The found object or null
*/
public static function getValues(&$params, &$values)
{
$contact = new CRM_Contact_BAO_Contact();
$contact->copyValues($params);
if ($contact->find(TRUE)) {
CRM_Core_DAO::storeValues($contact, $values);
$privacy = array();
foreach (self::$_commPrefs as $name) {
if (isset($contact->{$name})) {
$privacy[$name] = $contact->{$name};
}
}
if (!empty($privacy)) {
$values['privacy'] = $privacy;
}
// communication Prefferance
$preffComm = $comm = array();
$comm = explode(CRM_Core_DAO::VALUE_SEPARATOR, $contact->preferred_communication_method);
foreach ($comm as $value) {
$preffComm[$value] = 1;
}
$temp = array('preferred_communication_method' => $contact->preferred_communication_method);
$names = array('preferred_communication_method' => array('newName' => 'preferred_communication_method_display', 'groupName' => 'preferred_communication_method'));
CRM_Core_OptionGroup::lookupValues($temp, $names, FALSE);
$values['preferred_communication_method'] = $preffComm;
$values['preferred_communication_method_display'] = CRM_Utils_Array::value('preferred_communication_method_display', $temp);
$preferredMailingFormat = CRM_Core_SelectValues::pmf();
$values['preferred_mail_format'] = $preferredMailingFormat[$contact->preferred_mail_format];
// get preferred languages
if (!empty($contact->preferred_language)) {
$values['preferred_language'] = CRM_Core_PseudoConstant::getLabel('CRM_Contact_DAO_Contact', 'preferred_language', $contact->preferred_language);
}
// Calculating Year difference
if ($contact->birth_date) {
$birthDate = CRM_Utils_Date::customFormat($contact->birth_date, '%Y%m%d');
if ($birthDate < date('Ymd')) {
$age = CRM_Utils_Date::calculateAge($birthDate);
$values['age']['y'] = CRM_Utils_Array::value('years', $age);
$values['age']['m'] = CRM_Utils_Array::value('months', $age);
}
list($values['birth_date']) = CRM_Utils_Date::setDateDefaults($contact->birth_date, 'birth');
$values['birth_date_display'] = $contact->birth_date;
}
if ($contact->deceased_date) {
list($values['deceased_date']) = CRM_Utils_Date::setDateDefaults($contact->deceased_date, 'birth');
$values['deceased_date_display'] = $contact->deceased_date;
}
$contact->contact_id = $contact->id;
return $contact;
}
return NULL;
}
示例5: moveAllBelongings
//.........这里部分代码省略.........
$deleteDAO->id = $mainBlockId;
$deleteDAO->find(TRUE);
// if we about to delete a primary / billing block, set the flags for new block
// that we going to assign to main-contact
if ($primaryDAOId && $primaryDAOId == $deleteDAO->id) {
$otherBlockDAO->is_primary = 1;
}
if ($billingDAOId && $billingDAOId == $deleteDAO->id) {
$otherBlockDAO->is_billing = 1;
}
$deleteDAO->delete();
$deleteDAO->free();
}
$otherBlockDAO->update();
$otherBlockDAO->free();
}
}
}
// **** Do tables related migrations
if (!empty($moveTables)) {
CRM_Dedupe_Merger::moveContactBelongings($mainId, $otherId, $moveTables, $tableOperations);
unset($moveTables, $tableOperations);
}
// **** Do contact related migrations
CRM_Dedupe_Merger::moveContactBelongings($mainId, $otherId);
// FIXME: fix gender, prefix and postfix, so they're edible by createProfileContact()
$names['gender'] = array('newName' => 'gender_id', 'groupName' => 'gender');
$names['individual_prefix'] = array('newName' => 'prefix_id', 'groupName' => 'individual_prefix');
$names['individual_suffix'] = array('newName' => 'suffix_id', 'groupName' => 'individual_suffix');
$names['communication_style'] = array('newName' => 'communication_style_id', 'groupName' => 'communication_style');
$names['addressee'] = array('newName' => 'addressee_id', 'groupName' => 'addressee');
$names['email_greeting'] = array('newName' => 'email_greeting_id', 'groupName' => 'email_greeting');
$names['postal_greeting'] = array('newName' => 'postal_greeting_id', 'groupName' => 'postal_greeting');
CRM_Core_OptionGroup::lookupValues($submitted, $names, TRUE);
// fix custom fields so they're edible by createProfileContact()
static $treeCache = array();
if (!array_key_exists($migrationInfo['main_details']['contact_type'], $treeCache)) {
$treeCache[$migrationInfo['main_details']['contact_type']] = CRM_Core_BAO_CustomGroup::getTree($migrationInfo['main_details']['contact_type'], CRM_Core_DAO::$_nullObject, NULL, -1);
}
$cgTree =& $treeCache[$migrationInfo['main_details']['contact_type']];
$cFields = array();
foreach ($cgTree as $key => $group) {
if (!isset($group['fields'])) {
continue;
}
foreach ($group['fields'] as $fid => $field) {
$cFields[$fid]['attributes'] = $field;
}
}
if (!isset($submitted)) {
$submitted = array();
}
foreach ($submitted as $key => $value) {
if (substr($key, 0, 7) == 'custom_') {
$fid = (int) substr($key, 7);
if (empty($cFields[$fid])) {
continue;
}
$htmlType = $cFields[$fid]['attributes']['html_type'];
switch ($htmlType) {
case 'File':
$customFiles[] = $fid;
unset($submitted["custom_{$fid}"]);
break;
case 'Select Country':
case 'Select State/Province':
示例6: exportComponents
//.........这里部分代码省略.........
}
$row[$field . $fldValue] = $relDAO->{$fldValue};
}
}
} else {
if (isset($fieldValue) && $fieldValue != '') {
//check for custom data
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($relationField)) {
$row[$field . $relationField] = CRM_Core_BAO_CustomField::getDisplayValue($fieldValue, $cfID, $relationQuery[$field]->_options);
} else {
if (in_array($relationField, array('email_greeting', 'postal_greeting', 'addressee'))) {
//special case for greeting replacement
$fldValue = "{$relationField}_display";
$row[$field . $relationField] = $relDAO->{$fldValue};
} else {
//normal relationship fields
$row[$field . $relationField] = $fieldValue;
}
}
} else {
// if relation field is empty or null
$row[$field . $relationField] = '';
}
}
}
}
} else {
if (isset($fieldValue) && $fieldValue != '') {
//check for custom data
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($field)) {
$row[$field] = CRM_Core_BAO_CustomField::getDisplayValue($fieldValue, $cfID, $query->_options);
} else {
if (array_key_exists($field, $multipleSelectFields)) {
//option group fixes
$paramsNew = array($field => $fieldValue);
if ($field == 'test_tutoring') {
$name = array($field => array('newName' => $field, 'groupName' => 'test'));
} else {
if (substr($field, 0, 4) == 'cmr_') {
//for readers group
$name = array($field => array('newName' => $field, 'groupName' => substr($field, 0, -3)));
} else {
$name = array($field => array('newName' => $field, 'groupName' => $field));
}
}
CRM_Core_OptionGroup::lookupValues($paramsNew, $name, false);
$row[$field] = $paramsNew[$field];
} else {
if (in_array($field, array('email_greeting', 'postal_greeting', 'addressee'))) {
//special case for greeting replacement
$fldValue = "{$field}_display";
$row[$field] = $dao->{$fldValue};
} else {
//normal fields
$row[$field] = $fieldValue;
}
}
}
} else {
// if field is empty or null
$row[$field] = '';
}
}
}
}
}
}
}
//build header only once
$setHeader = false;
// add payment headers if required
if ($addPaymentHeader && $paymentFields) {
$headerRows = array_merge($headerRows, $paymentHeaders);
$addPaymentHeader = false;
}
// add payment related information
if ($paymentFields && isset($paymentDetails[$row[$paymentTableId]])) {
$row = array_merge($row, $paymentDetails[$row[$paymentTableId]]);
}
//remove organization name for individuals if it is set for current employer
if (CRM_Utils_Array::value('contact_type', $row) && $row['contact_type'] == 'Individual') {
$row['organization_name'] = '';
}
// CRM-3157: localise the output
// FIXME: we should move this to multilingual stack some day
require_once 'CRM/Core/I18n.php';
$i18n =& CRM_Core_I18n::singleton();
$translatable = array('preferred_communication_method', 'preferred_mail_format', 'gender', 'state_province', 'country', 'world_region');
foreach ($translatable as $column) {
if (isset($row[$column]) and $row[$column]) {
$row[$column] = $i18n->translate($row[$column]);
}
}
// add component info
$componentDetails[] = $row;
}
require_once 'CRM/Core/Report/Excel.php';
CRM_Core_Report_Excel::writeCSVFile(self::getExportFileName('csv', $exportMode), $headerRows, $componentDetails);
exit;
}
示例7: postProcess
//.........这里部分代码省略.........
if ($primaryDAOId) {
$updateDAO->is_primary = 0;
}
if ($billingDAOId) {
$updateDAO->is_billing = 0;
}
// overwrite - need to delete block from main contact.
if ($deleteBlockId && $operation == 2) {
eval("\$deleteDAO =& new CRM_Core_DAO_{$daoName}();");
$deleteDAO->id = $deleteBlockId;
$deleteDAO->find(true);
// since we overwrite primary block.
if ($primaryDAOId && $primaryDAOId == $deleteDAO->id) {
$updateDAO->is_primary = 1;
}
if ($billingDAOId && $billingDAOId == $deleteDAO->id) {
$updateDAO->is_billing = 1;
}
$deleteDAO->delete();
$deleteDAO->free();
}
$updateDAO->update();
$updateDAO->free();
}
}
}
// FIXME: fix gender, prefix and postfix, so they're edible by createProfileContact()
$names['gender'] = array('newName' => 'gender_id', 'groupName' => 'gender');
$names['individual_prefix'] = array('newName' => 'prefix_id', 'groupName' => 'individual_prefix');
$names['individual_suffix'] = array('newName' => 'suffix_id', 'groupName' => 'individual_suffix');
$names['addressee'] = array('newName' => 'addressee_id', 'groupName' => 'addressee');
$names['email_greeting'] = array('newName' => 'email_greeting_id', 'groupName' => 'email_greeting');
$names['postal_greeting'] = array('newName' => 'postal_greeting_id', 'groupName' => 'postal_greeting');
CRM_Core_OptionGroup::lookupValues($submitted, $names, true);
// FIXME: fix custom fields so they're edible by createProfileContact()
$cgTree =& CRM_Core_BAO_CustomGroup::getTree($this->_contactType, $this, null, -1);
foreach ($cgTree as $key => $group) {
if (!isset($group['fields'])) {
continue;
}
foreach ($group['fields'] as $fid => $field) {
$cFields[$fid]['attributes'] = $field;
}
}
if (!isset($submitted)) {
$submitted = array();
}
foreach ($submitted as $key => $value) {
if (substr($key, 0, 7) == 'custom_') {
$fid = (int) substr($key, 7);
$htmlType = $cFields[$fid]['attributes']['html_type'];
switch ($htmlType) {
case 'File':
$customFiles[] = $fid;
unset($submitted["custom_{$fid}"]);
break;
case 'Select Country':
case 'Select State/Province':
$submitted[$key] = CRM_Core_BAO_CustomField::getDisplayValue($value, $fid, $cFields);
break;
case 'CheckBox':
case 'AdvMulti-Select':
case 'Multi-Select':
case 'Multi-Select Country':
case 'Multi-Select State/Province':
// Merge values from both contacts for multivalue fields, CRM-4385
示例8: getValues
//.........这里部分代码省略.........
$title[] = $g['title'];
if ($g['visibility'] == 'Public Pages') {
$ids[] = $g['group_id'];
}
}
}
$values[$index] = implode(', ', $title);
$params[$index] = implode(',', $ids);
} else {
if ($name == 'tag') {
require_once 'CRM/Core/BAO/EntityTag.php';
$entityTags =& CRM_Core_BAO_EntityTag::getTag($cid);
$allTags =& CRM_Core_PseudoConstant::tag();
$title = array();
foreach ($entityTags as $tagId) {
$title[] = $allTags[$tagId];
}
$values[$index] = implode(', ', $title);
$params[$index] = implode(',', $entityTags);
} else {
if (array_key_exists($name, $studentFields)) {
require_once 'CRM/Core/OptionGroup.php';
$paramsNew = array($name => $details->{$name});
if ($name == 'test_tutoring') {
$names = array($name => array('newName' => $index, 'groupName' => 'test'));
} else {
if (substr($name, 0, 4) == 'cmr_') {
//for readers group
$names = array($name => array('newName' => $index, 'groupName' => substr($name, 0, -3)));
} else {
$names = array($name => array('newName' => $index, 'groupName' => $name));
}
}
CRM_Core_OptionGroup::lookupValues($paramsNew, $names, false);
$values[$index] = $paramsNew[$index];
$params[$index] = $paramsNew[$name];
} else {
$processed = false;
if (CRM_Core_Permission::access('Quest', false)) {
require_once 'CRM/Quest/BAO/Student.php';
$processed = CRM_Quest_BAO_Student::buildStudentForm($this, $field);
}
if (!$processed) {
if (substr($name, 0, 7) === 'do_not_' or substr($name, 0, 3) === 'is_') {
if ($details->{$name}) {
$values[$index] = '[ x ]';
}
} else {
require_once 'CRM/Core/BAO/CustomField.php';
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name)) {
$htmlType = $field['html_type'];
$dataType = $field['data_type'];
if ($htmlType == 'File') {
$fileURL = CRM_Core_BAO_CustomField::getFileURL($cid, $cfID);
$params[$index] = $values[$index] = $fileURL['file_url'];
} else {
$customVal = null;
if (isset($dao) && ($dao->data_type == 'Int' || $dao->data_type == 'Boolean')) {
$customVal = (int) $details->{$name};
} else {
if (isset($dao) && $dao->data_type == 'Float') {
$customVal = (double) $details->{$name};
} else {
if (!CRM_Utils_System::isNull(explode(CRM_Core_DAO::VALUE_SEPARATOR, $details->{$name}))) {
$customVal = $details->{$name};
}
示例9: getValues
//.........这里部分代码省略.........
$title = $ids = array();
foreach ($groups as $g) {
// CRM-8362: User and User Admin visibility groups should be included in display if user has
// VIEW permission on that group
$groupPerm = CRM_Contact_BAO_Group::checkPermission($g['group_id'], $g['title']);
if ($g['visibility'] != 'User and User Admin Only' || CRM_Utils_Array::key(CRM_Core_Permission::VIEW, $groupPerm)) {
$title[] = $g['title'];
if ($g['visibility'] == 'Public Pages') {
$ids[] = $g['group_id'];
}
}
}
$values[$index] = implode(', ', $title);
$params[$index] = implode(',', $ids);
} elseif ($name == 'tag') {
$entityTags = CRM_Core_BAO_EntityTag::getTag($cid);
$allTags = CRM_Core_PseudoConstant::tag();
$title = array();
foreach ($entityTags as $tagId) {
$title[] = $allTags[$tagId];
}
$values[$index] = implode(', ', $title);
$params[$index] = implode(',', $entityTags);
} elseif (array_key_exists($name, $studentFields)) {
$paramsNew = array($name => $details->{$name});
if ($name == 'test_tutoring') {
$names = array($name => array('newName' => $index, 'groupName' => 'test'));
// for readers group
} elseif (substr($name, 0, 4) == 'cmr_') {
$names = array($name => array('newName' => $index, 'groupName' => substr($name, 0, -3)));
} else {
$names = array($name => array('newName' => $index, 'groupName' => $name));
}
CRM_Core_OptionGroup::lookupValues($paramsNew, $names, FALSE);
$values[$index] = $paramsNew[$index];
$params[$index] = $paramsNew[$name];
} elseif ($name == 'activity_status_id') {
$activityStatus = CRM_Core_PseudoConstant::activityStatus();
$values[$index] = $activityStatus[$details->{$name}];
$params[$index] = $details->{$name};
} elseif ($name == 'activity_date_time') {
$values[$index] = CRM_Utils_Date::customFormat($details->{$name});
$params[$index] = $details->{$name};
} elseif ($name == 'contact_sub_type') {
$values[$index] = str_replace(CRM_Core_DAO::VALUE_SEPARATOR, ', ', trim($details->{$name}, CRM_Core_DAO::VALUE_SEPARATOR));
$params[$index] = $details->{$name};
} else {
$processed = FALSE;
if (CRM_Core_Permission::access('Quest', FALSE)) {
$processed = CRM_Quest_BAO_Student::buildStudentForm($this, $field);
}
if (!$processed) {
if (substr($name, 0, 7) === 'do_not_' || substr($name, 0, 3) === 'is_') {
if ($details->{$name}) {
$values[$index] = '[ x ]';
}
} else {
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name)) {
$htmlType = $field['html_type'];
$dataType = $field['data_type'];
// field_type is only set when we are retrieving profile values
// when sending email, we call the same function to get custom field
// values etc, i.e. emulating a profile
$fieldType = CRM_Utils_Array::value('field_type', $field);
if ($htmlType == 'File') {
$entityId = $cid;
示例10: array
//.........这里部分代码省略.........
if ($this->_action == CRM_Core_Action::BASIC) {
$searchType = 'basic';
} elseif ($this->_action == CRM_Core_Action::ADVANCED) {
$searchType = 'advance';
}
require_once 'CRM/Core/OptionGroup.php';
$links =& self::links($searchType, $this->_contextMenu);
//check explicitly added contact to a Smart Group.
$groupID = CRM_Utils_Array::key('1', $this->_formValues['group']);
while ($result->fetch()) {
$row = array();
// the columns we are interested in
foreach ($names as $property) {
if ($property == 'status') {
continue;
}
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($property)) {
$row[$property] = CRM_Core_BAO_CustomField::getDisplayValue($result->{$property}, $cfID, $this->_options, $result->contact_id);
} else {
if ($multipleSelectFields && array_key_exists($property, $multipleSelectFields)) {
//fix to display student checkboxes
$key = $property;
$paramsNew = array($key => $result->{$property});
if ($key == 'test_tutoring') {
$name = array($key => array('newName' => $key, 'groupName' => 'test'));
} else {
if (substr($key, 0, 4) == 'cmr_') {
//for readers group
$name = array($key => array('newName' => $key, 'groupName' => substr($key, 0, -3)));
} else {
$name = array($key => array('newName' => $key, 'groupName' => $key));
}
}
CRM_Core_OptionGroup::lookupValues($paramsNew, $name, false);
$row[$key] = $paramsNew[$key];
} else {
if (isset($tmfFields) && $tmfFields && array_key_exists($property, $tmfFields) || substr($property, 0, 12) == 'participant_') {
if (substr($property, -3) == '_id') {
$key = substr($property, 0, -3);
$paramsNew = array($key => $result->{$property});
$name = array($key => array('newName' => $key, 'groupName' => $key));
CRM_Core_OptionGroup::lookupValues($paramsNew, $name, false);
$row[$key] = $paramsNew[$key];
} else {
$row[$property] = $result->{$property};
}
} else {
if (strpos($property, '-im')) {
$row[$property] = $result->{$property};
if (!empty($result->{$property})) {
$imProviders = CRM_Core_PseudoConstant::IMProvider();
$providerId = $property . "-provider_id";
$providerName = $imProviders[$result->{$providerId}];
$row[$property] = $result->{$property} . " ({$providerName})";
}
} else {
if (in_array($property, array('addressee', 'email_greeting', 'postal_greeting'))) {
$greeting = $property . '_display';
$row[$property] = $result->{$greeting};
} else {
$row[$property] = $result->{$property};
}
}
}
}
}
示例11: exportComponents
//.........这里部分代码省略.........
$row[] = $output;
} else {
$row[] = '';
}
}
}
}
} else {
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($relationkey) && $is_valid) {
$row[] = $custom_data;
} else {
if ($query->_fields[$relationkey]['name'] && $is_valid) {
if ($query->_fields[$relationkey]['name'] == 'gender') {
$getGenders =& CRM_Core_PseudoConstant::gender();
$gender = array_search($data->gender_id, array_flip($getGenders));
$row[] = $gender;
} else {
if ($query->_fields[$relationkey]['name'] == 'greeting_type') {
$getgreeting =& CRM_Core_PseudoConstant::greeting();
$greeting = array_search($data->greeting_type_id, array_flip($getgreeting));
$row[] = $greeting;
} else {
$colValue = $query->_fields[$relationkey]['name'];
$row[] = $data->{$colValue};
}
}
} else {
if ($customData && $is_valid) {
$row[] = $customData;
} else {
$row[] = '';
}
}
}
}
}
} else {
if (isset($fieldValue) && $fieldValue != '') {
//check for custom data
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($field)) {
$row[$field] = CRM_Core_BAO_CustomField::getDisplayValue($fieldValue, $cfID, $query->_options);
} else {
if (array_key_exists($field, $multipleSelectFields)) {
//option group fixes
$paramsNew = array($field => $fieldValue);
if ($field == 'test_tutoring') {
$name = array($field => array('newName' => $field, 'groupName' => 'test'));
} else {
if (substr($field, 0, 4) == 'cmr_') {
//for readers group
$name = array($field => array('newName' => $field, 'groupName' => substr($field, 0, -3)));
} else {
$name = array($field => array('newName' => $field, 'groupName' => $field));
}
}
CRM_Core_OptionGroup::lookupValues($paramsNew, $name, false);
$row[$field] = $paramsNew[$field];
} else {
if (in_array($field, array('email_greeting', 'postal_greeting', 'addressee'))) {
//special case for greeting replacement
$fldValue = "{$field}_display";
$row[$field] = $dao->{$fldValue};
} else {
//normal fields
$row[$field] = $fieldValue;
}
}
}
} else {
// if field is empty or null
$row[$field] = '';
}
}
}
}
}
}
}
//build header only once
$setHeader = false;
// add payment headers if required
if ($addPaymentHeader && $paymentFields) {
$headerRows = array_merge($headerRows, $paymentHeaders);
$addPaymentHeader = false;
}
// add payment related information
if ($paymentFields && isset($paymentDetails[$row[$paymentTableId]])) {
$row = array_merge($row, $paymentDetails[$row[$paymentTableId]]);
}
//remove organization name for individuals if it is set for current employer
if (CRM_Utils_Array::value('contact_type', $row) && $row['contact_type'] == 'Individual') {
$row['organization_name'] = '';
}
// add component info
$componentDetails[] = $row;
}
require_once 'CRM/Core/Report/Excel.php';
CRM_Core_Report_Excel::writeCSVFile(self::getExportFileName('csv', $exportMode), $headerRows, $componentDetails);
exit;
}
示例12: _getValues
/**
* Given the list of params in the params array, fetch the object
* and store the values in the values array
*
* @param array $params input parameters to find object
* @param array $values output values of the object
*
* @return CRM_Contact_BAO_Contact|null the found object or null
* @access public
* @static
*/
private static function _getValues(&$params, &$values)
{
$contact =& new CRM_Contact_BAO_Contact();
$contact->copyValues($params);
if ($contact->find(true)) {
CRM_Core_DAO::storeValues($contact, $values);
$privacy = array();
foreach (self::$_commPrefs as $name) {
if (isset($contact->{$name})) {
$privacy[$name] = $contact->{$name};
}
}
if (!empty($privacy)) {
$values['privacy'] = $privacy;
}
// communication Prefferance
$preffComm = $comm = array();
$comm = explode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, $contact->preferred_communication_method);
foreach ($comm as $value) {
$preffComm[$value] = 1;
}
$temp = array('preferred_communication_method' => $contact->preferred_communication_method);
$names = array('preferred_communication_method' => array('newName' => 'preferred_communication_method_display', 'groupName' => 'preferred_communication_method'));
require_once 'CRM/Core/OptionGroup.php';
CRM_Core_OptionGroup::lookupValues($temp, $names, false);
$values['preferred_communication_method'] = $preffComm;
$values['preferred_communication_method_display'] = CRM_Utils_Array::value('preferred_communication_method_display', $temp);
CRM_Contact_DAO_Contact::addDisplayEnums($values);
// Calculating Year difference
if ($contact->birth_date) {
$birthDate = CRM_Utils_Date::customFormat($contact->birth_date, '%Y%m%d');
if ($birthDate < date('Ymd')) {
$age = CRM_Utils_Date::calculateAge($birthDate);
$values['age']['y'] = CRM_Utils_Array::value('years', $age);
$values['age']['m'] = CRM_Utils_Array::value('months', $age);
}
list($values['birth_date']) = CRM_Utils_Date::setDateDefaults($contact->birth_date, 'birth');
$values['birth_date_display'] = $contact->birth_date;
}
if ($contact->deceased_date) {
list($values['deceased_date']) = CRM_Utils_Date::setDateDefaults($contact->deceased_date, 'birth');
$values['deceased_date_display'] = $contact->deceased_date;
}
$contact->contact_id = $contact->id;
return $contact;
}
return null;
}
示例13: array
//.........这里部分代码省略.........
$names[] = 'contact_id';
} else {
$names[] = $field['name'];
}
}
}
}
require_once "CRM/Core/OptionGroup.php";
$multipleSelectFields = array('preferred_communication_method' => 1);
if (CRM_Core_Permission::access('Quest')) {
require_once 'CRM/Quest/BAO/Student.php';
$multipleSelectFields = CRM_Quest_BAO_Student::$multipleSelectFields;
}
if ($this->_linkToUF) {
require_once 'api/UFGroup.php';
}
require_once 'CRM/Contact/BAO/Contact/Utils.php';
while ($result->fetch()) {
if (isset($result->country)) {
// the query returns the untranslated country name
$i18n =& CRM_Core_I18n::singleton();
$result->country = $i18n->translate($result->country);
}
$row = array();
$empty = true;
$row[] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type);
if ($result->sort_name) {
$row['sort_name'] = $result->sort_name;
$empty = false;
} else {
continue;
}
foreach ($names as $name) {
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name)) {
$row[] = CRM_Core_BAO_CustomField::getDisplayValue($result->{$name}, $cfID, $this->_options, $result->contact_id);
} else {
if ($name == 'home_URL' && !empty($result->{$name})) {
$url = CRM_Utils_System::fixURL($result->{$name});
$row[] = "<a href=\"{$url}\">{$result->{$name}}</a>";
} else {
if ($multipleSelectFields && array_key_exists($name, $multipleSelectFields)) {
//fix to display student checkboxes
$key = $name;
$paramsNew = array($key => $result->{$name});
if ($key == 'test_tutoring') {
$name = array($key => array('newName' => $key, 'groupName' => 'test'));
} else {
if (substr($key, 0, 4) == 'cmr_') {
//for readers group
$name = array($key => array('newName' => $key, 'groupName' => substr($key, 0, -3)));
} else {
$name = array($key => array('newName' => $key, 'groupName' => $key));
}
}
CRM_Core_OptionGroup::lookupValues($paramsNew, $name, false);
$row[] = $paramsNew[$key];
} else {
if (strpos($name, '-im')) {
if (!empty($result->{$name})) {
$imProviders = CRM_Core_PseudoConstant::IMProvider();
$providerId = $name . "-provider_id";
$providerName = $imProviders[$result->{$providerId}];
$row[] = $result->{$name} . " ({$providerName})";
} else {
$row[] = '';
}
} elseif (in_array($name, array('addressee', 'email_greeting', 'postal_greeting'))) {
$dname = $name . '_display';
$row[] = $result->{$dname};
} elseif (in_array($name, array('birth_date', 'deceased_date'))) {
$row[] = CRM_Utils_Date::customFormat($result->{$name});
} elseif (isset($result->{$name})) {
$row[] = $result->{$name};
} else {
$row[] = '';
}
}
}
}
if (!empty($result->{$name})) {
$empty = false;
}
}
$newLinks = $links;
$params = array('id' => $result->contact_id, 'gid' => $this->_gid);
if ($this->_linkToUF) {
$ufID = crm_uf_get_uf_id($result->contact_id);
if (!$ufID) {
unset($newLinks[CRM_Core_Action::PROFILE]);
} else {
$params['ufID'] = $ufID;
}
}
$row[] = CRM_Core_Action::formLink($newLinks, $mask, $params);
if (!$empty) {
$rows[] = $row;
}
}
return $rows;
}
示例14: getSpecialValues
/**
* @param array $contact
* @return array
* $specialValues
*/
public static function getSpecialValues($contact)
{
$preferred_communication_method = CRM_Utils_Array::value('preferred_communication_method', $contact);
$value = empty($preferred_communication_method) ? array() : $preferred_communication_method;
$specialValues = array('preferred_communication_method' => $value, 'communication_style_id' => $value);
if (!empty($contact['preferred_communication_method'])) {
// api 3 returns pref_comm_method as an array, which breaks the lookup; so we reconstruct
$prefCommList = is_array($specialValues['preferred_communication_method']) ? implode(CRM_Core_DAO::VALUE_SEPARATOR, $specialValues['preferred_communication_method']) : $specialValues['preferred_communication_method'];
$specialValues['preferred_communication_method'] = CRM_Core_DAO::VALUE_SEPARATOR . $prefCommList . CRM_Core_DAO::VALUE_SEPARATOR;
}
$names = array('preferred_communication_method' => array('newName' => 'preferred_communication_method_display', 'groupName' => 'preferred_communication_method'));
CRM_Core_OptionGroup::lookupValues($specialValues, $names);
if (!empty($contact['communication_style'])) {
$specialValues['communication_style_id_display'] = $contact['communication_style'];
}
return $specialValues;
}
示例15: exportComponents
//.........这里部分代码省略.........
break;
default:
$row[$field . $relationField] = $fieldValue;
break;
}
}
}
} else {
// if relation field is empty or null
$row[$field . $relationField] = '';
}
}
}
}
} else {
if (isset($fieldValue) && $fieldValue != '') {
//check for custom data
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($field)) {
$row[$field] = CRM_Core_BAO_CustomField::getDisplayValue($fieldValue, $cfID, $query->_options);
} else {
if (array_key_exists($field, $multipleSelectFields)) {
//option group fixes
$paramsNew = array($field => $fieldValue);
if ($field == 'test_tutoring') {
$name = array($field => array('newName' => $field, 'groupName' => 'test'));
} else {
if (substr($field, 0, 4) == 'cmr_') {
//for readers group
$name = array($field => array('newName' => $field, 'groupName' => substr($field, 0, -3)));
} else {
$name = array($field => array('newName' => $field, 'groupName' => $field));
}
}
CRM_Core_OptionGroup::lookupValues($paramsNew, $name, false);
$row[$field] = $paramsNew[$field];
} else {
if (in_array($field, array('email_greeting', 'postal_greeting', 'addressee'))) {
//special case for greeting replacement
$fldValue = "{$field}_display";
$row[$field] = $dao->{$fldValue};
} else {
//normal fields with a touch of CRM-3157
switch ($field) {
case 'country':
case 'world_region':
$row[$field] = $i18n->crm_translate($fieldValue, array('context' => 'country'));
break;
case 'state_province':
$row[$field] = $i18n->crm_translate($fieldValue, array('context' => 'province'));
break;
case 'gender':
case 'preferred_communication_method':
case 'preferred_mail_format':
$row[$field] = $i18n->crm_translate($fieldValue);
break;
default:
$row[$field] = $fieldValue;
break;
}
}
}
}
} else {
// if field is empty or null
$row[$field] = '';
}