3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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-2015
35 * This class generates form components for Location Type.
37 class CRM_Admin_Form_PaymentProcessorType
extends CRM_Admin_Form
{
38 protected $_id = NULL;
40 protected $_fields = NULL;
42 public function preProcess() {
45 $this->_fields
= array(
48 'label' => ts('Name'),
53 'label' => ts('Title'),
57 'name' => 'billing_mode',
58 'label' => ts('Billing Mode'),
60 'rule' => 'positiveInteger',
61 'msg' => ts('Enter a positive integer'),
64 'name' => 'description',
65 'label' => ts('Description'),
68 'name' => 'user_name_label',
69 'label' => ts('User Name Label'),
72 'name' => 'password_label',
73 'label' => ts('Password Label'),
76 'name' => 'signature_label',
77 'label' => ts('Signature Label'),
80 'name' => 'subject_label',
81 'label' => ts('Subject Label'),
84 'name' => 'class_name',
85 'label' => ts('PHP class name'),
89 'name' => 'url_site_default',
90 'label' => ts('Live Site URL'),
93 'msg' => ts('Enter a valid URL'),
96 'name' => 'url_api_default',
97 'label' => ts('Live API URL'),
100 'msg' => ts('Enter a valid URL'),
103 'name' => 'url_recur_default',
104 'label' => ts('Live Recurring Payments URL'),
107 'msg' => ts('Enter a valid URL'),
110 'name' => 'url_button_default',
111 'label' => ts('Live Button URL'),
113 'msg' => ts('Enter a valid URL'),
116 'name' => 'url_site_test_default',
117 'label' => ts('Test Site URL'),
120 'msg' => ts('Enter a valid URL'),
123 'name' => 'url_api_test_default',
124 'label' => ts('Test API URL'),
127 'msg' => ts('Enter a valid URL'),
130 'name' => 'url_recur_test_default',
131 'label' => ts('Test Recurring Payments URL'),
134 'msg' => ts('Enter a valid URL'),
137 'name' => 'url_button_test_default',
138 'label' => ts('Test Button URL'),
140 'msg' => ts('Enter a valid URL'),
146 * Build the form object.
150 public function buildQuickForm($check = FALSE) {
151 parent
::buildQuickForm();
153 if ($this->_action
& CRM_Core_Action
::DELETE
) {
157 $attributes = CRM_Core_DAO
::getAttribute('CRM_Financial_DAO_PaymentProcessorType');
159 foreach ($this->_fields
as $field) {
160 $required = CRM_Utils_Array
::value('required', $field, FALSE);
161 $this->add('text', $field['name'],
162 $field['label'], $attributes['name'], $required
164 if (!empty($field['rule'])) {
165 $this->addRule($field['name'], $field['msg'], $field['rule']);
169 // is this processor active ?
170 $this->add('checkbox', 'is_active', ts('Is this Payment Processor Type active?'));
171 $this->add('checkbox', 'is_default', ts('Is this Payment Processor Type the default?'));
172 $this->add('checkbox', 'is_recur', ts('Does this Payment Processor Type support recurring donations?'));
178 public function setDefaultValues() {
182 $defaults['is_active'] = $defaults['is_default'] = 1;
183 $defaults['user_name_label'] = ts('User Name');
184 $defaults['password_label'] = ts('Password');
185 $defaults['signature_label'] = ts('Signature');
186 $defaults['subject_label'] = ts('Subject');
190 $dao = new CRM_Financial_DAO_PaymentProcessorType();
191 $dao->id
= $this->_id
;
193 if (!$dao->find(TRUE)) {
197 CRM_Core_DAO
::storeValues($dao, $defaults);
203 * Process the form submission.
205 public function postProcess() {
206 CRM_Utils_System
::flushCache('CRM_Financial_DAO_PaymentProcessorType');
208 if ($this->_action
& CRM_Core_Action
::DELETE
) {
209 CRM_Financial_BAO_PaymentProcessorType
::del($this->_id
);
213 $values = $this->controller
->exportValues($this->_name
);
215 if (!empty($values['is_default'])) {
217 UPDATE civicrm_payment_processor SET is_default = 0";
218 CRM_Core_DAO
::executeQuery($query, CRM_Core_DAO
::$_nullArray);
221 $dao = new CRM_Financial_DAO_PaymentProcessorType();
223 $dao->id
= $this->_id
;
224 $dao->is_default
= CRM_Utils_Array
::value('is_default', $values, 0);
225 $dao->is_active
= CRM_Utils_Array
::value('is_active', $values, 0);
226 $dao->is_recur
= CRM_Utils_Array
::value('is_recur', $values, 0);
228 $dao->name
= $values['name'];
229 $dao->description
= $values['description'];
231 foreach ($this->_fields
as $field) {
232 $dao->{$field['name']} = trim($values[$field['name']]);
233 if (empty($dao->{$field['name']})) {
234 $dao->{$field['name']} = 'null';