本文整理汇总了PHP中CRM_Contact_BAO_Query::getCustomFieldName方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_Query::getCustomFieldName方法的具体用法?PHP CRM_Contact_BAO_Query::getCustomFieldName怎么用?PHP CRM_Contact_BAO_Query::getCustomFieldName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_BAO_Query
的用法示例。
在下文中一共展示了CRM_Contact_BAO_Query::getCustomFieldName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: normalizeDefaultValues
/**
* Normalize default values for multiselect plugins.
*
* @param array $defaults
*
* @return array
*/
public function normalizeDefaultValues(&$defaults)
{
if (!is_array($defaults)) {
$defaults = array();
}
if ($this->_ssID && empty($_POST)) {
$specialFields = array('contact_type', 'group', 'contact_tags', 'member_membership_type_id', 'member_status_id');
foreach ($defaults as $element => $value) {
if (!empty($value) && is_array($value)) {
if (in_array($element, $specialFields)) {
$element = str_replace('member_membership_type_id', 'membership_type_id', $element);
$element = str_replace('member_status_id', 'membership_status_id', $element);
$defaults[$element] = array_keys($value);
} elseif (in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
$defaults[$element] = CRM_Utils_Array::value(key($value), $value);
if (is_string($defaults[$element])) {
$defaults[$element] = str_replace("%", '', $defaults[$element]);
}
}
}
if (substr($element, 0, 7) == 'custom_' && (substr($element, -5, 5) == '_from' || substr($element, -3, 3) == '_to')) {
// Ensure the _relative field is set if from or to are set to ensure custom date
// fields with 'from' or 'to' values are displayed when the are set in the smart group
// being loaded. (CRM-17116)
if (!isset($defaults[CRM_Contact_BAO_Query::getCustomFieldName($element) . '_relative'])) {
$defaults[CRM_Contact_BAO_Query::getCustomFieldName($element) . '_relative'] = 0;
}
}
}
}
return $defaults;
}
示例2: unserialize
/**
* Given an id, extract the formValues of the saved search.
*
* @param int $id
* The id of the saved search.
*
* @return array
* the values of the posted saved search used as default values in various Search Form
*/
public static function &getFormValues($id)
{
$fv = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $id, 'form_values');
$result = NULL;
if ($fv) {
// make sure u unserialize - since it's stored in serialized form
$result = unserialize($fv);
}
$specialFields = array('contact_type', 'group', 'contact_tags', 'member_membership_type_id', 'member_status_id');
foreach ($result as $element => $value) {
if (CRM_Contact_BAO_Query::isAlreadyProcessedForQueryFormat($value)) {
$id = CRM_Utils_Array::value(0, $value);
$value = CRM_Utils_Array::value(2, $value);
if (is_array($value) && in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
$value = CRM_Utils_Array::value(key($value), $value);
}
$result[$id] = $value;
unset($result[$element]);
continue;
}
if (!empty($value) && is_array($value)) {
if (in_array($element, $specialFields)) {
$element = str_replace('member_membership_type_id', 'membership_type_id', $element);
$element = str_replace('member_status_id', 'membership_status_id', $element);
CRM_Contact_BAO_Query::legacyConvertFormValues($element, $value);
$result[$element] = $value;
} elseif (in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
$result[$element] = CRM_Utils_Array::value(key($value), $value);
if (is_string($result[$element])) {
$result[$element] = str_replace("%", '', $result[$element]);
}
}
}
if (substr($element, 0, 7) == 'custom_' && (substr($element, -5, 5) == '_from' || substr($element, -3, 3) == '_to')) {
// Ensure the _relative field is set if from or to are set to ensure custom date
// fields with 'from' or 'to' values are displayed when the are set in the smart group
// being loaded. (CRM-17116)
if (!isset($result[CRM_Contact_BAO_Query::getCustomFieldName($element) . '_relative'])) {
$result[CRM_Contact_BAO_Query::getCustomFieldName($element) . '_relative'] = 0;
}
}
// check to see if we need to convert the old privacy array
// CRM-9180
if (!empty($result['privacy'])) {
if (is_array($result['privacy'])) {
$result['privacy_operator'] = 'AND';
$result['privacy_toggle'] = 1;
if (isset($result['privacy']['do_not_toggle'])) {
if ($result['privacy']['do_not_toggle']) {
$result['privacy_toggle'] = 2;
}
unset($result['privacy']['do_not_toggle']);
}
$result['privacy_options'] = array();
foreach ($result['privacy'] as $name => $val) {
if ($val) {
$result['privacy_options'][] = $name;
}
}
}
unset($result['privacy']);
}
}
return $result;
}
示例3: getFormValues
/**
* Given an id, extract the formValues of the saved search.
*
* @param int $id
* The id of the saved search.
*
* @return array
* the values of the posted saved search used as default values in various Search Form
*/
public static function getFormValues($id)
{
$fv = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $id, 'form_values');
$result = NULL;
if ($fv) {
// make sure u unserialize - since it's stored in serialized form
$result = unserialize($fv);
}
//CRM-19250: fetch the default date format to format mysql value as per CRM_Core_Error::addDate()
$dateFormat = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_PreferencesDate', 'searchDate', 'date_format', 'name');
$dateFormat = empty($dateFormat) ? CRM_Core_Config::singleton()->dateInputFormat : $dateFormat;
$dateFormat = CRM_Utils_Array::value($dateFormat, CRM_Core_SelectValues::datePluginToPHPFormats());
$specialFields = array('contact_type', 'group', 'contact_tags', 'member_membership_type_id', 'member_status_id');
foreach ($result as $element => $value) {
if (CRM_Contact_BAO_Query::isAlreadyProcessedForQueryFormat($value)) {
$id = CRM_Utils_Array::value(0, $value);
$value = CRM_Utils_Array::value(2, $value);
if (is_array($value) && in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
$value = CRM_Utils_Array::value(key($value), $value);
}
if (strpos($id, '_date_low') !== FALSE || strpos($id, '_date_high') !== FALSE) {
$result[$id] = date($dateFormat, strtotime($value));
$entityName = strstr($id, '_date', TRUE);
$result["{$entityName}_date_relative"] = 0;
} else {
$result[$id] = $value;
}
unset($result[$element]);
continue;
}
if (!empty($value) && is_array($value)) {
if (in_array($element, $specialFields)) {
// Remove the element to minimise support for legacy formats. It is stored in $value
// so will be re-set with the right name.
unset($result[$element]);
$element = str_replace('member_membership_type_id', 'membership_type_id', $element);
$element = str_replace('member_status_id', 'membership_status_id', $element);
CRM_Contact_BAO_Query::legacyConvertFormValues($element, $value);
$result[$element] = $value;
} elseif (in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
$result[$element] = CRM_Utils_Array::value(key($value), $value);
if (is_string($result[$element])) {
$result[$element] = str_replace("%", '', $result[$element]);
}
}
}
if (substr($element, 0, 7) == 'custom_' && (substr($element, -5, 5) == '_from' || substr($element, -3, 3) == '_to')) {
// Ensure the _relative field is set if from or to are set to ensure custom date
// fields with 'from' or 'to' values are displayed when the are set in the smart group
// being loaded. (CRM-17116)
if (!isset($result[CRM_Contact_BAO_Query::getCustomFieldName($element) . '_relative'])) {
$result[CRM_Contact_BAO_Query::getCustomFieldName($element) . '_relative'] = 0;
}
}
// check to see if we need to convert the old privacy array
// CRM-9180
if (!empty($result['privacy'])) {
if (is_array($result['privacy'])) {
$result['privacy_operator'] = 'AND';
$result['privacy_toggle'] = 1;
if (isset($result['privacy']['do_not_toggle'])) {
if ($result['privacy']['do_not_toggle']) {
$result['privacy_toggle'] = 2;
}
unset($result['privacy']['do_not_toggle']);
}
$result['privacy_options'] = array();
foreach ($result['privacy'] as $name => $val) {
if ($val) {
$result['privacy_options'][] = $name;
}
}
}
unset($result['privacy']);
}
}
return $result;
}