Fix calls to Request::retrieve
[civicrm-core.git] / CRM / Contact / Page / Inline / CommunicationPreferences.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
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 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 */
17
18 /**
19 * Dummy page for details of communication preferences.
20 */
21 class CRM_Contact_Page_Inline_CommunicationPreferences extends CRM_Core_Page {
22
23 /**
24 * Run the page.
25 *
26 * This method is called after the page is created.
27 *
28 * @throws \CRM_Core_Exception
29 */
30 public function run() {
31 // get the emails for this contact
32 $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE);
33
34 $params = ['id' => $contactId];
35
36 $defaults = [];
37 CRM_Contact_BAO_Contact::getValues($params, $defaults);
38 $defaults['privacy_values'] = CRM_Core_SelectValues::privacy();
39
40 $communicationStyle = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'communication_style_id');
41 if (!empty($communicationStyle)) {
42 if (!empty($defaults['communication_style_id'])) {
43 $defaults['communication_style_display'] = $communicationStyle[CRM_Utils_Array::value('communication_style_id', $defaults)];
44 }
45 else {
46 // Make sure the field is displayed as long as it is active, even if it is unset for this contact.
47 $defaults['communication_style_display'] = '';
48 }
49 }
50
51 $this->assign('contactId', $contactId);
52 $this->assign($defaults);
53
54 // check logged in user permission
55 CRM_Contact_Page_View::checkUserPermission($this, $contactId);
56
57 // finally call parent
58 parent::run();
59 }
60
61 }