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
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 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
156 public function buildQuickForm($check = FALSE) {
157 parent
::buildQuickForm();
159 if ($this->_action
& CRM_Core_Action
::DELETE
) {
163 $attributes = CRM_Core_DAO
::getAttribute( 'CRM_Financial_DAO_PaymentProcessorType' );
165 foreach ($this->_fields
as $field) {
166 $required = CRM_Utils_Array
::value('required', $field, FALSE);
167 $this->add('text', $field['name'],
168 $field['label'], $attributes['name'], $required
170 if (!empty($field['rule'])) {
171 $this->addRule($field['name'], $field['msg'], $field['rule']);
175 // is this processor active ?
176 $this->add('checkbox', 'is_active', ts('Is this Payment Processor Type active?'));
177 $this->add('checkbox', 'is_default', ts('Is this Payment Processor Type the default?'));
178 $this->add('checkbox', 'is_recur', ts('Does this Payment Processor Type support recurring donations?'));
184 function setDefaultValues() {
188 $defaults['is_active'] = $defaults['is_default'] = 1;
189 $defaults['user_name_label'] = ts('User Name');
190 $defaults['password_label'] = ts('Password');
191 $defaults['signature_label'] = ts('Signature');
192 $defaults['subject_label'] = ts('Subject');
196 $dao = new CRM_Financial_DAO_PaymentProcessorType( );
197 $dao->id
= $this->_id
;
199 if (!$dao->find(TRUE)) {
203 CRM_Core_DAO
::storeValues($dao, $defaults);
209 * Process the form submission
215 public function postProcess() {
216 CRM_Utils_System
::flushCache( 'CRM_Financial_DAO_PaymentProcessorType' );
218 if ($this->_action
& CRM_Core_Action
::DELETE
) {
219 CRM_Financial_BAO_PaymentProcessorType
::del($this->_id
);
223 $values = $this->controller
->exportValues($this->_name
);
225 if (!empty($values['is_default'])) {
227 UPDATE civicrm_payment_processor SET is_default = 0";
228 CRM_Core_DAO
::executeQuery($query, CRM_Core_DAO
::$_nullArray);
231 $dao = new CRM_Financial_DAO_PaymentProcessorType( );
233 $dao->id
= $this->_id
;
234 $dao->is_default
= CRM_Utils_Array
::value('is_default', $values, 0);
235 $dao->is_active
= CRM_Utils_Array
::value('is_active', $values, 0);
236 $dao->is_recur
= CRM_Utils_Array
::value('is_recur', $values, 0);
238 $dao->name
= $values['name'];
239 $dao->description
= $values['description'];
241 foreach ($this->_fields
as $field) {
242 $dao->{$field['name']} = trim($values[$field['name']]);
243 if (empty($dao->{$field['name']})) {
244 $dao->{$field['name']} = 'null';