3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
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 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * This form is intended to replace the overloading of many forms to generate a snippet for custom data.
21 class CRM_Custom_Form_CustomDataByType
extends CRM_Core_Form
{
24 * Contact ID associated with the Custom Data
28 public $_contactID = NULL;
31 * Preprocess function.
33 public function preProcess() {
35 $this->_type
= $this->_cdType
= CRM_Utils_Request
::retrieve('type', 'String', CRM_Core_DAO
::$_nullObject, TRUE);
36 $this->_subType
= CRM_Utils_Request
::retrieve('subType', 'String');
37 $this->_subName
= CRM_Utils_Request
::retrieve('subName', 'String');
38 $this->_groupCount
= CRM_Utils_Request
::retrieve('cgcount', 'Positive');
39 $this->_entityId
= CRM_Utils_Request
::retrieve('entityID', 'Positive');
40 $this->_contactID
= CRM_Utils_Request
::retrieve('cid', 'Positive');
41 $this->_groupID
= CRM_Utils_Request
::retrieve('groupID', 'Positive');
42 $this->_onlySubtype
= CRM_Utils_Request
::retrieve('onlySubtype', 'Boolean');
43 $this->_action
= CRM_Utils_Request
::retrieve('action', 'Alphanumeric');
44 $this->assign('cdType', FALSE);
45 $this->assign('cgCount', $this->_groupCount
);
47 $contactTypes = CRM_Contact_BAO_ContactType
::contactTypeInfo();
48 if (array_key_exists($this->_type
, $contactTypes)) {
49 $this->assign('contactId', $this->_entityId
);
51 if (!is_array($this->_subType
) && strstr($this->_subType
, CRM_Core_DAO
::VALUE_SEPARATOR
)) {
52 $this->_subType
= str_replace(CRM_Core_DAO
::VALUE_SEPARATOR
, ',', trim($this->_subType
, CRM_Core_DAO
::VALUE_SEPARATOR
));
54 CRM_Custom_Form_CustomData
::setGroupTree($this, $this->_subType
, $this->_groupID
, $this->_onlySubtype
);
56 $this->assign('suppressForm', TRUE);
57 $this->controller
->_generateQFKey
= FALSE;
65 public function setDefaultValues() {
67 CRM_Core_BAO_CustomGroup
::setDefaults($this->_groupTree
, $defaults, FALSE, FALSE, $this->get('action'));
74 public function buildQuickForm() {
75 $this->addElement('hidden', 'hidden_custom', 1);
76 $this->addElement('hidden', "hidden_custom_group_count[{$this->_groupID}]", $this->_groupCount
);
77 CRM_Core_BAO_CustomGroup
::buildQuickForm($this, $this->_groupTree
);