Merge pull request #14566 from civicrm/5.15
[civicrm-core.git] / CRM / Contact / Page / Inline / Phone.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
fee14197 4 | CiviCRM version 5 |
6a488035 5 +--------------------------------------------------------------------+
6b83d5bd 6 | Copyright CiviCRM LLC (c) 2004-2019 |
6a488035
TO
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
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. |
13 | |
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. |
18 | |
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 +--------------------------------------------------------------------+
26 */
27
28/**
29 *
30 * @package CRM
6b83d5bd 31 * @copyright CiviCRM LLC (c) 2004-2019
6a488035
TO
32 */
33
34/**
95cdcc0f 35 * Dummy page for details of Phone.
6a488035
TO
36 */
37class CRM_Contact_Page_Inline_Phone extends CRM_Core_Page {
38
39 /**
40 * Run the page.
41 *
42 * This method is called after the page is created.
6a488035 43 */
00be9182 44 public function run() {
6a488035
TO
45 // get the emails for this contact
46 $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
47
be2fb01f 48 $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', ['labelColumn' => 'display_name']);
b4f964d9 49 $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
6a488035 50
be2fb01f 51 $entityBlock = ['contact_id' => $contactId];
6a488035
TO
52 $phones = CRM_Core_BAO_Phone::getValues($entityBlock);
53 if (!empty($phones)) {
54 foreach ($phones as $key => & $value) {
55 $value['location_type'] = $locationTypes[$value['location_type_id']];
56 $value['phone_type'] = $phoneTypes[$value['phone_type_id']];
57 }
58 }
59
481a74f4 60 $contact = new CRM_Contact_BAO_Contact();
6a488035 61 $contact->id = $contactId;
ce80b209 62 $contact->find(TRUE);
be2fb01f 63 $privacy = [];
481a74f4
TO
64 foreach (CRM_Contact_BAO_Contact::$_commPrefs as $name) {
65 if (isset($contact->$name)) {
6a488035
TO
66 $privacy[$name] = $contact->$name;
67 }
68 }
8ef12e64 69
6a488035
TO
70 $this->assign('contactId', $contactId);
71 $this->assign('phone', $phones);
72 $this->assign('privacy', $privacy);
73
74 // check logged in user permission
75 CRM_Contact_Page_View::checkUserPermission($this, $contactId);
8ef12e64 76
77 // finally call parent
6a488035
TO
78 parent::run();
79 }
96025800 80
6a488035 81}