Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06b69b18 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * | |
30 | * @package CRM | |
06b69b18 | 31 | * @copyright CiviCRM LLC (c) 2004-2014 |
6a488035 TO |
32 | * $Id$ |
33 | * | |
34 | */ | |
35 | ||
36 | /** | |
37 | * form helper class for an Demographics object | |
38 | */ | |
39 | class CRM_Contact_Form_Edit_CustomData { | |
40 | ||
41 | /** | |
fe482240 | 42 | * Build all the data structures needed to build the form. |
6a488035 | 43 | * |
c490a46a | 44 | * @param CRM_Core_Form $form |
77b97be7 | 45 | * |
6a488035 | 46 | * @return void |
6a488035 | 47 | */ |
00be9182 | 48 | public static function preProcess(&$form) { |
6a488035 TO |
49 | $form->_type = CRM_Utils_Request::retrieve('type', 'String', CRM_Core_DAO::$_nullObject); |
50 | $form->_subType = CRM_Utils_Request::retrieve('subType', 'String', CRM_Core_DAO::$_nullObject); | |
51 | ||
52 | //build the custom data as other blocks. | |
53 | //$form->assign( "addBlock", false ); | |
54 | if ($form->_type) { | |
55 | $form->_addBlockName = 'CustomData'; | |
56 | $form->assign("addBlock", TRUE); | |
57 | $form->assign("blockName", $form->_addBlockName); | |
58 | } | |
59 | ||
60 | CRM_Custom_Form_CustomData::preProcess($form, NULL, $form->_subType, NULL, | |
61 | ($form->_type) ? $form->_type : $form->_contactType | |
62 | ); | |
63 | ||
64 | //assign group tree after build. | |
65 | $form->assign('groupTree', $form->_groupTree); | |
66 | } | |
67 | ||
68 | /** | |
fe482240 | 69 | * Build the form object elements for CustomData object. |
6a488035 | 70 | * |
77c5b619 TO |
71 | * @param CRM_Core_Form $form |
72 | * Reference to the form object. | |
6a488035 TO |
73 | * |
74 | * @return void | |
6a488035 | 75 | */ |
00be9182 | 76 | public static function buildQuickForm(&$form) { |
22e263ad | 77 | if (!empty($form->_submitValues)) { |
6a488035 TO |
78 | if ($customValueCount = CRM_Utils_Array::value('hidden_custom_group_count', $form->_submitValues)) { |
79 | if (is_array($customValueCount)) { | |
80 | if (array_key_exists(0, $customValueCount)) { | |
81 | unset($customValueCount[0]); | |
82 | } | |
83 | $form->_customValueCount = $customValueCount; | |
481a74f4 | 84 | $form->assign('customValueCount', $customValueCount); |
6a488035 TO |
85 | } |
86 | } | |
87 | } | |
88 | CRM_Custom_Form_CustomData::buildQuickForm($form); | |
89 | ||
90 | //build custom data. | |
91 | $contactSubType = NULL; | |
8cc574cf | 92 | if (!empty($_POST["hidden_custom"]) && !empty($_POST['contact_sub_type'])) { |
6a488035 TO |
93 | $contactSubType = $_POST['contact_sub_type']; |
94 | } | |
95 | else { | |
96 | $contactSubType = CRM_Utils_Array::value('contact_sub_type', $form->_values); | |
97 | } | |
98 | $form->assign('contactType', $form->_contactType); | |
99 | $form->assign('contactSubType', $contactSubType); | |
100 | } | |
101 | ||
102 | /** | |
c490a46a | 103 | * Set default values for the form. Note that in edit/view mode |
6a488035 TO |
104 | * the default values are retrieved from the database |
105 | * | |
6a488035 | 106 | * |
c490a46a | 107 | * @param CRM_Core_Form $form |
77b97be7 EM |
108 | * @param $defaults |
109 | * | |
355ba699 | 110 | * @return void |
6a488035 | 111 | */ |
00be9182 | 112 | public static function setDefaultValues(&$form, &$defaults) { |
6a488035 TO |
113 | $defaults += CRM_Custom_Form_CustomData::setDefaultValues($form); |
114 | } | |
96025800 | 115 | |
6a488035 | 116 | } |