本文整理汇总了PHP中CRM_Core_BAO_Address::fixAddress方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_Address::fixAddress方法的具体用法?PHP CRM_Core_BAO_Address::fixAddress怎么用?PHP CRM_Core_BAO_Address::fixAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_Address
的用法示例。
在下文中一共展示了CRM_Core_BAO_Address::fixAddress方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
/**
* takes an associative array and creates a contact object
*
* the function extract all the params it needs to initialize the create a
* contact object. the params array could contain additional unused name/value
* pairs
*
* @param array $params (reference ) an assoc array of name/value pairs
* @param array $ids the array that holds all the db ids
* @param array $locationId
*
* @return object CRM_Core_BAO_Address object
* @access public
* @static
*/
function add(&$params, &$ids, $locationId)
{
if (!CRM_Core_BAO_Address::dataExists($params, $locationId, $ids)) {
return null;
}
$address =& new CRM_Core_BAO_Address();
$address->location_id = $params['location'][$locationId]['id'];
$address->id = CRM_Utils_Array::value('address', $ids['location'][$locationId]);
CRM_Core_BAO_Address::fixAddress($params['location'][$locationId]['address']);
if ($address->copyValues($params['location'][$locationId]['address'])) {
// we copied only null stuff, so we delete the object
$address->delete();
return null;
}
return $address->save();
}
示例2: add
/**
* Takes an associative array and adds address.
*
* @param array $params
* (reference ) an assoc array of name/value pairs.
* @param bool $fixAddress
* True if you need to fix (format) address values.
* before inserting in db
*
* @return CRM_Core_BAO_Address|null
*/
public static function add(&$params, $fixAddress)
{
static $customFields = NULL;
$address = new CRM_Core_DAO_Address();
// fixAddress mode to be done
if ($fixAddress) {
CRM_Core_BAO_Address::fixAddress($params);
}
$hook = empty($params['id']) ? 'create' : 'edit';
CRM_Utils_Hook::pre($hook, 'Address', CRM_Utils_Array::value('id', $params), $params);
// if id is set & is_primary isn't we can assume no change
if (is_numeric(CRM_Utils_Array::value('is_primary', $params)) || empty($params['id'])) {
CRM_Core_BAO_Block::handlePrimary($params, get_class());
}
$config = CRM_Core_Config::singleton();
$address->copyValues($params);
$address->save();
if ($address->id) {
if (!$customFields) {
$customFields = CRM_Core_BAO_CustomField::getFields('Address', FALSE, TRUE);
}
if (!empty($customFields)) {
$addressCustom = CRM_Core_BAO_CustomField::postProcess($params, $address->id, 'Address', TRUE);
}
if (!empty($addressCustom)) {
CRM_Core_BAO_CustomValueTable::store($addressCustom, 'civicrm_address', $address->id);
}
//call the function to sync shared address
self::processSharedAddress($address->id, $params);
// call the function to create shared relationships
// we only create create relationship if address is shared by Individual
if (!CRM_Utils_System::isNull($address->master_id)) {
self::processSharedAddressRelationship($address->master_id, $params);
}
// lets call the post hook only after we've done all the follow on processing
CRM_Utils_Hook::post($hook, 'Address', $address->id, $address);
}
return $address;
}
示例3: getRowsElementsAndInfo
//.........这里部分代码省略.........
} elseif ($field == 'current_employer_id' && !empty($value)) {
$label = "{$value} (" . CRM_Contact_BAO_Contact::displayName($value) . ")";
}
$rows["move_{$field}"][$moniker] = $label;
if ($moniker == 'other') {
//CRM-14334
if ($value === NULL || $value == '') {
$value = 'null';
}
if ($value === 0 or $value === '0') {
$value = $qfZeroBug;
}
if (is_array($value) && empty($value[1])) {
$value[1] = NULL;
}
$elements[] = array('advcheckbox', "move_{$field}", NULL, NULL, NULL, $value);
$migrationInfo["move_{$field}"] = $value;
}
}
$rows["move_{$field}"]['title'] = $fields[$field]['title'];
}
// handle location blocks.
$locationBlocks = array('email', 'phone', 'address');
$locations = array();
foreach ($locationBlocks as $block) {
foreach (array('main' => $mainId, 'other' => $otherId) as $moniker => $cid) {
$cnt = 1;
$values = civicrm_api($block, 'get', array('contact_id' => $cid, 'version' => 3));
$count = $values['count'];
if ($count) {
if ($count > $cnt) {
foreach ($values['values'] as $value) {
if ($block == 'address') {
CRM_Core_BAO_Address::fixAddress($value);
$display = CRM_Utils_Address::format($value);
$locations[$moniker][$block][$cnt] = $value;
$locations[$moniker][$block][$cnt]['display'] = $display;
} else {
$locations[$moniker][$block][$cnt] = $value;
}
$cnt++;
}
} else {
$id = $values['id'];
if ($block == 'address') {
CRM_Core_BAO_Address::fixAddress($values['values'][$id]);
$display = CRM_Utils_Address::format($values['values'][$id]);
$locations[$moniker][$block][$cnt] = $values['values'][$id];
$locations[$moniker][$block][$cnt]['display'] = $display;
} else {
$locations[$moniker][$block][$cnt] = $values['values'][$id];
}
}
}
}
}
$allLocationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
$mainLocBlock = $locBlockIds = array();
$locBlockIds['main'] = $locBlockIds['other'] = array();
foreach (array('Email', 'Phone', 'IM', 'OpenID', 'Address') as $block) {
$name = strtolower($block);
foreach (array('main', 'other') as $moniker) {
$locIndex = CRM_Utils_Array::value($moniker, $locations);
$blockValue = CRM_Utils_Array::value($name, $locIndex, array());
if (empty($blockValue)) {
$locValue[$moniker][$name] = 0;
示例4: getRowsElementsAndInfo
//.........这里部分代码省略.........
$value[1] = NULL;
}
// Display a checkbox to migrate, only if the values are different
if ($value != $main[$field]) {
$elements[] = array('advcheckbox', "move_{$field}", NULL, NULL, NULL, $value);
}
$migrationInfo["move_{$field}"] = $value;
}
}
$rows["move_{$field}"]['title'] = $fields[$field]['title'];
}
// Handle location blocks.
// @todo OpenID not in API yet, so is not supported here.
// Set up useful information about the location blocks
$locationBlocks = self::getLocationBlockInfo();
$locations = array('main' => array(), 'other' => array());
$mainLocBlock = array();
// @todo This could probably be defined and used earlier
$mergeTargets = array('main' => $mainId, 'other' => $otherId);
foreach ($locationBlocks as $blockName => $blockInfo) {
// Collect existing fields from both 'main' and 'other' contacts first
// This allows us to match up location/types when building the table rows
foreach ($mergeTargets as $moniker => $cid) {
$cnt = 1;
$searchParams = array('version' => 3, 'contact_id' => $cid, 'options' => array('sort' => $blockInfo['sortString']));
$values = civicrm_api($blockName, 'get', $searchParams);
if ($values['count']) {
$cnt = 0;
foreach ($values['values'] as $index => $value) {
$locations[$moniker][$blockName][$cnt] = $value;
// Fix address display
$display = '';
if ($blockName == 'address') {
CRM_Core_BAO_Address::fixAddress($value);
$display = CRM_Utils_Address::format($value);
$locations[$moniker][$blockName][$cnt]['display'] = $display;
}
// Add any 'main' contact block values to an array for the JS
// @todo The JS should just access the main_details to find this info?
if ($moniker == 'main') {
if ($blockInfo['hasType']) {
// Handle websites, no location type ID
// @todo Remove the need for this specific 'if'
if ($blockName == 'website') {
$value['location_type_id'] = 0;
}
$mainLocBlock["main_" . $blockName . "_" . $value['location_type_id'] . "_" . $value[$blockInfo['hasType']]]['display'] = $value[$blockInfo['displayField']];
$mainLocBlock["main_" . $blockName . "_" . $value['location_type_id'] . "_" . $value[$blockInfo['hasType']]]['id'] = $value['id'];
} else {
// Get the correct display value for addresses
// @todo Remove the need for this if...
if ($blockName == 'address') {
$mainLocBlock["main_" . $blockName . "_" . $value['location_type_id']]['display'] = $display;
$mainLocBlock["main_" . $blockName . "_" . $value['location_type_id']]['id'] = $value['id'];
} else {
$mainLocBlock["main_" . $blockName . "_" . $value['location_type_id']]['display'] = $value[$blockInfo['displayField']];
$mainLocBlock["main_" . $blockName . "_" . $value['location_type_id']]['id'] = $value['id'];
}
}
}
$cnt++;
}
}
}
// Now, build the table rows appropriately, based off the information on
// the 'other' contact
示例5: emailReceipt
/**
* @param $events_in_cart
* @param array $params
*/
public function emailReceipt($events_in_cart, $params)
{
$contact_details = CRM_Contact_BAO_Contact::getContactDetails($this->payer_contact_id);
$state_province = new CRM_Core_DAO_StateProvince();
$state_province->id = $params["billing_state_province_id-{$this->_bltID}"];
$state_province->find();
$state_province->fetch();
$country = new CRM_Core_DAO_Country();
$country->id = $params["billing_country_id-{$this->_bltID}"];
$country->find();
$country->fetch();
foreach ($this->line_items as &$line_item) {
$location_params = array('entity_id' => $line_item['event']->id, 'entity_table' => 'civicrm_event');
$line_item['location'] = CRM_Core_BAO_Location::getValues($location_params, TRUE);
CRM_Core_BAO_Address::fixAddress($line_item['location']['address'][1]);
}
$send_template_params = array('table' => 'civicrm_msg_template', 'contactId' => $this->payer_contact_id, 'from' => $this->getDefaultFrom(), 'groupName' => 'msg_tpl_workflow_event', 'isTest' => FALSE, 'toEmail' => $contact_details[1], 'toName' => $contact_details[0], 'tplParams' => array('billing_name' => "{$params['billing_first_name']} {$params['billing_last_name']}", 'billing_city' => $params["billing_city-{$this->_bltID}"], 'billing_country' => $country->name, 'billing_postal_code' => $params["billing_postal_code-{$this->_bltID}"], 'billing_state' => $state_province->abbreviation, 'billing_street_address' => $params["billing_street_address-{$this->_bltID}"], 'credit_card_exp_date' => $params['credit_card_exp_date'], 'credit_card_type' => $params['credit_card_type'], 'credit_card_number' => "************" . substr($params['credit_card_number'], -4, 4), 'discounts' => $this->discounts, 'email' => $contact_details[1], 'events_in_cart' => $events_in_cart, 'line_items' => $this->line_items, 'name' => $contact_details[0], 'transaction_id' => $params['trxn_id'], 'transaction_date' => $params['trxn_date'], 'is_pay_later' => $this->is_pay_later, 'pay_later_receipt' => $this->pay_later_receipt), 'valueName' => 'event_registration_receipt', 'PDFFilename' => ts('confirmation') . '.pdf');
$template_params_to_copy = array('billing_name', 'billing_city', 'billing_country', 'billing_postal_code', 'billing_state', 'billing_street_address', 'credit_card_exp_date', 'credit_card_type', 'credit_card_number');
foreach ($template_params_to_copy as $template_param_to_copy) {
$this->set($template_param_to_copy, $send_template_params['tplParams'][$template_param_to_copy]);
}
CRM_Core_BAO_MessageTemplate::sendTemplate($send_template_params);
}
示例6: add
/**
* takes an associative array and adds phone
*
* @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
*
* @return object CRM_Core_BAO_Address object on success, null otherwise
* @access public
* @static
*/
static function add(&$params, $fixAddress)
{
$address =& new CRM_Core_DAO_Address();
// fixAddress mode to be done
if ($fixAddress) {
CRM_Core_BAO_Address::fixAddress($params);
}
$address->copyValues($params);
return $address->save();
}
示例7: add
/**
* takes an associative array and adds phone
*
* @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
*
* @return object CRM_Core_BAO_Address object on success, null otherwise
* @access public
* @static
*/
static function add(&$params, $fixAddress)
{
static $customFields = null;
$address = new CRM_Core_DAO_Address();
// fixAddress mode to be done
if ($fixAddress) {
CRM_Core_BAO_Address::fixAddress($params);
}
$address->copyValues($params);
$address->save();
if ($address->id) {
if (!$customFields) {
require_once 'CRM/Core/BAO/CustomField.php';
require_once 'CRM/Core/BAO/CustomValueTable.php';
$customFields = CRM_Core_BAO_CustomField::getFields('Address', false, true);
}
if (!empty($customFields)) {
$addressCustom = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $address->id, 'Address', true);
}
if (!empty($addressCustom)) {
CRM_Core_BAO_CustomValueTable::store($addressCustom, 'civicrm_address', $address->id);
}
//call the function to sync shared address
self::processSharedAddress($address->id, $params);
// call the function to create shared relationships
// we only create create relationship if address is shared by Individual
if ($address->master_id != 'null') {
self::processSharedAddressRelationship($address->master_id, $params);
}
}
return $address;
}
示例8: foreach
/**
* takes an associative array and creates a contact object and all the associated
* derived objects (i.e. individual, location, email, phone etc)
*
* This function is invoked from within the web form layer and also from the api layer
* primarily from the profile / contribute forms where we dont have a nice hierarchy
* and are too lazy to create one. This function should be obsoleted at some time
*
* @param array $params (reference ) an assoc array of name/value pairs
* @param array $ids the array that holds all the db ids
*
* @return object CRM_Contact_BAO_Contact object
* @access public
* @static
*/
function &createFlat(&$params, &$ids)
{
require_once 'CRM/Utils/Hook.php';
if (CRM_Utils_Array::value('contact', $ids)) {
CRM_Utils_Hook::pre('edit', 'Individual', $ids['contact'], $params);
} else {
CRM_Utils_Hook::pre('create', 'Individual', null, $params);
}
CRM_Core_DAO::transaction('BEGIN');
$params['contact_type'] = 'Individual';
$contact = CRM_Contact_BAO_Contact::add($params, $ids);
$params['contact_id'] = $contact->id;
require_once 'CRM/Contact/BAO/Individual.php';
CRM_Contact_BAO_Individual::add($params, $ids);
require_once 'CRM/Core/BAO/LocationType.php';
$locationType =& CRM_Core_BAO_LocationType::getDefault();
$locationTypeId = $locationType->id;
$locationIds = CRM_Utils_Array::value('location', $ids);
// extract the first location id
if ($locationIds) {
foreach ($locationIds as $dontCare => $locationId) {
$locationIds = $locationId;
break;
}
}
$location =& new CRM_Core_DAO_Location();
$location->location_type_id = $locationTypeId;
$location->entity_table = 'civicrm_contact';
$location->entity_id = $contact->id;
$location->id = CRM_Utils_Array::value('id', $locationIds);
if ($location->find(true)) {
if (!$location->is_primary) {
$location->is_primary = true;
}
} else {
$location->is_primary = true;
}
$location->save();
$address =& new CRM_Core_BAO_Address();
CRM_Core_BAO_Address::fixAddress($params);
if (!$address->copyValues($params)) {
$address->id = CRM_Utils_Array::value('address', $locationIds);
$address->location_id = $location->id;
$address->save();
}
$phone =& new CRM_Core_BAO_Phone();
if (!$phone->copyValues($params)) {
$blockIds = CRM_Utils_Array::value('phone', $locationIds);
$phone->id = CRM_Utils_Array::value(1, $blockIds);
$phone->location_id = $location->id;
$phone->is_primary = true;
$phone->save();
}
$email =& new CRM_Core_BAO_Email();
if (!$email->copyValues($params)) {
$blockIds = CRM_Utils_Array::value('email', $locationIds);
$email->id = CRM_Utils_Array::value(1, $blockIds);
$email->location_id = $location->id;
$email->is_primary = true;
$email->save();
}
/* Process custom field values and other values */
foreach ($params as $key => $value) {
if ($key == 'group') {
CRM_Contact_BAO_GroupContact::create($params['group'], $contact->id);
} else {
if ($key == 'tag') {
require_once 'CRM/Core/BAO/EntityTag.php';
CRM_Core_BAO_EntityTag::create($params['tag'], $contact->id);
} else {
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($key)) {
$custom_field_id = $cfID;
$cf =& new CRM_Core_BAO_CustomField();
$cf->id = $custom_field_id;
if ($cf->find(true)) {
switch ($cf->html_type) {
case 'Select Date':
$date = CRM_Utils_Date::format($value);
if (!$date) {
$date = '';
}
$customValue = $date;
break;
case 'CheckBox':
$customValue = implode(CRM_CORE_BAO_CUSTOMOPTION_VALUE_SEPERATOR, array_keys($value));
//.........这里部分代码省略.........