本文整理汇总了PHP中CRM_Core_BAO_Address::create方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_Address::create方法的具体用法?PHP CRM_Core_BAO_Address::create怎么用?PHP CRM_Core_BAO_Address::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_Address
的用法示例。
在下文中一共展示了CRM_Core_BAO_Address::create方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Function to create various elements of location block
*
* @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 $location
* @access public
* @static
*/
static function create(&$params, $fixAddress = TRUE, $entity = NULL)
{
$location = array();
if (!self::dataExists($params)) {
return $location;
}
// create location blocks.
foreach (self::$blocks as $block) {
if ($block != 'address') {
$location[$block] = CRM_Core_BAO_Block::create($block, $params, $entity);
} else {
$location[$block] = CRM_Core_BAO_Address::create($params, $fixAddress, $entity);
}
}
if ($entity) {
// this is a special case for adding values in location block table
$entityElements = array('entity_table' => $params['entity_table'], 'entity_id' => $params['entity_id']);
$location['id'] = self::createLocBlock($location, $entityElements);
} else {
// when we come from a form which displays all the location elements (like the edit form or the inline block
// elements, we can skip the below check. The below check adds quite a feq queries to an already overloaded
// form
if (!CRM_Utils_Array::value('updateBlankLocInfo', $params, FALSE)) {
// make sure contact should have only one primary block, CRM-5051
self::checkPrimaryBlocks(CRM_Utils_Array::value('contact_id', $params));
}
}
return $location;
}
示例2: create
/**
* Function to create various elements of location block
*
* @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 array $location
* @access public
* @static
*/
static function create(&$params, $fixAddress = true, $entity = null)
{
$location = array();
if (!self::dataExists($params)) {
return $location;
}
// create location blocks.
foreach (self::$blocks as $block) {
if ($block != 'address') {
eval('$location[$block] = CRM_Core_BAO_Block::create( $block, $params, $entity );');
} else {
$location[$block] = CRM_Core_BAO_Address::create($params, $fixAddress, $entity);
}
}
if ($entity) {
// this is a special case for adding values in location block table
$entityElements = array('entity_table' => $params['entity_table'], 'entity_id' => $params['entity_id']);
$location['id'] = self::createLocBlock($location, $entityElements);
} else {
// make sure contact should have only one primary block, CRM-5051
self::checkPrimaryBlocks(CRM_Utils_Array::value('contact_id', $params));
}
return $location;
}
示例3: postProcess
/**
* Process the form.
*
* @return void
*/
public function postProcess()
{
$params = $this->exportValues();
// Process / save address
$params['contact_id'] = $this->_contactId;
$params['updateBlankLocInfo'] = TRUE;
// process shared contact address.
CRM_Contact_BAO_Contact_Utils::processSharedAddress($params['address']);
if ($this->_parseStreetAddress) {
CRM_Contact_Form_Contact::parseAddress($params);
}
if ($this->_addressId > 0) {
$params['address'][$this->_locBlockNo]['id'] = $this->_addressId;
}
// save address changes
$address = CRM_Core_BAO_Address::create($params, TRUE);
$this->log();
$this->ajaxResponse['addressId'] = $address[0]->id;
$this->response();
}
示例4: postProcess
/**
* process the form
*
* @return void
* @access public
*/
public function postProcess()
{
$params = $this->exportValues();
// need to process / save address
$params['contact_id'] = $this->_contactId;
$params['updateBlankLocInfo'] = TRUE;
// process shared contact address.
CRM_Contact_BAO_Contact_Utils::processSharedAddress($params['address']);
if ($this->_parseStreetAddress) {
CRM_Contact_Form_Contact::parseAddress($params);
}
if ($this->_addressId > 0) {
$params['address'][$this->_locBlockNo]['id'] = $this->_addressId;
}
// save address changes
$address = CRM_Core_BAO_Address::create($params, TRUE);
// make entry in log table
CRM_Core_BAO_Log::register($this->_contactId, 'civicrm_contact', $this->_contactId);
$response = array('status' => 'save', 'addressId' => $address[0]->id);
$this->postProcessHook();
echo json_encode($response);
CRM_Utils_System::civiExit();
}
示例5: testGetValues
/**
* GetValues() method (get Address fields)
*/
public function testGetValues()
{
$contactId = Contact::createIndividual();
$params = array();
$params['address']['1'] = array('street_address' => 'Oberoi Garden', 'supplemental_address_1' => 'Attn: Accounting', 'supplemental_address_2' => 'Powai', 'city' => 'Athens', 'postal_code' => '01903', 'state_province_id' => '1000', 'country_id' => '1228', 'geo_code_1' => '18.219023', 'geo_code_2' => '-105.00973', 'location_type_id' => '1', 'is_primary' => '1', 'is_billing' => '0');
$params['contact_id'] = $contactId;
$fixAddress = TRUE;
CRM_Core_BAO_Address::create($params, $fixAddress, $entity = NULL);
$addressId = $this->assertDBNotNull('CRM_Core_DAO_Address', $contactId, 'id', 'contact_id', 'Database check for created address.');
$entityBlock = array('contact_id' => $contactId);
$address = CRM_Core_BAO_Address::getValues($entityBlock);
$this->assertEquals($address[1]['id'], $addressId);
$this->assertEquals($address[1]['contact_id'], $contactId);
$this->assertEquals($address[1]['street_address'], 'Oberoi Garden');
Contact::delete($contactId);
}