3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * Dummy page for details of address.
21 class CRM_Contact_Page_Inline_Address
extends CRM_Core_Page
{
26 * This method is called after the page is created.
28 public function run() {
29 // get the emails for this contact
30 $contactId = CRM_Utils_Request
::retrieve('cid', 'Positive', CRM_Core_DAO
::$_nullObject, TRUE);
31 $locBlockNo = CRM_Utils_Request
::retrieve('locno', 'Positive', CRM_Core_DAO
::$_nullObject, TRUE);
32 $addressId = CRM_Utils_Request
::retrieve('aid', 'Positive');
36 $locationTypes = CRM_Core_PseudoConstant
::get('CRM_Core_DAO_Address', 'location_type_id', ['labelColumn' => 'display_name']);
38 $entityBlock = ['id' => $addressId];
39 $address = CRM_Core_BAO_Address
::getValues($entityBlock, FALSE, 'id');
40 if (!empty($address)) {
41 foreach ($address as $key => & $value) {
42 $value['location_type'] = $locationTypes[$value['location_type_id']];
47 // we just need current address block
48 $currentAddressBlock['address'][$locBlockNo] = array_pop($address);
50 if (!empty($currentAddressBlock['address'][$locBlockNo])) {
51 // get contact name of shared contact names
52 $sharedAddresses = [];
53 $shareAddressContactNames = CRM_Contact_BAO_Contact_Utils
::getAddressShareContactNames($currentAddressBlock['address']);
54 foreach ($currentAddressBlock['address'] as $key => $addressValue) {
55 if (!empty($addressValue['master_id']) &&
56 !$shareAddressContactNames[$addressValue['master_id']]['is_deleted']
58 $sharedAddresses[$key]['shared_address_display'] = [
59 'address' => $addressValue['display'],
60 'name' => $shareAddressContactNames[$addressValue['master_id']]['name'],
64 $idValue = $currentAddressBlock['address'][$locBlockNo]['id'];
65 if (!empty($currentAddressBlock['address'][$locBlockNo]['master_id'])) {
66 $idValue = $currentAddressBlock['address'][$locBlockNo]['master_id'];
69 // add custom data of type address
70 $groupTree = CRM_Core_BAO_CustomGroup
::getTree('Address', NULL, $idValue);
72 // we setting the prefix to dnc_ below so that we don't overwrite smarty's grouptree var.
73 $currentAddressBlock['address'][$locBlockNo]['custom'] = CRM_Core_BAO_CustomGroup
::buildCustomDataView($this, $groupTree, FALSE, NULL, "dnc_");
74 $this->assign("dnc_viewCustomData", NULL);
76 $this->assign('add', $currentAddressBlock['address'][$locBlockNo]);
77 $this->assign('sharedAddresses', $sharedAddresses);
79 $contact = new CRM_Contact_BAO_Contact();
80 $contact->id
= $contactId;
83 foreach (CRM_Contact_BAO_Contact
::$_commPrefs as $name) {
84 if (isset($contact->$name)) {
85 $privacy[$name] = $contact->$name;
89 $this->assign('contactId', $contactId);
90 $this->assign('locationIndex', $locBlockNo);
91 $this->assign('addressId', $addressId);
92 $this->assign('privacy', $privacy);
94 // check logged in user permission
95 CRM_Contact_Page_View
::checkUserPermission($this, $contactId);
97 // finally call parent