Merge pull request #22886 from demeritcowboy/contributionview-notice3
[civicrm-core.git] / CRM / Contact / Form / 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 * Form helper class for custom data section.
20 */
21 class CRM_Contact_Form_Inline_CustomData extends CRM_Contact_Form_Inline {
22
23 /**
24 * Custom group id.
25 *
26 * @var int
27 */
28 public $_groupID;
29
30 /**
31 * Entity type of the table id.
32 *
33 * @var string
34 */
35 protected $_entityType;
36
37 /**
38 * Call preprocess.
39 */
40 public function preProcess() {
41 parent::preProcess();
42
43 $this->_groupID = CRM_Utils_Request::retrieve('groupID', 'Positive', $this, TRUE, NULL);
44 $this->assign('customGroupId', $this->_groupID);
45 $customRecId = CRM_Utils_Request::retrieve('customRecId', 'Positive', $this, FALSE, 1);
46 $cgcount = CRM_Utils_Request::retrieve('cgcount', 'Positive', $this, FALSE, 1);
47 $subType = CRM_Contact_BAO_Contact::getContactSubType($this->_contactId, ',');
48 CRM_Custom_Form_CustomData::preProcess($this, NULL, $subType, $cgcount,
49 $this->_contactType, $this->_contactId);
50 }
51
52 /**
53 * Build the form object elements for custom data.
54 */
55 public function buildQuickForm() {
56 parent::buildQuickForm();
57 CRM_Custom_Form_CustomData::buildQuickForm($this);
58 }
59
60 /**
61 * Set defaults for the form.
62 *
63 * @return array
64 */
65 public function setDefaultValues() {
66 return CRM_Custom_Form_CustomData::setDefaultValues($this);
67 }
68
69 /**
70 * Process the form.
71 */
72 public function postProcess() {
73 // Process / save custom data
74 // Get the form values and groupTree
75 $params = $this->controller->exportValues($this->_name);
76 CRM_Core_BAO_CustomValueTable::postProcess($params,
77 'civicrm_contact',
78 $this->_contactId,
79 $this->_entityType
80 );
81
82 $this->log();
83
84 CRM_Contact_BAO_GroupContactCache::opportunisticCacheFlush();
85
86 $this->response();
87 }
88
89 }