Commit | Line | Data |
---|---|---|
5b15263a EM |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
fee14197 | 4 | | CiviCRM version 5 | |
5b15263a | 5 | +--------------------------------------------------------------------+ |
f299f7db | 6 | | Copyright CiviCRM LLC (c) 2004-2020 | |
5b15263a EM |
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 | |
f299f7db | 31 | * @copyright CiviCRM LLC (c) 2004-2020 |
5b15263a EM |
32 | */ |
33 | ||
34 | /** | |
35 | * This form is intended to replace the overloading of many forms to generate a snippet for custom data. | |
36 | */ | |
37 | class CRM_Custom_Form_CustomDataByType extends CRM_Core_Form { | |
38 | ||
2fcb4a7f SL |
39 | /** |
40 | * Contact ID associated with the Custom Data | |
41 | * | |
42 | * @var int | |
43 | */ | |
44 | public $_contactID = NULL; | |
45 | ||
5b15263a EM |
46 | /** |
47 | * Preprocess function. | |
48 | */ | |
49 | public function preProcess() { | |
50 | ||
51 | $this->_type = $this->_cdType = CRM_Utils_Request::retrieve('type', 'String', CRM_Core_DAO::$_nullObject, TRUE); | |
52 | $this->_subType = CRM_Utils_Request::retrieve('subType', 'String'); | |
53 | $this->_subName = CRM_Utils_Request::retrieve('subName', 'String'); | |
54 | $this->_groupCount = CRM_Utils_Request::retrieve('cgcount', 'Positive'); | |
55 | $this->_entityId = CRM_Utils_Request::retrieve('entityID', 'Positive'); | |
2fcb4a7f | 56 | $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive'); |
5b15263a | 57 | $this->_groupID = CRM_Utils_Request::retrieve('groupID', 'Positive'); |
4bd532e8 | 58 | $this->_onlySubtype = CRM_Utils_Request::retrieve('onlySubtype', 'Boolean'); |
25cdc89e | 59 | $this->_action = CRM_Utils_Request::retrieve('action', 'Alphanumeric'); |
5b15263a EM |
60 | $this->assign('cdType', FALSE); |
61 | $this->assign('cgCount', $this->_groupCount); | |
62 | ||
f6ad11c1 | 63 | $contactTypes = CRM_Contact_BAO_ContactType::contactTypeInfo(); |
64 | if (array_key_exists($this->_type, $contactTypes)) { | |
65 | $this->assign('contactId', $this->_entityId); | |
66 | } | |
5b15263a EM |
67 | if (!is_array($this->_subType) && strstr($this->_subType, CRM_Core_DAO::VALUE_SEPARATOR)) { |
68 | $this->_subType = str_replace(CRM_Core_DAO::VALUE_SEPARATOR, ',', trim($this->_subType, CRM_Core_DAO::VALUE_SEPARATOR)); | |
69 | } | |
4bd532e8 | 70 | CRM_Custom_Form_CustomData::setGroupTree($this, $this->_subType, $this->_groupID, $this->_onlySubtype); |
466e6ca5 CW |
71 | |
72 | $this->assign('suppressForm', TRUE); | |
73 | $this->controller->_generateQFKey = FALSE; | |
5b15263a EM |
74 | } |
75 | ||
76 | /** | |
77 | * Set defaults. | |
78 | * | |
79 | * @return array | |
80 | */ | |
81 | public function setDefaultValues() { | |
be2fb01f | 82 | $defaults = []; |
5b15263a EM |
83 | CRM_Core_BAO_CustomGroup::setDefaults($this->_groupTree, $defaults, FALSE, FALSE, $this->get('action')); |
84 | return $defaults; | |
85 | } | |
86 | ||
87 | /** | |
88 | * Build quick form. | |
89 | */ | |
90 | public function buildQuickForm() { | |
91 | $this->addElement('hidden', 'hidden_custom', 1); | |
92 | $this->addElement('hidden', "hidden_custom_group_count[{$this->_groupID}]", $this->_groupCount); | |
93 | CRM_Core_BAO_CustomGroup::buildQuickForm($this, $this->_groupTree); | |
94 | } | |
95 | ||
96 | } |