3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
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
32 * $Id: PaymentProcessorType.php 9702 2007-05-29 23:57:16Z lobo $
37 * This class generates form components for Location Type
40 class CRM_Admin_Form_PaymentProcessorType
extends CRM_Admin_Form
{
41 protected $_id = NULL;
43 protected $_fields = NULL;
45 public function preProcess() {
48 $this->_fields
= array(
51 'label' => ts('Name'),
56 'label' => ts('Title'),
60 'name' => 'billing_mode',
61 'label' => ts('Billing Mode'),
63 'rule' => 'positiveInteger',
64 'msg' => ts('Enter a positive integer'),
67 'name' => 'description',
68 'label' => ts('Description'),
71 'name' => 'user_name_label',
72 'label' => ts('User Name Label'),
75 'name' => 'password_label',
76 'label' => ts('Password Label'),
79 'name' => 'signature_label',
80 'label' => ts('Signature Label'),
83 'name' => 'subject_label',
84 'label' => ts('Subject Label'),
87 'name' => 'class_name',
88 'label' => ts('PHP class name'),
92 'name' => 'url_site_default',
93 'label' => ts('Live Site URL'),
96 'msg' => ts('Enter a valid URL'),
99 'name' => 'url_api_default',
100 'label' => ts('Live API URL'),
103 'msg' => ts('Enter a valid URL'),
106 'name' => 'url_recur_default',
107 'label' => ts('Live Recurring Payments URL'),
110 'msg' => ts('Enter a valid URL'),
113 'name' => 'url_button_default',
114 'label' => ts('Live Button URL'),
116 'msg' => ts('Enter a valid URL'),
119 'name' => 'url_site_test_default',
120 'label' => ts('Test Site URL'),
123 'msg' => ts('Enter a valid URL'),
126 'name' => 'url_api_test_default',
127 'label' => ts('Test API URL'),
130 'msg' => ts('Enter a valid URL'),
133 'name' => 'url_recur_test_default',
134 'label' => ts('Test Recurring Payments URL'),
137 'msg' => ts('Enter a valid URL'),
140 'name' => 'url_button_test_default',
141 'label' => ts('Test Button URL'),
143 'msg' => ts('Enter a valid URL'),
149 * Build the form object.
155 public function buildQuickForm($check = FALSE) {
156 parent
::buildQuickForm();
158 if ($this->_action
& CRM_Core_Action
::DELETE
) {
162 $attributes = CRM_Core_DAO
::getAttribute('CRM_Financial_DAO_PaymentProcessorType');
164 foreach ($this->_fields
as $field) {
165 $required = CRM_Utils_Array
::value('required', $field, FALSE);
166 $this->add('text', $field['name'],
167 $field['label'], $attributes['name'], $required
169 if (!empty($field['rule'])) {
170 $this->addRule($field['name'], $field['msg'], $field['rule']);
174 // is this processor active ?
175 $this->add('checkbox', 'is_active', ts('Is this Payment Processor Type active?'));
176 $this->add('checkbox', 'is_default', ts('Is this Payment Processor Type the default?'));
177 $this->add('checkbox', 'is_recur', ts('Does this Payment Processor Type support recurring donations?'));
183 public function setDefaultValues() {
187 $defaults['is_active'] = $defaults['is_default'] = 1;
188 $defaults['user_name_label'] = ts('User Name');
189 $defaults['password_label'] = ts('Password');
190 $defaults['signature_label'] = ts('Signature');
191 $defaults['subject_label'] = ts('Subject');
195 $dao = new CRM_Financial_DAO_PaymentProcessorType();
196 $dao->id
= $this->_id
;
198 if (!$dao->find(TRUE)) {
202 CRM_Core_DAO
::storeValues($dao, $defaults);
208 * Process the form submission.
213 public function postProcess() {
214 CRM_Utils_System
::flushCache('CRM_Financial_DAO_PaymentProcessorType');
216 if ($this->_action
& CRM_Core_Action
::DELETE
) {
217 CRM_Financial_BAO_PaymentProcessorType
::del($this->_id
);
221 $values = $this->controller
->exportValues($this->_name
);
223 if (!empty($values['is_default'])) {
225 UPDATE civicrm_payment_processor SET is_default = 0";
226 CRM_Core_DAO
::executeQuery($query, CRM_Core_DAO
::$_nullArray);
229 $dao = new CRM_Financial_DAO_PaymentProcessorType();
231 $dao->id
= $this->_id
;
232 $dao->is_default
= CRM_Utils_Array
::value('is_default', $values, 0);
233 $dao->is_active
= CRM_Utils_Array
::value('is_active', $values, 0);
234 $dao->is_recur
= CRM_Utils_Array
::value('is_recur', $values, 0);
236 $dao->name
= $values['name'];
237 $dao->description
= $values['description'];
239 foreach ($this->_fields
as $field) {
240 $dao->{$field['name']} = trim($values[$field['name']]);
241 if (empty($dao->{$field['name']})) {
242 $dao->{$field['name']} = 'null';