3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2014
37 * this class builds custom data
39 class CRM_Custom_Form_CustomData
{
42 * @param CRM_Core_Form $form
43 * @param null|string $subName
44 * @param null|string $subType
45 * @param null|int $groupCount
46 * @param null|String $type
47 * @param null|int $entityID
48 * @param null $onlySubType
52 static function preProcess(&$form, $subName = NULL, $subType = NULL,
53 $groupCount = NULL, $type = NULL, $entityID = NULL, $onlySubType = NULL
59 $form->_type
= CRM_Utils_Request
::retrieve('type', 'String', $form);
62 if (isset($subType)) {
63 $form->_subType
= $subType;
66 $form->_subType
= CRM_Utils_Request
::retrieve('subType', 'String', $form);
69 if ($form->_subType
== 'null') {
70 $form->_subType
= NULL;
73 if (isset($subName)) {
74 $form->_subName
= $subName;
77 $form->_subName
= CRM_Utils_Request
::retrieve('subName', 'String', $form);
80 if ($form->_subName
== 'null') {
81 $form->_subName
= NULL;
85 $form->_groupCount
= $groupCount;
88 $form->_groupCount
= CRM_Utils_Request
::retrieve('cgcount', 'Positive', $form);
91 $form->assign('cgCount', $form->_groupCount
);
93 //carry qf key, since this form is not inhereting core form.
94 if ($qfKey = CRM_Utils_Request
::retrieve('qfKey', 'String', CRM_Core_DAO
::$_nullObject)) {
95 $form->assign('qfKey', $qfKey);
99 $form->_entityId
= $entityID;
102 $form->_entityId
= CRM_Utils_Request
::retrieve('entityID', 'Positive', $form);
105 $typeCheck = CRM_Utils_Request
::retrieve( 'type', 'String', CRM_Core_DAO
::$_nullObject );
106 $urlGroupId = CRM_Utils_Request
::retrieve('groupID', 'Positive', CRM_Core_DAO
::$_nullObject);
107 if ( isset($typeCheck) && $urlGroupId) {
108 $form->_groupID
= $urlGroupId;
110 $form->_groupID
= CRM_Utils_Request
::retrieve('groupID', 'Positive', $form);
113 $gid = (isset($form->_groupID
)) ?
$form->_groupID
: NULL;
114 $getCachedTree = isset($form->_getCachedTree
) ?
$form->_getCachedTree
: TRUE;
116 $subType = $form->_subType
;
117 if (!is_array($subType) && strstr($subType, CRM_Core_DAO
::VALUE_SEPARATOR
)) {
118 $subType = str_replace(CRM_Core_DAO
::VALUE_SEPARATOR
, ',', trim($subType, CRM_Core_DAO
::VALUE_SEPARATOR
));
121 $groupTree = &CRM_Core_BAO_CustomGroup
::getTree($form->_type
,
131 if (property_exists($form, '_customValueCount') && !empty($groupTree)) {
132 $form->_customValueCount
= CRM_Core_BAO_CustomGroup
::buildCustomDataView($form, $groupTree, TRUE, NULL, NULL);
134 // we should use simplified formatted groupTree
135 $groupTree = CRM_Core_BAO_CustomGroup
::formatGroupTree($groupTree, $form->_groupCount
, $form);
137 if (isset($form->_groupTree
) && is_array($form->_groupTree
)) {
138 $keys = array_keys($groupTree);
139 foreach ($keys as $key) {
140 $form->_groupTree
[$key] = $groupTree[$key];
144 $form->_groupTree
= $groupTree;
149 * @param CRM_Core_Form $form
153 public static function setDefaultValues(&$form) {
155 CRM_Core_BAO_CustomGroup
::setDefaults($form->_groupTree
, $defaults, FALSE, FALSE, $form->get('action'));
160 * @param CRM_Core_Form $form
163 public static function buildQuickForm(&$form) {
164 $form->addElement('hidden', 'hidden_custom', 1);
165 $form->addElement('hidden', "hidden_custom_group_count[{$form->_groupID}]", $form->_groupCount
);
166 CRM_Core_BAO_CustomGroup
::buildQuickForm($form, $form->_groupTree
);