本文整理汇总了PHP中CRM_Contact_BAO_Query::getWhereValues方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_Query::getWhereValues方法的具体用法?PHP CRM_Contact_BAO_Query::getWhereValues怎么用?PHP CRM_Contact_BAO_Query::getWhereValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_BAO_Query
的用法示例。
在下文中一共展示了CRM_Contact_BAO_Query::getWhereValues方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
/**
* Process form.
*
* @param CRM_Contact_BAO_Query $query
* @param array $values
*
* @return null
* @throws Exception
*/
public static function process(&$query, &$values)
{
list($name, $op, $distance, $grouping, $wildcard) = $values;
// also get values array for all address related info
$proximityVars = array('street_address' => 1, 'city' => 1, 'postal_code' => 1, 'state_province_id' => 0, 'country_id' => 0, 'state_province' => 0, 'country' => 0, 'distance_unit' => 0);
$proximityAddress = array();
$qill = array();
foreach ($proximityVars as $var => $recordQill) {
$proximityValues = $query->getWhereValues("prox_{$var}", $grouping);
if (!empty($proximityValues) && !empty($proximityValues[2])) {
$proximityAddress[$var] = $proximityValues[2];
if ($recordQill) {
$qill[] = $proximityValues[2];
}
}
}
if (empty($proximityAddress)) {
return NULL;
}
if (isset($proximityAddress['state_province_id'])) {
$proximityAddress['state_province'] = CRM_Core_PseudoConstant::stateProvince($proximityAddress['state_province_id']);
$qill[] = $proximityAddress['state_province'];
}
$config = CRM_Core_Config::singleton();
if (!isset($proximityAddress['country_id'])) {
// get it from state if state is present
if (isset($proximityAddress['state_province_id'])) {
$proximityAddress['country_id'] = CRM_Core_PseudoConstant::countryIDForStateID($proximityAddress['state_province_id']);
} elseif (isset($config->defaultContactCountry)) {
$proximityAddress['country_id'] = $config->defaultContactCountry;
}
}
if (!empty($proximityAddress['country_id'])) {
$proximityAddress['country'] = CRM_Core_PseudoConstant::country($proximityAddress['country_id']);
$qill[] = $proximityAddress['country'];
}
if (isset($proximityAddress['distance_unit']) && $proximityAddress['distance_unit'] == 'miles') {
$qillUnits = " {$distance} " . ts('miles');
$distance = $distance * 1609.344;
} else {
$qillUnits = " {$distance} " . ts('km');
$distance = $distance * 1000.0;
}
$qill = ts('Proximity search to a distance of %1 from %2', array(1 => $qillUnits, 2 => implode(', ', $qill)));
$fnName = isset($config->geocodeMethod) ? $config->geocodeMethod : NULL;
if (empty($fnName)) {
CRM_Core_Error::fatal(ts('Proximity searching requires you to set a valid geocoding provider'));
}
$query->_tables['civicrm_address'] = $query->_whereTables['civicrm_address'] = 1;
require_once str_replace('_', DIRECTORY_SEPARATOR, $fnName) . '.php';
$fnName::format($proximityAddress);
if (!is_numeric(CRM_Utils_Array::value('geo_code_1', $proximityAddress)) || !is_numeric(CRM_Utils_Array::value('geo_code_2', $proximityAddress))) {
// we are setting the where clause to 0 here, so we wont return anything
$qill .= ': ' . ts('We could not geocode the destination address.');
$query->_qill[$grouping][] = $qill;
$query->_where[$grouping][] = ' (0) ';
return NULL;
}
$query->_qill[$grouping][] = $qill;
$query->_where[$grouping][] = self::where($proximityAddress['geo_code_1'], $proximityAddress['geo_code_2'], $distance);
return NULL;
}