Merge pull request #19943 from civicrm/5.36
[civicrm-core.git] / CRM / Contact / Page / Inline / Email.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
bc77d7c0
TO
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 |
6a488035
TO
9 +--------------------------------------------------------------------+
10 */
11
12/**
13 *
14 * @package CRM
ca5cec67 15 * @copyright CiviCRM LLC https://civicrm.org/licensing
6a488035
TO
16 */
17
18/**
95cdcc0f 19 * Dummy page for details of Email.
6a488035
TO
20 */
21class CRM_Contact_Page_Inline_Email extends CRM_Core_Page {
22
23 /**
24 * Run the page.
25 *
26 * This method is called after the page is created.
6a488035 27 */
00be9182 28 public function run() {
6a488035 29 // get the emails for this contact
1be22cfb 30 $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE);
6a488035 31
be2fb01f 32 $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', ['labelColumn' => 'display_name']);
6a488035 33
be2fb01f 34 $entityBlock = ['contact_id' => $contactId];
6a488035
TO
35 $emails = CRM_Core_BAO_Email::getValues($entityBlock);
36 if (!empty($emails)) {
cef76e5f 37 foreach ($emails as &$value) {
6a488035
TO
38 $value['location_type'] = $locationTypes[$value['location_type_id']];
39 }
40 }
41
481a74f4 42 $contact = new CRM_Contact_BAO_Contact();
6a488035 43 $contact->id = $contactId;
ce80b209 44 $contact->find(TRUE);
be2fb01f 45 $privacy = [];
481a74f4
TO
46 foreach (CRM_Contact_BAO_Contact::$_commPrefs as $name) {
47 if (isset($contact->$name)) {
6a488035
TO
48 $privacy[$name] = $contact->$name;
49 }
50 }
51
52 $this->assign('contactId', $contactId);
53 $this->assign('email', $emails);
54 $this->assign('privacy', $privacy);
55
56 // check logged in user permission
57 CRM_Contact_Page_View::checkUserPermission($this, $contactId);
8ef12e64 58
59 // finally call parent
6a488035
TO
60 parent::run();
61 }
96025800 62
6a488035 63}