Merge pull request #19718 from aydun/wp-login-redirect
[civicrm-core.git] / CRM / Contact / Page / Inline / CustomData.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 * This page displays custom data during inline edit.
20 */
21 class CRM_Contact_Page_Inline_CustomData extends CRM_Core_Page {
22
23 /**
24 * Run the page.
25 *
26 * This method is called after the page is created.
27 */
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 $cgId = CRM_Utils_Request::retrieve('groupID', 'Positive', CRM_Core_DAO::$_nullObject, TRUE);
32 $customRecId = CRM_Utils_Request::retrieve('customRecId', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, 1);
33 $cgcount = CRM_Utils_Request::retrieve('cgcount', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, 1);
34
35 //custom groups Inline
36 $entityType = CRM_Contact_BAO_Contact::getContactType($contactId);
37 $entitySubType = CRM_Contact_BAO_Contact::getContactSubType($contactId);
38 $groupTree = CRM_Core_BAO_CustomGroup::getTree($entityType, NULL, $contactId,
39 $cgId, $entitySubType
40 );
41 $details = CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, NULL, $contactId);
42 //get the fields of single custom group record
43 if ($customRecId == 1) {
44 $fields = reset($details[$cgId]);
45 }
46 else {
47 $fields = $details[$cgId][$customRecId] ?? NULL;
48 }
49 $this->assign('cgcount', $cgcount);
50 $this->assign('customRecId', $customRecId);
51 $this->assign('contactId', $contactId);
52 $this->assign('customGroupId', $cgId);
53 $this->assign_by_ref('cd_edit', $fields);
54
55 // check logged in user permission
56 CRM_Contact_Page_View::checkUserPermission($this, $contactId);
57
58 // finally call parent
59 parent::run();
60 }
61
62 }