| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | CiviCRM version 4.7 | |
| 5 | +--------------------------------------------------------------------+ |
| 6 | | Copyright CiviCRM LLC (c) 2004-2015 | |
| 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 |
| 31 | * @copyright CiviCRM LLC (c) 2004-2015 |
| 32 | */ |
| 33 | |
| 34 | /** |
| 35 | * Form helper class for custom data section. |
| 36 | */ |
| 37 | class CRM_Contact_Form_Inline_CustomData extends CRM_Contact_Form_Inline { |
| 38 | |
| 39 | /** |
| 40 | * Custom group id. |
| 41 | * |
| 42 | * @int |
| 43 | */ |
| 44 | public $_groupID; |
| 45 | |
| 46 | /** |
| 47 | * Entity type of the table id. |
| 48 | * |
| 49 | * @var string |
| 50 | */ |
| 51 | protected $_entityType; |
| 52 | |
| 53 | /** |
| 54 | * Call preprocess. |
| 55 | */ |
| 56 | public function preProcess() { |
| 57 | parent::preProcess(); |
| 58 | |
| 59 | $this->_groupID = CRM_Utils_Request::retrieve('groupID', 'Positive', $this, TRUE, NULL, $_REQUEST); |
| 60 | $this->assign('customGroupId', $this->_groupID); |
| 61 | $customRecId = CRM_Utils_Request::retrieve('customRecId', 'Positive', $this, FALSE, 1, $_REQUEST); |
| 62 | $cgcount = CRM_Utils_Request::retrieve('cgcount', 'Positive', $this, FALSE, 1, $_REQUEST); |
| 63 | $subType = CRM_Contact_BAO_Contact::getContactSubType($this->_contactId, ','); |
| 64 | CRM_Custom_Form_CustomData::preProcess($this, NULL, $subType, $cgcount, |
| 65 | $this->_contactType, $this->_contactId); |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Build the form object elements for custom data. |
| 70 | */ |
| 71 | public function buildQuickForm() { |
| 72 | parent::buildQuickForm(); |
| 73 | CRM_Custom_Form_CustomData::buildQuickForm($this); |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Set defaults for the form. |
| 78 | * |
| 79 | * @return array |
| 80 | */ |
| 81 | public function setDefaultValues() { |
| 82 | return CRM_Custom_Form_CustomData::setDefaultValues($this); |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * Process the form. |
| 87 | */ |
| 88 | public function postProcess() { |
| 89 | // Process / save custom data |
| 90 | // Get the form values and groupTree |
| 91 | $params = $this->controller->exportValues($this->_name); |
| 92 | CRM_Core_BAO_CustomValueTable::postProcess($params, |
| 93 | 'civicrm_contact', |
| 94 | $this->_contactId, |
| 95 | $this->_entityType |
| 96 | ); |
| 97 | |
| 98 | $this->log(); |
| 99 | |
| 100 | // reset the group contact cache for this group |
| 101 | CRM_Contact_BAO_GroupContactCache::remove(); |
| 102 | |
| 103 | $this->response(); |
| 104 | } |
| 105 | |
| 106 | } |