3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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-2013
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 * Function to build the form
154 public function buildQuickForm($check = FALSE) {
155 parent
::buildQuickForm();
157 if ($this->_action
& CRM_Core_Action
::DELETE
) {
161 $attributes = CRM_Core_DAO
::getAttribute( 'CRM_Financial_DAO_PaymentProcessorType' );
163 foreach ($this->_fields
as $field) {
164 $required = CRM_Utils_Array
::value('required', $field, FALSE);
165 $this->add('text', $field['name'],
166 $field['label'], $attributes['name'], $required
168 if (CRM_Utils_Array
::value('rule', $field)) {
169 $this->addRule($field['name'], $field['msg'], $field['rule']);
173 // is this processor active ?
174 $this->add('checkbox', 'is_active', ts('Is this Payment Processor Type active?'));
175 $this->add('checkbox', 'is_default', ts('Is this Payment Processor Type the default?'));
176 $this->add('checkbox', 'is_recur', ts('Does this Payment Processor Type support recurring donations?'));
179 function setDefaultValues() {
183 $defaults['is_active'] = $defaults['is_default'] = 1;
184 $defaults['user_name_label'] = ts('User Name');
185 $defaults['password_label'] = ts('Password');
186 $defaults['signature_label'] = ts('Signature');
187 $defaults['subject_label'] = ts('Subject');
191 $dao = new CRM_Financial_DAO_PaymentProcessorType( );
192 $dao->id
= $this->_id
;
194 if (!$dao->find(TRUE)) {
198 CRM_Core_DAO
::storeValues($dao, $defaults);
204 * Function to process the form
210 public function postProcess() {
211 CRM_Utils_System
::flushCache( 'CRM_Financial_DAO_PaymentProcessorType' );
213 if ($this->_action
& CRM_Core_Action
::DELETE
) {
214 CRM_Financial_BAO_PaymentProcessorType
::del($this->_id
);
218 $values = $this->controller
->exportValues($this->_name
);
220 if (CRM_Utils_Array
::value('is_default', $values)) {
222 UPDATE civicrm_payment_processor SET is_default = 0";
223 CRM_Core_DAO
::executeQuery($query, CRM_Core_DAO
::$_nullArray);
226 $dao = new CRM_Financial_DAO_PaymentProcessorType( );
228 $dao->id
= $this->_id
;
229 $dao->is_default
= CRM_Utils_Array
::value('is_default', $values, 0);
230 $dao->is_active
= CRM_Utils_Array
::value('is_active', $values, 0);
231 $dao->is_recur
= CRM_Utils_Array
::value('is_recur', $values, 0);
233 $dao->name
= $values['name'];
234 $dao->description
= $values['description'];
236 foreach ($this->_fields
as $field) {
237 $dao->{$field['name']} = trim($values[$field['name']]);
238 if (empty($dao->{$field['name']})) {
239 $dao->{$field['name']} = 'null';