Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
06b69b18 | 4 | | CiviCRM version 4.5 | |
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 | +--------------------------------------------------------------------+ | |
26 | */ | |
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 | /** | |
42 | * build all the data structures needed to build the form | |
43 | * | |
77b97be7 EM |
44 | * @param $form |
45 | * | |
6a488035 TO |
46 | * @return void |
47 | * @access public | |
48 | */ | |
49 | static function preProcess(&$form) { | |
50 | $form->_type = CRM_Utils_Request::retrieve('type', 'String', CRM_Core_DAO::$_nullObject); | |
51 | $form->_subType = CRM_Utils_Request::retrieve('subType', 'String', CRM_Core_DAO::$_nullObject); | |
52 | ||
53 | //build the custom data as other blocks. | |
54 | //$form->assign( "addBlock", false ); | |
55 | if ($form->_type) { | |
56 | $form->_addBlockName = 'CustomData'; | |
57 | $form->assign("addBlock", TRUE); | |
58 | $form->assign("blockName", $form->_addBlockName); | |
59 | } | |
60 | ||
61 | CRM_Custom_Form_CustomData::preProcess($form, NULL, $form->_subType, NULL, | |
62 | ($form->_type) ? $form->_type : $form->_contactType | |
63 | ); | |
64 | ||
65 | //assign group tree after build. | |
66 | $form->assign('groupTree', $form->_groupTree); | |
67 | } | |
68 | ||
69 | /** | |
70 | * build the form elements for CustomData object | |
71 | * | |
72 | * @param CRM_Core_Form $form reference to the form object | |
73 | * | |
74 | * @return void | |
75 | * @access public | |
76 | * @static | |
77 | */ | |
78 | static function buildQuickForm(&$form) { | |
79 | if(!empty($form->_submitValues)) { | |
80 | if ($customValueCount = CRM_Utils_Array::value('hidden_custom_group_count', $form->_submitValues)) { | |
81 | if (is_array($customValueCount)) { | |
82 | if (array_key_exists(0, $customValueCount)) { | |
83 | unset($customValueCount[0]); | |
84 | } | |
85 | $form->_customValueCount = $customValueCount; | |
86 | $form->assign( 'customValueCount', $customValueCount); | |
87 | } | |
88 | } | |
89 | } | |
90 | CRM_Custom_Form_CustomData::buildQuickForm($form); | |
91 | ||
92 | //build custom data. | |
93 | $contactSubType = NULL; | |
8cc574cf | 94 | if (!empty($_POST["hidden_custom"]) && !empty($_POST['contact_sub_type'])) { |
6a488035 TO |
95 | $contactSubType = $_POST['contact_sub_type']; |
96 | } | |
97 | else { | |
98 | $contactSubType = CRM_Utils_Array::value('contact_sub_type', $form->_values); | |
99 | } | |
100 | $form->assign('contactType', $form->_contactType); | |
101 | $form->assign('contactSubType', $contactSubType); | |
102 | } | |
103 | ||
104 | /** | |
105 | * This function sets the default values for the form. Note that in edit/view mode | |
106 | * the default values are retrieved from the database | |
107 | * | |
108 | * @access public | |
109 | * | |
77b97be7 EM |
110 | * @param $form |
111 | * @param $defaults | |
112 | * | |
355ba699 | 113 | * @return void |
6a488035 TO |
114 | */ |
115 | static function setDefaultValues(&$form, &$defaults) { | |
116 | $defaults += CRM_Custom_Form_CustomData::setDefaultValues($form); | |
117 | } | |
118 | } | |
119 |