3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2019
35 * Dummy page for details of address.
37 class CRM_Contact_Page_Inline_Address
extends CRM_Core_Page
{
42 * This method is called after the page is created.
44 public function run() {
45 // get the emails for this contact
46 $contactId = CRM_Utils_Request
::retrieve('cid', 'Positive', CRM_Core_DAO
::$_nullObject, TRUE, NULL, $_REQUEST);
47 $locBlockNo = CRM_Utils_Request
::retrieve('locno', 'Positive', CRM_Core_DAO
::$_nullObject, TRUE, NULL, $_REQUEST);
48 $addressId = CRM_Utils_Request
::retrieve('aid', 'Positive', CRM_Core_DAO
::$_nullObject, FALSE, NULL, $_REQUEST);
52 $locationTypes = CRM_Core_PseudoConstant
::get('CRM_Core_DAO_Address', 'location_type_id', ['labelColumn' => 'display_name']);
54 $entityBlock = ['id' => $addressId];
55 $address = CRM_Core_BAO_Address
::getValues($entityBlock, FALSE, 'id');
56 if (!empty($address)) {
57 foreach ($address as $key => & $value) {
58 $value['location_type'] = $locationTypes[$value['location_type_id']];
63 // we just need current address block
64 $currentAddressBlock['address'][$locBlockNo] = array_pop($address);
66 if (!empty($currentAddressBlock['address'][$locBlockNo])) {
67 // get contact name of shared contact names
68 $sharedAddresses = [];
69 $shareAddressContactNames = CRM_Contact_BAO_Contact_Utils
::getAddressShareContactNames($currentAddressBlock['address']);
70 foreach ($currentAddressBlock['address'] as $key => $addressValue) {
71 if (!empty($addressValue['master_id']) &&
72 !$shareAddressContactNames[$addressValue['master_id']]['is_deleted']
74 $sharedAddresses[$key]['shared_address_display'] = [
75 'address' => $addressValue['display'],
76 'name' => $shareAddressContactNames[$addressValue['master_id']]['name'],
80 $idValue = $currentAddressBlock['address'][$locBlockNo]['id'];
81 if (!empty($currentAddressBlock['address'][$locBlockNo]['master_id'])) {
82 $idValue = $currentAddressBlock['address'][$locBlockNo]['master_id'];
85 // add custom data of type address
86 $groupTree = CRM_Core_BAO_CustomGroup
::getTree('Address', NULL, $idValue);
88 // we setting the prefix to dnc_ below so that we don't overwrite smarty's grouptree var.
89 $currentAddressBlock['address'][$locBlockNo]['custom'] = CRM_Core_BAO_CustomGroup
::buildCustomDataView($this, $groupTree, FALSE, NULL, "dnc_");
90 $this->assign("dnc_viewCustomData", NULL);
92 $this->assign('add', $currentAddressBlock['address'][$locBlockNo]);
93 $this->assign('sharedAddresses', $sharedAddresses);
95 $contact = new CRM_Contact_BAO_Contact();
96 $contact->id
= $contactId;
99 foreach (CRM_Contact_BAO_Contact
::$_commPrefs as $name) {
100 if (isset($contact->$name)) {
101 $privacy[$name] = $contact->$name;
105 $this->assign('contactId', $contactId);
106 $this->assign('locationIndex', $locBlockNo);
107 $this->assign('addressId', $addressId);
108 $this->assign('privacy', $privacy);
110 // check logged in user permission
111 CRM_Contact_Page_View
::checkUserPermission($this, $contactId);
113 // finally call parent