<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.4 |
+ | CiviCRM version 4.5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
* $Id$
*
*/
/**
* takes an associative array and creates a address
*
- * @param array $params (reference ) an assoc array of name/value pairs
- * @param boolean $fixAddress true if you need to fix (format) address values
+ * @param array $params (reference ) an assoc array of name/value pairs
+ * @param boolean $fixAddress true if you need to fix (format) address values
* before inserting in db
*
+ * @param null $entity
+ *
* @return array $blocks array of created address
* @access public
* @static
*/
- static function create(&$params, $fixAddress, $entity = NULL) {
+ static function create(&$params, $fixAddress = TRUE, $entity = NULL) {
if (!isset($params['address']) || !is_array($params['address'])) {
return;
}
}
$addressExists = self::dataExists($value);
- if ( !CRM_Utils_Array::value('id', $value) ) {
+ if (empty($value['id'])) {
if ($updateBlankLocInfo) {
if ((!empty($addresses) || !$addressExists) && array_key_exists($key, $addresses)) {
$value['id'] = $addresses[$key];
continue;
}
- if ($isPrimary && CRM_Utils_Array::value('is_primary', $value)) {
+ if ($isPrimary && !empty($value['is_primary'])) {
$isPrimary = FALSE;
}
else {
$value['is_primary'] = 0;
}
- if ($isBilling && CRM_Utils_Array::value('is_billing', $value)) {
+ if ($isBilling && !empty($value['is_billing'])) {
$isBilling = FALSE;
}
else {
$value['is_billing'] = 0;
}
- if (!CRM_Utils_Array::value('manual_geo_code', $value)) {
+ if (empty($value['manual_geo_code'])) {
$value['manual_geo_code'] = 0;
}
$value['contact_id'] = $contactId;
* @static
*/
static function fixAddress(&$params) {
- if (CRM_Utils_Array::value('billing_street_address', $params)) {
+ if (!empty($params['billing_street_address'])) {
//Check address is comming from online contribution / registration page
//Fixed :CRM-5076
$billing = array(
foreach ($billing as $key => $val) {
if ($value = CRM_Utils_Array::value($val, $params)) {
- if (CRM_Utils_Array::value($key, $params)) {
+ if (!empty($params[$key])) {
unset($params[$val]);
}
else {
}
/* Split the zip and +4, if it's in US format */
- if (CRM_Utils_Array::value('postal_code', $params) &&
+ if (!empty($params['postal_code']) &&
preg_match('/^(\d{4,5})[+-](\d{4})$/',
$params['postal_code'],
$match
* Given the list of params in the params array, fetch the object
* and store the values in the values array
*
- * @param array $entityBlock associated array of fields
- * @param boolean $microformat if microformat output is required
- * @param int $fieldName conditional field name
+ * @param array $entityBlock associated array of fields
+ * @param boolean $microformat if microformat output is required
+ * @param int|string $fieldName conditional field name
*
* @return array $addresses array with address fields
* @access public
$addresses = array();
$address = new CRM_Core_BAO_Address();
- if (!CRM_Utils_Array::value('entity_table', $entityBlock)) {
+ if (empty($entityBlock['entity_table'])) {
$address->$fieldName = CRM_Utils_Array::value($fieldName, $entityBlock);
}
else {
$nameVal = explode('-', $values['name']);
$fldName = CRM_Utils_Array::value(0, $nameVal);
$locType = CRM_Utils_Array::value(1, $nameVal);
- if (CRM_Utils_Array::value('location_type_id', $values)) {
+ if (!empty($values['location_type_id'])) {
$locType = $values['location_type_id'];
}
$params['condition'] = 'state_province_id IN (' . implode(',', (array) $props['state_province_id']) . ')';
}
break;
+ // Not a real field in this entity
+ case 'world_region':
+ return CRM_Core_PseudoConstant::worldRegion();
+ break;
}
return CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context);
}
-}
\ No newline at end of file
+}