3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
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 generates form components for Mapping
40 class CRM_Admin_Form_Mapping
extends CRM_Admin_Form
{
43 * Function to build the form
48 public function preProcess() {
50 $mapping = new CRM_Core_DAO_Mapping();
51 $mapping->id
= $this->_id
;
53 $this->assign('mappingName', $mapping->name
);
56 public function buildQuickForm() {
57 parent
::buildQuickForm();
58 if ($this->_action
== CRM_Core_Action
::DELETE
) {
62 $this->applyFilter('__ALL__', 'trim');
64 $this->add('text', 'name', ts('Name'),
65 CRM_Core_DAO
::getAttribute('CRM_Core_DAO_Mapping', 'name'), TRUE
67 $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array('CRM_Core_DAO_Mapping', $this->_id
));
69 $this->addElement('text', 'description', ts('Description'),
70 CRM_Core_DAO
::getAttribute('CRM_Core_DAO_Mapping', 'description')
73 $mappingType = $this->addElement('select', 'mapping_type_id', ts('Mapping Type'), CRM_Core_PseudoConstant
::get('CRM_Core_DAO_Mapping', 'mapping_type_id'));
75 if ($this->_action
== CRM_Core_Action
::UPDATE
) {
76 $mappingType->freeze();
84 function setDefaultValues() {
85 $defaults = parent
::setDefaultValues();
90 * Function to process the form
96 public function postProcess() {
97 // store the submitted values in an array
98 $params = $this->exportValues();
100 if ($this->_action
== CRM_Core_Action
::DELETE
) {
102 CRM_Core_BAO_Mapping
::del($this->_id
);
107 $params['id'] = $this->_id
;
110 CRM_Core_BAO_Mapping
::add($params);